Skip to content

fix(core): Avoid console output and telemetry init when plugins are disabled #741

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

Merged
merged 1 commit into from
May 20, 2025

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented May 20, 2025

In #714, we extracted a lot of the plugin pre-initialization logic into the createSentryBuildPluginManager function. Only after this manager was created, we'd check for the disabled option. However, within the plugin manager creation function, we'd already do validation on passed options, as well as initialize the Sentry SDK. Which both previously only happened after we checked for disabled (h/t @s1gr1d and @Jimmy89 for finding this).

This PR ensures we early-return within the createSentryBuildPluginManager function, so that we return a manager that no-ops in some methods. Not the prettiest solution in the world but unfortunately we have to normalize the user options first and merge them with process.env and an optional .env file, before we can reliably check for disabled. In the future, we could also return undefined in createSentryBuildPluginManager in case of the plugin being disabled but this would be a breaking change and also somewhat inconvenient.

Additionally, I refactored some of the return types to ensure we don't accidentally introduce breaking changes.

fixes #740

@Lms24 Lms24 self-assigned this May 20, 2025
@Lms24 Lms24 requested review from AbhiPrasad and s1gr1d May 20, 2025 11:21
Copy link
Member

@s1gr1d s1gr1d left a comment

Choose a reason for hiding this comment

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

Looks good 👌

@Lms24 Lms24 merged commit 7130a86 into main May 20, 2025
23 checks passed
@Lms24 Lms24 deleted the lms/fix-output-when-disabled branch May 20, 2025 14:31
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request May 24, 2025
| datasource | package             | from  | to    |
| ---------- | ------------------- | ----- | ----- |
| npm        | @sentry/vite-plugin | 3.4.0 | 3.5.0 |


## [v3.5.0](https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/HEAD/CHANGELOG.md#350)

-   feat(core): Add hook to customize source map file resolution ([#732](getsentry/sentry-javascript-bundler-plugins#732))
-   fix(core): Avoid console output and telemetry init when plugins are disabled ([#741](getsentry/sentry-javascript-bundler-plugins#741))

Work in this release was contributed by [@thecodewarrior](https://github.com/thecodewarrior). Thank you for your contribution!
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request May 24, 2025
| datasource | package             | from  | to    |
| ---------- | ------------------- | ----- | ----- |
| npm        | @sentry/vite-plugin | 3.4.0 | 3.5.0 |


## [v3.5.0](https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/HEAD/CHANGELOG.md#350)

-   feat(core): Add hook to customize source map file resolution ([#732](getsentry/sentry-javascript-bundler-plugins#732))
-   fix(core): Avoid console output and telemetry init when plugins are disabled ([#741](getsentry/sentry-javascript-bundler-plugins#741))

Work in this release was contributed by [@thecodewarrior](https://github.com/thecodewarrior). Thank you for your contribution!
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.

New version complains about missing values while disable = true
2 participants