feat: add device-based consent to override MPID-scoped consent#726
Conversation
Enables Inspire-style flows where consent is collected before MPID changes at checkout, so kit forwarding rules and uploads keep the correct consent state.
PR SummaryHigh Risk Overview New public surface:
Reviewed by Cursor Bugbot for commit 2e277cd. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2e277cd. Configure here.
| return getDeviceConsentState(); | ||
| } | ||
| return getConsentState(mpid); | ||
| } |
There was a problem hiding this comment.
Stale device consent without flag
Medium Severity
After deviceBasedConsentEnabled is off at startup, a device consent value previously written by mirrored setConsentState can remain in preferences. getEffectiveConsentState still prefers that stored device consent, but setConsentState no longer updates device storage, so MPID consent changes may not reach kit forwarding or uploads.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 2e277cd. Configure here.
|
## [5.80.0](v5.79.2...v5.80.0) (2026-06-25) ### Features * add device-based consent to override MPID-scoped consent ([#726](#726)) ([e92d352](e92d352))





Add device-level consent state
Summary
Adds a device-level consent state that, when set, supersedes user/MPID-level consent everywhere consent is evaluated. Previously consent could only be recorded per-user (per-MPID), meaning consent decisions were lost across identity changes and couldn't represent a single device-wide choice. This adds an optional device-scoped consent that takes precedence over per-user consent.
When device consent is set, it overrides user/MPID-level consent for:
shouldIncludeFromConsentRules)onConsentStateUpdatedforwarded callsIt is persisted device-wide (independent of the active MPID, stored in app-level
SharedPreferences) and setting it triggers the same kit refresh as a user consent change. Set it tonullto clear and revert to user/MPID-level consent.MParticleOptions.deviceBasedConsentEnabled(true)additionally mirrorsMParticleUser.setConsentState()into device storage, so existing consent-prompt code continues to work without changes when the MPID changes during checkout.How it works
A new
getEffectiveConsentState(mpid)onConfigManageris the single resolution point: it returns the device consent if present, otherwise falls back to the per-MPID consent. All consent-evaluation call sites now route through it.deviceBasedConsentEnabledis persisted across launches. When enabled,MParticleUserDelegate.setConsentState()writes to both MPID storage and device storage so consent collected on an anonymous profile is retained after identity changes.Sample code
Enable device mirroring at startup (recommended for consent-before-login flows):
Set / update / clear at runtime:
Testing
Added unit tests covering device-consent override precedence and flag persistence (
ConfigManagerTest), and updated the public API surface count (ApiVisibilityTest).Related iOS PR: mParticle/mparticle-apple-sdk#784