From 30865c510eb4e1f2d9390ea5860fbedb2bbc1b99 Mon Sep 17 00:00:00 2001 From: christopherpettinga Date: Tue, 5 Mar 2024 16:11:23 +0000 Subject: [PATCH] ICMSLST-2524 - Update to GA tags Analytics team sent us the wrong scripts tags, the new ones no longer contain the auth code or the environment --- .env.local-docker | 8 -------- web/jinja2.py | 12 ------------ web/templates/base.html | 25 +++++++++---------------- web/tests/views/test_cookie_views.py | 16 +--------------- 4 files changed, 10 insertions(+), 51 deletions(-) diff --git a/.env.local-docker b/.env.local-docker index 98eae61c8..59936f926 100644 --- a/.env.local-docker +++ b/.env.local-docker @@ -94,14 +94,6 @@ E2E_USER_PASSWORD=admin # Google Analytics GTM_ENABLED=False -GTM_CASEWORKER_AUTH_KEY='' -GTM_IMPORTER_AUTH_KEY='' -GTM_EXPORTER_AUTH_KEY='' - GTM_CASEWORKER_CONTAINER_ID='' GTM_IMPORTER_CONTAINER_ID='' GTM_EXPORTER_CONTAINER_ID='' - -GTM_CASEWORKER_PREVIEW_KEY='' -GTM_IMPORTER_PREVIEW_KEY='' -GTM_EXPORTER_PREVIEW_KEY='' diff --git a/web/jinja2.py b/web/jinja2.py index 41f384018..603401f6a 100644 --- a/web/jinja2.py +++ b/web/jinja2.py @@ -194,9 +194,7 @@ def environment(**options): "get_css_rules_as_string": get_css_rules_as_string, "get_file_base64": get_file_base64, "gtm_enabled": settings.GTM_ENABLED, - "get_gtm_auth_key": get_gtm_auth_key, "get_gtm_container_id": get_gtm_container_id, - "get_gtm_preview_key": get_gtm_preview_key, } ) env.filters["show_all_attrs"] = show_all_attrs @@ -220,16 +218,6 @@ def get_file_base64(path: str) -> str: return base64.b64encode(file_path.read_bytes()).decode("utf-8") # /PS-IGNORE -def get_gtm_auth_key(request: AuthenticatedHttpRequest) -> str: - current_site = request.site - return settings.GTM_AUTH_KEYS[current_site.name] - - def get_gtm_container_id(request: AuthenticatedHttpRequest) -> str: current_site = request.site return settings.GTM_CONTAINER_IDS[current_site.name] - - -def get_gtm_preview_key(request: AuthenticatedHttpRequest) -> str: - current_site = request.site - return settings.GTM_PREVIEW_KEYS[current_site.name] diff --git a/web/templates/base.html b/web/templates/base.html index 8448f839e..e2a1060f7 100644 --- a/web/templates/base.html +++ b/web/templates/base.html @@ -5,19 +5,13 @@ {% if gtm_enabled %} - + {% endif %} @@ -48,9 +42,8 @@ {% if gtm_enabled %} {% endif %} diff --git a/web/tests/views/test_cookie_views.py b/web/tests/views/test_cookie_views.py index a8929f983..878908f3a 100644 --- a/web/tests/views/test_cookie_views.py +++ b/web/tests/views/test_cookie_views.py @@ -13,42 +13,28 @@ class TestGtmTags: def test_site_names_match(self): - """Testing that the keys used in the GTM dicts match the actual SiteName choices.""" - assert set(settings.GTM_AUTH_KEYS.keys()) == set(SiteName.labels) + """Testing that the keys used in the GTM container dict match the actual SiteName choices.""" assert set(settings.GTM_CONTAINER_IDS.keys()) == set(SiteName.labels) - assert set(settings.GTM_PREVIEW_KEYS.keys()) == set(SiteName.labels) @override_settings( - GTM_AUTH_KEYS={"Caseworker": "cw_auth_key"}, GTM_CONTAINER_IDS={"Caseworker": "cw_container_id"}, - GTM_PREVIEW_KEYS={"Caseworker": "cw_preview_key"}, ) def test_caseworker_tags_rendered_correctly(self, cw_client): response = cw_client.get("", follow=True) - assert "gtm_auth=cw_auth_key" in response.content.decode("utf-8") - assert "gtm_preview=cw_preview_key" in response.content.decode("utf-8") assert "id=cw_container_id" in response.content.decode("utf-8") @override_settings( - GTM_AUTH_KEYS={"Export A Certificate": "export_auth_key"}, GTM_CONTAINER_IDS={"Export A Certificate": "export_container_id"}, - GTM_PREVIEW_KEYS={"Export A Certificate": "export_preview_key"}, ) def test_export_tags_rendered_correctly(self, exporter_client): response = exporter_client.get("", follow=True) - assert "gtm_auth=export_auth_key" in response.content.decode("utf-8") - assert "gtm_preview=export_preview_key" in response.content.decode("utf-8") assert "id=export_container_id" in response.content.decode("utf-8") @override_settings( - GTM_AUTH_KEYS={"Import A Licence": "import_auth_key"}, GTM_CONTAINER_IDS={"Import A Licence": "import_container_id"}, - GTM_PREVIEW_KEYS={"Import A Licence": "import_preview_key"}, ) def test_import_tags_rendered_correctly(self, importer_client): response = importer_client.get("", follow=True) - assert "gtm_auth=import_auth_key" in response.content.decode("utf-8") - assert "gtm_preview=import_preview_key" in response.content.decode("utf-8") assert "id=import_container_id" in response.content.decode("utf-8")