Skip to content

Get current state of context from SDK for testing #5120

Discussion options

You must be logged in to vote

Hey @cameronmcefee , of course. All you need to do is to access the current scope. Here is how to do that:

import * as Sentry from "@sentry/browser" // or any other package you are using

const scope = Sentry.getCurrentHub().getScope();

console.log(scope)

This will output something like this:

{
  _attachments:(0) []
  _breadcrumbs:(6) [{…}, {…}, {…}, {…}, {…}, {…}]
  _contexts:{}
  _eventProcessors:(2) [ƒ, ƒ]
  _extra:{}
  _fingerprint:undefined
  _level:undefined
  _notifyingListeners:false
  _requestSession:undefined
  _scopeListeners:(0) []
  _sdkProcessingMetadata:{}
  _session:undefined
  _span:Transaction {traceId: '7850459a2da940a6acaacef00f4f7e84', spanId: 'bcd1a108e5c04863', sta…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@cameronmcefee
Comment options

Answer selected by AbhiPrasad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants