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

Improve @next/plugin-sentry support and expose additional to plugin hooks #18272

Closed
wants to merge 3 commits into from
Closed

Improve @next/plugin-sentry support and expose additional to plugin hooks #18272

wants to merge 3 commits into from

Conversation

kamilogorek
Copy link
Contributor

required-env is currently removed, as it doesn't respect NEXT_PUBLIC_ presence, so despite providing NEXT_PUBLIC_SENTRY_DSN it would still complain that it's not there, unless { env: { NEXT_PUBLIC_SENTRY_DSN } } would be manually provided in next.config.js.

* TODO(kamil): Unify SDK configuration options.
* Workaround for callbacks, integrations and any unserializable config options.
**/
exports.serverConfig = {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The runtime configuration approach is not needed if you compile the configuration values into the bundle (prefixing using NEXT_PUBLIC_. However keep in mind that we shouldn't do that for the getRelease part given it will cause every single build to invalidate the webpack cache.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but there's no way to provide additional configuration to Sentry.init without that approach, as NEXT_PUBLIC_ supports only serializable values.

packages/next/next-server/server/next-server.ts Outdated Show resolved Hide resolved
Comment on lines +13 to +16
const { serverRuntimeConfig = {}, publicRuntimeConfig = {} } =
getConfig() || {}
const runtimeConfig =
serverRuntimeConfig.sentry || publicRuntimeConfig.sentry || {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

next/config should not be used. This is not compatible with Next.js' SSG mode and only exists for legacy reasons.

Comment on lines +12 to +13
const { publicRuntimeConfig = {} } = getConfig() || {}
const runtimeConfig = publicRuntimeConfig.sentry || {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

next/config should not be used. This is not compatible with Next.js' SSG mode and only exists for legacy reasons.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Timer What do you suggest to replace it?

Comment on lines +7 to +8
const { serverRuntimeConfig = {}, publicRuntimeConfig = {} } =
getConfig() || {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

next/config should not be used. This is not compatible with Next.js' SSG mode and only exists for legacy reasons.

Comment on lines +71 to +82
serverRuntimeConfig: {
sentry: {
type: 'server',
},
},
// Sentry.init config for client-side code (and fallback for server-side)
// can accept only serializeable values. For more granular control see below.
publicRuntimeConfig: {
sentry: {
type: 'client',
},
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be moved to your own sentry.config.js file or similar.

"SENTRY_DSN",
"SENTRY_RELEASE"
]
"required-env": []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are there no longer any required envs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the PR description.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should fix the bug with the key please instead of bypassing it!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree. This PR is the effect of PoC work, and it was necessary to go around this limitation for demo purposes.

@timneutkens
Copy link
Member

@Mike-Koech reported your account as spammer.

@kamilogorek kamilogorek closed this Apr 8, 2021
@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants