mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
Use different mixpanel tokens while deployed vs in development
(imported from commit 4fac466a822d49cb0e1a7592dbd77d8ee019803e)
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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<i.length;g++)f(c,i[g]);
|
||||
b._i.push([a,e,d])};b.__SV=1.2}})(document,window.mixpanel||[]);
|
||||
mixpanel.init("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
|
||||
mixpanel.init("{{ mixpanel_token }}");
|
||||
</script>
|
||||
|
||||
{# We need to import jQuery before Bootstrap #}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user