mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-12 14:00:17 +02:00
Analytics - Extra Ignore Path
This commit is contained in:
parent
38df580a56
commit
13e88492f1
@ -1,11 +1,11 @@
|
||||
# Generated by Django 3.1.13 on 2021-10-15 05:02
|
||||
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def modify_aa_team_token_add_page_ignore_paths(apps, schema_editor):
|
||||
# We can't import the Person model directly as it may be a newer
|
||||
# version than this migration expects. We use the historical version.
|
||||
# Add /admin/ and /user_notifications_count/ path to ignore
|
||||
|
||||
AnalyticsPath = apps.get_model('analytics', 'AnalyticsPath')
|
||||
admin = AnalyticsPath.objects.create(ignore_path=r"^\/admin\/.*")
|
||||
@ -17,8 +17,19 @@ def modify_aa_team_token_add_page_ignore_paths(apps, schema_editor):
|
||||
|
||||
|
||||
def undo_modify_aa_team_token_add_page_ignore_paths(apps, schema_editor):
|
||||
# nothing should need to migrate away here?
|
||||
return True
|
||||
#
|
||||
AnalyticsPath = apps.get_model('analytics', 'AnalyticsPath')
|
||||
Tokens = apps.get_model('analytics', 'AnalyticsTokens')
|
||||
|
||||
token = Tokens.objects.get(token="UA-186249766-2")
|
||||
try:
|
||||
admin = AnalyticsPath.objects.get(ignore_path=r"^\/admin\/.*", analyticstokens=token)
|
||||
user_notifications_count = AnalyticsPath.objects.get(ignore_path=r"^\/user_notifications_count\/.*", analyticstokens=token)
|
||||
admin.delete()
|
||||
user_notifications_count.delete()
|
||||
except ObjectDoesNotExist:
|
||||
# Its fine if it doesnt exist, we just dont want them building up when re-migrating
|
||||
pass
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
40
allianceauth/analytics/migrations/0006_more_ignore_paths.py
Normal file
40
allianceauth/analytics/migrations/0006_more_ignore_paths.py
Normal file
@ -0,0 +1,40 @@
|
||||
# Generated by Django 3.2.8 on 2021-10-19 01:47
|
||||
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def modify_aa_team_token_add_page_ignore_paths(apps, schema_editor):
|
||||
# Add the /account/activate path to ignore
|
||||
|
||||
AnalyticsPath = apps.get_model('analytics', 'AnalyticsPath')
|
||||
account_activate = AnalyticsPath.objects.create(ignore_path=r"^\/account\/activate\/.*")
|
||||
|
||||
Tokens = apps.get_model('analytics', 'AnalyticsTokens')
|
||||
token = Tokens.objects.get(token="UA-186249766-2")
|
||||
token.ignore_paths.add(account_activate)
|
||||
|
||||
|
||||
def undo_modify_aa_team_token_add_page_ignore_paths(apps, schema_editor):
|
||||
#
|
||||
AnalyticsPath = apps.get_model('analytics', 'AnalyticsPath')
|
||||
Tokens = apps.get_model('analytics', 'AnalyticsTokens')
|
||||
|
||||
token = Tokens.objects.get(token="UA-186249766-2")
|
||||
|
||||
try:
|
||||
account_activate = AnalyticsPath.objects.get(ignore_path=r"^\/account\/activate\/.*", analyticstokens=token)
|
||||
account_activate.delete()
|
||||
except ObjectDoesNotExist:
|
||||
# Its fine if it doesnt exist, we just dont want them building up when re-migrating
|
||||
pass
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('analytics', '0005_alter_analyticspath_ignore_path'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(modify_aa_team_token_add_page_ignore_paths, undo_modify_aa_team_token_add_page_ignore_paths)
|
||||
]
|
@ -21,8 +21,8 @@ if getattr(settings, "ANALYTICS_ENABLE_DEBUG", False) and settings.DEBUG:
|
||||
# Force sending of analytics data during in a debug/test environemt
|
||||
# Usefull for developers working on this feature.
|
||||
logger.warning(
|
||||
"You have 'ANALYTICS_ENABLE_DEBUG' Enabled! "
|
||||
"This debug instance will send analytics data!")
|
||||
"You have 'ANALYTICS_ENABLE_DEBUG' Enabled! "
|
||||
"This debug instance will send analytics data!")
|
||||
DEBUG_URL = COLLECTION_URL
|
||||
|
||||
ANALYTICS_URL = COLLECTION_URL
|
||||
@ -59,13 +59,13 @@ def analytics_event(category: str,
|
||||
|
||||
if allowed is True:
|
||||
tracking_id = token.token
|
||||
send_ga_tracking_celery_event.s(tracking_id=tracking_id,
|
||||
client_id=client_id,
|
||||
category=category,
|
||||
action=action,
|
||||
label=label,
|
||||
value=value).\
|
||||
apply_async(priority=9)
|
||||
send_ga_tracking_celery_event.s(
|
||||
tracking_id=tracking_id,
|
||||
client_id=client_id,
|
||||
category=category,
|
||||
action=action,
|
||||
label=label,
|
||||
value=value).apply_async(priority=9)
|
||||
|
||||
|
||||
@shared_task()
|
||||
|
Loading…
x
Reference in New Issue
Block a user