mirror of https://github.com/doccano/doccano.git
Browse Source
Merge pull request #76 from CatalystCode/feature/configurable-google-analytics
Merge pull request #76 from CatalystCode/feature/configurable-google-analytics
Feature/Make client-side analytics configurablepull/73/head
Hiroki Nakayama
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 120 additions and 37 deletions
Unified View
Diff Options
-
2Dockerfile
-
10app/app/settings.py
-
11app/server/templates/base.html
-
14app/server/templates/tags/azure_appinsights.html
-
10app/server/templates/tags/google_analytics.html
-
0app/server/templatetags/__init__.py
-
18app/server/templatetags/analytics.py
-
91azuredeploy.json
-
1requirements.txt
@ -0,0 +1,14 @@ |
|||||
|
{# See https://apmtips.com/blog/2015/03/18/javascript-snippet-explained/ #} |
||||
|
{% if azure_appinsights_ikey %} |
||||
|
<script type="text/javascript"> |
||||
|
var appInsights=window.appInsights||function(a){ |
||||
|
function b(a){c[a]=function(){var b=arguments;c.queue.push(function(){c[a].apply(c,b)})}}var c={config:a},d=document,e=window;setTimeout(function(){var b=d.createElement("script");b.src=a.url||"https://az416426.vo.msecnd.net/scripts/a/ai.0.js",d.getElementsByTagName("script")[0].parentNode.appendChild(b)});try{c.cookie=d.cookie}catch(a){}c.queue=[];for(var f=["Event","Exception","Metric","PageView","Trace","Dependency"];f.length;)b("track"+f.pop());if(b("setAuthenticatedUserContext"),b("clearAuthenticatedUserContext"),b("startTrackEvent"),b("stopTrackEvent"),b("startTrackPage"),b("stopTrackPage"),b("flush"),!a.disableExceptionTracking){f="onerror",b("_"+f);var g=e[f];e[f]=function(a,b,d,e,h){var i=g&&g(a,b,d,e,h);return!0!==i&&c["_"+f](a,b,d,e,h),i}}return c |
||||
|
}({ |
||||
|
{% if DEBUG %} |
||||
|
enableDebug: true, |
||||
|
{% endif %} |
||||
|
instrumentationKey: "{{ azure_appinsights_ikey }}" |
||||
|
}); |
||||
|
window.appInsights=appInsights,appInsights.queue&&0===appInsights.queue.length&&appInsights.trackPageView(); |
||||
|
</script> |
||||
|
{% endif %} |
@ -0,0 +1,10 @@ |
|||||
|
{% if google_tracking_id %} |
||||
|
<!-- Global site tag (gtag.js) - Google Analytics --> |
||||
|
<script async src="https://www.googletagmanager.com/gtag/js?id={{ google_tracking_id }}"></script> |
||||
|
<script> |
||||
|
window.dataLayer = window.dataLayer || []; |
||||
|
function gtag() { dataLayer.push(arguments); } |
||||
|
gtag("js", new Date()); |
||||
|
gtag("config", "{{ google_tracking_id }}"); |
||||
|
</script> |
||||
|
{% endif %} |
@ -0,0 +1,18 @@ |
|||||
|
from django import template |
||||
|
|
||||
|
from app import settings |
||||
|
|
||||
|
register = template.Library() |
||||
|
|
||||
|
|
||||
|
@register.inclusion_tag('tags/google_analytics.html') |
||||
|
def google_analytics(): |
||||
|
return {'google_tracking_id': settings.GOOGLE_TRACKING_ID} |
||||
|
|
||||
|
|
||||
|
@register.inclusion_tag('tags/azure_appinsights.html') |
||||
|
def azure_appinsights(): |
||||
|
return { |
||||
|
'DEBUG': settings.DEBUG, |
||||
|
'azure_appinsights_ikey': settings.APPLICATION_INSIGHTS['ikey'], |
||||
|
} |
Write
Preview
Loading…
Cancel
Save