diff --git a/package.json b/package.json index 7f6a6b4ae3..f727f0ed5d 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,6 @@ "@babel/core": "^7.22.10", "@babel/preset-env": "^7.22.10", "@babel/register": "^7.22.15", - "@google-analytics/data": "^4.12.1", "@google-cloud/trace-agent": "^7.1.2", "@parse/node-apn": "^5.2.3", "@slack/webhook": "^6.1.0", diff --git a/website/client/src/libs/analytics.js b/website/client/src/libs/analytics.js index 8606d044b4..b60d40a3d7 100644 --- a/website/client/src/libs/analytics.js +++ b/website/client/src/libs/analytics.js @@ -5,7 +5,6 @@ import Vue from 'vue'; import getStore from '@/store'; const DEBUG_ENABLED = import.meta.env.DEBUG_ENABLED === 'true'; -const GA_ID = import.meta.env.GA_ID; const IS_PRODUCTION = import.meta.env.NODE_ENV === 'production'; const REQUIRED_FIELDS = ['eventCategory', 'eventAction']; @@ -66,14 +65,6 @@ export function track (properties, options = {}) { // Use nextTick to avoid blocking the UI Vue.nextTick(() => { if (_doesNotHaveRequiredFields(properties)) return; - - const trackOnClient = options && options.trackOnClient === true; - // Track events on the server by default - if (trackOnClient === true) { - if (window.gtag) { - window.gtag('event', properties.eventAction, properties); - } - } const store = getStore(); store.dispatch('analytics:trackEvent', properties); }); @@ -85,20 +76,7 @@ export function updateUser (properties = {}) { // Use nextTick to avoid blocking the UI Vue.nextTick(() => { _gatherUserStats(properties); - if (window.gtag) { - window.gtag('set', 'user_properties', properties); - } const store = getStore(); store.dispatch('analytics:updateUserProperties', properties); }); } - -export async function setup () { - const user = _getConsentedUser(); - if (!user) return; - await Vue.loadScript(`https://www.googletagmanager.com/gtag/js?id=${GA_ID}`); - window.gtag('config', GA_ID, { - debug_mode: DEBUG_ENABLED || !IS_PRODUCTION, - user_id: user._id, - }); -} diff --git a/website/client/src/store/actions/auth.js b/website/client/src/store/actions/auth.js index ecb84d9066..13593bbca6 100644 --- a/website/client/src/store/actions/auth.js +++ b/website/client/src/store/actions/auth.js @@ -1,8 +1,6 @@ import axios from 'axios'; import { authAsCredentialsState, LOCALSTORAGE_AUTH_KEY } from '@/libs/auth'; -const GA_ID = import.meta.env.GA_ID; - function saveLocalDataAuth (store, apiId, apiToken) { const credentialsObj = { auth: { @@ -123,9 +121,6 @@ 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}`; } diff --git a/website/client/vite.config.mjs b/website/client/vite.config.mjs index a664909fc5..61c3615818 100644 --- a/website/client/vite.config.mjs +++ b/website/client/vite.config.mjs @@ -26,7 +26,6 @@ const envVars = [ 'EMAILS_COMMUNITY_MANAGER_EMAIL', 'EMAILS_TECH_ASSISTANCE_EMAIL', 'EMAILS_PRESS_ENQUIRY_EMAIL', - 'GA_ID', 'STRIPE_PUB_KEY', 'GOOGLE_CLIENT_ID', 'APPLE_AUTH_CLIENT_ID', diff --git a/website/server/libs/analyticsService.js b/website/server/libs/analyticsService.js index 1799cdf46c..b5d5f5e4ab 100644 --- a/website/server/libs/analyticsService.js +++ b/website/server/libs/analyticsService.js @@ -261,7 +261,7 @@ function _updateProperties (properties, uuid) { .catch(err => logger.error(err, 'Error while sending data to Amplitude.')); } -// There's no error handling directly here because it's handled inside _sendDataTo{Amplitude|Google} +// There's no error handling directly here because it's handled inside _sendDataToAmplitude async function track (eventType, data, loggerOnly = false) { const { user } = data; if (!user || !user.preferences || !user.preferences.analyticsConsent) { @@ -280,7 +280,7 @@ async function track (eventType, data, loggerOnly = false) { } // There's no error handling directly here because -// it's handled inside _sendPurchaseDataTo{Amplitude|Google} +// it's handled inside _sendPurchaseDataToAmplitude async function trackPurchase (data) { const { user } = data; if (!user || !user.preferences || !user.preferences.analyticsConsent) {