mirror of
https://github.com/jazzband/django-analytical.git
synced 2026-03-16 22:20:25 +00:00
Rename MIXPANEL_TOKEN setting
Wes Winham's mixpanel-celery package uses the MIXPANEL_API_TOKEN setting. Use the same name for the Mixpanel token setting.
This commit is contained in:
parent
8649c07c24
commit
27b272f6fd
5 changed files with 19 additions and 11 deletions
|
|
@ -1,3 +1,10 @@
|
|||
Version 0.7.0
|
||||
-------------
|
||||
* Renamed ``MIXPANEL_TOKEN`` setting to ``MIXPANEL_API_TOKEN`` for
|
||||
compatibility with Wes Winham's mixpanel-celery_ package.
|
||||
|
||||
.. _mixpanel_celery: https://github.com/winhamwr/mixpanel-celery
|
||||
|
||||
Version 0.6.0
|
||||
-------------
|
||||
* Added support for the Reinvigorate service.
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ from analytical.utils import is_internal_ip, disable_html, get_identity, \
|
|||
get_required_setting
|
||||
|
||||
|
||||
MIXPANEL_TOKEN_RE = re.compile(r'^[0-9a-f]{32}$')
|
||||
MIXPANEL_API_TOKEN_RE = re.compile(r'^[0-9a-f]{32}$')
|
||||
TRACKING_CODE = """
|
||||
<script type="text/javascript">
|
||||
var mpq = [];
|
||||
|
|
@ -39,7 +39,7 @@ def mixpanel(parser, token):
|
|||
Mixpanel tracking template tag.
|
||||
|
||||
Renders Javascript code to track page visits. You must supply
|
||||
your Mixpanel token in the ``MIXPANEL_TOKEN`` setting.
|
||||
your Mixpanel token in the ``MIXPANEL_API_TOKEN`` setting.
|
||||
"""
|
||||
bits = token.split_contents()
|
||||
if len(bits) > 1:
|
||||
|
|
@ -48,8 +48,8 @@ def mixpanel(parser, token):
|
|||
|
||||
class MixpanelNode(Node):
|
||||
def __init__(self):
|
||||
self.token = get_required_setting('MIXPANEL_TOKEN',
|
||||
MIXPANEL_TOKEN_RE,
|
||||
self.token = get_required_setting(
|
||||
'MIXPANEL_API_TOKEN', MIXPANEL_API_TOKEN_RE,
|
||||
"must be a string containing a 32-digit hexadecimal number")
|
||||
|
||||
def render(self, context):
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class MixpanelTagTestCase(TagTestCase):
|
|||
super(MixpanelTagTestCase, self).setUp()
|
||||
self.settings_manager.set(OPTIMIZELY_ACCOUNT_NUMBER='1234567')
|
||||
self.settings_manager.set(
|
||||
MIXPANEL_TOKEN='0123456789abcdef0123456789abcdef')
|
||||
MIXPANEL_API_TOKEN='0123456789abcdef0123456789abcdef')
|
||||
|
||||
def test_tag(self):
|
||||
r = self.render_tag('mixpanel', 'mixpanel')
|
||||
|
|
@ -35,15 +35,15 @@ class MixpanelTagTestCase(TagTestCase):
|
|||
r)
|
||||
|
||||
def test_no_token(self):
|
||||
self.settings_manager.delete('MIXPANEL_TOKEN')
|
||||
self.settings_manager.delete('MIXPANEL_API_TOKEN')
|
||||
self.assertRaises(AnalyticalException, MixpanelNode)
|
||||
|
||||
def test_wrong_token(self):
|
||||
self.settings_manager.set(
|
||||
MIXPANEL_TOKEN='0123456789abcdef0123456789abcde')
|
||||
MIXPANEL_API_TOKEN='0123456789abcdef0123456789abcde')
|
||||
self.assertRaises(AnalyticalException, MixpanelNode)
|
||||
self.settings_manager.set(
|
||||
MIXPANEL_TOKEN='0123456789abcdef0123456789abcdef0')
|
||||
MIXPANEL_API_TOKEN='0123456789abcdef0123456789abcdef0')
|
||||
self.assertRaises(AnalyticalException, MixpanelNode)
|
||||
|
||||
def test_identify(self):
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ settings required to enable each service are listed here:
|
|||
|
||||
* :doc:`Mixpanel <services/mixpanel>`::
|
||||
|
||||
MIXPANEL_TOKEN = '0123456789abcdef0123456789abcdef'
|
||||
MIXPANEL_API_TOKEN = '0123456789abcdef0123456789abcdef'
|
||||
|
||||
* :doc:`Optimizely <services/optimizely>`::
|
||||
|
||||
|
|
|
|||
|
|
@ -55,9 +55,10 @@ Setting the token
|
|||
Every website you track events for with Mixpanel gets its own token,
|
||||
and the :ttag:`mixpanel` tag will include it in the rendered Javascript
|
||||
code. You can find the project token on the Mixpanel *projects* page.
|
||||
Set :const:`MIXPANEL_TOKEN` in the project :file:`settings.py` file::
|
||||
Set :const:`MIXPANEL_API_TOKEN` in the project :file:`settings.py`
|
||||
file::
|
||||
|
||||
MIXPANEL_TOKEN = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
||||
MIXPANEL_API_TOKEN = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
||||
|
||||
If you do not set a token, the tracking code will not be rendered.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue