Skip to content

Commit 799dab0

Browse files
authored
feat(v8/browser): Remove deprecated wrap export (#11127)
In #8927 we deprecated and removed the `wrap` method. This PR removes the deprecated export from v8.
1 parent 7eed1ef commit 799dab0

File tree

4 files changed

+7
-85
lines changed

4 files changed

+7
-85
lines changed

MIGRATION.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,11 +570,12 @@ interface Transport {
570570

571571
### Browser SDK (Browser, React, Vue, Angular, Ember, etc.)
572572

573-
Removed top-level exports: `Offline`, `makeXHRTransport`, `BrowserTracing`
573+
Removed top-level exports: `Offline`, `makeXHRTransport`, `BrowserTracing`, `wrap`
574574

575575
- [Removal of the `BrowserTracing` integration](./MIGRATION.md#removal-of-the-browsertracing-integration)
576576
- [Removal of Offline integration](./MIGRATION.md#removal-of-the-offline-integration)
577577
- [Removal of `makeXHRTransport` transport](./MIGRATION.md#removal-of-makexhrtransport-transport)
578+
- [Removal of `wrap` method](./MIGRATION.md#removal-of-wrap-method)
578579

579580
#### Removal of the `BrowserTracing` integration
580581

@@ -592,6 +593,10 @@ The `Offline` integration has been removed in favor of the
592593
The `makeXHRTransport` transport has been removed. Only `makeFetchTransport` is available now. This means that the
593594
Sentry SDK requires the fetch API to be available in the environment.
594595

596+
#### Removal of `wrap` method
597+
598+
The `wrap` method has been removed. There is no replacement API.
599+
595600
### Server-side SDKs (Node, Deno, Bun, etc.)
596601

597602
Removed top-level exports: `enableAnrDetection`, `Anr`, `deepReadDirSync`

packages/browser/src/exports.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ export {
9393
onLoad,
9494
showReportDialog,
9595
captureUserFeedback,
96-
// eslint-disable-next-line deprecation/deprecation
97-
wrap,
9896
} from './sdk';
9997

10098
export { breadcrumbsIntegration } from './integrations/breadcrumbs';

packages/browser/src/sdk.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { dedupeIntegration } from '@sentry/core';
2121
import type { BrowserClientOptions, BrowserOptions } from './client';
2222
import { BrowserClient } from './client';
2323
import { DEBUG_BUILD } from './debug-build';
24-
import { WINDOW, wrap as internalWrap } from './helpers';
24+
import { WINDOW } from './helpers';
2525
import { breadcrumbsIntegration } from './integrations/breadcrumbs';
2626
import { browserApiErrorsIntegration } from './integrations/browserapierrors';
2727
import { globalHandlersIntegration } from './integrations/globalhandlers';
@@ -268,23 +268,6 @@ export function onLoad(callback: () => void): void {
268268
callback();
269269
}
270270

271-
/**
272-
* Wrap code within a try/catch block so the SDK is able to capture errors.
273-
*
274-
* @deprecated This function will be removed in v8.
275-
* It is not part of Sentry's official API and it's easily replaceable by using a try/catch block
276-
* and calling Sentry.captureException.
277-
*
278-
* @param fn A function to wrap.
279-
*
280-
* @returns The result of wrapped function call.
281-
*/
282-
// TODO(v8): Remove this function
283-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
284-
export function wrap(fn: (...args: any) => any): any {
285-
return internalWrap(fn)();
286-
}
287-
288271
/**
289272
* Enable automatic Session Tracking for the initial page load.
290273
*/

packages/browser/test/unit/index.test.ts

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
getReportDialogEndpoint,
66
inboundFiltersIntegration,
77
} from '@sentry/core';
8-
import type { WrappedFunction } from '@sentry/types';
98
import * as utils from '@sentry/utils';
109

1110
import type { Event } from '../../src';
@@ -23,7 +22,6 @@ import {
2322
getCurrentScope,
2423
init,
2524
showReportDialog,
26-
wrap,
2725
} from '../../src';
2826
import { getDefaultBrowserClientOptions } from './helper/browser-client-options';
2927
import { makeSimpleTransport } from './mocks/simpletransport';
@@ -402,65 +400,3 @@ describe('SentryBrowser initialization', () => {
402400
});
403401
});
404402
});
405-
406-
describe('wrap()', () => {
407-
it('should wrap and call function while capturing error', done => {
408-
const options = getDefaultBrowserClientOptions({
409-
beforeSend: (event: Event): Event | null => {
410-
expect(event.exception!.values![0].type).toBe('TypeError');
411-
expect(event.exception!.values![0].value).toBe('mkey');
412-
done();
413-
return null;
414-
},
415-
dsn,
416-
});
417-
setCurrentClient(new BrowserClient(options));
418-
419-
try {
420-
// eslint-disable-next-line deprecation/deprecation
421-
wrap(() => {
422-
throw new TypeError('mkey');
423-
});
424-
} catch (e) {
425-
// no-empty
426-
}
427-
});
428-
429-
it('should return result of a function call', () => {
430-
// eslint-disable-next-line deprecation/deprecation
431-
const result = wrap(() => 2);
432-
expect(result).toBe(2);
433-
});
434-
435-
it('should allow for passing this and arguments through binding', () => {
436-
// eslint-disable-next-line deprecation/deprecation
437-
const result = wrap(
438-
function (this: unknown, a: string, b: number): unknown[] {
439-
return [this, a, b];
440-
}.bind({ context: 'this' }, 'b', 42),
441-
);
442-
443-
expect((result as unknown[])[0]).toEqual({ context: 'this' });
444-
expect((result as unknown[])[1]).toBe('b');
445-
expect((result as unknown[])[2]).toBe(42);
446-
447-
// eslint-disable-next-line deprecation/deprecation
448-
const result2 = wrap(
449-
function (this: { x: number }): number {
450-
return this.x;
451-
}.bind({ x: 42 }),
452-
);
453-
454-
expect(result2).toBe(42);
455-
});
456-
457-
it('should ignore frozen functions', () => {
458-
const func = Object.freeze(() => 42);
459-
460-
// eslint-disable-next-line deprecation/deprecation
461-
wrap(func);
462-
463-
expect(func()).toBe(42);
464-
expect((func as WrappedFunction).__sentry_wrapped__).toBeUndefined();
465-
});
466-
});

0 commit comments

Comments
 (0)