Skip to content

Commit

Permalink
fix init
Browse files Browse the repository at this point in the history
  • Loading branch information
oriefrati committed Jan 12, 2024
1 parent 6691b60 commit 94785c0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions examples/client/Locomotion/src/services/Mixpanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -105,6 +107,7 @@ class MixpanelService {
};

resetIdentifier = async () => {
if (!this.isInit) return;
await this.mixpanel.clearSuperProperties();
await this.mixpanel.reset();
};
Expand All @@ -115,6 +118,7 @@ class MixpanelService {
};

demoMode = (isDemoUser) => {
if (!this.isInit) return;
if (isDemoUser) {
this.mixpanel.optOutTracking();
} else {
Expand Down

0 comments on commit 94785c0

Please sign in to comment.