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
This commit is contained in:
Shivam Mishra
2024-07-15 17:42:35 +05:30
committed by GitHub
parent 787ac3134d
commit 5cfac31f93

View File

@@ -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,