Skip to content

Commit bb69207

Browse files
committed
move Carrier interface to @sentry/types
1 parent 0e446d6 commit bb69207

File tree

6 files changed

+37
-30
lines changed

6 files changed

+37
-30
lines changed

packages/hub/src/hub.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import {
33
Breadcrumb,
44
BreadcrumbHint,
5+
Carrier,
56
Client,
67
CustomSamplingContext,
78
Event,
@@ -23,7 +24,7 @@ import {
2324
} from '@sentry/types';
2425
import { consoleSandbox, dateTimestampInSeconds, getGlobalObject, isNodeEnv, logger, uuid4 } from '@sentry/utils';
2526

26-
import { Carrier, DomainAsCarrier, Layer } from './interfaces';
27+
import { DomainAsCarrier, Layer } from './interfaces';
2728
import { Scope } from './scope';
2829
import { Session } from './session';
2930

@@ -552,10 +553,10 @@ function hasHubOnCarrier(carrier: Carrier): boolean {
552553
* @hidden
553554
*/
554555
export function getHubFromCarrier(carrier: Carrier): Hub {
555-
if (carrier && carrier.__SENTRY__ && carrier.__SENTRY__.hub) return carrier.__SENTRY__.hub;
556+
if (carrier && carrier.__SENTRY__ && carrier.__SENTRY__.hub) return carrier.__SENTRY__.hub as Hub;
556557
carrier.__SENTRY__ = carrier.__SENTRY__ || {};
557558
carrier.__SENTRY__.hub = new Hub();
558-
return carrier.__SENTRY__.hub;
559+
return carrier.__SENTRY__.hub as Hub;
559560
}
560561

561562
/**

packages/hub/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// eslint-disable-next-line deprecation/deprecation
2-
export { Carrier, DomainAsCarrier, Layer } from './interfaces';
2+
export { DomainAsCarrier, Layer } from './interfaces';
33
export { addGlobalEventProcessor, Scope } from './scope';
44
export { Session } from './session';
55
export {
@@ -12,3 +12,6 @@ export {
1212
makeMain,
1313
setHubOnCarrier,
1414
} from './hub';
15+
16+
// For backwards compatibillity
17+
export { Carrier } from '@sentry/types';

packages/hub/src/interfaces.ts

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { Client } from '@sentry/types';
1+
import { Carrier, Client } from '@sentry/types';
22

3-
import { Hub } from './hub';
43
import { Scope } from './scope';
54

65
/**
@@ -12,28 +11,6 @@ export interface Layer {
1211
scope?: Scope;
1312
}
1413

15-
/**
16-
* An object that contains a hub and maintains a scope stack.
17-
* @hidden
18-
*/
19-
export interface Carrier {
20-
__SENTRY__?: {
21-
hub?: Hub;
22-
/**
23-
* Extra Hub properties injected by various SDKs
24-
*/
25-
extensions?: {
26-
/** Hack to prevent bundlers from breaking our usage of the domain package in the cross-platform Hub package */
27-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
28-
domain?: { [key: string]: any };
29-
} & {
30-
/** Extension methods for the hub, which are bound to the current Hub instance */
31-
// eslint-disable-next-line @typescript-eslint/ban-types
32-
[key: string]: Function;
33-
};
34-
};
35-
}
36-
3714
/**
3815
* @hidden
3916
* @deprecated Can be removed once `Hub.getActiveDomain` is removed.

packages/types/src/hub.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,29 @@ export interface Hub {
226226
*/
227227
captureSession(endSession: boolean): void;
228228
}
229+
230+
/**
231+
* An object that contains a hub and maintains a scope stack.
232+
* @hidden
233+
*/
234+
export interface Carrier {
235+
__SENTRY__?: {
236+
hub?: Hub;
237+
/**
238+
* Extra Hub properties injected by various SDKs
239+
*/
240+
extensions?: {
241+
/** Hack to prevent bundlers from breaking our usage of the domain package in the cross-platform Hub package */
242+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
243+
domain?: { [key: string]: any };
244+
245+
/** Hack to prevent bundlers from breaking our usage of the these functions in the cross-platform Utils package */
246+
unsafeToBase64?: (plaintext: string) => string;
247+
unsafeFromBase64?: (base64String: string) => string;
248+
} & {
249+
/** Extension methods for the hub, which are bound to the current Hub instance */
250+
// eslint-disable-next-line @typescript-eslint/ban-types
251+
[key: string]: Function;
252+
};
253+
};
254+
}

packages/types/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export { Event, EventHint } from './event';
88
export { EventProcessor } from './eventprocessor';
99
export { Exception } from './exception';
1010
export { Extra, Extras } from './extra';
11-
export { Hub } from './hub';
11+
export { Carrier, Hub } from './hub';
1212
export { Integration, IntegrationClass } from './integration';
1313
export { LogLevel } from './loglevel';
1414
export { Mechanism } from './mechanism';

packages/utils/src/compat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Integration } from '@sentry/types';
1+
import { Carrier, Integration } from '@sentry/types';
22

33
/**
44
* Checks whether we're in the Node.js or Browser environment

0 commit comments

Comments
 (0)