Skip to content

ref(browser): Extract global handlers private methods #4265

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 12 commits into from
Dec 14, 2021

Conversation

AbhiPrasad
Copy link
Member

@AbhiPrasad AbhiPrasad commented Dec 10, 2021

  • Move hub and client getters out to a common call and pass them down
  • Move private methods into regular functions as they don't use class
    props (pass down hub, client options explicitly)
  • Use dynamic dispatch object, _installFunc to call install methods on instrumentation
  • Extract capture exception into common method function addMechanismAndCapture
  • Alias unminified variable names (remove event.exception.values[0].stacktrace.frames)
  • Extract logging into function function globalHandlerLog
  • Introduce function to call getCurrentHub and return client options.

@AbhiPrasad AbhiPrasad added this to the Treeshaking / Bundle Size milestone Dec 10, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Dec 10, 2021

size-limit report

Path Base Size (f042723) Current Size Change
@sentry/browser - CDN Bundle (gzipped) 21.67 KB 21.41 KB -1.23% 🔽
@sentry/browser - Webpack 23.35 KB 23.2 KB -0.64% 🔽
@sentry/browser - Webpack - gzip = false 82.8 KB 81.27 KB -1.85% 🔽
@sentry/react - Webpack 23.38 KB 23.24 KB -0.64% 🔽
@sentry/nextjs Client - Webpack 48.01 KB 47.83 KB -0.39% 🔽
@sentry/browser + @sentry/tracing - CDN Bundle (gzipped) 29.99 KB 29.73 KB -0.87% 🔽

@AbhiPrasad
Copy link
Member Author

I broke the integration tests! Nice!

- Move hub and client getters out to a common call and pass them down
- Check for integration existence early on
- Move private methods into regular functions as they don't use class
  props
this makes me mad that this is a thing
@AbhiPrasad AbhiPrasad marked this pull request as ready for review December 13, 2021 19:53
if (installFunc && options[key as GlobalHandlersIntegrationsOptionKeys]) {
globalHandlerLog(key);
installFunc(hub, attachStacktrace);
this._installFunc[key as GlobalHandlersIntegrationsOptionKeys] = undefined;
Copy link
Member Author

Choose a reason for hiding this comment

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

tbh idk why have this guard because addInstrumentationHandler should be sufficient, but keeping it here for now 🤷

@AbhiPrasad AbhiPrasad requested a review from mitsuhiko December 14, 2021 01:35
@AbhiPrasad AbhiPrasad enabled auto-merge (squash) December 14, 2021 18:08
@AbhiPrasad AbhiPrasad merged commit 7e0a307 into master Dec 14, 2021
@AbhiPrasad AbhiPrasad deleted the abhi-global-handlers branch December 14, 2021 18:38
onurtemizkan pushed a commit that referenced this pull request Dec 19, 2021
- Move private methods into regular functions as they don't use class
  props
- Use dynamic dispatch object, `_installFunc` to call install methods on instrumentation
- Extract capture exception into common method `function addMechanismAndCapture`
- Alias unminified variable names (remove `event.exception.values[0].stacktrace.frames`)
- Extract logging into function `function globalHandlerLog`
- Introduce function to call `getCurrentHub` and return client options.
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