Don't show an error if analytics fails to activate

This commit is contained in:
Andrew Kingston 2022-01-24 18:58:22 +00:00
parent da4d462f8c
commit 18d5d66a71
2 changed files with 22 additions and 19 deletions

View File

@ -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())
}
}

View File

@ -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.
})
})
}
}