Skip to content

ref(utils): Change addInstrumentationHandler to take reg args #4309

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

Merged
merged 5 commits into from
Dec 16, 2021

Conversation

AbhiPrasad
Copy link
Member

@AbhiPrasad AbhiPrasad commented Dec 16, 2021

Passing in an object is not necessary as there is always going to be two arguments required. We can just convert this to explicitly passing the options, it saves on bundle size. This type change is done in 28b8ef0

In addition, we can remove the guards around type and callback because addInstrumentationHandler is an internally used function, so Typescript and our test suite should handle the function getting called with arguments of the correct type.

We can (and should) keep refactoring this - but I think this is a good intermediate step. 7659398 updates the browser package with the new addInstrumentationHandler implementation. 3ec7566 does the same for tracing.

9d105cd just does some clean up.

Passing in an object is not necessary as there is always going to be two
arguments required. We can just convert this to explicitly passing the
options, it saves on bundle size.

In addition, we can remove the guards around `type` and `callback`
because addInstrumentationHandler is an internally used function, so
Typescript and our test suite should handle the function getting called
with arguments of the correct type.
Comment on lines -86 to -88
if (!handler || typeof handler.type !== 'string' || typeof handler.callback !== 'function') {
return;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this guard because we are the only ones using this addInstrumentationHandler

@github-actions
Copy link
Contributor

github-actions bot commented Dec 16, 2021

size-limit report

Path Base Size (1082ad6) Current Size Change
@sentry/browser - CDN Bundle (gzipped) 21.01 KB 20.96 KB -0.21% 🔽
@sentry/browser - CDN Bundle (minified) 66.97 KB 66.76 KB -0.31% 🔽
@sentry/browser - Webpack 22.79 KB 22.75 KB -0.18% 🔽
@sentry/browser - Webpack - gzip = false 78.2 KB 77.98 KB -0.29% 🔽
@sentry/react - Webpack 22.82 KB 22.78 KB -0.18% 🔽
@sentry/nextjs Client - Webpack 47.34 KB 47.29 KB -0.11% 🔽
@sentry/browser + @sentry/tracing - CDN Bundle (gzipped) 29.35 KB 29.31 KB -0.12% 🔽

@mitsuhiko mitsuhiko merged commit 477aec2 into master Dec 16, 2021
@mitsuhiko mitsuhiko deleted the abhi-ref-add-instrumentation-handlers branch December 16, 2021 16:26
onurtemizkan pushed a commit that referenced this pull request Dec 19, 2021
Change addInstrumentationHandler to take reg args

Passing in an object is not necessary as there is always going to be two
arguments required. We can just convert this to explicitly passing the
options, it saves on bundle size.

In addition, we can remove the guards around `type` and `callback`
because addInstrumentationHandler is an internally used function, so
Typescript and our test suite should handle the function getting called
with arguments of the correct type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants