Skip to content

feat: send set_user_attributes event#82

Merged
khushi1033 merged 1 commit intodevelopmentfrom
feat/send-set-user-attributes-event
Apr 1, 2026
Merged

feat: send set_user_attributes event#82
khushi1033 merged 1 commit intodevelopmentfrom
feat/send-set-user-attributes-event

Conversation

@khushi1033
Copy link
Copy Markdown
Contributor

@khushi1033 khushi1033 commented Apr 1, 2026

Summary

Extends the kit to emit a set_user_attributes event through the Rokt event stream whenever mParticle calls setUserAttribute on the forwarder. This follows the same pattern already established for onLoginComplete, onLogoutComplete, onModifyComplete, and onUserIdentified, which all send identity-category events via window.Rokt.__event_stream__.

The event reuses the existing _buildIdentityEvent helper, producing a consistent shape across all identity events:

  • EventName: "set_user_attributes"
  • EventDataType: 14 (MessageType.Profile)
  • MPID: sourced from self.filters.filteredUser (stored on the instance)
  • SessionId: sourced from window.mParticle.sessionManager
  • UserIdentities: sourced from filteredUser.getUserIdentities()
  • UserAttributes: the full updated attribute map, merged in by _enrichEvent
    before the event is sent

Testing Plan

Unit tests: added covering correct event name and data type, successful stream forwarding with correct payload, queuing when __event_stream__ is unavailable, and no-throw when window.Rokt is undefined. Edge case for null MPID and UserIdentities when filteredUser is not set is also covered.

Manual: call set user attibutes in the mock app and confirm a set_user_attributes event appears in the Rokt event stream with the correct payload in the network tab.

@khushi1033 khushi1033 changed the base branch from main to development April 1, 2026 19:00
@khushi1033 khushi1033 marked this pull request as ready for review April 1, 2026 19:11
@khushi1033 khushi1033 assigned jaissica12 and unassigned jaissica12 Apr 1, 2026
@khushi1033 khushi1033 requested a review from jaissica12 April 1, 2026 19:12

receivedEvents.length.should.equal(1);
receivedEvents[0].EventName.should.equal('set_user_attributes');
receivedEvents[0].EventDataType.should.equal(14);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should this actually be 14? (Did someone decide that and I'm just unaware)
https://github.com/mParticle/mparticle-web-sdk/blob/master/src/types.ts#L16-L20
when there's a user attribute change, MP server expects 17
when there's a user identity change, MP server expects 18. I actually don't know when "Profile" or 14 is used.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah I discussed with Alex when we were implementing login, logout, identify, and modify_user events, and we decided to go with Profile (14). I assumed we'd want to keep it consistent for this event as well, but if theres a specific type for UserAttributeChange (17) then that probably fits better.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Technically, this isn't a user attribute change, but a pseudo "new" event, so Profile better aligns with the expected behavior, like we did with the Identity methods.

Copy link
Copy Markdown
Collaborator

@rmi22186 rmi22186 left a comment

Choose a reason for hiding this comment

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

This LGTM so long as the question about profile has been addressed previously in a conversation I may not be privy to.

@khushi1033 khushi1033 merged commit 9995f09 into development Apr 1, 2026
16 of 20 checks passed
github-actions bot pushed a commit that referenced this pull request Apr 3, 2026
# [1.21.0](v1.20.0...v1.21.0) (2026-04-03)

### Features

* send set_user_attributes event ([#82](#82)) ([9995f09](9995f09))
@mparticle-automation
Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 1.21.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants