Browse Source

Add server-side analytics via AppInsights

pull/76/head
Clemens Wolff 5 years ago
parent
commit
e4fd74ec6f
3 changed files with 7 additions and 2 deletions
  1. 6
      app/app/settings.py
  2. 2
      app/server/templatetags/analytics.py
  3. 1
      requirements.txt

6
app/app/settings.py

@ -62,6 +62,7 @@ MIDDLEWARE = [
'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
'social_django.middleware.SocialAuthExceptionMiddleware', 'social_django.middleware.SocialAuthExceptionMiddleware',
'applicationinsights.django.ApplicationInsightsMiddleware',
] ]
ROOT_URLCONF = 'app.urls' ROOT_URLCONF = 'app.urls'
@ -185,6 +186,9 @@ SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
IMPORT_BATCH_SIZE = 500 IMPORT_BATCH_SIZE = 500
GOOGLE_TRACKING_ID = os.getenv('GOOGLE_TRACKING_ID', 'UA-125643874-2') GOOGLE_TRACKING_ID = os.getenv('GOOGLE_TRACKING_ID', 'UA-125643874-2')
AZURE_APPINSIGHTS_IKEY = os.getenv('AZURE_APPINSIGHTS_IKEY')
APPLICATION_INSIGHTS = {
'ikey': os.getenv('AZURE_APPINSIGHTS_IKEY'),
}
django_heroku.settings(locals(), test_runner=False) django_heroku.settings(locals(), test_runner=False)

2
app/server/templatetags/analytics.py

@ -14,5 +14,5 @@ def google_analytics():
def azure_appinsights(): def azure_appinsights():
return { return {
'DEBUG': settings.DEBUG, 'DEBUG': settings.DEBUG,
'azure_appinsights_ikey': settings.AZURE_APPINSIGHTS_IKEY,
'azure_appinsights_ikey': settings.APPLICATION_INSIGHTS['ikey'],
} }

1
requirements.txt

@ -1,3 +1,4 @@
applicationinsights==0.11.7
dj-database-url==0.5.0 dj-database-url==0.5.0
Django==2.1.5 Django==2.1.5
django-filter==2.0.0 django-filter==2.0.0

Loading…
Cancel
Save