Gate kit startup on hasConsent#1
Conversation
Add hasConsent (default false) to options and shared instance, defer kit initialization/configuration until consent is granted, and document usage in README. Includes unit tests for consent gating.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c1e2869c0c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (![MParticle sharedInstance].hasConsent) { | ||
| MPILogWarning(@"configureKits - hasConsent is NO, deferring kit configuration until consent is granted"); | ||
| [MParticle sharedInstance].deferredKitConfiguration_PRIVATE = kitConfigurations; | ||
| return; |
There was a problem hiding this comment.
Flush cached kits even when consent is not granted
The consent gate returns before the null-config handling, so when configureKits is called with kitConfigurations == nil while hasConsent is NO, we never execute the flushSerializedKits path that previously cleared stale kit state. Because deferredKitConfiguration_PRIVATE is then also nil, a later hasConsent = YES transition falls back to cached kit configs and can start kits that the latest server config intentionally removed.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Can you address the issues and update?
| if (launchOptions != nil && ![kitRegister.wrapperInstance started]) { | ||
| if ([kitRegister.wrapperInstance respondsToSelector:@selector(setLaunchOptions:)]) { |
There was a problem hiding this comment.
Start deferred kits even when launch options are nil
The new delayed-start fallback only runs when launchOptions is non-nil, but normal app launches can legitimately have nil launch options. In consent-gated flows where kits are initialized after UIApplicationDidFinishLaunchingNotification has already fired, this condition prevents start from being called and leaves those kits (notably sideloaded ones initialized via startKitRegister) permanently inactive.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Can you address the issues and update?
Summary
This PR adds a consent gate for integration kit startup.
hasConsentonMParticleOptionsandMParticle(default:false)README.md(new Consent section after Kits)Details
hasConsent == false:hasConsenttransitionfalse -> true:API / Usage
options.hasConsent = truebeforestart(...)false, then later setMParticle.sharedInstance().hasConsent = true(Examples included in
README.md.)Tests
xcodebuild test(iOS Simulator) PASSED/tmp/mparticle-test-results.xcresultUnitTests/ObjCTests/MPKitConsentGateTests.mNotes / Compatibility
hasConsent = trueat startup to preserve prior behavior.