Skip to content

feat: add Rokt Brain event type constants#1269

Open
jaissica12 wants to merge 3 commits into
developmentfrom
feat/rokt-brain-event-types
Open

feat: add Rokt Brain event type constants#1269
jaissica12 wants to merge 3 commits into
developmentfrom
feat/rokt-brain-event-types

Conversation

@jaissica12
Copy link
Copy Markdown
Contributor

@jaissica12 jaissica12 commented May 19, 2026

Background

This PR extends the mParticle Web SDK to support additional event types commonly used in commerce and engagement flows (e.g., view_cart, add_shipping_info, subscribe, sign_up). New typed constants are added to ProductActionType and a new RoktEvents object, allowing partners to log these events through existing SDK methods.

What Has Changed

  • Extended ProductActionType with 8 new commerce-adjacent values (11–18): ViewCart, AddShippingInfo, AddPaymentInfo, PaymentMethodSelected, PaymentAttempted, PaymentSucceeded, PaymentFailed, RefundInitiated
  • Added isRoktCommerceType() helper to identify new commerce types by range
  • Added Rokt.CommerceEventType custom flag auto-population in events.js for new commerce types, carrying the snake_case event name (e.g., payment_succeeded)
  • Added RoktEvents const object with 11 non-commerce event name constants (SignUp, Subscribe, StartTrial, GenerateLead, Search, Upsell, EarnVirtualCurrency, DwellTime, Hover, Scroll, ClickToExpand)
  • Added RoktEventName union type with (string & {}) escape hatch for arbitrary event names
  • Updated getName() and getExpansionName() helpers to cover new ProductActionType values
  • Extended SDKProductActionType enum, MParticleWebSDK interface, instance manager, and stub
  • Exposed RoktEvents on mParticle instance for customer use
  • New values map to Unknown on the wire (MPServer safe) while preserving actual event names via Rokt.CommerceEventType custom flag for kit-side enrichment
  • Re-exported new types from public-types.ts
  • Updated tests: isRoktCommerceType coverage in types.spec.ts, public API key assertion in instance manager tests

Screenshots/Video

  • PaymentSucceeded
Screenshot 2026-05-21 at 2 53 01 PM - [Forwarder] Batch sent to Kit - action: "unknown" (what the core SDK sends) Screenshot 2026-05-21 at 2 45 30 PM - [Rokt Kit] Before enrichment - action: "unknown" (same batch arriving in Kit) Screenshot 2026-05-21 at 2 46 32 PM - [Rokt Kit] After enrichment - action: "payment_succeeded" (enriched before __batch_stream__) Screenshot 2026-05-21 at 2 46 54 PM
  • Sign up
Screenshot 2026-05-20 at 2 34 06 PM Screenshot 2026-05-20 at 2 34 18 PM Screenshot 2026-05-20 at 2 37 20 PM
  • [Forwarder] Batch sent to Kit - Rokt what the core SDK sends)
Screenshot 2026-05-21 at 3 50 10 PM
  • [Rokt Kit] Before enrichment
Screenshot 2026-05-21 at 3 52 22 PM
  • [Rokt Kit] After enrichment
Screenshot 2026-05-21 at 3 52 54 PM
  • Subscribe
Screenshot 2026-05-20 at 2 40 50 PM Screenshot 2026-05-20 at 2 41 09 PM Screenshot 2026-05-20 at 2 41 33 PM
  • [Forwarder] Batch sent to Kit (what the core SDK sends)
Screenshot 2026-05-21 at 3 56 30 PM
  • [Rokt Kit] Before enrichment
Screenshot 2026-05-21 at 3 56 55 PM
  • [Rokt Kit] After enrichment
Screenshot 2026-05-21 at 3 57 18 PM

Checklist

  • I have performed a self-review of my own code.
  • I have made corresponding changes to the documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have tested this locally.

Additional Notes

  • Android and Apple SDKs will mirror this design in a follow-on
  • Related Kit PR #97

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

@jaissica12 jaissica12 changed the base branch from master to development May 20, 2026 17:59
@jaissica12 jaissica12 marked this pull request as ready for review May 20, 2026 18:44
@jaissica12 jaissica12 requested a review from a team as a code owner May 20, 2026 18:44
@cursor
Copy link
Copy Markdown

cursor Bot commented May 20, 2026

PR Summary

Low Risk
Low risk, mostly additive constants/types and wiring; behavior changes only apply when using the new Rokt commerce-adjacent ProductActionType values, which now intentionally send as EventType.Unknown with an extra custom flag.

Overview
Adds Rokt Brain event constants to the public Web SDK surface: new RoktEvents string constants (and RoktEventName type) plus 8 new commerce-adjacent ProductActionType values (ViewCart through RefundInitiated).

Updates commerce logging so these new product action types map to EventType.Unknown for server payloads while preserving the intended action via CustomFlags['Rokt.CommerceEventType'], and exposes RoktEvents on both mParticle instances and the instance manager (with stubs/public type exports and tests updated accordingly).

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

Comment thread src/types.ts
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
12.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

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