feat(nextjs): Inject user sentry config files at app startup via webpack #3463
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.
NB: Currently this branch is coming off of another branch (the one removing the plugin). Once that's merged, this can get rebased.
This PR replaces the functionality of the old
on-init-server.js
andon-init-client.js
, which lived in the now-defunct plugin and served purely as an automatic way to callsentry.server.config.js
andsentry.client.config.js
(in which the SDK user puts their Sentry startup code (Sentry.init()
,Sentry.configureScope()
, etc)).Instead of using the plugin hooks, it modifies the webpack config's
entry
entry, to injectsentry.server.config.js
intopages/_document
(which serves as the base of all SSR pages) andsentry.client.config.js
intomain
, which is the base for all client-side JS. Hat tip to @kamilogorek for the implementation on which this is based.TODO:
main.js
entry ofwebpack.entry
) because that was the only thing I could get to work to deal with all of the async/await/promise stuff happening. There are a number of lines of code commented out, alternate versions of various async lines, but no combination seemed to work. Very open to suggested fixes.