Add user identifier for Sentry - #863
Conversation
| const userData = await loadUserData(); | ||
|
|
||
| if ( ! userData.sentryUserId ) { | ||
| userData.sentryUserId = crypto.randomUUID(); |
There was a problem hiding this comment.
WDYT about studioInstanceId?
| userData.sentryUserId = crypto.randomUUID(); | |
| userData.studioInstanceId = crypto.randomUUID(); |
There was a problem hiding this comment.
This is what I referred to in the PR description 😄
Per @nightnei's suggestion, I considered naming the
sentryUserIdkey in the user config differently to indicate that it could be used for other reporting purposes in the future. However, I concluded that this is hypothetical, and it's better to optimize for the scenario at hand by using an explicit name.
To elaborate, I think a name like studioInstanceId is more difficult to understand at a glance, and there's currently no plan to use it for other purposes than Sentry reporting.
To that end, I think it's better to cross that bridge when and if we get there.
| } | ||
|
|
||
| console.log( 'Setting Sentry user ID:', userData.sentryUserId ); | ||
| Sentry.setUser( { id: userData.sentryUserId } ); |
There was a problem hiding this comment.
Also, looking at Sentry UI - it seems studio-instance-id will be more clear at a glance:
| Sentry.setUser( { id: userData.sentryUserId } ); | |
| Sentry.setUser( { studio-instance-id: userData.sentryUserId } ); |
There was a problem hiding this comment.
Sentry.setUser doesn't accept arbitrary keys. The id parameter is standardized. See docs
There was a problem hiding this comment.
Oh, in this case I definitely ok with naming 👍
Related issues
Proposed Changes
Store a UUID in
appdata-v1.jsonto identify users in Sentry. This will help us determine how many users are affected by the issues logged to Sentry.The UUID is (like all UUIDs) random, meaning we don't log any PII to Sentry.
Per @nightnei's suggestion, I considered naming the
sentryUserIdkey in the user config differently to indicate that it could be used for other reporting purposes in the future. However, I concluded that this is hypothetical, and it's better to optimize for the scenario at hand by using an explicit name.Testing Instructions
Setting Sentry user ID: xxxxx…in your console output and take note of your IDApp bootedTags > user(feel free to ping me for directions)Pre-merge Checklist