Class: Scope

sentry.Scope

Holds additional event information. Scope.applyToEvent will be called by the client before an event will be sent.

Implements

  • Scope

Constructors

constructor

new Scope(): Scope

Returns

Scope

Properties

_attachments

Protected _attachments: Attachment[]

Attachments


_breadcrumbs

Protected _breadcrumbs: Breadcrumb[]

Array of breadcrumbs.


_client

Protected Optional _client: Client<ClientOptions<BaseTransportOptions>>

The client on this scope


_contexts

Protected _contexts: Contexts

Contexts


_eventProcessors

Protected _eventProcessors: EventProcessor[]

Callback list that will be called after applyToEvent.


_extra

Protected _extra: Extras

Extra


_fingerprint

Protected Optional _fingerprint: string[]

Fingerprint


_level

Protected Optional _level: SeverityLevel | Severity

Severity


_notifyingListeners

Protected _notifyingListeners: boolean

Flag if notifying is happening.


_propagationContext

Protected _propagationContext: PropagationContext

Propagation Context for distributed tracing


_requestSession

Protected Optional _requestSession: RequestSession

Request Mode Session Status


_scopeListeners

Protected _scopeListeners: (scope: Scope) => void[]

Callback for client to receive scope changes.


_sdkProcessingMetadata

Protected _sdkProcessingMetadata: Object

A place to stash data which is needed at some point in the SDK’s event processing pipeline but which shouldn’t get sent to Sentry

Index signature

▪ [key: string]: unknown


_session

Protected Optional _session: Session

Session


_span

Protected Optional _span: Span

Span


_tags

Protected _tags: Object

Tags

Index signature

▪ [key: string]: Primitive


_transactionName

Protected Optional _transactionName: string

Transaction Name


_user

Protected _user: User

User

Methods

_notifyScopeListeners

_notifyScopeListeners(): void

This will be called on every set call.

Returns

void


addAttachment

addAttachment(attachment): this

Parameters

Name Type
attachment Attachment

Returns

this

Inherit Doc

Implementation of

ScopeInterface.addAttachment


addBreadcrumb

addBreadcrumb(breadcrumb, maxBreadcrumbs?): this

Parameters

Name Type
breadcrumb Breadcrumb
maxBreadcrumbs? number

Returns

this

Inherit Doc

Implementation of

ScopeInterface.addBreadcrumb


addEventProcessor

addEventProcessor(callback): this

Parameters

Name Type
callback EventProcessor

Returns

this

Inherit Doc

Implementation of

ScopeInterface.addEventProcessor


captureEvent

captureEvent(event, hint?): string

Captures a manually created event for this scope and sends it to Sentry.

Parameters

Name Type Description
event Event -
hint? EventHint Optional additional data to attach to the Sentry event.

Returns

string

the id of the captured event.

Implementation of

ScopeInterface.captureEvent


captureException

captureException(exception, hint?): string

Capture an exception for this scope.

Parameters

Name Type Description
exception unknown The exception to capture.
hint? EventHint Optinal additional data to attach to the Sentry event.

Returns

string

the id of the captured Sentry event.

Implementation of

ScopeInterface.captureException


captureMessage

captureMessage(message, level?, hint?): string

Capture a message for this scope.

Parameters

Name Type Description
message string The message to capture.
level? SeverityLevel An optional severity level to report the message with.
hint? EventHint Optional additional data to attach to the Sentry event.

Returns

string

the id of the captured message.

Implementation of

ScopeInterface.captureMessage


clear

clear(): this

Returns

this

Inherit Doc

Implementation of

ScopeInterface.clear


clearAttachments

clearAttachments(): this

Returns

this

Inherit Doc

Implementation of

ScopeInterface.clearAttachments


clearBreadcrumbs

clearBreadcrumbs(): this

Returns

this

Inherit Doc

Implementation of

ScopeInterface.clearBreadcrumbs


clone

clone(): Scope

Clone this scope instance.

Returns

Scope


getAttachments

getAttachments(): Attachment[]

Returns

Attachment[]

Inherit Doc

Deprecated

Use getScopeData() instead.

Implementation of

ScopeInterface.getAttachments


getClient

getClient(): undefined | Client<ClientOptions<BaseTransportOptions>>

Get the client assigned to this scope.

It is generally recommended to use the global function Sentry.getClient() instead, unless you know what you are doing.

Returns

undefined | Client<ClientOptions<BaseTransportOptions>>

Implementation of

ScopeInterface.getClient


getLastBreadcrumb

getLastBreadcrumb(): undefined | Breadcrumb

Returns

undefined | Breadcrumb

Inherit Doc

Implementation of

ScopeInterface.getLastBreadcrumb


getPropagationContext

getPropagationContext(): PropagationContext

Returns

PropagationContext

Inherit Doc

Implementation of

ScopeInterface.getPropagationContext


getRequestSession

getRequestSession(): undefined | RequestSession

Returns

undefined | RequestSession

Inherit Doc

Implementation of

ScopeInterface.getRequestSession


getScopeData

getScopeData(): ScopeData

Returns

ScopeData

Inherit Doc

Implementation of

ScopeInterface.getScopeData


getSession

getSession(): undefined | Session

Returns

undefined | Session

Inherit Doc

Implementation of

ScopeInterface.getSession


getSpan

getSpan(): undefined | Span

Returns the Span if there is one.

Returns

undefined | Span

Deprecated

Use getActiveSpan() instead.

Implementation of

ScopeInterface.getSpan


getTransaction

getTransaction(): undefined | Transaction

Returns the Transaction attached to the scope (if there is one).

Returns

undefined | Transaction

Deprecated

You should not rely on the transaction, but just use startSpan() APIs instead.

Implementation of

ScopeInterface.getTransaction


getUser

getUser(): undefined | User

Returns

undefined | User

Inherit Doc

Implementation of

ScopeInterface.getUser


setClient

setClient(client): void

Update the client on the scope.

Parameters

Name Type
client undefined | Client<ClientOptions<BaseTransportOptions>>

Returns

void

Implementation of

ScopeInterface.setClient


setContext

setContext(key, context): this

Parameters

Name Type
key string
context null | Context

Returns

this

Inherit Doc

Implementation of

ScopeInterface.setContext


setExtra

setExtra(key, extra): this

Parameters

Name Type
key string
extra unknown

Returns

this

Inherit Doc

Implementation of

ScopeInterface.setExtra


setExtras

setExtras(extras): this

Parameters

Name Type
extras Extras

Returns

this

Inherit Doc

Implementation of

ScopeInterface.setExtras


setFingerprint

setFingerprint(fingerprint): this

Parameters

Name Type
fingerprint string[]

Returns

this

Inherit Doc

Implementation of

ScopeInterface.setFingerprint


setLevel

setLevel(level): this

Parameters

Name Type
level SeverityLevel | Severity

Returns

this

Inherit Doc

Implementation of

ScopeInterface.setLevel


setPropagationContext

setPropagationContext(context): this

Parameters

Name Type
context PropagationContext

Returns

this

Inherit Doc

Implementation of

ScopeInterface.setPropagationContext


setRequestSession

setRequestSession(requestSession?): this

Parameters

Name Type
requestSession? RequestSession

Returns

this

Inherit Doc

Implementation of

ScopeInterface.setRequestSession


setSDKProcessingMetadata

setSDKProcessingMetadata(newData): this

Add data which will be accessible during event processing but won’t get sent to Sentry

Parameters

Name Type
newData Object

Returns

this

Implementation of

ScopeInterface.setSDKProcessingMetadata


setSession

setSession(session?): this

Parameters

Name Type
session? Session

Returns

this

Inherit Doc

Implementation of

ScopeInterface.setSession


setSpan

setSpan(span?): this

Sets the Span on the scope.

Parameters

Name Type Description
span? Span Span

Returns

this

Deprecated

Instead of setting a span on a scope, use startSpan()/startSpanManual() instead.

Implementation of

ScopeInterface.setSpan


setTag

setTag(key, value): this

Parameters

Name Type
key string
value Primitive

Returns

this

Inherit Doc

Implementation of

ScopeInterface.setTag


setTags

setTags(tags): this

Parameters

Name Type
tags Object

Returns

this

Inherit Doc

Implementation of

ScopeInterface.setTags


setTransactionName

setTransactionName(name?): this

Sets the transaction name on the scope for future events.

Parameters

Name Type
name? string

Returns

this

Implementation of

ScopeInterface.setTransactionName


setUser

setUser(user): this

Parameters

Name Type
user null | User

Returns

this

Inherit Doc

Implementation of

ScopeInterface.setUser


update

update(captureContext?): this

Parameters

Name Type
captureContext? CaptureContext

Returns

this

Inherit Doc

Implementation of

ScopeInterface.update


clone

clone(scope?): Scope

Inherit values from the parent scope.

Parameters

Name Type
scope? Scope

Returns

Scope

Deprecated

Use scope.clone() and new Scope() instead.