UNPKG

11 kBTypeScriptView Raw
1import type { Breadcrumb, BreadcrumbHint } from './breadcrumb';
2import type { Client } from './client';
3import type { Event, EventHint } from './event';
4import type { Extra, Extras } from './extra';
5import type { Integration, IntegrationClass } from './integration';
6import type { Primitive } from './misc';
7import type { Scope } from './scope';
8import type { Session } from './session';
9import type { Severity, SeverityLevel } from './severity';
10import type { CustomSamplingContext, Transaction, TransactionContext } from './transaction';
11import type { User } from './user';
12/**
13 * Internal class used to make sure we always have the latest internal functions
14 * working in case we have a version conflict.
15 *
16 * @deprecated The `Hub` interface will be removed in a future major version of the SDK in favour of
17 * `Scope` and `Client` objects and APIs.
18 *
19 * Most APIs referencing `Hub` are themselves and will be removed in version 8 of the SDK. More information:
20 * - [Migration Guide](https://github.com/getsentry/sentry-javascript/blob/develop/MIGRATION.md#deprecate-hub)
21 */
22export interface Hub {
23 /**
24 * Checks if this hub's version is older than the given version.
25 *
26 * @param version A version number to compare to.
27 * @return True if the given version is newer; otherwise false.
28 *
29 * @deprecated This will be removed in v8.
30 */
31 isOlderThan(version: number): boolean;
32 /**
33 * This binds the given client to the current scope.
34 * @param client An SDK client (client) instance.
35 *
36 * @deprecated Use `initAndBind()` directly.
37 */
38 bindClient(client?: Client): void;
39 /**
40 * Create a new scope to store context information.
41 *
42 * The scope will be layered on top of the current one. It is isolated, i.e. all
43 * breadcrumbs and context information added to this scope will be removed once
44 * the scope ends. Be sure to always remove this scope with {@link this.popScope}
45 * when the operation finishes or throws.
46 *
47 * @returns Scope, the new cloned scope
48 *
49 * @deprecated Use `withScope` instead.
50 */
51 pushScope(): Scope;
52 /**
53 * Removes a previously pushed scope from the stack.
54 *
55 * This restores the state before the scope was pushed. All breadcrumbs and
56 * context information added since the last call to {@link this.pushScope} are
57 * discarded.
58 *
59 * @deprecated Use `withScope` instead.
60 */
61 popScope(): boolean;
62 /**
63 * Creates a new scope with and executes the given operation within.
64 * The scope is automatically removed once the operation
65 * finishes or throws.
66 *
67 * This is essentially a convenience function for:
68 *
69 * pushScope();
70 * callback();
71 * popScope();
72 *
73 * @param callback that will be enclosed into push/popScope.
74 *
75 * @deprecated Use `Sentry.withScope()` instead.
76 */
77 withScope<T>(callback: (scope: Scope) => T): T;
78 /**
79 * Returns the client of the top stack.
80 * @deprecated Use `Sentry.getClient()` instead.
81 */
82 getClient(): Client | undefined;
83 /**
84 * Returns the scope of the top stack.
85 * @deprecated Use `Sentry.getCurrentScope()` instead.
86 */
87 getScope(): Scope;
88 /**
89 * Get the currently active isolation scope.
90 * The isolation scope is used to isolate data between different hubs.
91 *
92 * @deprecated Use `Sentry.getIsolationScope()` instead.
93 */
94 getIsolationScope(): Scope;
95 /**
96 * Captures an exception event and sends it to Sentry.
97 *
98 * @param exception An exception-like object.
99 * @param hint May contain additional information about the original exception.
100 * @returns The generated eventId.
101 *
102 * @deprecated Use `Sentry.captureException()` instead.
103 */
104 captureException(exception: any, hint?: EventHint): string;
105 /**
106 * Captures a message event and sends it to Sentry.
107 *
108 * @param message The message to send to Sentry.
109 * @param level Define the level of the message.
110 * @param hint May contain additional information about the original exception.
111 * @returns The generated eventId.
112 *
113 * @deprecated Use `Sentry.captureMessage()` instead.
114 */
115 captureMessage(message: string, level?: Severity | SeverityLevel, hint?: EventHint): string;
116 /**
117 * Captures a manually created event and sends it to Sentry.
118 *
119 * @param event The event to send to Sentry.
120 * @param hint May contain additional information about the original exception.
121 *
122 * @deprecated Use `Sentry.captureEvent()` instead.
123 */
124 captureEvent(event: Event, hint?: EventHint): string;
125 /**
126 * This is the getter for lastEventId.
127 *
128 * @returns The last event id of a captured event.
129 *
130 * @deprecated This will be removed in v8.
131 */
132 lastEventId(): string | undefined;
133 /**
134 * Records a new breadcrumb which will be attached to future events.
135 *
136 * Breadcrumbs will be added to subsequent events to provide more context on
137 * user's actions prior to an error or crash.
138 *
139 * @param breadcrumb The breadcrumb to record.
140 * @param hint May contain additional information about the original breadcrumb.
141 *
142 * @deprecated Use `Sentry.addBreadcrumb()` instead.
143 */
144 addBreadcrumb(breadcrumb: Breadcrumb, hint?: BreadcrumbHint): void;
145 /**
146 * Updates user context information for future events.
147 *
148 * @param user User context object to be set in the current context. Pass `null` to unset the user.
149 *
150 * @deprecated Use `Sentry.setUser()` instead.
151 */
152 setUser(user: User | null): void;
153 /**
154 * Set an object that will be merged sent as tags data with the event.
155 *
156 * @param tags Tags context object to merge into current context.
157 *
158 * @deprecated Use `Sentry.setTags()` instead.
159 */
160 setTags(tags: {
161 [key: string]: Primitive;
162 }): void;
163 /**
164 * Set key:value that will be sent as tags data with the event.
165 *
166 * Can also be used to unset a tag, by passing `undefined`.
167 *
168 * @param key String key of tag
169 * @param value Value of tag
170 *
171 * @deprecated Use `Sentry.setTag()` instead.
172 */
173 setTag(key: string, value: Primitive): void;
174 /**
175 * Set key:value that will be sent as extra data with the event.
176 * @param key String of extra
177 * @param extra Any kind of data. This data will be normalized.
178 *
179 * @deprecated Use `Sentry.setExtra()` instead.
180 */
181 setExtra(key: string, extra: Extra): void;
182 /**
183 * Set an object that will be merged sent as extra data with the event.
184 * @param extras Extras object to merge into current context.
185 *
186 * @deprecated Use `Sentry.setExtras()` instead.
187 */
188 setExtras(extras: Extras): void;
189 /**
190 * Sets context data with the given name.
191 * @param name of the context
192 * @param context Any kind of data. This data will be normalized.
193 *
194 * @deprecated Use `Sentry.setContext()` instead.
195 */
196 setContext(name: string, context: {
197 [key: string]: any;
198 } | null): void;
199 /**
200 * Callback to set context information onto the scope.
201 *
202 * @param callback Callback function that receives Scope.
203 * @deprecated Use `getScope()` directly.
204 */
205 configureScope(callback: (scope: Scope) => void): void;
206 /**
207 * For the duration of the callback, this hub will be set as the global current Hub.
208 * This function is useful if you want to run your own client and hook into an already initialized one
209 * e.g.: Reporting issues to your own sentry when running in your component while still using the users configuration.
210 *
211 * TODO v8: This will be merged with `withScope()`
212 */
213 run(callback: (hub: Hub) => void): void;
214 /**
215 * Returns the integration if installed on the current client.
216 *
217 * @deprecated Use `Sentry.getClient().getIntegration()` instead.
218 */
219 getIntegration<T extends Integration>(integration: IntegrationClass<T>): T | null;
220 /**
221 * Returns all trace headers that are currently on the top scope.
222 *
223 * @deprecated Use `spanToTraceHeader()` instead.
224 */
225 traceHeaders(): {
226 [key: string]: string;
227 };
228 /**
229 * Starts a new `Transaction` and returns it. This is the entry point to manual tracing instrumentation.
230 *
231 * A tree structure can be built by adding child spans to the transaction, and child spans to other spans. To start a
232 * new child span within the transaction or any span, call the respective `.startChild()` method.
233 *
234 * Every child span must be finished before the transaction is finished, otherwise the unfinished spans are discarded.
235 *
236 * The transaction must be finished with a call to its `.end()` method, at which point the transaction with all its
237 * finished child spans will be sent to Sentry.
238 *
239 * @param context Properties of the new `Transaction`.
240 * @param customSamplingContext Information given to the transaction sampling function (along with context-dependent
241 * default values). See {@link Options.tracesSampler}.
242 *
243 * @returns The transaction which was just started
244 *
245 * @deprecated Use `startSpan()`, `startSpanManual()` or `startInactiveSpan()` instead.
246 */
247 startTransaction(context: TransactionContext, customSamplingContext?: CustomSamplingContext): Transaction;
248 /**
249 * Starts a new `Session`, sets on the current scope and returns it.
250 *
251 * To finish a `session`, it has to be passed directly to `client.captureSession`, which is done automatically
252 * when using `hub.endSession()` for the session currently stored on the scope.
253 *
254 * When there's already an existing session on the scope, it'll be automatically ended.
255 *
256 * @param context Optional properties of the new `Session`.
257 *
258 * @returns The session which was just started
259 *
260 * @deprecated Use top-level `startSession` instead.
261 */
262 startSession(context?: Session): Session;
263 /**
264 * Ends the session that lives on the current scope and sends it to Sentry
265 *
266 * @deprecated Use top-level `endSession` instead.
267 */
268 endSession(): void;
269 /**
270 * Sends the current session on the scope to Sentry
271 *
272 * @param endSession If set the session will be marked as exited and removed from the scope
273 *
274 * @deprecated Use top-level `captureSession` instead.
275 */
276 captureSession(endSession?: boolean): void;
277 /**
278 * Returns if default PII should be sent to Sentry and propagated in outgoing requests
279 * when Tracing is used.
280 *
281 * @deprecated Use top-level `getClient().getOptions().sendDefaultPii` instead. This function
282 * only unnecessarily increased API surface but only wrapped accessing the option.
283 */
284 shouldSendDefaultPii(): boolean;
285}
286//# sourceMappingURL=hub.d.ts.map
\No newline at end of file