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 81558588dc
commit e1a1d47238
2 changed files with 22 additions and 19 deletions

View File

@ -18,15 +18,11 @@ 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")
}
}
identify(id, metadata) {

View File

@ -54,7 +54,9 @@ export function createAuthStore() {
})
if (user) {
analytics.activate().then(() => {
analytics
.activate()
.then(() => {
analytics.identify(user._id, user)
analytics.showChat({
email: user.email,
@ -66,6 +68,11 @@ export function createAuthStore() {
"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.
})
}
}