GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(feedback): Inject preact from feedbackModal into feedbackScreenshot integration by ryan953 · Pull Request #12535 · getsentry/sentry-javascript

Conversation

@ryan953

@ryan953 ryan953 commented Jun 18, 2024

Copy link
Copy Markdown
Member

I believe the error we're seeing in #12534 is from having preact bundled twice: once into the Modal integration, and then again into the Screenshot one.

This PR updates the Screenshot code so that it requires preact to be injected into it, which should reduce the bundle size of that integration, but also solve the bug because there will only be one instance of preact and it's state within the sdk.

Fixes #12534

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ryan953
fix(feedback): Inject preact from feedbackModal into feedbackScreensh…
37e40a0
…ot integration
@ryan953
ryan953 requested a review from a team as a code owner June 18, 2024 22:31
billyvg
billyvg approved these changes Jun 19, 2024
View reviewed changes

@billyvg billyvg left a comment

Copy link
Copy Markdown
Member

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.

How do we ensure this doesn't regress in the future?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
ryan953 added 2 commits June 24, 2024 13:53
@ryan953
Merge branch 'develop' into ryan953/12534-feedback-inject-preact
68fb148
@ryan953
use type keyword instead of interface for non-exported shape
facf0d5
@ryan953

ryan953 commented Jun 24, 2024

Copy link
Copy Markdown
Member Author

How do we ensure this doesn't regress in the future?

It'd be good to have the bundle-size check again. i expect if we're fixing the problem correctly, size will be smaller for the screenshot portion

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Jun 24, 2024

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
@sentry/browser 22.22 KB (0%)
@sentry/browser (incl. Tracing) 33.31 KB (0%)
@sentry/browser (incl. Tracing, Replay) 69.09 KB (0%)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 62.42 KB (0%)
@sentry/browser (incl. Tracing, Replay with Canvas) 73.15 KB (0%)
@sentry/browser (incl. Tracing, Replay, Feedback) 85.76 KB (+0.49% 🔺)
@sentry/browser (incl. Tracing, Replay, Feedback, metrics) 87.62 KB (+0.48% 🔺)
@sentry/browser (incl. metrics) 26.5 KB (0%)
@sentry/browser (incl. Feedback) 38.87 KB (+1.08% 🔺)
@sentry/browser (incl. sendFeedback) 26.85 KB (-0.02% 🔽)
@sentry/browser (incl. FeedbackAsync) 31.45 KB (-0.01% 🔽)
@sentry/react 24.97 KB (0%)
@sentry/react (incl. Tracing) 36.36 KB (0%)
@sentry/vue 26.33 KB (0%)
@sentry/vue (incl. Tracing) 35.17 KB (0%)
@sentry/svelte 22.36 KB (0%)
CDN Bundle 23.42 KB (0%)
CDN Bundle (incl. Tracing) 35.05 KB (0%)
CDN Bundle (incl. Tracing, Replay) 69.18 KB (0%)
CDN Bundle (incl. Tracing, Replay, Feedback) 74.38 KB (0%)
CDN Bundle - uncompressed 68.8 KB (0%)
CDN Bundle (incl. Tracing) - uncompressed 103.66 KB (0%)
CDN Bundle (incl. Tracing, Replay) - uncompressed 214.13 KB (0%)
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 226.79 KB (0%)
@sentry/nextjs (client) 36.24 KB (0%)
@sentry/sveltekit (client) 33.95 KB (0%)
@sentry/node 113.27 KB (+0.01% 🔺)
@sentry/node - without tracing 90.65 KB (0%)
@sentry/aws-serverless 99.74 KB (0%)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ryan953

ryan953 commented Jun 24, 2024

Copy link
Copy Markdown
Member Author

Welp, bundle sizes are about the same, up by ~420bytes.

I guess that's the overhead of the extra variable passing? If we look at the bundled files (esm, easier to see) we can see that feedback-modal has preact inside it, and feedback-screenshot does not:
https://gist.github.com/ryan953/5f5846d894bc8d534007414ab3af3b02

See line 1206 in feedback-modal.tsx which includes var hooks = /*#__PURE__*/Object.freeze({
That should be a difference of 14kb

This is what I expected, but

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ryan953

ryan953 commented Jun 24, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

aha! We can't trust these bundle numbers because above for what we're doing here. Any bundle in the size-limit report above with "Feedback" in it will include all code. It's expected that stuff will be tree-shaken if modal & screenshots are not needed or async loaded.

I added a case to https://github.com/getsentry/sentry-javascript/blob/70e942d6426da9f8ce1ed1a267e266620e07da24/packages/feedback/rollup.bundle.config.mjs to compare the bundle sizes of all three integrations directly, ran it before and after this change.

this is the new snippet ...makeBundleConfigVariants( makeBaseBundleConfig({ bundleType: 'addon', entrypoints: ['src/core/integration.ts'], jsVersion: 'es6', licenseTitle: '@sentry-internal/feedback-core', outputFileBase: () => 'bundles/feedback-core', sucrase: { // The feedback widget is using preact so we need different pragmas and jsx runtimes jsxPragma: 'h', jsxFragmentPragma: 'Fragment', jsxRuntime: 'classic', }, }), ),

The numbers for the built files are:

Integration File Size Before (bytes) File Size After (bytes
bundles/feedback-core 58,678 58,717
bundles/feedback-modal 70,127 71,372
bundles/feedback-screenshot 20,369 17,156
delta - -1,929

So by those numbers we should be shifting some bytes from screenshots into modal, but saving 2kb overall. Assuming tree-shaking is happening. If there's no tree-shaking then folks shouldn't use the async bundle at all, they'll get the full bundle, which is represented in the size-limit report above.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ryan953
ryan953 merged commit c49c9f3 into develop Jun 24, 2024
@ryan953
ryan953 deleted the ryan953/12534-feedback-inject-preact branch June 24, 2024 22:12
@andreiborza andreiborza mentioned this pull request Jul 5, 2024
fix(feedback): Add missing h import in ScreenshotEditor (#12713) #12784
Merged
ryan953 added a commit that referenced this pull request Jul 8, 2024
@andreiborza @ryan953
fix(feedback): Add missing h import in ScreenshotEditor (#12713) (#…
3883517
…12784)

This broke the `Add a screenshot` button on the user feedback, see
#12713

This has been explicitly removed in favor of injecting `h` in
#12535 but at that
point it seems to be too late to do.

Co-authored-by: Ryan Albrecht <[email protected]>
@ryan953 ryan953 mentioned this pull request Jul 9, 2024
ref(feedback): Let CropCorner inherit the existing h prop #12814
Merged
andreiborza pushed a commit that referenced this pull request Jul 9, 2024
@ryan953
ref(feedback): Let CropCorner inherit the existing h prop (#12814)
aefbfaa
I noticed this after
#12784, but the
`<CropCorner>` wasn't inside the `ScreenshotEditorFactory()` function.
So of course it wasn't getting access to the `h` ref that is passed in.
That variable is what the `<div>` gets transpiled into -> it becomes
`h.createElement('div')`.

So what i'm doing is moving `CropCorner` into a `CropCornerFactory` so
we can pass `h` in and hopefully not have the extra `import .. from
'preact';` in the 2nd bundle.

Related to #12535
@q1blue q1blue mentioned this pull request Jul 16, 2024
[Snyk] Upgrade @sentry/react from 7.16.0 to 8.12.0 https-quantumblockchainai-atlassian-net/ossinsight#764
Open
@voidedstarlight voidedstarlight mentioned this pull request Jul 17, 2024
[Snyk] Upgrade @sentry/browser from 8.11.0 to 8.12.0 climatechangeinformation-org/website#162
Closed
This was referenced Jul 17, 2024
[Snyk] Upgrade @sentry/browser from 8.11.0 to 8.12.0 mong/mongts#2782
Closed
[Snyk] Upgrade @sentry/react from 8.11.0 to 8.12.0 mong/mongts#2783
Closed
@q1blue q1blue mentioned this pull request Jul 18, 2024
[Snyk] Upgrade @sentry/react from 7.16.0 to 8.13.0 https-quantumblockchainai-atlassian-net/ossinsight#773
Open
@FengShangWuQi FengShangWuQi mentioned this pull request Jul 21, 2024
[Snyk] Upgrade @sentry/gatsby from 7.20.0 to 8.13.0 FengShangWuQi/fengshangwuqi.github.io#1909
Closed
This was referenced Jul 26, 2024
[Snyk] Upgrade @sentry/react from 7.16.0 to 8.14.0 https-quantumblockchainai-atlassian-net/ossinsight#781
Open
[Snyk] Upgrade @sentry/react from 7.16.0 to 8.15.0 https-quantumblockchainai-atlassian-net/ossinsight#783
Open
[Snyk] Upgrade @sentry/react from 7.16.0 to 8.16.0 https-quantumblockchainai-atlassian-net/ossinsight#787
Open
[Snyk] Upgrade @sentry/react from 7.16.0 to 8.17.0 https-quantumblockchainai-atlassian-net/ossinsight#791
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@billyvg billyvg billyvg approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Bug Report: Screenshot Button Error in Report a Bug Form

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@ryan953 @billyvg
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.