-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat(feedback): Create async bundles and code to resolve helper integrations #11621
Conversation
size-limit report 📦
|
It looks like |
ya, i think i need to have different entrypoints, right now it's re-using the same index.ts file. but i also noticed that |
@mydea can you take another look at the async loader helper function? It seems to me that it only works when the SDK is loaded via CDN and window.Sentry exists. Also, I was surprised the sizes are the same even though imports are different for the Feedback and FeedbackAsync variants that the CI posted above and Billy pointed out. |
Hopefully fixed here: #11673 |
f2f0d83
to
55500be
Compare
@billyvg following up, i expected that the size for Once that's sorted we should be all set imo |
5c5130a
to
55500be
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bundler seemed like it wasn't tree-shaking properly when this file was combined with src/feedback.ts
. Splitting them apart resulted in the bundle-sizes I expected
feedbackScreenshotIntegration, | ||
getFeedback, | ||
} from '@sentry-internal/feedback'; | ||
export { feedbackIntegration } from './feedback'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that we're using feedbackIntegration
as the default here, not feedbackAsyncIntegration
. (same in the othe bundle configs)
So CDN users, by default, won't have async loading.
This is something we can talk about and change outside this PR
|
||
// This is for users who want to have a lazy-loaded feedback widget | ||
export const feedbackAsyncIntegration = buildFeedbackIntegration({ | ||
lazyLoadIntegration, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole buildFeedbackIntegration
exists, and is called from inside the browser package, so that we can inject lazyLoadIntegration
instead of creating a circular dependency between @sentry/browser
and @sentry/feedback
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
// The type here should be `keyof typeof LazyLoadableIntegrations`, but that'll cause a cicrular | ||
// dependency with @sentry/core | ||
lazyLoadIntegration: (name: 'feedbackModalIntegration' | 'feedbackScreenshotIntegration') => Promise<IntegrationFn>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not for this PR, but should this type be moved to @sentry/types
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ya, we can do that in a followup. It depends on a list of strings, keyof
so might need some copy+paste too.
]); | ||
if (!modalIntegration || (showScreenshot && !screenshotIntegration)) { | ||
// trouble! | ||
throw new Error('Missing feedback helper integration!'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know how an integration could be missing? Would be helpful to provide a potential solution or a link to one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idk if we strictly know what was supposed to be setup and failed. Certainly if either is missing then the async loading didn't work.
That could easily happen on purpose if the site relies on async loading but the user is offline right now, for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the comment with a TODO. We can for sure add help for the developer so they can make any adjustments, but user-facing i'm not sure where to go with it.
As noticed by @ryan953 here: #11621 (comment), this was not actually working properly in NPM-mode. I added a proper test for this and fixed this, so hopefully should be all good now.
This imports the various feedback bits into
@sentry/browser
and re-exports them as two 'built' integrations:feedbackIntegration
feedbackAsyncIntegration
The idea is that the former includes everything already imported, and the latter will leverage
lazyLoadIntegration
to bring in extra code when needed. This means that Sentry users can decide which integration to import as they setup the SDK. We can decide to a favored approach when we write the docs and installation instructions, right now for npm/yarn/pnpm users both options are viable.There is, as of this PR, no CDN or Loader bundle that leverages async loading. The CDN bundles are published with all the code included.
The bundle sizes, compressed, are currently at:
@sentry/browser 21.67 KB
@sentry/browser (incl. sendFeedback) 26.45 KB
@sentry/browser (incl. FeedbackAsync) 30.93 KB
@sentry/browser (incl. Feedback) 37.78 KB
The expectation is that as we add stuff to the Feedback bundle, FeedbackAsync won't get any larger at all.
To followup:
yarn site-limit --why
and looking at@sentry/browser (incl. FeedbackAsync)
is what I was looking atunknown
in the@sentry/types
package, but not used outside of@sentry/feedback
. These can probably be re-integrated and improved in a followup PR.Fixes #11435