Skip to content

Gate kit startup on hasConsent#1

Closed
sorinc03 wants to merge 1 commit into
mainfrom
codex/consent-gated-kit-startup
Closed

Gate kit startup on hasConsent#1
sorinc03 wants to merge 1 commit into
mainfrom
codex/consent-gated-kit-startup

Conversation

@sorinc03
Copy link
Copy Markdown
Owner

Summary

This PR adds a consent gate for integration kit startup.

  • Introduces hasConsent on MParticleOptions and MParticle (default: false)
  • Prevents kits from initializing/configuring/starting until consent is granted
  • Core (non-kit) SDK behavior continues to initialize and operate as normal
  • Documents usage in README.md (new Consent section after Kits)

Details

  • hasConsent == false:
    • Kit initialization and kit configuration are deferred/cached (no kit start)
  • hasConsent transition false -> true:
    • Initializes kits and applies any deferred kit configuration
    • Preserves existing identity-based deferral behavior for configurations that require MPID/consent filtering

API / Usage

  • Start kits immediately: set options.hasConsent = true before start(...)
  • Defer kits: start with default false, then later set MParticle.sharedInstance().hasConsent = true

(Examples included in README.md.)

Tests

  • xcodebuild test (iOS Simulator) PASSED
    • Executed 821 tests, 0 failures
    • Result bundle: /tmp/mparticle-test-results.xcresult
  • Added new coverage: UnitTests/ObjCTests/MPKitConsentGateTests.m

Notes / Compatibility

  • Apps that rely on kits starting immediately should explicitly set hasConsent = true at startup to preserve prior behavior.
  • Gating is applied at kit init/config/start boundaries; non-kit SDK logic should be unaffected.

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.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +2037 to +2040
if (![MParticle sharedInstance].hasConsent) {
MPILogWarning(@"configureKits - hasConsent is NO, deferring kit configuration until consent is granted");
[MParticle sharedInstance].deferredKitConfiguration_PRIVATE = kitConfigurations;
return;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you address the issues and update?

Comment on lines +565 to +566
if (launchOptions != nil && ![kitRegister.wrapperInstance started]) {
if ([kitRegister.wrapperInstance respondsToSelector:@selector(setLaunchOptions:)]) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you address the issues and update?

@sorinc03 sorinc03 closed this Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant