Skip to content

Commit ac278e7

Browse files
authored
feat(core): Deprecate methods on Hub (#10124)
Except for `bindClient()` which needs a separate replacement. For everything else we already have a replacement in place! Then in a follow up we can deprecate `getCurrentHub()` itself.
1 parent 281d77c commit ac278e7

File tree

88 files changed

+500
-331
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+500
-331
lines changed

dev-packages/browser-integration-tests/loader-suites/loader/noOnLoad/sdkLoadedInMeanwhile/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ sentryTest('it does not download the SDK if the SDK was loaded in the meanwhile'
5454
expect(sentryEventCount).toBe(1);
5555

5656
// Ensure loader does not overwrite init/config
57-
const options = await page.evaluate(() => (window as any).Sentry.getCurrentHub().getClient()?.getOptions());
57+
const options = await page.evaluate(() => (window as any).Sentry.getClient()?.getOptions());
5858
expect(options?.replaysSessionSampleRate).toBe(0.42);
5959

6060
expect(eventData.exception?.values?.length).toBe(1);

dev-packages/browser-integration-tests/loader-suites/loader/onLoad/customBrowserTracing/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ sentryTest('should handle custom added BrowserTracing integration', async ({ get
2727
expect(eventData.transaction_info?.source).toEqual('url');
2828

2929
const tracePropagationTargets = await page.evaluate(() => {
30-
const browserTracing = (window as any).Sentry.getCurrentHub().getClient().getIntegrationById('BrowserTracing');
30+
const browserTracing = (window as any).Sentry.getClient().getIntegrationById('BrowserTracing');
3131
return browserTracing.options.tracePropagationTargets;
3232
});
3333

dev-packages/browser-integration-tests/loader-suites/loader/onLoad/customInit/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ sentryTest('always calls onLoad init correctly', async ({ getLocalTestUrl, page
3030

3131
expect(await page.evaluate('window.__hadSentry')).toEqual(false);
3232
expect(await page.evaluate('window.__sentryOnLoad')).toEqual(1);
33-
expect(await page.evaluate('Sentry.getCurrentHub().getClient().getOptions().sampleRate')).toEqual(0.5);
33+
expect(await page.evaluate('Sentry.getClient().getOptions().sampleRate')).toEqual(0.5);
3434
});

dev-packages/browser-integration-tests/loader-suites/loader/onLoad/customIntegrations/test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ sentryTest('should handle custom added integrations & default integrations', asy
2424
});
2525

2626
const hasCustomIntegration = await page.evaluate(() => {
27-
return !!(window as any).Sentry.getCurrentHub().getClient().getIntegrationById('CustomIntegration');
27+
return !!(window as any).Sentry.getClient().getIntegrationById('CustomIntegration');
2828
});
2929

3030
const hasReplay = await page.evaluate(() => {
31-
return !!(window as any).Sentry.getCurrentHub().getClient().getIntegrationById('Replay');
31+
return !!(window as any).Sentry.getClient().getIntegrationById('Replay');
3232
});
3333
const hasBrowserTracing = await page.evaluate(() => {
34-
return !!(window as any).Sentry.getCurrentHub().getClient().getIntegrationById('BrowserTracing');
34+
return !!(window as any).Sentry.getClient().getIntegrationById('BrowserTracing');
3535
});
3636

3737
expect(hasCustomIntegration).toEqual(true);

dev-packages/browser-integration-tests/loader-suites/loader/onLoad/customIntegrationsFunction/test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ sentryTest(
2121
});
2222

2323
const hasCustomIntegration = await page.evaluate(() => {
24-
return !!(window as any).Sentry.getCurrentHub().getClient().getIntegrationById('CustomIntegration');
24+
return !!(window as any).Sentry.getClient().getIntegrationById('CustomIntegration');
2525
});
2626

2727
const hasReplay = await page.evaluate(() => {
28-
return !!(window as any).Sentry.getCurrentHub().getClient().getIntegrationById('Replay');
28+
return !!(window as any).Sentry.getClient().getIntegrationById('Replay');
2929
});
3030
const hasBrowserTracing = await page.evaluate(() => {
31-
return !!(window as any).Sentry.getCurrentHub().getClient().getIntegrationById('BrowserTracing');
31+
return !!(window as any).Sentry.getClient().getIntegrationById('BrowserTracing');
3232
});
3333

3434
expect(hasCustomIntegration).toEqual(true);

dev-packages/browser-integration-tests/loader-suites/loader/onLoad/customReplay/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ sentryTest('should handle custom added Replay integration', async ({ getLocalTes
2727
expect(eventData.segment_id).toBe(0);
2828

2929
const useCompression = await page.evaluate(() => {
30-
const replay = (window as any).Sentry.getCurrentHub().getClient().getIntegrationById('Replay');
30+
const replay = (window as any).Sentry.getClient().getIntegrationById('Replay');
3131
return replay._replay.getOptions().useCompression;
3232
});
3333

dev-packages/browser-integration-tests/loader-suites/loader/onLoad/sentryOnLoad/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ sentryTest('sentryOnLoad callback is called before Sentry.onLoad()', async ({ ge
1111

1212
expect(eventData.message).toBe('Test exception');
1313

14-
expect(await page.evaluate('Sentry.getCurrentHub().getClient().getOptions().tracesSampleRate')).toEqual(0.123);
14+
expect(await page.evaluate('Sentry.getClient().getOptions().tracesSampleRate')).toEqual(0.123);
1515
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Sentry.onLoad(function () {
22
// this should be called _after_ window.sentryOnLoad
3-
Sentry.captureException(`Test exception: ${Sentry.getCurrentHub().getClient().getOptions().tracesSampleRate}`);
3+
Sentry.captureException(`Test exception: ${Sentry.getClient().getOptions().tracesSampleRate}`);
44
});

dev-packages/browser-integration-tests/loader-suites/loader/onLoad/sentryOnLoadAndOnLoad/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ sentryTest('sentryOnLoad callback is used', async ({ getLocalTestUrl, page }) =>
1111

1212
expect(eventData.message).toBe('Test exception: 0.123');
1313

14-
expect(await page.evaluate('Sentry.getCurrentHub().getClient().getOptions().tracesSampleRate')).toEqual(0.123);
14+
expect(await page.evaluate('Sentry.getClient().getOptions().tracesSampleRate')).toEqual(0.123);
1515
});

dev-packages/e2e-tests/test-applications/create-next-app/pages/api/success.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
66
// eslint-disable-next-line deprecation/deprecation
77
const transaction = Sentry.startTransaction({ name: 'test-transaction', op: 'e2e-test' });
88
// eslint-disable-next-line deprecation/deprecation
9-
Sentry.getCurrentHub().getScope().setSpan(transaction);
9+
Sentry.getCurrentScope().setSpan(transaction);
1010

1111
// eslint-disable-next-line deprecation/deprecation
1212
const span = transaction.startChild();

0 commit comments

Comments
 (0)