Skip to content

Commit eadf9c0

Browse files
authored
feat(browser): Export browserProfilingIntegration (#10438)
And deprecate `new BrowserProfilingIntegration()`
1 parent 793ad71 commit eadf9c0

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

packages/browser/src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,8 @@ export type { SpanStatusType } from '@sentry/core';
8383
export type { Span } from '@sentry/types';
8484
export { makeBrowserOfflineTransport } from './transports/offline';
8585
export { onProfilingStartRouteTransaction } from './profiling/hubextensions';
86-
export { BrowserProfilingIntegration } from './profiling/integration';
86+
export {
87+
// eslint-disable-next-line deprecation/deprecation
88+
BrowserProfilingIntegration,
89+
browserProfilingIntegration,
90+
} from './profiling/integration';

packages/browser/src/profiling/integration.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { convertIntegrationFnToClass, getCurrentScope } from '@sentry/core';
1+
import { convertIntegrationFnToClass, defineIntegration, getCurrentScope } from '@sentry/core';
22
import type { Client, EventEnvelope, Integration, IntegrationClass, IntegrationFn, Transaction } from '@sentry/types';
33
import type { Profile } from '@sentry/types/src/profiling';
44
import { logger } from '@sentry/utils';
@@ -18,7 +18,7 @@ import {
1818

1919
const INTEGRATION_NAME = 'BrowserProfiling';
2020

21-
const browserProfilingIntegration = (() => {
21+
const _browserProfilingIntegration = (() => {
2222
return {
2323
name: INTEGRATION_NAME,
2424
// TODO v8: Remove this
@@ -102,6 +102,8 @@ const browserProfilingIntegration = (() => {
102102
};
103103
}) satisfies IntegrationFn;
104104

105+
export const browserProfilingIntegration = defineIntegration(_browserProfilingIntegration);
106+
105107
/**
106108
* Browser profiling integration. Stores any event that has contexts["profile"]["profile_id"]
107109
* This exists because we do not want to await async profiler.stop calls as transaction.finish is called
@@ -110,9 +112,13 @@ const browserProfilingIntegration = (() => {
110112
* integration less reliable as we might be dropping profiles when the cache is full.
111113
*
112114
* @experimental
115+
* @deprecated Use `browserProfilingIntegration()` instead.
113116
*/
114117
// eslint-disable-next-line deprecation/deprecation
115118
export const BrowserProfilingIntegration = convertIntegrationFnToClass(
116119
INTEGRATION_NAME,
117120
browserProfilingIntegration,
118121
) as IntegrationClass<Integration & { setup: (client: Client) => void }>;
122+
123+
// eslint-disable-next-line deprecation/deprecation
124+
export type BrowserProfilingIntegration = typeof BrowserProfilingIntegration;

packages/browser/test/unit/profiling/integration.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { BrowserClient } from '@sentry/browser';
22
import * as Sentry from '@sentry/browser';
33

4-
import { BrowserProfilingIntegration } from '../../../src/profiling/integration';
54
import type { JSSelfProfile } from '../../../src/profiling/jsSelfProfiling';
65

76
describe('BrowserProfilingIntegration', () => {
@@ -44,7 +43,7 @@ describe('BrowserProfilingIntegration', () => {
4443
send,
4544
};
4645
},
47-
integrations: [new Sentry.BrowserTracing(), new BrowserProfilingIntegration()],
46+
integrations: [Sentry.browserTracingIntegration(), Sentry.browserProfilingIntegration()],
4847
});
4948

5049
const client = Sentry.getClient<BrowserClient>();

0 commit comments

Comments
 (0)