Skip to content

Race condition between user identity and OneTrust kit initialization on Android #605

Description

@zeeshy30

Description

We are seeing a race condition in the mParticle OneTrust kit on Android. The kit initializes before a currentUser is established. On devices with a cached previous_mpid, this is masked since a user is immediately available. However, on fresh installs or after clearing app data, currentUser is null at kit initialization. This produces the warning:

OneTrust consent could not be processed as MParticle's Current user is not set

Afterwards, when the Identity API succeeds, the kit does not retry applying consent, so consent never gets bound to the user, even if we try to update the consent by reopening the OneTrust Banner.

Steps to Reproduce:

  • Fresh install the app (or clear app data, not just cache).
  • Initialize mParticle with OneTrust kit enabled.
  • Observe logs on startup:

OneTrust consent could not be processed as MParticle's Current user is not set

  • Compare to a device with existing previous_mpid where consent attaches normally.

Expected Behavior:

The kit should either:

  • Delay consent processing until a currentUser exists, or
  • Listen for identity callbacks and retry consent application once a user is available

Impact

Consent state is silently dropped on first launch in fresh environments

Environment

SDK: mParticle Android SDK 5.73.2
Platform: Android Phone + Android TV
Integration: React Native app with OneTrust SDK

Logs Observed

2025-09-12 15:53:28.381  8634-8667  mParticle               com.vesper.sandbox                   V  Identity identify request: 
                                                                                                    {"client_sdk":{"platform":"android","sdk_vendor":"mparticle","sdk_version":"5.73.2"},"environment":"development","request_timestamp_ms":1757681608380,"request_id":"dc83c2cb-fab5-4a31-b9ed-a47a5d90d440","known_identities":{"android_aaid":"2c0c9e24-f3b9-43b6-8efb-bb8ed00763f9","device_application_stamp":"ecc64119-b88a-48c5-a032-16ff0a4a6c5d"}}
2025-09-12 15:53:28.396  8634-8634  mParticle               com.vesper.sandbox                   I  Clearing Data Plan
2025-09-12 15:53:28.396  8634-8634  mParticle               com.vesper.sandbox                   D  Initializing kit: OneTrust
2025-09-12 15:53:28.396  8634-8634  mParticle               com.vesper.sandbox                   W  OneTrust consent could not be processed as MParticle's Current user is not set
2025-09-12 15:53:28.397  8634-8634  mParticle               com.vesper.sandbox                   D  Loading new kit config
2025-09-12 15:53:28.766  8634-8667  mParticle               com.vesper.sandbox                   V  Identity response code: 200
2025-09-12 15:53:28.766  8634-8667  mParticle               com.vesper.sandbox                   V  Identity result: {"context":null,"matched_identities":{"android_aaid":"2c0c9e24-f3b9-43b6-8efb-bb8ed00763f9","device_application_stamp":"ecc64119-b88a-48c5-a032-16ff0a4a6c5d"},"is_ephemeral":true,"mpid":"4595420489449470560","is_logged_in":false}

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions