UNPKG

5.47 kBTypeScriptView Raw
1import type { Attachment, Breadcrumb, CaptureContext, Context, Contexts, Event, EventHint, EventProcessor, Extra, Extras, Primitive, RequestSession, Scope as ScopeInterface, Session, Severity, SeverityLevel, Span, Transaction, User } from '@sentry/types';
2/**
3 * Holds additional event information. {@link Scope.applyToEvent} will be
4 * called by the client before an event will be sent.
5 */
6export declare class Scope implements ScopeInterface {
7 /** Flag if notifying is happening. */
8 protected _notifyingListeners: boolean;
9 /** Callback for client to receive scope changes. */
10 protected _scopeListeners: Array<(scope: Scope) => void>;
11 /** Callback list that will be called after {@link applyToEvent}. */
12 protected _eventProcessors: EventProcessor[];
13 /** Array of breadcrumbs. */
14 protected _breadcrumbs: Breadcrumb[];
15 /** User */
16 protected _user: User;
17 /** Tags */
18 protected _tags: {
19 [key: string]: Primitive;
20 };
21 /** Extra */
22 protected _extra: Extras;
23 /** Contexts */
24 protected _contexts: Contexts;
25 /** Attachments */
26 protected _attachments: Attachment[];
27 /**
28 * A place to stash data which is needed at some point in the SDK's event processing pipeline but which shouldn't get
29 * sent to Sentry
30 */
31 protected _sdkProcessingMetadata: {
32 [key: string]: unknown;
33 };
34 /** Fingerprint */
35 protected _fingerprint?: string[];
36 /** Severity */
37 protected _level?: Severity | SeverityLevel;
38 /** Transaction Name */
39 protected _transactionName?: string;
40 /** Span */
41 protected _span?: Span;
42 /** Session */
43 protected _session?: Session;
44 /** Request Mode Session Status */
45 protected _requestSession?: RequestSession;
46 constructor();
47 /**
48 * Inherit values from the parent scope.
49 * @param scope to clone.
50 */
51 static clone(scope?: Scope): Scope;
52 /**
53 * Add internal on change listener. Used for sub SDKs that need to store the scope.
54 * @hidden
55 */
56 addScopeListener(callback: (scope: Scope) => void): void;
57 /**
58 * @inheritDoc
59 */
60 addEventProcessor(callback: EventProcessor): this;
61 /**
62 * @inheritDoc
63 */
64 setUser(user: User | null): this;
65 /**
66 * @inheritDoc
67 */
68 getUser(): User | undefined;
69 /**
70 * @inheritDoc
71 */
72 getRequestSession(): RequestSession | undefined;
73 /**
74 * @inheritDoc
75 */
76 setRequestSession(requestSession?: RequestSession): this;
77 /**
78 * @inheritDoc
79 */
80 setTags(tags: {
81 [key: string]: Primitive;
82 }): this;
83 /**
84 * @inheritDoc
85 */
86 setTag(key: string, value: Primitive): this;
87 /**
88 * @inheritDoc
89 */
90 setExtras(extras: Extras): this;
91 /**
92 * @inheritDoc
93 */
94 setExtra(key: string, extra: Extra): this;
95 /**
96 * @inheritDoc
97 */
98 setFingerprint(fingerprint: string[]): this;
99 /**
100 * @inheritDoc
101 */
102 setLevel(level: Severity | SeverityLevel): this;
103 /**
104 * @inheritDoc
105 */
106 setTransactionName(name?: string): this;
107 /**
108 * @inheritDoc
109 */
110 setContext(key: string, context: Context | null): this;
111 /**
112 * @inheritDoc
113 */
114 setSpan(span?: Span): this;
115 /**
116 * @inheritDoc
117 */
118 getSpan(): Span | undefined;
119 /**
120 * @inheritDoc
121 */
122 getTransaction(): Transaction | undefined;
123 /**
124 * @inheritDoc
125 */
126 setSession(session?: Session): this;
127 /**
128 * @inheritDoc
129 */
130 getSession(): Session | undefined;
131 /**
132 * @inheritDoc
133 */
134 update(captureContext?: CaptureContext): this;
135 /**
136 * @inheritDoc
137 */
138 clear(): this;
139 /**
140 * @inheritDoc
141 */
142 addBreadcrumb(breadcrumb: Breadcrumb, maxBreadcrumbs?: number): this;
143 /**
144 * @inheritDoc
145 */
146 getLastBreadcrumb(): Breadcrumb | undefined;
147 /**
148 * @inheritDoc
149 */
150 clearBreadcrumbs(): this;
151 /**
152 * @inheritDoc
153 */
154 addAttachment(attachment: Attachment): this;
155 /**
156 * @inheritDoc
157 */
158 getAttachments(): Attachment[];
159 /**
160 * @inheritDoc
161 */
162 clearAttachments(): this;
163 /**
164 * Applies data from the scope to the event and runs all event processors on it.
165 *
166 * @param event Event
167 * @param hint Object containing additional information about the original exception, for use by the event processors.
168 * @hidden
169 */
170 applyToEvent(event: Event, hint?: EventHint): PromiseLike<Event | null>;
171 /**
172 * Add data which will be accessible during event processing but won't get sent to Sentry
173 */
174 setSDKProcessingMetadata(newData: {
175 [key: string]: unknown;
176 }): this;
177 /**
178 * This will be called after {@link applyToEvent} is finished.
179 */
180 protected _notifyEventProcessors(processors: EventProcessor[], event: Event | null, hint: EventHint, index?: number): PromiseLike<Event | null>;
181 /**
182 * This will be called on every set call.
183 */
184 protected _notifyScopeListeners(): void;
185 /**
186 * Applies fingerprint from the scope to the event if there's one,
187 * uses message if there's one instead or get rid of empty fingerprint
188 */
189 private _applyFingerprint;
190}
191/**
192 * Add a EventProcessor to be kept globally.
193 * @param callback EventProcessor to add
194 */
195export declare function addGlobalEventProcessor(callback: EventProcessor): void;
196//# sourceMappingURL=scope.d.ts.map
\No newline at end of file