getsentry / sentry-docs

Sentry's documentation (and tools to build it)
https://docs.sentry.io
Other
325 stars 1.39k forks source link

Best practice examples when adding User context to events for server side and client side (Sveltekit SDK) #10233

Open Pascaltib opened 1 month ago

Pascaltib commented 1 month ago

Core or SDK?

Platform/SDK

Which part? Which one?

Sveltekit

Description

It is not clear how to set User context in frontend and backend. It would be nice to have a recommendation.

For example in the server side hooks should every authenticated request set Sentry.setUser({ id: user!.id }) and clear it when unauthenticated (Sentry.setUser(null))?

How would this apply to client side? Should it be set or unset in a global layout.svelte?

Suggested Solution

Show a simple example of how to set/unset this information in server hooks and in a client side layout.svelte (if this is a recommended solution).

Additionally some info on things to avoid.

getsantry[bot] commented 1 month ago

Assigning to @getsentry/support for routing ⏲️