Skip to content

Commit 376d33f

Browse files
committed
feat(v7/types): Deprecate Hub interface
1 parent 8639fa6 commit 376d33f

File tree

13 files changed

+38
-5
lines changed

13 files changed

+38
-5
lines changed

packages/core/src/hub.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export interface Carrier {
115115
* themselves and will also be removed in version 8. More information:
116116
* - [Migration Guide](https://github.com/getsentry/sentry-javascript/blob/develop/MIGRATION.md#deprecate-hub)
117117
*/
118+
// eslint-disable-next-line deprecation/deprecation
118119
export class Hub implements HubInterface {
119120
/** Is a {@link Layer}[] containing the client and scope */
120121
private readonly _stack: Layer[];

packages/core/src/utils/isSentryRequestUrl.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { Client, DsnComponents, Hub } from '@sentry/types';
66
*
77
* TODO(v8): Remove Hub fallback type
88
*/
9+
// eslint-disable-next-line deprecation/deprecation
910
export function isSentryRequestUrl(url: string, hubOrClient: Hub | Client | undefined): boolean {
1011
const client =
1112
hubOrClient && isHub(hubOrClient)
@@ -34,6 +35,7 @@ function removeTrailingSlash(str: string): string {
3435
return str[str.length - 1] === '/' ? str.slice(0, -1) : str;
3536
}
3637

38+
// eslint-disable-next-line deprecation/deprecation
3739
function isHub(hubOrClient: Hub | Client | undefined): hubOrClient is Hub {
3840
// eslint-disable-next-line deprecation/deprecation
3941
return (hubOrClient as Hub).getClient !== undefined;

packages/core/test/lib/utils/isSentryRequestUrl.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ describe('isSentryRequestUrl', () => {
2121
getClient: () => {
2222
return client;
2323
},
24+
// eslint-disable-next-line deprecation/deprecation
2425
} as unknown as Hub;
2526

2627
// Works with hub passed

packages/integrations/test/reportingobserver.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const withScope = jest.fn(callback => {
1414

1515
const captureMessage = jest.fn();
1616

17+
// eslint-disable-next-line deprecation/deprecation
1718
const mockHub = {} as unknown as Hub;
1819

1920
const mockReportingObserverConstructor = jest.fn();

packages/profiling-node/src/hubextensions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { isValidSampleRate } from './utils';
1010
export const MAX_PROFILE_DURATION_MS = 30 * 1000;
1111

1212
type StartTransaction = (
13+
// eslint-disable-next-line deprecation/deprecation
1314
this: Hub,
1415
transactionContext: TransactionContext,
1516
customSamplingContext?: CustomSamplingContext,
@@ -142,6 +143,7 @@ export function stopTransactionProfile(
142143
*/
143144
export function __PRIVATE__wrapStartTransactionWithProfiling(startTransaction: StartTransaction): StartTransaction {
144145
return function wrappedStartTransaction(
146+
// eslint-disable-next-line deprecation/deprecation
145147
this: Hub,
146148
transactionContext: TransactionContext,
147149
customSamplingContext?: CustomSamplingContext,

packages/profiling-node/src/integration.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export class ProfilingIntegration implements Integration {
5555
* @inheritDoc
5656
*/
5757
public readonly name: string;
58+
// eslint-disable-next-line deprecation/deprecation
5859
public getCurrentHub?: () => Hub;
5960

6061
public constructor() {
@@ -64,6 +65,7 @@ export class ProfilingIntegration implements Integration {
6465
/**
6566
* @inheritDoc
6667
*/
68+
// eslint-disable-next-line deprecation/deprecation
6769
public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void {
6870
this.getCurrentHub = getCurrentHub;
6971
// eslint-disable-next-line deprecation/deprecation

packages/profiling-node/test/hubextensions.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ function makeHubMock({
4747
}: {
4848
profilesSampleRate: number | undefined;
4949
client?: Partial<NodeClient>;
50+
// eslint-disable-next-line deprecation/deprecation
5051
}): Hub {
5152
return {
5253
getClient: jest.fn().mockImplementation(() => {
@@ -59,6 +60,7 @@ function makeHubMock({
5960
...(client ?? {}),
6061
};
6162
}),
63+
// eslint-disable-next-line deprecation/deprecation
6264
} as unknown as Hub;
6365
}
6466

packages/profiling-node/test/integration.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ describe('ProfilingIntegration', () => {
7171
// eslint-disable-next-line deprecation/deprecation
7272
const integration = new ProfilingIntegration();
7373

74+
// eslint-disable-next-line deprecation/deprecation
7475
const getCurrentHub = jest.fn((): Hub => {
7576
return {
7677
getClient: () => {
@@ -86,6 +87,7 @@ describe('ProfilingIntegration', () => {
8687
getTransport: () => transport,
8788
};
8889
},
90+
// eslint-disable-next-line deprecation/deprecation
8991
} as Hub;
9092
});
9193
const addGlobalEventProcessor = () => void 0;
@@ -106,7 +108,9 @@ describe('ProfilingIntegration', () => {
106108
// eslint-disable-next-line deprecation/deprecation
107109
const integration = new ProfilingIntegration();
108110

111+
// eslint-disable-next-line deprecation/deprecation
109112
const getCurrentHub = jest.fn((): Hub => {
113+
// eslint-disable-next-line deprecation/deprecation
110114
return { getClient: () => undefined } as Hub;
111115
});
112116
const addGlobalEventProcessor = () => void 0;
@@ -122,13 +126,15 @@ describe('ProfilingIntegration', () => {
122126
// eslint-disable-next-line deprecation/deprecation
123127
const integration = new ProfilingIntegration();
124128

129+
// eslint-disable-next-line deprecation/deprecation
125130
const getCurrentHub = jest.fn((): Hub => {
126131
return {
127132
getClient: () => {
128133
return {
129134
getDsn: () => undefined,
130135
};
131136
},
137+
// eslint-disable-next-line deprecation/deprecation
132138
} as Hub;
133139
});
134140
const addGlobalEventProcessor = () => void 0;
@@ -144,6 +150,7 @@ describe('ProfilingIntegration', () => {
144150
// eslint-disable-next-line deprecation/deprecation
145151
const integration = new ProfilingIntegration();
146152

153+
// eslint-disable-next-line deprecation/deprecation
147154
const getCurrentHub = jest.fn((): Hub => {
148155
return {
149156
getClient: () => {
@@ -154,6 +161,7 @@ describe('ProfilingIntegration', () => {
154161
getTransport: () => undefined,
155162
};
156163
},
164+
// eslint-disable-next-line deprecation/deprecation
157165
} as Hub;
158166
});
159167
const addGlobalEventProcessor = () => void 0;
@@ -174,6 +182,7 @@ describe('ProfilingIntegration', () => {
174182
// eslint-disable-next-line deprecation/deprecation
175183
const integration = new ProfilingIntegration();
176184

185+
// eslint-disable-next-line deprecation/deprecation
177186
const getCurrentHub = jest.fn((): Hub => {
178187
return {
179188
getClient: () => {
@@ -189,6 +198,7 @@ describe('ProfilingIntegration', () => {
189198
getTransport: () => transport,
190199
};
191200
},
201+
// eslint-disable-next-line deprecation/deprecation
192202
} as Hub;
193203
});
194204
const addGlobalEventProcessor = () => void 0;
@@ -209,6 +219,7 @@ describe('ProfilingIntegration', () => {
209219
const integration = new ProfilingIntegration();
210220
const emitter = new EventEmitter();
211221

222+
// eslint-disable-next-line deprecation/deprecation
212223
const getCurrentHub = jest.fn((): Hub => {
213224
return {
214225
getClient: () => {
@@ -226,6 +237,7 @@ describe('ProfilingIntegration', () => {
226237
getTransport: () => transport,
227238
} as any;
228239
},
240+
// eslint-disable-next-line deprecation/deprecation
229241
} as Hub;
230242
});
231243

@@ -245,6 +257,7 @@ describe('ProfilingIntegration', () => {
245257
const integration = new ProfilingIntegration();
246258
const emitter = new EventEmitter();
247259

260+
// eslint-disable-next-line deprecation/deprecation
248261
const getCurrentHub = jest.fn((): Hub => {
249262
return {
250263
getClient: () => {
@@ -262,6 +275,7 @@ describe('ProfilingIntegration', () => {
262275
getTransport: () => transport,
263276
} as any;
264277
},
278+
// eslint-disable-next-line deprecation/deprecation
265279
} as Hub;
266280
});
267281

packages/types/src/hub.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ import type { User } from './user';
1313
/**
1414
* Internal class used to make sure we always have the latest internal functions
1515
* working in case we have a version conflict.
16+
*
17+
* @deprecated The `Hub` interface will be removed in a future major version of the SDK in favour of
18+
* `Scope` and `Client` objects and APIs.
19+
*
20+
* Most APIs referencing `Hub` are themselves and will be removed in version 8 of the SDK. More information:
21+
* - [Migration Guide](https://github.com/getsentry/sentry-javascript/blob/develop/MIGRATION.md#deprecate-hub)
1622
*/
1723
export interface Hub {
1824
/**
@@ -226,6 +232,7 @@ export interface Hub {
226232
*
227233
* TODO v8: This will be merged with `withScope()`
228234
*/
235+
// eslint-disable-next-line deprecation/deprecation
229236
run(callback: (hub: Hub) => void): void;
230237

231238
/**

packages/types/src/index.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export type { Event, EventHint, EventType, ErrorEvent, TransactionEvent, Seriali
5353
export type { EventProcessor } from './eventprocessor';
5454
export type { Exception } from './exception';
5555
export type { Extra, Extras } from './extra';
56+
// eslint-disable-next-line deprecation/deprecation
5657
export type { Hub } from './hub';
5758
export type { Integration, IntegrationClass, IntegrationFn, IntegrationFnResult } from './integration';
5859
export type { Mechanism } from './mechanism';
@@ -153,9 +154,5 @@ export type {
153154

154155
export type { BrowserClientReplayOptions, BrowserClientProfilingOptions } from './browseroptions';
155156
export type { CheckIn, MonitorConfig, FinishedCheckIn, InProgressCheckIn, SerializedCheckIn } from './checkin';
156-
export type {
157-
MetricsAggregator,
158-
MetricBucketItem,
159-
MetricInstance,
160-
} from './metrics';
157+
export type { MetricsAggregator, MetricBucketItem, MetricInstance } from './metrics';
161158
export type { ParameterizedString } from './parameterize';

packages/types/src/integration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export interface Integration {
7777
*
7878
* NOTE: In v8, this will become optional, and not receive any arguments anymore.
7979
*/
80+
// eslint-disable-next-line deprecation/deprecation
8081
setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void;
8182

8283
/**

packages/utils/src/eventbuilder.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ function getMessageForObject(exception: object): string {
6969
* @hidden
7070
*/
7171
export function eventFromUnknownInput(
72+
// eslint-disable-next-line deprecation/deprecation
7273
getHubOrClient: (() => Hub) | Client | undefined,
7374
stackParser: StackParser,
7475
exception: unknown,

packages/utils/test/eventbuilder.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Hub, Scope } from '@sentry/types';
22

33
import { createStackParser, eventFromUnknownInput, nodeStackLineParser } from '../src';
44

5+
// eslint-disable-next-line deprecation/deprecation
56
function getCurrentHub(): Hub {
67
// Some fake hub to get us through
78
return {
@@ -11,6 +12,7 @@ function getCurrentHub(): Hub {
1112
setExtra: () => {},
1213
} as unknown as Scope;
1314
},
15+
// eslint-disable-next-line deprecation/deprecation
1416
} as unknown as Hub;
1517
}
1618

0 commit comments

Comments
 (0)