Skip to content

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

Open
thomson-t wants to merge 4 commits into
mainfrom
feat/rokt-api-usage-diagnostics
Open

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

Conversation

@thomson-t

@thomson-t thomson-t commented Aug 19, 2026

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. It is the Android counterpart to mParticle/mparticle-apple-sdk#813 and 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.
  • Keep android-core decoupled from kit types through a RoktApiDiagnosticsForwarder interface.
  • Match the identifiers reported by the Apple SDK while retaining applicable Android-specific public APIs.
  • Include bounded mParticle and commerce event categories in LOG_EVENT diagnostics without exposing event names, attributes, or unrecognized action values.
  • Suppress diagnostics when SDK and kit internals invoke public APIs, preventing internal plumbing from being reported as partner usage.
  • Report distinct Rokt facade identifiers so drop-offs between an mParticle facade call and the native Rokt call remain observable.
  • Forward synchronously through a bounded lookup without delay or retry.
  • Update both roktSdkVersion and roktPaymentExtensionVersion to 6.0.3 so the Rokt SDK and payment extension remain aligned.
  • Update API visibility expectations for the added public API instrumentation.

Testing

  • trunk check
  • ./gradlew build
  • ./gradlew test
  • ./gradlew ktlintCheck
  • Full GitHub Build and Test workflow, including unit, lint, Rokt kit, compatibility, and API 28 instrumented tests

Checklist

  • Self-review completed
  • Tests added or updated
  • Tested locally

thomson-t and others added 2 commits August 18, 2026 17:09
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 19, 2026 13:51
@cursor

cursor Bot commented Aug 19, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Wide instrumentation on hot public API paths and identity/event flows; behavior is gated on an active Rokt kit and uses suppression for internals, but any missed wrap could misreport usage or add minor per-call overhead.

Overview
Adds bounded Rokt public-API usage diagnostics across the Android SDK so partner calls through mParticle can be distinguished from direct native Rokt usage (aligned with the Apple SDK change; requires Rokt 6.0.3 and Rokt.logMParticleApiCall).

Core exposes logRoktApiUsage / withoutRoktApiUsage (thread-local suppression) and forwards fixed uppercase codes through KitFrameworkWrapper → new RoktApiDiagnosticsForwarder on the active Rokt kit. Instrumentation covers core analytics/identity/user APIs, messaging/media helpers, and the Rokt facade (including facade-specific codes). logEvent maps to granular codes by event/commerce type; internal paths (auto-upload, LTV→logEvent, push-token modify, kit identify/logEvent) are wrapped so they are not counted as partner usage.

Bumps roktSdkVersion and roktPaymentExtensionVersion to 6.0.3 and adds/updates unit tests plus public API visibility count.

Reviewed by Cursor Bugbot for commit a696a7b. 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 2 potential issues.

Fix All in Cursor

❌ 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 bfb6cd7. Configure here.

Comment thread android-core/src/main/java/com/mparticle/MParticle.java

@Override
public boolean setUserAttributeList(String key, Object value) {
MParticle.logRoktApiUsage("SET_USER_ATTRIBUTE_LIST");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

User attribute setter not instrumented

Medium Severity

setUserAttribute and bulk setUserAttributes never emit a Rokt usage code, while list, increment, remove, and tag setters do. Partner attribute writes, one of the most common public user APIs, stay invisible in Rokt diagnostics and will not match the Apple identifier set.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit bfb6cd7. Configure here.

@BrandonStalnaker BrandonStalnaker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just a few small things

}

public void logEvent(@NonNull BaseEvent event) {
MParticle.logRoktApiUsage("LOG_EVENT");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It might be more useful to move this to logMPEvent and logCommerceEvent and then you could append the event type to the call. Alternatively you coudl just add the event type here.
MParticle.logRoktApiUsage("LOG_EVENT" + NSStringFromEventType(event.type));

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added bound event types getRoktLogEventDiagnosticCode

Comment thread android-core/src/main/java/com/mparticle/MParticle.java
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.

2 participants