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,15 +18,11 @@ class AnalyticsHub {
} }
async activate() { async activate() {
try {
// Check analytics are enabled // Check analytics are enabled
const analyticsStatus = await API.getAnalyticsStatus() const analyticsStatus = await API.getAnalyticsStatus()
if (analyticsStatus.enabled) { if (analyticsStatus.enabled) {
this.clients.forEach(client => client.init()) this.clients.forEach(client => client.init())
} }
} catch (error) {
notifications.error("Error checking analytics status")
}
} }
identify(id, metadata) { identify(id, metadata) {

View File

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