Snowplow iOS SDK : How to access the userId property

I’m using the Snowplow iOS SDK and our data team relies on the userId property generated by Snowplow ( Understanding the client session context ).

I need to be able to access userId from the iOS SDK to make requests later, how can I do that?

@Florent, you need to decide what you want the user ID to be. Once you know what that is (login username, email address, etc), you would set it with setUserId method: (this is equivalent to user_id in events table).

If you are referring to UUID generated for client session context, it can be accessed from com_snowplowanalytics_snowplow_client_session_1 table (if Redshift is used). Surely, the client session has to be enabled first:

We are not setting any user id ourselves so I guess we are using the UUID generated for client session context (should we?). The property name is userID in the co property of the json that Snowplow sends when tracking an event.

I don’t understand your answer, I want to access the userID property from my iOS app in Swift. I only see the setUserId method which populates an other property called uid.

Hi @Florent,

Starting from version 0.8.0 of Obj-C Tracker you can access session user_id with getSessionUserId method:

1 Like

@Florent, I didn’t realize you were asking about accessing the value from the tracker; I assumed you were talking about setting the user ID and pointed out where to find it when doing data modeling.

As @Yulia pointed out there is getSessionUserId method of SPTracker object. It returns UUID for userID.

Thanks! Turns out we were using an outdated version without that method.