Commits

Simon Law  committed 86bad29

Make it possible to disable enrollment and goal record analytics.

  • Participants
  • Parent commits c03c64b

Comments (0)

Files changed (1)

File django_lean/lean_analytics/models.py

+from django.conf import settings
+
 from django_lean.experiments.models import GoalRecord
 from django_lean.experiments.signals import goal_recorded, user_enrolled
 from django_lean.lean_analytics import get_all_analytics
 
 
 def analytics_goalrecord(sender, goal_record, experiment_user, *args, **kwargs):
-    for analytics in get_all_analytics():
-        analytics.record(goal_record=goal_record,
-                         experiment_user=experiment_user)
+    if getattr(settings, 'LEAN_ANALYTICS_FOR_EXPERIMENTS', False):
+        for analytics in get_all_analytics():
+            analytics.record(goal_record=goal_record,
+                             experiment_user=experiment_user)
 
 goal_recorded.connect(analytics_goalrecord, sender=GoalRecord)
 
 def analytics_enrolled(sender, experiment, experiment_user, group_id,
                        *args, **kwargs):
-    for analytics in get_all_analytics():
-        analytics.enroll(experiment=experiment,
-                         experiment_user=experiment_user,
-                         group_id=group_id)
+    if getattr(settings, 'LEAN_ANALYTICS_FOR_EXPERIMENTS', False):
+        for analytics in get_all_analytics():
+            analytics.enroll(experiment=experiment,
+                             experiment_user=experiment_user,
+                             group_id=group_id)
 
 user_enrolled.connect(analytics_enrolled)