From 5cfac31f930f9be79cd16d0d6916aee99751a889 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Mon, 15 Jul 2024 17:42:35 +0530 Subject: [PATCH] fix: return if user is not present (#9768) Fixes https://chatwoot-p3.sentry.io/share/issue/aa6a3c0accb345e984ed80eaddc3efd5/ In the case where the user is redirected to the page from a redirect like google login, the analytics helper breaks. This PR fixes it by checking if the user is present. This does not break the user email tracking since the user is redirected anyway and the `AnalyticsHelper` is reinitialised --- app/javascript/dashboard/helper/AnalyticsHelper/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/javascript/dashboard/helper/AnalyticsHelper/index.js b/app/javascript/dashboard/helper/AnalyticsHelper/index.js index bf91d9a91..382f8aab0 100644 --- a/app/javascript/dashboard/helper/AnalyticsHelper/index.js +++ b/app/javascript/dashboard/helper/AnalyticsHelper/index.js @@ -38,9 +38,10 @@ export class AnalyticsHelper { * @param {Object} user - User object */ identify(user) { - if (!this.analytics) { + if (!this.analytics || !user) { return; } + this.user = user; this.analytics.identify(this.user.email, { userId: this.user.id,