Skip to content

Scoped breadcrumbs (Sentry.withScope) #2009

Closed
@pgorecki

Description

@pgorecki

Package + Version

  • @sentry/browser
  • @sentry/node
  • raven-js
  • raven-node (raven for node)
  • other:

Version:

5.0.6

Description

I'm not sure if this is a bug or a lack of clear documentation.

The following code is a slightly modified snipped taken from https://docs.sentry.io/enriching-error-data/scopes/?platform=javascript

Sentry.addBreadcrumb({ message: 'My Breadcrumb' });
Sentry.withScope(scope => {
  scope.setTag("my-tag", "my value");
  scope.setLevel('warning');
  scope.addBreadcrumb({ message: 'scope breadcrumb' });
  // will be tagged with my-tag="my value"
  Sentry.captureException(new Error('oops!'));
});

Running the following code
will result in an isse with only 2 breadcrums:

  • generic | My Breadcrumb
  • exception | Error: oops!

I would expect to see the scope breadcrumb on the list of breadcrums. How can I capture an exception within a local scope, so that scope breadcrumbs are also reported?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions