From 8ac7ae8d1f9ee599965c5d468d59b7ef5c27909a Mon Sep 17 00:00:00 2001
From: Jason Jackson
Date: Wed, 13 Nov 2024 17:10:31 -0500
Subject: [PATCH 1/6] Wrap calls to ga check for analytics_tracking_id
---
.../themes/material/default/selectidp-links.twig | 8 ++++++--
.../themes/material/mfa/new-backup-codes.twig | 8 +++++---
.../material/mfa/prompt-for-mfa-backupcode.twig | 8 +++++---
.../themes/material/mfa/prompt-for-mfa-manager.twig | 8 +++++---
.../themes/material/mfa/prompt-for-mfa-totp.twig | 8 +++++---
.../themes/material/mfa/prompt-for-mfa-webauthn.twig | 2 +-
.../themes/material/silauth/loginuserpass.twig | 12 ++++++++----
7 files changed, 35 insertions(+), 19 deletions(-)
diff --git a/modules/material/themes/material/default/selectidp-links.twig b/modules/material/themes/material/default/selectidp-links.twig
index 3609027..1e55d3e 100644
--- a/modules/material/themes/material/default/selectidp-links.twig
+++ b/modules/material/themes/material/default/selectidp-links.twig
@@ -15,11 +15,15 @@
document.querySelector('form').appendChild(idpInput);
- ga('send', 'event', 'hub', 'choice', 'IdP', id);
+ {% if analytics_tracking_id is not empty %}
+ ga('send', 'event', 'hub', 'choice', 'IdP', id);
+ {% endif %}
}
function clickedAnyway(idpName) {
- ga('send', 'event', 'hub', 'choice-disabled', 'IdP', idpName);
+ {% if analytics_tracking_id is not empty %}
+ ga('send', 'event', 'hub', 'choice-disabled', 'IdP', idpName);
+ {% endif %}
}
diff --git a/modules/material/themes/material/mfa/new-backup-codes.twig b/modules/material/themes/material/mfa/new-backup-codes.twig
index 015b637..12dd59d 100644
--- a/modules/material/themes/material/mfa/new-backup-codes.twig
+++ b/modules/material/themes/material/mfa/new-backup-codes.twig
@@ -136,9 +136,11 @@
-
+ {% if analytics_tracking_id is not empty %}
+
+ {% endif %}
{% endif %}
diff --git a/modules/material/themes/material/mfa/prompt-for-mfa-backupcode.twig b/modules/material/themes/material/mfa/prompt-for-mfa-backupcode.twig
index 3f6603b..a275153 100644
--- a/modules/material/themes/material/mfa/prompt-for-mfa-backupcode.twig
+++ b/modules/material/themes/material/mfa/prompt-for-mfa-backupcode.twig
@@ -53,9 +53,11 @@
-
+ {% if analytics_tracking_id is not empty %}
+
+ {% endif %}
{% endif %}
diff --git a/modules/material/themes/material/mfa/prompt-for-mfa-manager.twig b/modules/material/themes/material/mfa/prompt-for-mfa-manager.twig
index 0a6197b..d7ab56a 100644
--- a/modules/material/themes/material/mfa/prompt-for-mfa-manager.twig
+++ b/modules/material/themes/material/mfa/prompt-for-mfa-manager.twig
@@ -53,9 +53,11 @@
-
+ {% if analytics_tracking_id is not empty %}
+
+ {% endif %}
{% endif %}
diff --git a/modules/material/themes/material/mfa/prompt-for-mfa-totp.twig b/modules/material/themes/material/mfa/prompt-for-mfa-totp.twig
index b6701a5..d8dd51c 100644
--- a/modules/material/themes/material/mfa/prompt-for-mfa-totp.twig
+++ b/modules/material/themes/material/mfa/prompt-for-mfa-totp.twig
@@ -51,9 +51,11 @@
-
+ {% if analytics_tracking_id is not empty %}
+
+ {% endif %}
{% endif %}
diff --git a/modules/material/themes/material/mfa/prompt-for-mfa-webauthn.twig b/modules/material/themes/material/mfa/prompt-for-mfa-webauthn.twig
index e15c1b4..61370b2 100644
--- a/modules/material/themes/material/mfa/prompt-for-mfa-webauthn.twig
+++ b/modules/material/themes/material/mfa/prompt-for-mfa-webauthn.twig
@@ -94,7 +94,7 @@
- {% if error_message is not empty %}
+ {% if error_message is not empty and analytics_tracking_id is not empty %}
diff --git a/modules/material/themes/material/silauth/loginuserpass.twig b/modules/material/themes/material/silauth/loginuserpass.twig
index f56333d..bfafb71 100644
--- a/modules/material/themes/material/silauth/loginuserpass.twig
+++ b/modules/material/themes/material/silauth/loginuserpass.twig
@@ -28,7 +28,9 @@
});
}
- ga('send', 'event', 'reCAPTCHA', 'required');
+ {% if analytics_tracking_id is not empty %}
+ ga('send', 'event', 'reCAPTCHA', 'required');
+ {% endif %}
{% endif %}
@@ -100,9 +102,11 @@
-
+ {% if analytics_tracking_id is not empty %}
+
+ {% endif %}
{% endif %}
From 81b1ecd431d67ba156b00ba1bff96a2201576f7a Mon Sep 17 00:00:00 2001
From: Michael Wilson
Date: Wed, 27 Nov 2024 07:32:21 +0930
Subject: [PATCH 2/6] fix google analytics and use don't use inline onclick
---
.../material/default/selectidp-links.twig | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/modules/material/themes/material/default/selectidp-links.twig b/modules/material/themes/material/default/selectidp-links.twig
index 3609027..acec01a 100644
--- a/modules/material/themes/material/default/selectidp-links.twig
+++ b/modules/material/themes/material/default/selectidp-links.twig
@@ -14,9 +14,21 @@
idpInput.value = id;
document.querySelector('form').appendChild(idpInput);
-
- ga('send', 'event', 'hub', 'choice', 'IdP', id);
+ gtag('event', 'IdP', {
+ 'event_category': 'hub',
+ 'event_label': 'choice',
+ 'value': id
+ });
+ document.querySelector('form').submit();
}
+
+ document.addEventListener('DOMContentLoaded', () => {
+ document.querySelectorAll('button[data-entityid]').forEach((idp) => {
+ idp.addEventListener('click', () => {
+ setSelectedIdp(idp.dataset.entityid);
+ });
+ });
+ });
function clickedAnyway(idpName) {
ga('send', 'event', 'hub', 'choice-disabled', 'IdP', idpName);
@@ -61,7 +73,7 @@
title="{{ '{selectidp-links:enabled}'|trans({'%idpName%': idp|entityDisplayName}) }}"
>