Skip to content

feat: support sending login, logout, identify, and modify_user events#81

Merged
khushi1033 merged 5 commits intodevelopmentfrom
feat/send-login-logout-events
Mar 27, 2026
Merged

feat: support sending login, logout, identify, and modify_user events#81
khushi1033 merged 5 commits intodevelopmentfrom
feat/send-login-logout-events

Conversation

@khushi1033
Copy link
Copy Markdown

@khushi1033 khushi1033 commented Mar 26, 2026

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.

@khushi1033 khushi1033 marked this pull request as ready for review March 26, 2026 19:59
src/Rokt-Kit.js Outdated
function onLoginComplete(filteredUser) {
self.userAttributes = filteredUser.getAllUserAttributes();
_sendEventStream({
EventName: 'User Login',
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We need to confirm these match what's expected

@khushi1033 khushi1033 changed the title feat: support sending login/logout events feat: support sending login/logout, identify, and modify_user events Mar 27, 2026
@khushi1033 khushi1033 changed the title feat: support sending login/logout, identify, and modify_user events feat: support sending login, logout, identify, and modify_user events Mar 27, 2026
@khushi1033 khushi1033 merged commit 78061a5 into development Mar 27, 2026
5 checks passed
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