diff --git a/humbug/settings.py b/humbug/settings.py index 1ba508c0e3..2bab362537 100644 --- a/humbug/settings.py +++ b/humbug/settings.py @@ -526,7 +526,11 @@ if DEPLOYED: S3_KEY="xxxxxxxxxxxxxxxxxxxx" S3_SECRET_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" S3_BUCKET="humbug-user-uploads" + + MIXPANEL_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" else: S3_KEY="xxxxxxxxxxxxxxxxxxxx" S3_SECRET_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" S3_BUCKET="humbug-user-uploads-test" + + MIXPANEL_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" diff --git a/templates/zephyr/base.html b/templates/zephyr/base.html index 7c1d20bc75..97c35c8d26 100644 --- a/templates/zephyr/base.html +++ b/templates/zephyr/base.html @@ -25,7 +25,7 @@ (function(e,b){if(!b.__SV){var a,f,i,g;window.mixpanel=b;a=e.createElement("script");a.type="text/javascript";a.async=!0;a.src=("https:"===e.location.protocol?"https:":"http:")+'//cdn.mxpnl.com/libs/mixpanel-2.2.min.js';f=e.getElementsByTagName("script")[0];f.parentNode.insertBefore(a,f);b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!== typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config people.set people.set_once people.increment people.append people.track_charge people.clear_charges people.delete_user".split(" ");for(g=0;g {# We need to import jQuery before Bootstrap #} diff --git a/zephyr/lib/response.py b/zephyr/lib/response.py index 5bf887e7a2..823a37b2d8 100644 --- a/zephyr/lib/response.py +++ b/zephyr/lib/response.py @@ -1,6 +1,7 @@ from __future__ import absolute_import from django.http import HttpResponse, HttpResponseNotAllowed +from django.conf import settings import django.shortcuts import simplejson @@ -30,5 +31,19 @@ def json_success(data={}): def json_error(msg, data={}, status=400): return json_response(res_type="error", msg=msg, data=data, status=status) +# We wrap render_to_response so that we can always add some data to +# the template context dictionary. In particular, we add the +# mixpanel token (which varies based on whether we're deployed or +# not) because the mixpanel code is included in base.html. def render_to_response(template, *args, **kwargs): + if args: + dictionary = args[0] + else: + try: + dictionary = kwargs['dictionary'] + except KeyError: + dictionary = {} + kwargs['dictionary'] = dictionary + + dictionary['mixpanel_token'] = settings.MIXPANEL_TOKEN return django.shortcuts.render_to_response(template, *args, **kwargs)