setUserId vs user context

Hi Snowplowers, I’m working with our team to instrument all of our event firings and contexts sent with those events. One thing I am grappling with is whether or not to use the setUserId function to pass a custom userId into the events table. I have actually created a robust user context to pass alongside every event that includes our custom userId as well as other user properties known at the time of the event. Is it necessary or beneficial then to use the setUserId function if we are sending a user custom context that already includes a custom userId?

Hi Travis,

I’d recommend sticking with your user context. The setUserId method is a good approach if the only user context you want to capture is a user ID: as soon as there is other user-level metadata that you want to capture a user context is a more flexible approach.

Fantastic, thanks for the clarification Yali!