sentry-javascript
sentry-javascript copied to clipboard
Sentry 8 Performance set user Context in node express server
Is there an existing issue for this?
- [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- [x] I have reviewed the documentation https://docs.sentry.io/
- [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Self-hosted/on-premise
Which SDK are you using?
@sentry/node
SDK Version
8.34.0
Framework Version
Node20 Express4
Link to Sentry event
No response
Reproduction Example/SDK Setup
Sentry.init({
dsn: sentryConfig.dsn,
environment: this.configService.env,
maxBreadcrumbs: 50,
integrations: [
nodeProfilingIntegration()
],
tracesSampleRate: 1.0,
profilesSampleRate: 1.0
})
const tags = sentryConfig.tags || {}
Sentry.setTags(tags)
this.express.use((req, res, next) => {
Sentry.withIsolationScope(null, (scope) => {
scope.setUser({ id: 'toto' })
next()
})
})
Steps to Reproduce
I want to set a user context for each request in my Express API.
Each request is sent to Sentry's performance monitoring, but I can't find any examples on how to add user context or extra data inside a transaction.
Could you provide an example?
Expected Result
Set user inside each sentry event
Actual Result
Need to increase it