mixpanel-react-native icon indicating copy to clipboard operation
mixpanel-react-native copied to clipboard

distinct_id becomes null after upgrading from v3.0.5 to v3.0.9

Open enu-kuro opened this issue 9 months ago • 1 comments

After upgrading mixpanel-react-native from v3.0.5 to v3.0.9, all events started showing distinct_id: null ("<nil>" in Mixpanel).

This seems to match the issue described in this pull request: https://github.com/mixpanel/mixpanel-react-native/pull/273

enu-kuro avatar Apr 18 '25 04:04 enu-kuro

I have a question regarding the implementation of initializationCompletePromise() in MixpanelPersistent.

Currently, the method is defined as:

  async initializationCompletePromise(token) {
    Promise.all([
      this.loadIdentity(token),
      this.loadSuperProperties(token),
      this.loadTimeEvents(token),
      this.loadOptOut(token),
      this.loadAppHasOpenedBefore(token),
    ]);
  }

It seems that the Promise.all() result is not returned, meaning that the initialize() method might proceed before identity and other states are fully loaded.

Shouldn't it be written as:

  async initializationCompletePromise(token) {
    return Promise.all([
      this.loadIdentity(token),
      this.loadSuperProperties(token),
      this.loadTimeEvents(token),
      this.loadOptOut(token),
      this.loadAppHasOpenedBefore(token),
    ]);
  }

This would ensure that the asynchronous loading completes before other methods rely on the identity state.

enu-kuro avatar Apr 18 '25 05:04 enu-kuro