From 94785c0c5faa32e00995a05090b64966ef6a7749 Mon Sep 17 00:00:00 2001 From: Ori Efrati Date: Fri, 12 Jan 2024 02:04:53 +0200 Subject: [PATCH] fix init --- examples/client/Locomotion/src/services/Mixpanel.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/client/Locomotion/src/services/Mixpanel.js b/examples/client/Locomotion/src/services/Mixpanel.js index fc4ece30d..253c85bc6 100644 --- a/examples/client/Locomotion/src/services/Mixpanel.js +++ b/examples/client/Locomotion/src/services/Mixpanel.js @@ -35,12 +35,14 @@ class MixpanelService { this.isInit = false; this.mixpanel = {}; this.shouldTrackEvents = shouldTrackEvents(); - if (this.shouldTrackEvents) { - this.init(); - } + this.init(); } init = async () => { + if (!this.shouldTrackEvents) { + return; + } + if (!this.isInit && Config.MIXPANEL_TOKEN) { const trackAutomaticEvents = true; this.mixpanel = new Mixpanel(Config.MIXPANEL_TOKEN, trackAutomaticEvents); @@ -105,6 +107,7 @@ class MixpanelService { }; resetIdentifier = async () => { + if (!this.isInit) return; await this.mixpanel.clearSuperProperties(); await this.mixpanel.reset(); }; @@ -115,6 +118,7 @@ class MixpanelService { }; demoMode = (isDemoUser) => { + if (!this.isInit) return; if (isDemoUser) { this.mixpanel.optOutTracking(); } else {