Title: Passing `() => scope` as `captureContext` does not work · Issue #10686 · getsentry/sentry-javascript · GitHub
Open Graph Title: Passing `() => scope` as `captureContext` does not work · Issue #10686 · getsentry/sentry-javascript
X Title: Passing `() => scope` as `captureContext` does not work · Issue #10686 · getsentry/sentry-javascript
Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using the latest SDK release https://github.com/...
Open Graph Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
X Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/10686
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Passing `() => scope` as `captureContext` does not work","articleBody":"### Is there an existing issue for this?\n\n- [X] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues\n- [X] I have reviewed the documentation https://docs.sentry.io/\n- [X] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases\n\n### How do you use Sentry?\n\nSentry Saas (sentry.io)\n\n### Which SDK are you using?\n\n@sentry/node\n\n### SDK Version\n\n7.101.1\n\n### Framework Version\n\n_No response_\n\n### Link to Sentry event\n\nhttps://s1seven.sentry.io/issues/4488829135/?environment=local&project=5880685&query=is%3Aunresolved&referrer=issue-stream&statsPeriod=7d&stream_index=0&utc=true\n\n### SDK Setup\n\n```js\r\ninit({\r\n tracesSampleRate: 1.0,\r\n ...params,\r\n autoSessionTracking: true,\r\n integrations: [\r\n browserTracingIntegration(),\r\n ...(params.integrations || []),\r\n ],\r\n```\n\n### Steps to Reproduce\n\nPrior to v7.87.0 we were able to use `setExtra` and see the information in the ui, we set the data like this:\r\n\r\n```ts\r\n const { method, statusCode, path, stack } = errorResponse;\r\n const request = context.getRequest\u003cExtendedRequest>();\r\n const scope = new Scope();\r\n if (request.currentUser) {\r\n scope.setUser(request.currentUser);\r\n } else if (request.currentCompany) {\r\n scope.setUser(request.currentCompany);\r\n }\r\n scope.setExtras({\r\n ...(!isEmpty(request.currentScopes) && {\r\n [SentryExtrasProps.access_scopes]: request.currentScopes,\r\n }),\r\n [SentryExtrasProps.request_id]: request.requestId,\r\n [SentryExtrasProps.stack]: stack,\r\n [SentryExtrasProps.http_headers]: request.headers,\r\n [SentryExtrasProps.http_method]: request.method,\r\n [SentryExtrasProps.http_params]: request.params,\r\n [SentryExtrasProps.http_query]: request.query,\r\n [SentryExtrasProps.http_body]: request.body,\r\n [SentryExtrasProps.error_message]: errorResponse.message,\r\n [SentryExtrasProps.error_details]: errorResponse.details,\r\n });\r\n const mode = extractModeFromHttpRequest(request);\r\n scope.setTags({\r\n requestId: request.requestId,\r\n statusCode,\r\n method,\r\n path,\r\n protocol: 'http',\r\n ...(mode ? { mode } : {}),\r\n ...tags,\r\n });\r\n```\r\n\r\nWe used to use `setExtra` but that stopped working in v7.87.0, so we switched to `setExtras`, but that seemed to stop working in v7.89.0.\r\n\r\nThere is no deprecated tag on either of those methods, and in the release notes for v7.101.1 it says:\r\n`feat(core): Write data from setUser, setTags, setExtras, setTag, setExtra, and setContext to isolation\r\nscope ([#10163](https://github.com/getsentry/sentry-javascript/pull/10163))` so it appears that they are still in use.\r\n\r\nHowever in the docs (https://docs.sentry.io/platforms/javascript/enriching-events/context/#additional-data) it says the following:\r\n```\r\nAdditional Data is deprecated in favor of structured contexts.\r\nSentry used to support adding unstructured \"Additional Data\" via setExtra.\r\n```\r\n\r\nAs you can see in the screenshot, we could previously see all this information:\r\n\u003cimg width=\"879\" alt=\"image\" src=\"https://github.com/getsentry/sentry-javascript/assets/21305201/7830c868-a097-4f2c-b190-f006cd400b81\">\r\n\r\nSince v7.89.0 all that information is missing.\n\n### Expected Result\n\nI should still be able to see that extra information in the UI. There should be clear documentation and deprecated tags if `setExtra` and `setExtras` are no longer to be used.\n\n### Actual Result\n\nAll that extra information is now missing:\r\n\u003cimg width=\"1225\" alt=\"image\" src=\"https://github.com/getsentry/sentry-javascript/assets/21305201/a9c81b5c-310c-4c1b-99df-6508b275e5e9\">\r\n","author":{"url":"https://github.com/eamon0989","@type":"Person","name":"eamon0989"},"datePublished":"2024-02-16T09:29:37Z","url":"https://github.com/getsentry/sentry-javascript/issues/10686"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b66423f8-f1e3-c3b2-89f8-d42a84f6df59 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CEE6:AD997:2AD6281:370B921:6B0402B7 |
| html-safe-nonce | 2562d9d0ff8d91c3ae8a507355e20f081d8c0f706a1c8fc0de0e825a62bc2154 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRUU2OkFEOTk3OjJBRDYyODE6MzcwQjkyMTo2QjA0MDJCNyIsInZpc2l0b3JfaWQiOiI4MTkzOTEyNjMzMTQyMDE4NzQzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 7e34450cfea8b34abf53c86520aeabbe7a2acd8b8fbb3db4902c3619b3b5beab |
| hovercard-subject-tag | issue:2138203590 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/10686/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a18237dbfe2f2e24321d8a75396c4f81c1b127a3cab6b0142e86e9378873fb52/getsentry/sentry-javascript/issues/10686 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a18237dbfe2f2e24321d8a75396c4f81c1b127a3cab6b0142e86e9378873fb52/getsentry/sentry-javascript/issues/10686 |
| og:image:alt | Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | eamon0989 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width