Skip to content
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

ref(nextjs): Invert serverside injection criteria #6206

Merged

Conversation

lobsterkatie
Copy link
Member

In nextjs, all non-API pages (other than sometimes _error) include the _app component. Up until now, we've leveraged this fact when deciding which webpack entrypoints should have sentry.server.config.js injected during serverside build; specifically, we inject into _app, _error, and all API handlers, but not any other non-API pages.

This works fine, but it means that if we want to be able to pick and choose which non-API pages get the config file injected, we're out of luck. Either we inject into _app (and therefore all non-API pages) or we don't (and therefore no non-API pages). In order to allow selective injection (which will be included in an upcoming PR), this inverts the logic: instead of _app being the only non-API page into which we inject, it is now one of the only pages we don't inject into. (The other is _document, which plays a similar role as _app does.) Given that _app and _document can't stand on their own (without the context of a page component inside of them), they don't need to have Sentry injected separately. Having it injected into the pages _app and _document wrap is sufficient.

(Note that this change only applies to serverside injection. Client-side, we still only inject into _app, as we can't be selective about which pages get instrumented on the front end given all of the global monkeypatching we do.)

@github-actions
Copy link
Contributor

github-actions bot commented Nov 15, 2022

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.51 KB (+0.07% 🔺)
@sentry/browser - ES5 CDN Bundle (minified) 60.36 KB (+0.05% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.17 KB (+0.09% 🔺)
@sentry/browser - ES6 CDN Bundle (minified) 53.71 KB (+0.03% 🔺)
@sentry/browser - Webpack (gzipped + minified) 19.9 KB (+0.04% 🔺)
@sentry/browser - Webpack (minified) 65.12 KB (+0.04% 🔺)
@sentry/react - Webpack (gzipped + minified) 19.93 KB (+0.07% 🔺)
@sentry/nextjs Client - Webpack (gzipped + minified) 45.89 KB (+0.03% 🔺)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 26.33 KB (+0.04% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 24.74 KB (+0.06% 🔺)

@lobsterkatie lobsterkatie force-pushed the kmclb-nextjs-invert-serverside-injection-criteria branch from 78dc8b8 to c98a180 Compare November 15, 2022 08:02
packages/nextjs/src/config/webpack.ts Show resolved Hide resolved
packages/nextjs/src/config/webpack.ts Show resolved Hide resolved
packages/nextjs/src/config/webpack.ts Show resolved Hide resolved
@lobsterkatie lobsterkatie force-pushed the kmclb-add-stringMatchesSomePattern-helper branch from 5d5d1e9 to 58afac0 Compare November 15, 2022 14:32
@lobsterkatie lobsterkatie force-pushed the kmclb-nextjs-invert-serverside-injection-criteria branch 2 times, most recently from d04f3bc to 054796b Compare November 15, 2022 14:43
Base automatically changed from kmclb-add-stringMatchesSomePattern-helper to master November 15, 2022 15:12
@lobsterkatie lobsterkatie force-pushed the kmclb-nextjs-invert-serverside-injection-criteria branch from 054796b to 3eeff43 Compare November 15, 2022 16:07
@lobsterkatie lobsterkatie merged commit 66bcbd7 into master Nov 15, 2022
@lobsterkatie lobsterkatie deleted the kmclb-nextjs-invert-serverside-injection-criteria branch November 15, 2022 17:51
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.

None yet

2 participants