1 | import type { Attachment } from './attachment';
|
2 | import type { Breadcrumb } from './breadcrumb';
|
3 | import type { Client } from './client';
|
4 | import type { Context, Contexts } from './context';
|
5 | import type { Event, EventHint } from './event';
|
6 | import type { EventProcessor } from './eventprocessor';
|
7 | import type { Extra, Extras } from './extra';
|
8 | import type { Primitive } from './misc';
|
9 | import type { RequestSession, Session } from './session';
|
10 | import type { SeverityLevel } from './severity';
|
11 | import type { Span } from './span';
|
12 | import type { PropagationContext } from './tracing';
|
13 | import type { User } from './user';
|
14 |
|
15 | export type CaptureContext = Scope | Partial<ScopeContext> | ((scope: Scope) => Scope);
|
16 | /** JSDocs */
|
17 | export interface ScopeContext {
|
18 | user: User;
|
19 | level: SeverityLevel;
|
20 | extra: Extras;
|
21 | contexts: Contexts;
|
22 | tags: {
|
23 | [key: string]: Primitive;
|
24 | };
|
25 | fingerprint: string[];
|
26 | requestSession: RequestSession;
|
27 | propagationContext: PropagationContext;
|
28 | }
|
29 | export interface ScopeData {
|
30 | eventProcessors: EventProcessor[];
|
31 | breadcrumbs: Breadcrumb[];
|
32 | user: User;
|
33 | tags: {
|
34 | [key: string]: Primitive;
|
35 | };
|
36 | extra: Extras;
|
37 | contexts: Contexts;
|
38 | attachments: Attachment[];
|
39 | propagationContext: PropagationContext;
|
40 | sdkProcessingMetadata: {
|
41 | [key: string]: unknown;
|
42 | };
|
43 | fingerprint: string[];
|
44 | level?: SeverityLevel;
|
45 | transactionName?: string;
|
46 | span?: Span;
|
47 | }
|
48 | /**
|
49 | * Holds additional event information.
|
50 | */
|
51 | export interface Scope {
|
52 | /**
|
53 | * Update the client on the scope.
|
54 | */
|
55 | setClient(client: Client | undefined): void;
|
56 | /**
|
57 | * Get the client assigned to this scope.
|
58 | *
|
59 | * It is generally recommended to use the global function `Sentry.getClient()` instead, unless you know what you are doing.
|
60 | */
|
61 | getClient<C extends Client>(): C | undefined;
|
62 | /**
|
63 | * Sets the last event id on the scope.
|
64 | * @param lastEventId The last event id of a captured event.
|
65 | */
|
66 | setLastEventId(lastEventId: string | undefined): void;
|
67 | /**
|
68 | * This is the getter for lastEventId.
|
69 | * @returns The last event id of a captured event.
|
70 | */
|
71 | lastEventId(): string | undefined;
|
72 | /**
|
73 | * Add internal on change listener. Used for sub SDKs that need to store the scope.
|
74 | * @hidden
|
75 | */
|
76 | addScopeListener(callback: (scope: Scope) => void): void;
|
77 | /** Add new event processor that will be called during event processing. */
|
78 | addEventProcessor(callback: EventProcessor): this;
|
79 | /** Get the data of this scope, which is applied to an event during processing. */
|
80 | getScopeData(): ScopeData;
|
81 | /**
|
82 | * Updates user context information for future events.
|
83 | *
|
84 | * @param user User context object to be set in the current context. Pass `null` to unset the user.
|
85 | */
|
86 | setUser(user: User | null): this;
|
87 | /**
|
88 | * Returns the `User` if there is one
|
89 | */
|
90 | getUser(): User | undefined;
|
91 | /**
|
92 | * Set an object that will be merged sent as tags data with the event.
|
93 | * @param tags Tags context object to merge into current context.
|
94 | */
|
95 | setTags(tags: {
|
96 | [key: string]: Primitive;
|
97 | }): this;
|
98 | /**
|
99 | * Set key:value that will be sent as tags data with the event.
|
100 | *
|
101 | * Can also be used to unset a tag by passing `undefined`.
|
102 | *
|
103 | * @param key String key of tag
|
104 | * @param value Value of tag
|
105 | */
|
106 | setTag(key: string, value: Primitive): this;
|
107 | /**
|
108 | * Set an object that will be merged sent as extra data with the event.
|
109 | * @param extras Extras object to merge into current context.
|
110 | */
|
111 | setExtras(extras: Extras): this;
|
112 | /**
|
113 | * Set key:value that will be sent as extra data with the event.
|
114 | * @param key String of extra
|
115 | * @param extra Any kind of data. This data will be normalized.
|
116 | */
|
117 | setExtra(key: string, extra: Extra): this;
|
118 | /**
|
119 | * Sets the fingerprint on the scope to send with the events.
|
120 | * @param fingerprint string[] to group events in Sentry.
|
121 | */
|
122 | setFingerprint(fingerprint: string[]): this;
|
123 | /**
|
124 | * Sets the level on the scope for future events.
|
125 | * @param level string {@link SeverityLevel}
|
126 | */
|
127 | setLevel(level: SeverityLevel): this;
|
128 | /**
|
129 | * Sets the transaction name on the scope so that the name of the transaction
|
130 | * (e.g. taken server route or page location) is attached to future events.
|
131 | *
|
132 | * IMPORTANT: Calling this function does NOT change the name of the currently active
|
133 | * span. If you want to change the name of the active span, use `span.updateName()`
|
134 | * instead.
|
135 | *
|
136 | * By default, the SDK updates the scope's transaction name automatically on sensible
|
137 | * occasions, such as a page navigation or when handling a new request on the server.
|
138 | */
|
139 | setTransactionName(name?: string): this;
|
140 | /**
|
141 | * Sets context data with the given name.
|
142 | * @param name of the context
|
143 | * @param context an object containing context data. This data will be normalized. Pass `null` to unset the context.
|
144 | */
|
145 | setContext(name: string, context: Context | null): this;
|
146 | /**
|
147 | * Returns the `Session` if there is one
|
148 | */
|
149 | getSession(): Session | undefined;
|
150 | /**
|
151 | * Sets the `Session` on the scope
|
152 | */
|
153 | setSession(session?: Session): this;
|
154 | /**
|
155 | * Returns the `RequestSession` if there is one
|
156 | */
|
157 | getRequestSession(): RequestSession | undefined;
|
158 | /**
|
159 | * Sets the `RequestSession` on the scope
|
160 | */
|
161 | setRequestSession(requestSession?: RequestSession): this;
|
162 | /**
|
163 | * Updates the scope with provided data. Can work in three variations:
|
164 | * - plain object containing updatable attributes
|
165 | * - Scope instance that'll extract the attributes from
|
166 | * - callback function that'll receive the current scope as an argument and allow for modifications
|
167 | * @param captureContext scope modifier to be used
|
168 | */
|
169 | update(captureContext?: CaptureContext): this;
|
170 | /** Clears the current scope and resets its properties. */
|
171 | clear(): this;
|
172 | /**
|
173 | * Adds a breadcrumb to the scope
|
174 | * @param breadcrumb Breadcrumb
|
175 | * @param maxBreadcrumbs number of max breadcrumbs to merged into event.
|
176 | */
|
177 | addBreadcrumb(breadcrumb: Breadcrumb, maxBreadcrumbs?: number): this;
|
178 | /**
|
179 | * Get the last breadcrumb.
|
180 | */
|
181 | getLastBreadcrumb(): Breadcrumb | undefined;
|
182 | /**
|
183 | * Clears all breadcrumbs from the scope.
|
184 | */
|
185 | clearBreadcrumbs(): this;
|
186 | /**
|
187 | * Adds an attachment to the scope
|
188 | * @param attachment Attachment options
|
189 | */
|
190 | addAttachment(attachment: Attachment): this;
|
191 | /**
|
192 | * Clears attachments from the scope
|
193 | */
|
194 | clearAttachments(): this;
|
195 | /**
|
196 | * Add data which will be accessible during event processing but won't get sent to Sentry
|
197 | */
|
198 | setSDKProcessingMetadata(newData: {
|
199 | [key: string]: unknown;
|
200 | }): this;
|
201 | /**
|
202 | * Add propagation context to the scope, used for distributed tracing
|
203 | */
|
204 | setPropagationContext(context: PropagationContext): this;
|
205 | /**
|
206 | * Get propagation context from the scope, used for distributed tracing
|
207 | */
|
208 | getPropagationContext(): PropagationContext;
|
209 | /**
|
210 | * Capture an exception for this scope.
|
211 | *
|
212 | * @param exception The exception to capture.
|
213 | * @param hint Optional additional data to attach to the Sentry event.
|
214 | * @returns the id of the captured Sentry event.
|
215 | */
|
216 | captureException(exception: unknown, hint?: EventHint): string;
|
217 | /**
|
218 | * Capture a message for this scope.
|
219 | *
|
220 | * @param message The message to capture.
|
221 | * @param level An optional severity level to report the message with.
|
222 | * @param hint Optional additional data to attach to the Sentry event.
|
223 | * @returns the id of the captured message.
|
224 | */
|
225 | captureMessage(message: string, level?: SeverityLevel, hint?: EventHint): string;
|
226 | /**
|
227 | * Capture a Sentry event for this scope.
|
228 | *
|
229 | * @param event The event to capture.
|
230 | * @param hint Optional additional data to attach to the Sentry event.
|
231 | * @returns the id of the captured event.
|
232 | */
|
233 | captureEvent(event: Event, hint?: EventHint): string;
|
234 | /**
|
235 | * Clone all data from this scope into a new scope.
|
236 | */
|
237 | clone(): Scope;
|
238 | }
|
239 | //# sourceMappingURL=scope.d.ts.map |
\ | No newline at end of file |