Skip to content

ref(browser): Don't use Breadcrumbs integration in send event flow #5024

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 2 commits into from
May 3, 2022

Conversation

lforst
Copy link
Contributor

@lforst lforst commented May 3, 2022

Avoids directly using the Breadcrumbs integration class in non-integration code to reduce bundle size if manually creating a client instead of using Sentry.init().

Ref: https://getsentry.atlassian.net/browse/WEB-820

@github-actions
Copy link
Contributor

github-actions bot commented May 3, 2022

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 18.73 KB (-7.03% 🔽)
@sentry/browser - ES5 CDN Bundle (minified) 58.44 KB (-9.55% 🔽)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 17.51 KB (-7.16% 🔽)
@sentry/browser - ES6 CDN Bundle (minified) 52.6 KB (-9.26% 🔽)
@sentry/browser - Webpack (gzipped + minified) 19.21 KB (-17.32% 🔽)
@sentry/browser - Webpack (minified) 62.11 KB (-23.99% 🔽)
@sentry/react - Webpack (gzipped + minified) 19.24 KB (-17.36% 🔽)
@sentry/nextjs Client - Webpack (gzipped + minified) 42.91 KB (-10.71% 🔽)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 24.52 KB (-5.97% 🔽)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 23.1 KB (-5.66% 🔽)

@lforst lforst marked this pull request as ready for review May 3, 2022 12:58
@lforst lforst requested review from AbhiPrasad and Lms24 May 3, 2022 12:58
@AbhiPrasad AbhiPrasad added this to the 7.0.0 milestone May 3, 2022
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Nice work! LGTM (seems work similarly to what we discussed a few days ago).

*
* @returns The installed integration or `undefined` if no integration with that `id` was installed.
*/
public getIntegrationById(integrationId: string): Integration | undefined {
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about making this should be generic over an Integration? This means the caller can define the value without needing a cast.

Suggested change
public getIntegrationById(integrationId: string): Integration | undefined {
public getIntegrationById<I extends Integration>(integrationId: string): I | undefined {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Honestly, I do not like it. I do not want to help people to disable TS checks. If you are sure that your code is right go ahead and cast it, because that is way more explicitly saying that you're doing some dangerous stuff than using a generic, which kind of hides the danger...

* Options of the breadcrumbs integration.
*/
// This field is public, because we use it in the browser client to check if the `sentry` option is enabled.
public readonly options: Readonly<BreadcrumbsOptions>;
Copy link
Member

Choose a reason for hiding this comment

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

This now means that options cannot be minified - but I guess not the end of the world.

if (integration) {
integration.addSentryBreadcrumb(event);
// We only want to add the sentry event breadcrumb when the user has the breadcrumb integration installed and
// activated its`sentry` option.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// activated its`sentry` option.
// activated it's `sentry` option.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

while I do now notice that there's a space missing I think this should actually be "its" because "it is" would definitely not fit here

@lforst lforst merged commit 00c00fa into 7.x May 3, 2022
@lforst lforst deleted the lforst-remove-breadcrumbs-usage branch May 3, 2022 13:40
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.

3 participants