Skip to content

Commit

Permalink
feat(nuxt): add silent, errorHandler, release to `SourceMapsOpt…
Browse files Browse the repository at this point in the history
…ions` (#15246)

This pull request includes changes to enhance the configuration options
for managing Sentry source maps in a Nuxt.js project. The most important
changes include adding new options to suppress logs, handle errors
during release creation, and manage Sentry releases.

Enhancements to Sentry source maps configuration:

*
[`packages/nuxt/src/common/types.ts`](diffhunk://#diff-199725da81bbdbb2e85f3dfe2b1a2bf453b4c9755059e5050815d7fcde2f59a5R11-R41):
Added `silent`, `errorHandler`, and `release` options to the
`SourceMapsOptions` type to provide more control over logging, error
handling, and release management.
*
[`packages/nuxt/src/vite/sourceMaps.ts`](diffhunk://#diff-d511a0577f152ed6476e519722483c904cd2878586fdcd27f71c5587036bee37R96-R98):
Updated the `getPluginOptions` function to include the new `silent`,
`errorHandler`, and `release` options, allowing them to be used during
the source maps upload process.

Before submitting a pull request, please take a look at our

[Contributing](https://github.com/getsentry/sentry-javascript/blob/master/CONTRIBUTING.md)
guidelines and verify:

- [x] If you've added code that should be tested, please add tests.
- [x] Ensure your code lints and the test suite passes (`yarn lint`) &
(`yarn test`).

---------

Co-authored-by: Sigrid Huemer <[email protected]>
  • Loading branch information
maxmaxme and s1gr1d authored Feb 3, 2025
1 parent e4333e5 commit fa8c180
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
44 changes: 44 additions & 0 deletions packages/nuxt/src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,50 @@ export type SentryNuxtClientOptions = Omit<Parameters<typeof initVue>[0] & objec
export type SentryNuxtServerOptions = Omit<Parameters<typeof initNode>[0] & object, 'app'>;

type SourceMapsOptions = {
/**
* Suppresses all logs.
*
* @default false
*/
silent?: boolean;

/**
* When an error occurs during release creation or sourcemaps upload, the plugin will call this function.
*
* By default, the plugin will simply throw an error, thereby stopping the bundling process.
* If an `errorHandler` callback is provided, compilation will continue, unless an error is
* thrown in the provided callback.
*
* To allow compilation to continue but still emit a warning, set this option to the following:
*
* ```js
* (err) => {
* console.warn(err);
* }
* ```
*/
errorHandler?: (err: Error) => void;

/**
* Options related to managing the Sentry releases for a build.
*
* More info: https://docs.sentry.io/product/releases/
*/
release?: {
/**
* Unique identifier for the release you want to create.
*
* This value can also be specified via the `SENTRY_RELEASE` environment variable.
*
* Defaults to automatically detecting a value for your environment.
* This includes values for Cordova, Heroku, AWS CodeBuild, CircleCI, Xcode, and Gradle, and otherwise uses the git `HEAD`'s commit SHA.
* (the latter requires access to git CLI and for the root directory to be a valid repository)
*
* If you didn't provide a value and the plugin can't automatically detect one, no release will be created.
*/
name?: string;
};

/**
* If this flag is `true`, and an auth token is detected, the Sentry SDK will
* automatically generate and upload source maps to Sentry during a production build.
Expand Down
6 changes: 6 additions & 0 deletions packages/nuxt/src/vite/sourceMaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ export function getPluginOptions(
telemetry: sourceMapsUploadOptions.telemetry ?? true,
url: sourceMapsUploadOptions.url ?? process.env.SENTRY_URL,
debug: moduleOptions.debug ?? false,
silent: sourceMapsUploadOptions.silent ?? false,
errorHandler: sourceMapsUploadOptions.errorHandler,
release: {
name: sourceMapsUploadOptions.release?.name,
...moduleOptions?.unstable_sentryBundlerPluginOptions?.release,
},
_metaOptions: {
telemetry: {
metaFramework: 'nuxt',
Expand Down

0 comments on commit fa8c180

Please sign in to comment.