mirror of
https://github.com/jazzband/django-analytical.git
synced 2026-03-16 22:20:25 +00:00
Add tests for anonymous user
This commit is contained in:
parent
3503561666
commit
0e8b4b244a
12 changed files with 77 additions and 26 deletions
|
|
@ -4,7 +4,7 @@ Tests for the Clicky template tags and filters.
|
|||
|
||||
import re
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User, AnonymousUser
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
|
||||
|
|
@ -46,6 +46,11 @@ class ClickyTagTestCase(TagTestCase):
|
|||
'var clicky_custom = {"session": {"username": "test"}};' in r,
|
||||
r)
|
||||
|
||||
@override_settings(ANALYTICAL_AUTO_IDENTIFY=True)
|
||||
def test_identify_anonymous_user(self):
|
||||
r = ClickyNode().render(Context({'user': AnonymousUser()}))
|
||||
self.assertFalse('var clicky_custom = {"session": {"username":' in r, r)
|
||||
|
||||
def test_custom(self):
|
||||
r = ClickyNode().render(Context({'clicky_var1': 'val1',
|
||||
'clicky_var2': 'val2'}))
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Tests for the GoSquared template tags and filters.
|
||||
"""
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User, AnonymousUser
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
|
||||
|
|
@ -48,6 +48,11 @@ class GoSquaredTagTestCase(TagTestCase):
|
|||
}))
|
||||
self.assertTrue('GoSquared.UserName = "test_identity";' in r, r)
|
||||
|
||||
@override_settings(ANALYTICAL_AUTO_IDENTIFY=True)
|
||||
def test_identify_anonymous_user(self):
|
||||
r = GoSquaredNode().render(Context({'user': AnonymousUser()}))
|
||||
self.assertFalse('GoSquared.UserName = ' in r, r)
|
||||
|
||||
@override_settings(ANALYTICAL_INTERNAL_IPS=['1.1.1.1'])
|
||||
def test_render_internal_ip(self):
|
||||
req = HttpRequest()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Tests for the KISSinsights template tags and filters.
|
||||
"""
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User, AnonymousUser
|
||||
from django.template import Context
|
||||
|
||||
from analytical.templatetags.kiss_insights import KissInsightsNode
|
||||
|
|
@ -46,6 +46,11 @@ class KissInsightsTagTestCase(TagTestCase):
|
|||
r = KissInsightsNode().render(Context({'user': User(username='test')}))
|
||||
self.assertTrue("_kiq.push(['identify', 'test']);" in r, r)
|
||||
|
||||
@override_settings(ANALYTICAL_AUTO_IDENTIFY=True)
|
||||
def test_identify_anonymous_user(self):
|
||||
r = KissInsightsNode().render(Context({'user': AnonymousUser()}))
|
||||
self.assertFalse("_kiq.push(['identify', " in r, r)
|
||||
|
||||
def test_show_survey(self):
|
||||
r = KissInsightsNode().render(
|
||||
Context({'kiss_insights_show_survey': 1234}))
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Tests for the KISSmetrics tags and filters.
|
||||
"""
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User, AnonymousUser
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
|
||||
|
|
@ -47,6 +47,11 @@ class KissMetricsTagTestCase(TagTestCase):
|
|||
r = KissMetricsNode().render(Context({'user': User(username='test')}))
|
||||
self.assertTrue("_kmq.push(['identify', 'test']);" in r, r)
|
||||
|
||||
@override_settings(ANALYTICAL_AUTO_IDENTIFY=True)
|
||||
def test_identify_anonymous_user(self):
|
||||
r = KissMetricsNode().render(Context({'user': AnonymousUser()}))
|
||||
self.assertFalse("_kmq.push(['identify', " in r, r)
|
||||
|
||||
def test_event(self):
|
||||
r = KissMetricsNode().render(Context({'kiss_metrics_event':
|
||||
('test_event', {'prop1': 'val1', 'prop2': 'val2'})}))
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Tests for the Mixpanel tags and filters.
|
||||
"""
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User, AnonymousUser
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
|
||||
|
|
@ -46,6 +46,11 @@ class MixpanelTagTestCase(TagTestCase):
|
|||
r = MixpanelNode().render(Context({'user': User(username='test')}))
|
||||
self.assertTrue("mpq.push(['identify', 'test']);" in r, r)
|
||||
|
||||
@override_settings(ANALYTICAL_AUTO_IDENTIFY=True)
|
||||
def test_identify_anonymous_user(self):
|
||||
r = MixpanelNode().render(Context({'user': AnonymousUser()}))
|
||||
self.assertFalse("mpq.push(['identify', " in r, r)
|
||||
|
||||
def test_event(self):
|
||||
r = MixpanelNode().render(Context({'mixpanel_event':
|
||||
('test_event', {'prop1': 'val1', 'prop2': 'val2'})}))
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Tests for the Olark template tags and filters.
|
||||
"""
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User, AnonymousUser
|
||||
from django.template import Context
|
||||
|
||||
from analytical.templatetags.olark import OlarkNode
|
||||
|
|
@ -39,6 +39,11 @@ class OlarkTestCase(TagTestCase):
|
|||
self.assertTrue("olark('api.chat.updateVisitorNickname', "
|
||||
"{snippet: 'Test User (test)'});" in r, r)
|
||||
|
||||
@override_settings(ANALYTICAL_AUTO_IDENTIFY=True)
|
||||
def test_identify_anonymous_user(self):
|
||||
r = OlarkNode().render(Context({'user': AnonymousUser()}))
|
||||
self.assertFalse("olark('api.chat.updateVisitorNickname', " in r, r)
|
||||
|
||||
def test_nickname(self):
|
||||
r = OlarkNode().render(Context({'olark_nickname': 'testnick'}))
|
||||
self.assertTrue("olark('api.chat.updateVisitorNickname', "
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@
|
|||
Tests for the Performable template tags and filters.
|
||||
"""
|
||||
|
||||
from django.contrib.auth.models import User, AnonymousUser
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
|
||||
from analytical.templatetags.performable import PerformableNode
|
||||
from analytical.tests.utils import TagTestCase, override_settings, SETTING_DELETED
|
||||
from analytical.utils import AnalyticalException
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
@override_settings(PERFORMABLE_API_KEY='123ABC')
|
||||
|
|
@ -48,6 +48,11 @@ class PerformableTagTestCase(TagTestCase):
|
|||
r = PerformableNode().render(Context({'user': User(username='test')}))
|
||||
self.assertTrue('_paq.push(["identify", {identity: "test"}]);' in r, r)
|
||||
|
||||
@override_settings(ANALYTICAL_AUTO_IDENTIFY=True)
|
||||
def test_identify_anonymous_user(self):
|
||||
r = PerformableNode().render(Context({'user': AnonymousUser()}))
|
||||
self.assertFalse('_paq.push(["identify", ' in r, r)
|
||||
|
||||
|
||||
class PerformableEmbedTagTestCase(TagTestCase):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ Tests for the Reinvigorate template tags and filters.
|
|||
|
||||
import re
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User, AnonymousUser
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
|
||||
|
|
@ -44,6 +44,12 @@ class ReinvigorateTagTestCase(TagTestCase):
|
|||
self.assertTrue('var re_name_tag = "Test User";' in r, r)
|
||||
self.assertTrue('var re_context_tag = "test@example.com";' in r, r)
|
||||
|
||||
@override_settings(ANALYTICAL_AUTO_IDENTIFY=True)
|
||||
def test_identify_anonymous_user(self):
|
||||
r = ReinvigorateNode().render(Context({'user': AnonymousUser()}))
|
||||
self.assertFalse('var re_name_tag = ' in r, r)
|
||||
self.assertFalse('var re_context_tag = ' in r, r)
|
||||
|
||||
def test_tags(self):
|
||||
r = ReinvigorateNode().render(Context({'reinvigorate_var1': 'val1',
|
||||
'reinvigorate_var2': 2}))
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Tests for the SnapEngage template tags and filters.
|
||||
"""
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User, AnonymousUser
|
||||
from django.template import Context
|
||||
from django.utils import translation
|
||||
|
||||
|
|
@ -234,6 +234,11 @@ class SnapEngageTestCase(TagTestCase):
|
|||
User(username='test', email='test@example.com')}))
|
||||
self.assertTrue('SnapABug.setUserEmail("test@example.com");' in r, r)
|
||||
|
||||
@override_settings(ANALYTICAL_AUTO_IDENTIFY=True)
|
||||
def test_identify_anonymous_user(self):
|
||||
r = SnapEngageNode().render(Context({'user': AnonymousUser()}))
|
||||
self.assertFalse('SnapABug.setUserEmail(' in r, r)
|
||||
|
||||
def test_language(self):
|
||||
r = SnapEngageNode().render(Context({'snapengage_locale': 'fr'}))
|
||||
self.assertTrue('SnapABug.setLocale("fr");' in r, r)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ Tests for the Spring Metrics template tags and filters.
|
|||
|
||||
import re
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth.models import User, AnonymousUser
|
||||
from django.http import HttpRequest
|
||||
from django.template import Context
|
||||
|
||||
|
|
@ -43,6 +43,11 @@ class SpringMetricsTagTestCase(TagTestCase):
|
|||
self.assertTrue("_springMetq.push(['setdata', "
|
||||
"{'email': 'test@test.com'}]);" in r, r)
|
||||
|
||||
@override_settings(ANALYTICAL_AUTO_IDENTIFY=True)
|
||||
def test_identify_anonymous_user(self):
|
||||
r = SpringMetricsNode().render(Context({'user': AnonymousUser()}))
|
||||
self.assertFalse("_springMetq.push(['setdata', {'email':" in r, r)
|
||||
|
||||
def test_custom(self):
|
||||
r = SpringMetricsNode().render(Context({'spring_metrics_var1': 'val1',
|
||||
'spring_metrics_var2': 'val2'}))
|
||||
|
|
|
|||
|
|
@ -59,11 +59,6 @@ class WoopraTagTestCase(TagTestCase):
|
|||
r = WoopraNode().render(Context({'user': User(username='test')}))
|
||||
self.assertTrue('var woo_visitor = {"name": "test"};' in r, r)
|
||||
|
||||
@override_settings(ANALYTICAL_AUTO_IDENTIFY=True)
|
||||
def test_identify_anonymous_user(self):
|
||||
r = WoopraNode().render(Context({'user': AnonymousUser()}))
|
||||
self.assertTrue('var woo_visitor = {};' in r, r)
|
||||
|
||||
@override_settings(ANALYTICAL_AUTO_IDENTIFY=True)
|
||||
def test_no_identify_when_explicit_name(self):
|
||||
r = WoopraNode().render(Context({'woopra_name': 'explicit',
|
||||
|
|
@ -76,6 +71,11 @@ class WoopraTagTestCase(TagTestCase):
|
|||
'user': User(username='implicit')}))
|
||||
self.assertTrue('var woo_visitor = {"email": "explicit"};' in r, r)
|
||||
|
||||
@override_settings(ANALYTICAL_AUTO_IDENTIFY=True)
|
||||
def test_identify_anonymous_user(self):
|
||||
r = WoopraNode().render(Context({'user': AnonymousUser()}))
|
||||
self.assertTrue('var woo_visitor = {};' in r, r)
|
||||
|
||||
@override_settings(ANALYTICAL_INTERNAL_IPS=['1.1.1.1'])
|
||||
def test_render_internal_ip(self):
|
||||
req = HttpRequest()
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Spring Metrics -- conversion tracking
|
|||
=====================================
|
||||
|
||||
`Spring Metrics`_ is a convesions analysis tool. It shows you the top
|
||||
converting sources, search keywords ande landing pages. The real-time
|
||||
dashboard shows you how customers interacted with your website and how
|
||||
converting sources, search keywords and landing pages. The real-time
|
||||
dashboard shows you how customers interact with your website and how
|
||||
to increase conversion.
|
||||
|
||||
.. _`Spring Metrics`: http://www.springmetrics.com/
|
||||
|
|
@ -87,11 +87,11 @@ Alternatively, you can mark conversion pages using the
|
|||
Tracking revenue
|
||||
----------------
|
||||
|
||||
The most important value tracked by Spring Metrics is that of revenue.
|
||||
Using the :data:`spring_metrics_revenue` template context variable, you
|
||||
can let the :ttag:`spring_metrics` tag pass earned revenue to Spring
|
||||
Metrics. You can set the context variable in your view when you render
|
||||
a template containing thetracking code::
|
||||
Spring Metrics allows you to track the value of conversions. Using the
|
||||
:data:`spring_metrics_revenue` template context variable, you can let
|
||||
the :ttag:`spring_metrics` tag pass earned revenue to Spring Metrics.
|
||||
You can set the context variable in your view when you render a
|
||||
template containing the tracking code::
|
||||
|
||||
context = RequestContext({
|
||||
'spring_metrics_convert': 'sale',
|
||||
|
|
@ -106,10 +106,10 @@ if you already tagged the page in Spring Metrics.)
|
|||
Custom data
|
||||
-----------
|
||||
|
||||
Spring Metrics can also track other data. Interesting examples would be
|
||||
transaction IDs or e-mail addresses from logged in users. By setting
|
||||
any :data:`spring_metrics_X` template context variable, Spring Metrics
|
||||
will track a variable named :data:`X`. For example::
|
||||
Spring Metrics can also track other data. Interesting examples could be
|
||||
transaction IDs or the e-mail addresses from logged in users. By
|
||||
setting any :data:`spring_metrics_X` template context variable, Spring
|
||||
Metrics will track a variable named :data:`X`. For example::
|
||||
|
||||
context = RequestContext({
|
||||
'spring_metrics_revenue': '30.53',
|
||||
|
|
|
|||
Loading…
Reference in a new issue