From e1a1d472381a5e22f7ed2acb8a9b5054a946d1d5 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 24 Jan 2022 18:58:22 +0000 Subject: [PATCH] Don't show an error if analytics fails to activate --- packages/builder/src/analytics/index.js | 12 +++------ packages/builder/src/stores/portal/auth.js | 29 ++++++++++++++-------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/packages/builder/src/analytics/index.js b/packages/builder/src/analytics/index.js index 26947a2320..a9c3d2e2d7 100644 --- a/packages/builder/src/analytics/index.js +++ b/packages/builder/src/analytics/index.js @@ -18,14 +18,10 @@ class AnalyticsHub { } async activate() { - try { - // Check analytics are enabled - const analyticsStatus = await API.getAnalyticsStatus() - if (analyticsStatus.enabled) { - this.clients.forEach(client => client.init()) - } - } catch (error) { - notifications.error("Error checking analytics status") + // Check analytics are enabled + const analyticsStatus = await API.getAnalyticsStatus() + if (analyticsStatus.enabled) { + this.clients.forEach(client => client.init()) } } diff --git a/packages/builder/src/stores/portal/auth.js b/packages/builder/src/stores/portal/auth.js index 3895b57e82..b0f626099c 100644 --- a/packages/builder/src/stores/portal/auth.js +++ b/packages/builder/src/stores/portal/auth.js @@ -54,18 +54,25 @@ export function createAuthStore() { }) if (user) { - analytics.activate().then(() => { - analytics.identify(user._id, user) - analytics.showChat({ - email: user.email, - created_at: (user.createdAt || Date.now()) / 1000, - name: user.account?.name, - user_id: user._id, - tenant: user.tenantId, - "Company size": user.account?.size, - "Job role": user.account?.profession, + analytics + .activate() + .then(() => { + analytics.identify(user._id, user) + analytics.showChat({ + email: user.email, + created_at: (user.createdAt || Date.now()) / 1000, + name: user.account?.name, + user_id: user._id, + tenant: user.tenantId, + "Company size": user.account?.size, + "Job role": user.account?.profession, + }) + }) + .catch(() => { + // This request may fail due to browser extensions blocking requests + // containing the word analytics, so we don't want to spam users with + // an error here. }) - }) } }