fix(analytics): record user ID in GA if consented

This commit is contained in:
Kalista Payne
2025-08-27 13:59:15 -05:00
parent 7644e202c9
commit 305192ed1f
2 changed files with 7 additions and 3 deletions

View File

@@ -106,8 +106,9 @@ export async function setup () {
const user = _getConsentedUser();
if (!user) return;
await Vue.loadScript(`https://www.googletagmanager.com/gtag/js?id=${GA_ID}`);
if (DEBUG_ENABLED || !IS_PRODUCTION) {
window.gtag('config', GA_ID, { debug_mode: true });
}
window.gtag('config', GA_ID, {
debug_mode: DEBUG_ENABLED || !IS_PRODUCTION,
user_id: user._id,
});
amplitude.getInstance().init(AMPLITUDE_KEY);
}

View File

@@ -121,6 +121,9 @@ export async function appleAuth (store, params) {
export function logout (store, options = {}) {
localStorage.clear();
sessionStorage.clear();
if (window.gtag) {
window.gtag('config', GA_ID, { user_id: null });
}
const query = options.redirectToLogin === true ? '?redirectToLogin=true' : '';
window.location.href = `/logout-server${query}`;
}