ref(nextjs): Invert serverside injection criteria #6206
Merged
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.
In nextjs, all non-API pages (other than sometimes
_error) include the_appcomponent. Up until now, we've leveraged this fact when deciding which webpack entrypoints should havesentry.server.config.jsinjected 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_appbeing 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_appdoes.) Given that_appand_documentcan'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_appand_documentwrap 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.)