Skip to content

feat: report mParticle API usage through the Rokt kit - #759

Closed
thomson-t wants to merge 2 commits into
mParticle:mainfrom
thomson-t:feat/rokt-api-usage-diagnostics
Closed

feat: report mParticle API usage through the Rokt kit#759
thomson-t wants to merge 2 commits into
mParticle:mainfrom
thomson-t:feat/rokt-api-usage-diagnostics

Conversation

@thomson-t

Copy link
Copy Markdown
Collaborator

Background

Rokt diagnostics can identify native SDK API usage, but calls made through mParticle are not currently distinguishable. This adds bounded, non-sensitive API identifiers only when the Rokt kit is active. Android port of mParticle/mparticle-apple-sdk#813; requires Rokt SDK 6.0.3, which exposes the public Rokt.logMParticleApiCall entry point.

What Has Changed

  • Instrument public mParticle core, identity, user, session, messaging, media, and Rokt-facade APIs to forward a fixed, uppercase code vocabulary through the active Rokt kit only (no-op otherwise), via a decoupled RoktApiDiagnosticsForwarder interface so android-core stays free of kit types.
  • Reported APIs match iOS #813: dropped identifiers iOS deliberately excludes (single-attribute setUserAttribute) and Android-only internal machinery that would misreport SDK plumbing as partner calls (identity getters, identity-state listeners); renamed SET_UPDATE_INTERVALSET_UPLOAD_INTERVAL; added RESET, SET_LOG_LEVEL, GET_INTEGRATION_ATTRIBUTES, GET_ATTRIBUTION_INFO, IS_KIT_ACTIVE, GET_KIT_INSTANCE.
  • Kept Android-specific public APIs that are neither internal nor noisy (install referrer, non-auto push toggles, media audio state); dropped internally/auto-fired ones (location tracking, uncaught-exception toggles, push registration, enablePushNotifications).
  • The mParticle Rokt facade (kits/rokt/rokt/.../Rokt.kt) reports a distinct [MP_API_*] set (SELECT_PLACEMENTS, SELECT_SHOPPABLE_ADS, PURCHASE_FINALIZED, ROKT_EVENTS, ROKT_CLOSE, ROKT_SET_SESSION_ID, ROKT_GET_SESSION_ID, REGISTER_PAYMENT_EXTENSION) — additive by design with the native SDK's own [API_*] diagnostics, so drop-offs between the facade call and the native call are observable.
  • Never over-log: diagnostics are suppressed while SDK/kit internals invoke public APIs — auto-upload, logLtvIncreaselogEvent, push-token modify, and the Rokt kit's attribute enrichment / event + identity forwarding — via MParticle.withoutRoktApiUsage.
  • No delay / no crash / no retry: forwarding is a bounded synchronous lookup on the caller thread; the code is validated and buffered inside the Rokt SDK (logMParticleApiCall). API arguments and values are never included — code identifiers only.

Testing

  • :android-core:testDebugUnitTest for MParticleTest and KitFrameworkWrapperTest pass locally, including new tests for active-kit gating and internal-call suppression.
  • Note: the Rokt-kit module build could not be run in the authoring sandbox (Maven Central 429 rate-limiting on com.rokt:roktsdk:6.0.3); it will be validated in CI.

Checklist

  • Self-review completed
  • Tests added or updated
  • Tested locally (core: yes; rokt kit: pending CI — see note)

🤖 Generated with Claude Code

Rokt diagnostics can identify native SDK API usage, but calls made through
mParticle are not distinguishable. This instruments public mParticle core,
identity, user, session, messaging, media, and Rokt-facade APIs to forward a
bounded, non-sensitive API identifier into the Rokt SDK — only when the Rokt
kit is active. Android port of mParticle/mparticle-apple-sdk#813.

- Forward diagnostics through the active Rokt kit via a decoupled
  RoktApiDiagnosticsForwarder interface (core stays free of kit types) using a
  fixed uppercase code vocabulary. Requires Rokt SDK 6.0.3 and calls its public
  Rokt.logMParticleApiCall API.
- Match the iOS reported-API set: drop identifiers iOS deliberately excludes
  (single setUserAttribute) and Android-only internal machinery (identity
  getters/state listeners); rename SET_UPDATE_INTERVAL -> SET_UPLOAD_INTERVAL;
  add RESET, SET_LOG_LEVEL, GET_INTEGRATION_ATTRIBUTES, GET_ATTRIBUTION_INFO,
  IS_KIT_ACTIVE, GET_KIT_INSTANCE.
- Keep Android-specific public APIs that are neither internal nor noisy (install
  referrer, non-auto push toggles, media audio state).
- Never over-log: suppress diagnostics while SDK/kit internals invoke public
  APIs (auto-upload, logLtvIncrease -> logEvent, push-token modify, and the Rokt
  kit's attribute enrichment / event + identity forwarding) via
  MParticle.withoutRoktApiUsage.
- Exclude all API arguments and values from diagnostics; code identifiers only.
- Add core tests for active-kit gating and internal-call suppression.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@thomson-t
thomson-t requested a review from a team as a code owner August 18, 2026 21:10
@cursor

cursor Bot commented Aug 18, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Wide instrumentation on hot public APIs adds synchronous kit lookups on the caller thread, but behavior is gated to active Rokt and code-only diagnostics with explicit internal suppression.

Overview
Adds Rokt-facing public API usage diagnostics so partner calls through mParticle can be distinguished from direct native SDK usage when the Rokt kit is active.

Core introduces logRoktApiUsage / withoutRoktApiUsage (thread-local suppression) and a RoktApiDiagnosticsForwarder hook on KitFrameworkWrapper that forwards fixed uppercase codes to RoktKitRokt.logMParticleApiCall. Instrumentation spans core, identity, user, messaging, media, and the Rokt facade (SELECT_PLACEMENTS, etc.). Internal paths (LTV → logEvent, push-token modify, kit identity sync / event forwarding) run inside withoutRoktApiUsage so they are not double-counted.

Rokt SDK is bumped 6.0.1 → 6.0.3 in gradle.properties, kit defaults, and rokt-sdk-plus. Unit tests cover forwarding, active-kit gating, and suppression; MParticle public method count in ApiVisibilityTest moves to 67.

Reviewed by Cursor Bugbot for commit bfb6cd7. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 8a4d883. Configure here.

* Force upload all queued messages to the mParticle server.
*/
public void upload() {
MParticle.logRoktApiUsage("UPLOAD");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Internal uploads misreported as partner

Medium Severity

upload now always emits UPLOAD, but SDK-internal callers still invoke it directly without withoutRoktApiUsage. Session-end endUploadLoop, alias-driven uploads, and the nested upload inside setUpdateInterval are therefore reported as partner API usage whenever the Rokt kit is active, contradicting the intended never-over-log behavior.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 8a4d883. Configure here.

@thomson-t

Copy link
Copy Markdown
Collaborator Author

Superseded by #761 so the head branch lives directly in mParticle/mparticle-android-sdk rather than a fork. The replacement uses the same reviewed commits and preserves the SDK Team review request.

@thomson-t thomson-t closed this Aug 19, 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