UNPKG

7.12 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 { SeverityLevel } from './severity';
10import type { User } from './user';
11/**
12 * Internal class used to make sure we always have the latest internal functions
13 * working in case we have a version conflict.
14 *
15 * @deprecated This interface will be removed in a future major version of the SDK in favour of
16 * `Scope` and `Client` objects and APIs.
17 *
18 * Most APIs referencing `Hub` are themselves and will be removed in version 8 of the SDK. More information:
19 * - [Migration Guide](https://github.com/getsentry/sentry-javascript/blob/develop/MIGRATION.md#deprecate-hub)
20 *
21 */
22export interface Hub {
23 /**
24 * This binds the given client to the current scope.
25 * @param client An SDK client (client) instance.
26 *
27 * @deprecated Use `initAndBind()` directly.
28 */
29 bindClient(client?: Client): void;
30 /**
31 * Creates a new scope with and executes the given operation within.
32 * The scope is automatically removed once the operation
33 * finishes or throws.
34 *
35 * This is essentially a convenience function for:
36 *
37 * pushScope();
38 * callback();
39 * popScope();
40 *
41 * @param callback that will be enclosed into push/popScope.
42 *
43 * @deprecated Use `Sentry.withScope()` instead.
44 */
45 withScope<T>(callback: (scope: Scope) => T): T;
46 /**
47 * Returns the client of the top stack.
48 * @deprecated Use `Sentry.getClient()` instead.
49 */
50 getClient<C extends Client>(): C | undefined;
51 /**
52 * Returns the scope of the top stack.
53 * @deprecated Use `Sentry.getCurrentScope()` instead.
54 */
55 getScope(): Scope;
56 /**
57 * Get the currently active isolation scope.
58 * The isolation scope is used to isolate data between different hubs.
59 *
60 * @deprecated Use `Sentry.getIsolationScope()` instead.
61 */
62 getIsolationScope(): Scope;
63 /**
64 * Captures an exception event and sends it to Sentry.
65 *
66 * @param exception An exception-like object.
67 * @param hint May contain additional information about the original exception.
68 * @returns The generated eventId.
69 *
70 * @deprecated Use `Sentry.captureException()` instead.
71 */
72 captureException(exception: any, hint?: EventHint): string;
73 /**
74 * Captures a message event and sends it to Sentry.
75 *
76 * @param message The message to send to Sentry.
77 * @param level Define the level of the message.
78 * @param hint May contain additional information about the original exception.
79 * @returns The generated eventId.
80 *
81 * @deprecated Use `Sentry.captureMessage()` instead.
82 */
83 captureMessage(message: string, level?: SeverityLevel, hint?: EventHint): string;
84 /**
85 * Captures a manually created event and sends it to Sentry.
86 *
87 * @param event The event to send to Sentry.
88 * @param hint May contain additional information about the original exception.
89 *
90 * @deprecated Use `Sentry.captureEvent()` instead.
91 */
92 captureEvent(event: Event, hint?: EventHint): string;
93 /**
94 * Records a new breadcrumb which will be attached to future events.
95 *
96 * Breadcrumbs will be added to subsequent events to provide more context on
97 * user's actions prior to an error or crash.
98 *
99 * @param breadcrumb The breadcrumb to record.
100 * @param hint May contain additional information about the original breadcrumb.
101 *
102 * @deprecated Use `Sentry.addBreadcrumb()` instead.
103 */
104 addBreadcrumb(breadcrumb: Breadcrumb, hint?: BreadcrumbHint): void;
105 /**
106 * Updates user context information for future events.
107 *
108 * @param user User context object to be set in the current context. Pass `null` to unset the user.
109 *
110 * @deprecated Use `Sentry.setUser()` instead.
111 */
112 setUser(user: User | null): void;
113 /**
114 * Set an object that will be merged sent as tags data with the event.
115 *
116 * @param tags Tags context object to merge into current context.
117 *
118 * @deprecated Use `Sentry.setTags()` instead.
119 */
120 setTags(tags: {
121 [key: string]: Primitive;
122 }): void;
123 /**
124 * Set key:value that will be sent as tags data with the event.
125 *
126 * Can also be used to unset a tag, by passing `undefined`.
127 *
128 * @param key String key of tag
129 * @param value Value of tag
130 *
131 * @deprecated Use `Sentry.setTag()` instead.
132 */
133 setTag(key: string, value: Primitive): void;
134 /**
135 * Set key:value that will be sent as extra data with the event.
136 * @param key String of extra
137 * @param extra Any kind of data. This data will be normalized.
138 *
139 * @deprecated Use `Sentry.setExtra()` instead.
140 */
141 setExtra(key: string, extra: Extra): void;
142 /**
143 * Set an object that will be merged sent as extra data with the event.
144 * @param extras Extras object to merge into current context.
145 *
146 * @deprecated Use `Sentry.setExtras()` instead.
147 */
148 setExtras(extras: Extras): void;
149 /**
150 * Sets context data with the given name.
151 * @param name of the context
152 * @param context Any kind of data. This data will be normalized.
153 *
154 * @deprecated Use `Sentry.setContext()` instead.
155 */
156 setContext(name: string, context: {
157 [key: string]: any;
158 } | null): void;
159 /**
160 * Returns the integration if installed on the current client.
161 *
162 * @deprecated Use `Sentry.getClient().getIntegration()` instead.
163 */
164 getIntegration<T extends Integration>(integration: IntegrationClass<T>): T | null;
165 /**
166 * Starts a new `Session`, sets on the current scope and returns it.
167 *
168 * To finish a `session`, it has to be passed directly to `client.captureSession`, which is done automatically
169 * when using `hub.endSession()` for the session currently stored on the scope.
170 *
171 * When there's already an existing session on the scope, it'll be automatically ended.
172 *
173 * @param context Optional properties of the new `Session`.
174 *
175 * @returns The session which was just started
176 *
177 * @deprecated Use top-level `startSession` instead.
178 */
179 startSession(context?: Session): Session;
180 /**
181 * Ends the session that lives on the current scope and sends it to Sentry
182 *
183 * @deprecated Use top-level `endSession` instead.
184 */
185 endSession(): void;
186 /**
187 * Sends the current session on the scope to Sentry
188 *
189 * @param endSession If set the session will be marked as exited and removed from the scope
190 *
191 * @deprecated Use top-level `captureSession` instead.
192 */
193 captureSession(endSession?: boolean): void;
194}
195//# sourceMappingURL=hub.d.ts.map
\No newline at end of file