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

feat(nuxt): add silent, errorHandler, release to SourceMapsOptions #15246

Merged
merged 3 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading