feat: support sending login, logout, identify, and modify_user events#81
Merged
khushi1033 merged 5 commits intodevelopmentfrom Mar 27, 2026
Merged
feat: support sending login, logout, identify, and modify_user events#81khushi1033 merged 5 commits intodevelopmentfrom
khushi1033 merged 5 commits intodevelopmentfrom
Conversation
alexs-mparticle
requested changes
Mar 26, 2026
jamesnrokt
reviewed
Mar 26, 2026
src/Rokt-Kit.js
Outdated
| function onLoginComplete(filteredUser) { | ||
| self.userAttributes = filteredUser.getAllUserAttributes(); | ||
| _sendEventStream({ | ||
| EventName: 'User Login', |
There was a problem hiding this comment.
We need to confirm these match what's expected
alexs-mparticle
approved these changes
Mar 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements onLoginComplete, onLogoutComplete, onUserIdentified, and onModifyComplete kit callbacks so all four identity lifecycle events are forwarded to the Rokt v2/sessions events pipeline as user_login, user_logout, user_identified, and user_modified respectively.
Each callback updates self.userAttributes from the incoming user before firing — ensuring _enrichEvent carries post-identity-change attributes — then calls _sendEventStream, which queues the event if the launcher isn't ready yet. A shared _buildIdentityEvent helper constructs the event payload with MPID, SessionId, UserAttributes, and UserIdentities for all four callbacks.
Note: user_login, user_logout, user_identified, and user_modified are not yet in the v2 event registry; the API accepts them with a warning.
Testing Plan
Unit tests: added for all four callbacks covering: attribute update, successful stream forwarding with correct payload (including MPID, SessionId, UserAttributes, UserIdentities), queuing when event_stream is unavailable, and queuing when window.Rokt is undefined. Edge cases for null MPID and null SessionId are also covered on the login callback (shared behaviour via _buildIdentityEvent).
Manual: mParticle.Identity.login() / logout() on local sample app and confirmed POST /v2/sessions/events requests appear with the correct eventType in the network tab. mParticle.Identity.identify() and mParticle.Identity.modify() were called via the browser console to verify user_identified and user_modified events respectively.