{"action":"created","issue":{"url":"https://api.github.com/repos/getsentry/sentry-javascript/issues/1725","repository_url":"https://api.github.com/repos/getsentry/sentry-javascript","labels_url":"https://api.github.com/repos/getsentry/sentry-javascript/issues/1725/labels{/name}","comments_url":"https://api.github.com/repos/getsentry/sentry-javascript/issues/1725/comments","events_url":"https://api.github.com/repos/getsentry/sentry-javascript/issues/1725/events","html_url":"https://github.com/getsentry/sentry-javascript/issues/1725","id":379158592,"node_id":"MDU6SXNzdWUzNzkxNTg1OTI=","number":1725,"title":"Scoping issues","user":{"login":"spobrien","id":1926808,"node_id":"MDQ6VXNlcjE5MjY4MDg=","avatar_url":"https://avatars2.githubusercontent.com/u/1926808?v=4","gravatar_id":"","url":"https://api.github.com/users/spobrien","html_url":"https://github.com/spobrien","followers_url":"https://api.github.com/users/spobrien/followers","following_url":"https://api.github.com/users/spobrien/following{/other_user}","gists_url":"https://api.github.com/users/spobrien/gists{/gist_id}","starred_url":"https://api.github.com/users/spobrien/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spobrien/subscriptions","organizations_url":"https://api.github.com/users/spobrien/orgs","repos_url":"https://api.github.com/users/spobrien/repos","events_url":"https://api.github.com/users/spobrien/events{/privacy}","received_events_url":"https://api.github.com/users/spobrien/received_events","type":"User","site_admin":false},"labels":[{"id":1084500199,"node_id":"MDU6TGFiZWwxMDg0NTAwMTk5","url":"https://api.github.com/repos/getsentry/sentry-javascript/labels/Type:%20Question","name":"Type: Question","color":"074168","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2018-11-09T13:18:46Z","updated_at":"2018-11-15T10:06:08Z","closed_at":null,"author_association":"NONE","body":"- [x] Review the documentation: https://docs.sentry.io/\r\n- [x] Search for existing issues: https://github.com/getsentry/sentry-javascript/issues\r\n- [x] Use the latest release: https://github.com/getsentry/sentry-javascript/releases\r\n\r\n## Package + Version\r\n\r\n- [ ] `@sentry/browser`\r\n- [x] `@sentry/node`\r\n- [ ] `raven-js`\r\n- [ ] `raven-node` _(raven for node)_\r\n- [ ] other:\r\n\r\n### Version:\r\n\r\n```\r\n4.3.0\r\n```\r\n\r\n## Description\r\n\r\nHello there! \r\n\r\nI am experiencing some scoping issues in my application and unsure how to solve - I have tried a variety of different things but to little avail so far. \r\n\r\nMy application is message based and has a number of handlers - the problem is that the tags and extra are being shared amongst each other and I need to localise the scope. \r\n\r\nInitially I was wrapping the message flow like so:\r\n```\r\n\tstatic async wrap(name, handler) {\r\n\t\ttry {\r\n\t\t\tawait handler();\r\n\t\t} catch (err) {\r\n\t\t\tSentry.captureException(err);\r\n\t\t}\r\n\t}\r\n```\r\n\r\nAnd calling this from within \r\n```\r\n\tstatic addTag(name, value) {\r\n\t\tSentry.configureScope(scope => {\r\n\t\t\tscope.setTag(name, value);\r\n\t\t});\r\n\t}\r\n```\r\n\r\nBoth functions were in an external class.\r\n\r\nI tried replacing with 'withScope' - that didn't work and I can kinda see why. So then I am wondering what is the way forward with this, can you do something like this (I tried this exactly and did not seem to work) ?\r\n\r\n\t\tawait Sentry.withScope(async scope => {\r\n\t\t\ttry {\r\n\t\t\t\tscope.setTag('eventName', name);\r\n\t\t\t\tawait handler();\r\n\t\t\t} catch (err) {\r\n\t\t\t\tSentry.captureException(err);\r\n\t\t\t}\r\n\t\t});\r\n\r\nPerhaps I am not using sentry in a very natural way but the the task at hand is to add to our existing APM format so a little stumped. \r\n"},"comment":{"url":"https://api.github.com/repos/getsentry/sentry-javascript/issues/comments/438986310","html_url":"https://github.com/getsentry/sentry-javascript/issues/1725#issuecomment-438986310","issue_url":"https://api.github.com/repos/getsentry/sentry-javascript/issues/1725","id":438986310,"node_id":"MDEyOklzc3VlQ29tbWVudDQzODk4NjMxMA==","user":{"login":"spobrien","id":1926808,"node_id":"MDQ6VXNlcjE5MjY4MDg=","avatar_url":"https://avatars2.githubusercontent.com/u/1926808?v=4","gravatar_id":"","url":"https://api.github.com/users/spobrien","html_url":"https://github.com/spobrien","followers_url":"https://api.github.com/users/spobrien/followers","following_url":"https://api.github.com/users/spobrien/following{/other_user}","gists_url":"https://api.github.com/users/spobrien/gists{/gist_id}","starred_url":"https://api.github.com/users/spobrien/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spobrien/subscriptions","organizations_url":"https://api.github.com/users/spobrien/orgs","repos_url":"https://api.github.com/users/spobrien/repos","events_url":"https://api.github.com/users/spobrien/events{/privacy}","received_events_url":"https://api.github.com/users/spobrien/received_events","type":"User","site_admin":false},"created_at":"2018-11-15T10:06:08Z","updated_at":"2018-11-15T10:06:08Z","author_association":"NONE","body":"Thanks @kamilogorek - that might be something to investigate then. "}}
{"actor":{"display_login":"spobrien"}}