feat: add batch stream wrapper function#86
Conversation
jamesnrokt
left a comment
There was a problem hiding this comment.
Fairly hard to review given the changes to implement the interface at the same time as the batching updates. May be worth splitting?
src/Rokt-Kit.ts
Outdated
| getMPID(): string; | ||
| getAllUserAttributes(): Record<string, unknown>; | ||
| interface FilteredUser extends IMParticleUser { | ||
| getMPID?(): string; |
There was a problem hiding this comment.
Why are we removing getAllUserAttributes() but keeping the others?
There was a problem hiding this comment.
We shouldn't need to extend IMParticleUser at all. if you look at the definition, it extends, User, which has all of these.
Yes it's technically a filtered user, but there's no difference bewteen an IMparticleUser and a FilteredUser from an interface perspective, so let's just use IMparticleUser.
There was a problem hiding this comment.
@khushi1033 - just making sure yous ee this comment, since you pushed a change to fix alex's update, which made this comment, and my reply "outdated", and collapsed the comment.
There was a problem hiding this comment.
@rmi22186 Yeah sorry was still looking into it - I'm running into an issue though, since getMPID and getUserIdentities live on the User base type, which IMParticleUser extends, Typescript can't see them. Seeing in this comment it's intentionally not re-exported so thinking might have to stick to extending until that's updated?
There was a problem hiding this comment.
@khushi1033 that's probably fine for now because eventually will be removed from . I'd add a comment saying that it needs to be cleaned up in the future so we don't forget. Something to add to our cool down week I'd say.
Co-authored-by: James Newman <james.newman@rokt.com>
# [1.24.0](v1.23.0...v1.24.0) (2026-04-09) ### Features * add batch stream wrapper function ([#86](#86)) ([c361fa2](c361fa2))
|
🎉 This PR is included in version 1.24.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Summary
Implements the processBatch hook to support batch-level event forwarding. When called by the mParticle SDK after each batch upload, the kit forwards the full batch object (events, user attributes, identities, consent state, and non-event lifecycle data) to window.Rokt.batch_stream on the Rokt WSDK. Mirrors the existing event queue pattern with two new queues: batchQueue (drains when the kit initialises) and batchStreamQueue (drains when batch_stream becomes available).
Updated @mparticle/web-sdk to pull in the latest type definitions (Batch, SDKEvent, IMParticleUser, KitInterface). To fully conform to KitInterface, the following changes were made:
Testing Plan
Added #processBatch tests in test/src/tests.spec.ts covering: happy path forwarding, non-event data passthrough, pre-init queuing and flush, batch_stream unavailable queuing and flush, window.Rokt undefined graceful fallback, and flush ordering. All tests existing from before continue to pass without modification.