Skip to content

feat!: mParticle SDK v9, Shoppable Ads, Rokt payment extension & placement events#84

Merged
jamesnrokt merged 7 commits into
mainfrom
shoppable-ads
Jun 10, 2026
Merged

feat!: mParticle SDK v9, Shoppable Ads, Rokt payment extension & placement events#84
jamesnrokt merged 7 commits into
mainfrom
shoppable-ads

Conversation

@rmi22186

@rmi22186 rmi22186 commented Apr 20, 2026

Copy link
Copy Markdown
Member

Background

Long-running feature branch merging into main. It bundles the previously reviewed work plus follow-up hardening:

⚠️ Breaking change

Raises the iOS minimum deployment target to 15.6 — apps below 15.6 cannot adopt this release. Driven by the native upgrade to mParticle Apple SDK v9 / Rokt kit v9 (from v8). iOS integrators must also adopt the renamed RoktPaymentExtension kit and the AppDelegate registration pattern. Android native deps are only a minor bump (android-core / rokt-kit 5.71.0 → 5.79.1).

The plugin's own JS/Cordova API is otherwise backward compatible — all surface changes are additive.

What's new (JS API)

  • Shoppable Ads — Rokt.selectShoppableAds, Rokt.purchaseFinalized (iOS; Android no-op + warning for now)
  • Unified Rokt payment extension @mparticle/cordova-rokt-payment-extension (replaces the Stripe-specific kit, which never shipped to main)
  • Rokt.setSessionId / getSessionId / handleURLCallback
  • Rokt placement events — Rokt.events(identifier, onEvent) + Rokt.EventType
  • Rokt.ColorMode config

Verification

  • iOS + Android example apps build; JS + Android unit tests pass.
  • Placement events verified end-to-end on iOS simulator and Android emulator (Mobile Team Test account): ShowLoadingIndicator → HideLoadingIndicator → PlacementReady → PlacementInteractive delivered to the JS callback, overlay rendered interactively.

Notes

  • Android Shoppable Ads (selectShoppableAds / purchaseFinalized) is not yet supported — no-op + warning.
  • The version bump and CHANGELOG retag are handled separately by the release workflow (draft-release-publish.yml, major bump).

Reference Issue (For employees only. Ignore if you are an outside contributor)

@rmi22186 rmi22186 requested a review from thomson-t April 20, 2026 18:53
@rmi22186 rmi22186 requested a review from a team as a code owner April 20, 2026 18:53
@cursor

cursor Bot commented Apr 20, 2026

Copy link
Copy Markdown

PR Summary

High Risk
Major native SDK bump, higher iOS minimum, payment-extension registration, and payment redirect handling are integration-sensitive; Android Shoppable Ads paths are intentionally stubbed.

Overview
Breaking: Upgrades native stacks to mParticle Apple SDK / Rokt kit ~> 9.2 and Android core/rokt-kit 5.79.x, raises the example app iOS deployment target to 16.0, and replaces the Stripe-only kit with @mparticle/cordova-rokt-payment-extension (RoktPaymentExtension ~> 2.0). iOS selectPlacements is migrated to v9 RoktConfig APIs; wrapper SDK version is set in CDVMParticle.m and wired into release CI.

Rokt JS surface (additive): events + EventType, selectShoppableAds / purchaseFinalized (iOS native; Android warns and no-ops), setSessionId / getSessionId, and handleURLCallback (iOS). Android adds a coroutine-backed roktEvents bridge with subscription teardown on destroy.

Integrator/docs/example: Large README Rokt section; example wires payment extension, Swift RoktPaymentSetup, Xcode hook, and demo buttons. Release workflow versions and dry-runs the new payment-extension npm package.

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

@rmi22186 rmi22186 changed the title Shoppable ads feat: Implement Shoppable Ads Apr 20, 2026
thomson-t
thomson-t previously approved these changes Apr 20, 2026
Comment thread example/hooks/after_platform_add/010_copy_platform_specific_files.js Outdated
…ension (#93)

* chore: bump native deps to mParticle-Apple-SDK 9.2 / android-core 5.79.0

Aligns the Cordova plugin's pinned native versions with what the
sibling RN and Flutter wrappers shipped at the same release line:

- iOS `mParticle-Apple-SDK`     ~> 9.0    → ~> 9.2
- iOS `mParticle-Rokt`          ~> 9.0    → ~> 9.2
- Android `android-core`        5.71.0    → 5.79.0
- Android `android-rokt-kit`    5.71.0    → 5.79.0
- README Podfile note bumped to 9.2.0 or later

Apple SDK 9.2 widens the MPRokt surface (registerPaymentExtension:,
handleURLCallback:, setSessionId:/getSessionId, expanded RoktEvent
hierarchy) and stops the partner from having to thread stripeKey
through Cordova JS — the Rokt kit now reads stripePublishableKey
from kit configuration in the mParticle dashboard.

Follow-up commits in this branch bridge the new methods and rename
the Stripe-named payment kit to the unified RoktPaymentExtension.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* refactor: rename Rokt Stripe payment kit to unified RoktPaymentExtension

`RoktStripePaymentExtension 0.1.x` was the Stripe-only iOS Rokt
payment extension. Upstream Rokt has since unified its providers
into a single `RoktPaymentExtension` package (`~> 2.0`) that
internally routes to Stripe for Apple Pay / card / Afterpay /
Clearpay / PayPal — partner code no longer needs to pick a provider
at integration time.

- `Kits/RoktStripePayment/`  →  `Kits/RoktPaymentExtension/`
- npm + Cordova id `@mparticle/cordova-rokt-stripe-payment-kit`
  → `@mparticle/cordova-rokt-payment-extension`
- pod `RoktStripePaymentExtension ~> 0.1`  →  `RoktPaymentExtension ~> 2.0`
- `example/config.xml` plugin reference updated to the new id / path
- `example/platform_overrides/ios/RoktPaymentSetup.swift` imports
  the unified module and constructs `RoktPaymentExtension(applePayMerchantId:)`
  instead of `RoktStripePaymentExtension(applePayMerchantId:)`.
- AppDelegate comment + copy-hook comment updated.

The Swift helper still calls `MParticle.sharedInstance().rokt.register(_:)`
(which is the Swift form of `[[MParticle sharedInstance].rokt
registerPaymentExtension:]`). The Rokt kit on mParticle Apple SDK 9.2
pulls `stripePublishableKey` from kit configuration in the mParticle
dashboard and forwards it to Rokt at registration time, so the host
app only needs to provide the Apple Pay merchant identifier.

README still references the old Stripe-named symbols — fixed in the
docs commit later in this branch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat: bridge setSessionId / getSessionId / handleURLCallback on Rokt

mParticle Apple SDK 9.2 widened MPRokt with three pass-through
APIs that the Cordova bridge can now forward:

- `setSessionId:` / `-getSessionId` — let JS share a session id with
  a WebView leg of the same flow, matching the standalone Rokt SDK
  and the React Native wrapper.
- `handleURLCallback:` — receive deep-link return URLs from
  redirect-based Rokt payment methods (AfterPay, PayPal) and ask the
  registered payment extension(s) to claim them. Returns BOOL so the
  host can fall back to its own URL routing on no-claim.

`registerPaymentExtension:` is intentionally NOT exposed in JS.
The concrete extension class has a Swift failable initializer that
isn't `@objc`-exported, so partners need a Swift bridge file in
their app target anyway; once they have it, registering from
AppDelegate is one line. A JS API would only add plumbing without
removing the native setup, encourage per-call registration footguns,
and diverge from how the RN and Flutter wrappers handle it.

- iOS: real selectors against `[[MParticle sharedInstance].rokt …]`.
- Android: `setSessionId` and `getSessionId` are real calls
  (`MParticle.getInstance().Rokt().setSessionId / .getSessionId`);
  `handleURLCallback` is a logged no-op matching the RN/Flutter
  pattern until the Android SDK ships the same API.
- JS: `setSessionId` is fire-and-forget, `getSessionId` and
  `handleURLCallback` accept a completion that receives the
  session-id string and a BOOL `handled`, respectively.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* docs: align README + CHANGELOG with 9.2 / unified payment-extension flow

README's Shoppable Ads section was wired up against the old Stripe-named
plugin (`@mparticle/cordova-rokt-stripe-payment-kit`,
`RoktStripePaymentExtension`). Rewrite it for the unified
`@mparticle/cordova-rokt-payment-extension` kit and quote the
Swift bridge example partners need in their app target.

- Step 1: install the unified payment-extension kit instead of the
  Stripe-named one.
- Step 2: full Swift bridge snippet (RoktPaymentSetup.swift) plus the
  AppDelegate call. Notes that the Rokt kit on mParticle Apple SDK
  9.2 reads `stripePublishableKey` from the mParticle dashboard, so
  partners no longer need to ship a Stripe key from JS.
- New step 4 covers `handleURLCallback` for redirect-based payments
  (AfterPay, PayPal).
- New step 5 covers `setSessionId` / `getSessionId` for WebView
  session continuity.
- CHANGELOG `[Unreleased]` documents the three native bumps, the
  Stripe → unified rename, and the three new bridged JS methods.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* chore: wire example app for Shoppable Ads testing

Register the unified Rokt payment extension in the example AppDelegate,
randomize the selectShoppableAds confirmation ref / email per tap so
Rokt's dedup doesn't suppress repeat requests during local testing, and
disable the response cache. Adds patched mParticle 9.2 podspecs that
bump the RoktContracts requirement to ~> 1.0 so the example resolves
cleanly against current Rokt-Widget.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix: address review feedback and fix red example CI on Shoppable Ads 9.2

- Sync example/package-lock.json with package.json so `npm ci` passes
  (was missing @mparticle/cordova-rokt-payment-extension → EUSAGE, failing
  both example build jobs before any build ran).
- Remove orphaned patched-podspecs (pinned 9.0.1, violating the plugin's
  ~> 9.2 constraint). Published mParticle-Apple-SDK 9.2.0 already declares
  RoktContracts (~> 2.0), so a clean pod install resolves to RoktContracts
  2.0.2 / RoktPaymentExtension 2.0.3 with no overrides. Verified end-to-end:
  example builds on cordova-ios 7.1.1, Rokt kit 9.2.0 inits, payment
  extension registers, selectShoppableAds renders.
- Remove the 'Strip before commit' globalEvents diagnostic from the example
  AppDelegate.
- Use file: prefix for the cordova-rokt-payment-extension dev dependency.
- Bump android-core / android-rokt-kit to 5.79.1 (latest stable 5.x).

Addresses all three Cursor Bugbot comments on #93.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: James Newman <james.newman@rokt.com>
Comment thread plugin/src/ios/CDVMParticle.m Outdated
Comment thread example/hooks/after_platform_add/configure_xcode_swift.rb Outdated
Add mparticle.Rokt.events(identifier, onEvent) — a standalone subscriber
mirroring the native events API shape (not folded into selectPlacements) —
plus mparticle.Rokt.EventType constants.

iOS (CDVMParticle.m): roktEvents: forwards to MPRokt events:onEvent:;
dictionaryFromRoktEvent: serializes every RoktEvent subclass from
RoktContracts 2.0.2 to a dict and streams via CDVPluginResult with
setKeepCallback:YES for multi-shot delivery.

Android (MParticleCordovaPlugin.java): roktEvents subscribes to the
events(identifier) Flow via onEach/launchIn, serializes each event to JSON,
and streams with keepCallback. Each placement's collection scope is tracked
in a map keyed by identifier: re-subscribing the same identifier cancels the
prior scope instead of stacking a second collector, and onDestroy cancels
every active scope so collectors stop running and never deliver through a
callbackContext bound to a destroyed WebView.

README + example: Placement Events section and a Subscribe to Events button.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@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.

There are 6 total unresolved issues (including 4 from previous reviews).

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 61277b8. Configure here.

Comment thread plugin/src/ios/CDVMParticle.m
Comment thread plugin/src/ios/CDVMParticle.m
- Android selectShoppableAds/purchaseFinalized now accept a callbackContext and
  send a PluginResult, so the JS promises resolve instead of dangling (#3).
- purchaseFinalized is a no-op + warning on Android, matching selectShoppableAds
  (unsupported) and handleURLCallback — avoids calling the Rokt SDK with no
  active shoppable session (#2).
- Quote iosPath/script path in the platform-add hook so project roots containing
  spaces don't break `cordova platform add ios` (#1).
- Make configure_xcode_swift.rb idempotent: reuse an existing RoktPaymentSetup.swift
  reference and skip re-adding it, so re-runs don't create duplicate compile sources (#5).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jamesnrokt jamesnrokt changed the title feat: Implement Shoppable Ads feat!: mParticle SDK v9, Shoppable Ads, Rokt payment extension & placement events Jun 5, 2026
jamesnrokt and others added 2 commits June 5, 2026 14:28
…lease flow (#95)

The release workflow only ever versioned/published the plugin and Rokt kit,
leaving two gaps:

- CDVMParticle.m reported an empty wrapper version to mParticle
  (_setWrapperSdk_internal version:@""). Seed it with the current version and
  add a release-workflow step that bumps it alongside plugin.xml, so it tracks
  every release instead of going stale.
- Kits/RoktPaymentExtension (new this release) was not managed by the release
  flow at all, so it had drifted to 3.0.0 and would never be version-bumped or
  published. Add version-bump + plugin.xml + dry-run-publish steps mirroring the
  Rokt kit, align it to 3.0.1, and list the extra files in the release PR body.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
# Conflicts:
#	CHANGELOG.md
#	example/package-lock.json
@jamesnrokt jamesnrokt merged commit 0af6497 into main Jun 10, 2026
9 of 11 checks passed
@jamesnrokt jamesnrokt deleted the shoppable-ads branch June 10, 2026 13:30
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.

3 participants