1 | /**
|
2 | * NOTE: In order to avoid circular dependencies, if you add a function to this module and it needs to print something,
|
3 | * you must either a) use `console.log` rather than the logger, or b) put your function elsewhere.
|
4 | *
|
5 | * Note: This file was originally called `global.ts`, but was changed to unblock users which might be doing
|
6 | * string replaces with bundlers like Vite for `global` (would break imports that rely on importing from utils/src/global).
|
7 | *
|
8 | * Why worldwide?
|
9 | *
|
10 | * Why not?
|
11 | */
|
12 | import type { Client, MetricsAggregator, Scope } from '@sentry/types';
|
13 | import type { SdkSource } from './env';
|
14 | interface SentryCarrier {
|
15 | acs?: any;
|
16 | stack?: any;
|
17 | globalScope?: Scope;
|
18 | defaultIsolationScope?: Scope;
|
19 | defaultCurrentScope?: Scope;
|
20 | globalMetricsAggregators?: WeakMap<Client, MetricsAggregator> | undefined;
|
21 | /** Overwrites TextEncoder used in `@sentry/utils`, need for `react-native@0.73` and older */
|
22 | encodePolyfill?: (input: string) => Uint8Array;
|
23 | /** Overwrites TextDecoder used in `@sentry/utils`, need for `react-native@0.73` and older */
|
24 | decodePolyfill?: (input: Uint8Array) => string;
|
25 | }
|
26 | type BackwardsCompatibleSentryCarrier = SentryCarrier & {
|
27 | hub: any;
|
28 | integrations?: any[];
|
29 | logger: any;
|
30 | extensions?: {
|
31 | /** Extension methods for the hub, which are bound to the current Hub instance */
|
32 | [key: string]: Function;
|
33 | };
|
34 | };
|
35 | /** Internal global with common properties and Sentry extensions */
|
36 | export type InternalGlobal = {
|
37 | navigator?: {
|
38 | userAgent?: string;
|
39 | };
|
40 | console: Console;
|
41 | Sentry?: any;
|
42 | onerror?: {
|
43 | (event: object | string, source?: string, lineno?: number, colno?: number, error?: Error): any;
|
44 | __SENTRY_INSTRUMENTED__?: true;
|
45 | __SENTRY_LOADER__?: true;
|
46 | };
|
47 | onunhandledrejection?: {
|
48 | (event: unknown): boolean;
|
49 | __SENTRY_INSTRUMENTED__?: true;
|
50 | __SENTRY_LOADER__?: true;
|
51 | };
|
52 | SENTRY_ENVIRONMENT?: string;
|
53 | SENTRY_DSN?: string;
|
54 | SENTRY_RELEASE?: {
|
55 | id?: string;
|
56 | };
|
57 | SENTRY_SDK_SOURCE?: SdkSource;
|
58 | /**
|
59 | * Debug IDs are indirectly injected by Sentry CLI or bundler plugins to directly reference a particular source map
|
60 | * for resolving of a source file. The injected code will place an entry into the record for each loaded bundle/JS
|
61 | * file.
|
62 | */
|
63 | _sentryDebugIds?: Record<string, string>;
|
64 | __SENTRY__: Record<Exclude<string, 'version'>, SentryCarrier> & {
|
65 | version?: string;
|
66 | } & BackwardsCompatibleSentryCarrier;
|
67 | /**
|
68 | * Raw module metadata that is injected by bundler plugins.
|
69 | *
|
70 | * Keys are `error.stack` strings, values are the metadata.
|
71 | */
|
72 | _sentryModuleMetadata?: Record<string, any>;
|
73 | _sentryEsmLoaderHookRegistered?: boolean;
|
74 | };
|
75 | /** Get's the global object for the current JavaScript runtime */
|
76 | export declare const GLOBAL_OBJ: InternalGlobal;
|
77 | /**
|
78 | * Returns a global singleton contained in the global `__SENTRY__[]` object.
|
79 | *
|
80 | * If the singleton doesn't already exist in `__SENTRY__`, it will be created using the given factory
|
81 | * function and added to the `__SENTRY__` object.
|
82 | *
|
83 | * @param name name of the global singleton on __SENTRY__
|
84 | * @param creator creator Factory function to create the singleton if it doesn't already exist on `__SENTRY__`
|
85 | * @param obj (Optional) The global object on which to look for `__SENTRY__`, if not `GLOBAL_OBJ`'s return value
|
86 | * @returns the singleton
|
87 | */
|
88 | export declare function getGlobalSingleton<T>(name: keyof SentryCarrier, creator: () => T, obj?: unknown): T;
|
89 | export {};
|
90 | //# sourceMappingURL=worldwide.d.ts.map |
\ | No newline at end of file |