Skip to content

feat: per-event user override in analytics().sendEvent()#43

Merged
vklimontovich merged 1 commit into
mainfrom
feat/sendevent-user-override
Jun 5, 2026
Merged

feat: per-event user override in analytics().sendEvent()#43
vklimontovich merged 1 commit into
mainfrom
feat/sendevent-user-override

Conversation

@vklimontovich
Copy link
Copy Markdown
Collaborator

What

analytics().sendEvent() gains an optional user:

sendEvent(eventName, { props?, user?: UserContext })

When provided, it sets the event's userContext directly, overriding callbacks.getUser for that one event.

Why

getUser derives identity from the request (cookie/session). Some server events have a subject that isn't the requester — e.g. an email pixel/click where the recipient is encoded in the link (?e=). There was no way to attach that identity, so it could only go in props (not the identity columns / no identify). This adds a per-event override for exactly those cases.

Testing

typecheck + all tests pass.

sendEvent now accepts an optional `user` (UserContext) that identifies the event
explicitly, overriding callbacks.getUser for that event. This covers server
events whose subject isn't the request's session user — e.g. an email recipient
resolved from a tracking link — so they land as real identity (userId/traits)
instead of plain props.
@vklimontovich vklimontovich merged commit 446c0ca into main Jun 5, 2026
3 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.

1 participant