Skip to content

Commit

Permalink
Use different analytics account for non-prod (#384)
Browse files Browse the repository at this point in the history
  • Loading branch information
beets authored Sep 4, 2020
1 parent 7a2d5c8 commit fdfed7d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
15 changes: 9 additions & 6 deletions server/configmodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,35 @@ class Config:
TEST = False
WEBDRIVER = False
CACHE_TYPE = 'simple' # Flask-Caching related configs
GAE_VERSION = (
os.environ.get('GAE_VERSION') or
datetime.datetime.today().strftime("%m-%d-%H-%M"))
GAE_VERSION = (os.environ.get('GAE_VERSION') or
datetime.datetime.today().strftime("%m-%d-%H-%M"))


class ProductionConfig(Config):
API_PROJECT = 'datcom-mixer'
API_ROOT = 'https://api.datacommons.org'
GCS_BUCKET = "datcom-browser-prod.appspot.com"
GCS_BUCKET = 'datcom-browser-prod.appspot.com'
GA_ACCOUNT = 'UA-117119267-1'


class DevelopmentConfig(Config):
API_PROJECT = 'datcom-mixer-staging'
API_ROOT = 'https://datacommons.endpoints.datcom-mixer-staging.cloud.goog'
GCS_BUCKET = "datcom-browser-staging.appspot.com"
GCS_BUCKET = 'datcom-browser-staging.appspot.com'
GA_ACCOUNT = 'UA-117119267-2'


class WebdriverConfig(Config):
WEBDRIVER = True
API_PROJECT = 'datcom-mixer-staging'
API_ROOT = 'https://datacommons.endpoints.datcom-mixer-staging.cloud.goog'
GCS_BUCKET = ""
GCS_BUCKET = ''
GA_ACCOUNT = ''


class TestConfig(Config):
TEST = True
API_PROJECT = 'api-project'
API_ROOT = 'api-root'
GCS_BUCKET = 'gcs-bucket'
GA_ACCOUNT = ''
1 change: 1 addition & 0 deletions server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
format='%(asctime)s %(levelname)s %(lineno)d : %(message)s')

app = create_app()
app.jinja_env.globals['GA_ACCOUNT'] = app.config['GA_ACCOUNT']

GCS_BUCKET = app.config['GCS_BUCKET']
_MAX_SEARCH_RESULTS = 1000
Expand Down
4 changes: 3 additions & 1 deletion server/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,14 @@ <h6>Data Commons</h6>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script async src="https://cse.google.com/cse.js?cx=010079880385165835740%3Aosnv3q-sw08"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-117119267-1"></script>
{%- if GA_ACCOUNT -%}
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-117119267-1');
gtag('config', '{{ GA_ACCOUNT }}');
</script>
{%- endif -%}
{% block footer %}
{% endblock %}
</body>
Expand Down

0 comments on commit fdfed7d

Please sign in to comment.