Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate or Change type of exported wrap function #8897

Closed
Tracked by #9508
Lms24 opened this issue Aug 29, 2023 · 1 comment
Closed
Tracked by #9508

Deprecate or Change type of exported wrap function #8897

Lms24 opened this issue Aug 29, 2023 · 1 comment
Assignees
Labels
Meta: Breaking Package: browser Issues related to the Sentry Browser SDK Type: Improvement
Milestone

Comments

@Lms24
Copy link
Member

Lms24 commented Aug 29, 2023

Problem Statement

TIL: In the browser SDK, we export a wrap function that people can wrap around any function call.

It'll try/catch whatever happens inside and report an error to Sentry (using our internal wrap function). This function is typed with any.

export function wrap(fn: (...args: any) => any): any {
return internalWrap(fn)();
}

Solution Brainstorm

We should rewrite the type here to use generics:

export function wrap<F>(fn: () => F): F

We can now add the newly typed function and deprecate the any-typed one to remove in v8

Alternative

Deprecate the function and remove it? I never saw this before and afaict it's not documented anywhere.

@Lms24 Lms24 added Type: Improvement Package: browser Issues related to the Sentry Browser SDK labels Aug 29, 2023
@Lms24 Lms24 added this to the 8.0.0 milestone Aug 29, 2023
@Lms24 Lms24 changed the title Change type of exported wrap function Deprecate or Change type of exported wrap function Sep 1, 2023
@Lms24
Copy link
Member Author

Lms24 commented Sep 1, 2023

I'd rather deprecate this function and remove it in v8, given that this function is not documented anywhere and it's not used by SDKs inheriting from Browser. (also checked RN, Electron, Cordova and Capacitor SDKs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Meta: Breaking Package: browser Issues related to the Sentry Browser SDK Type: Improvement
Projects
None yet
Development

No branches or pull requests

1 participant