Skip to content

Commit fa8c180

Browse files
maxmaxmes1gr1d
andauthored
feat(nuxt): add silent, errorHandler, release to SourceMapsOptions (getsentry#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 <32902192+s1gr1d@users.noreply.github.com>
1 parent e4333e5 commit fa8c180

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

packages/nuxt/src/common/types.ts

+44
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,50 @@ export type SentryNuxtClientOptions = Omit<Parameters<typeof initVue>[0] & objec
88
export type SentryNuxtServerOptions = Omit<Parameters<typeof initNode>[0] & object, 'app'>;
99

1010
type SourceMapsOptions = {
11+
/**
12+
* Suppresses all logs.
13+
*
14+
* @default false
15+
*/
16+
silent?: boolean;
17+
18+
/**
19+
* When an error occurs during release creation or sourcemaps upload, the plugin will call this function.
20+
*
21+
* By default, the plugin will simply throw an error, thereby stopping the bundling process.
22+
* If an `errorHandler` callback is provided, compilation will continue, unless an error is
23+
* thrown in the provided callback.
24+
*
25+
* To allow compilation to continue but still emit a warning, set this option to the following:
26+
*
27+
* ```js
28+
* (err) => {
29+
* console.warn(err);
30+
* }
31+
* ```
32+
*/
33+
errorHandler?: (err: Error) => void;
34+
35+
/**
36+
* Options related to managing the Sentry releases for a build.
37+
*
38+
* More info: https://docs.sentry.io/product/releases/
39+
*/
40+
release?: {
41+
/**
42+
* Unique identifier for the release you want to create.
43+
*
44+
* This value can also be specified via the `SENTRY_RELEASE` environment variable.
45+
*
46+
* Defaults to automatically detecting a value for your environment.
47+
* This includes values for Cordova, Heroku, AWS CodeBuild, CircleCI, Xcode, and Gradle, and otherwise uses the git `HEAD`'s commit SHA.
48+
* (the latter requires access to git CLI and for the root directory to be a valid repository)
49+
*
50+
* If you didn't provide a value and the plugin can't automatically detect one, no release will be created.
51+
*/
52+
name?: string;
53+
};
54+
1155
/**
1256
* If this flag is `true`, and an auth token is detected, the Sentry SDK will
1357
* automatically generate and upload source maps to Sentry during a production build.

packages/nuxt/src/vite/sourceMaps.ts

+6
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ export function getPluginOptions(
9393
telemetry: sourceMapsUploadOptions.telemetry ?? true,
9494
url: sourceMapsUploadOptions.url ?? process.env.SENTRY_URL,
9595
debug: moduleOptions.debug ?? false,
96+
silent: sourceMapsUploadOptions.silent ?? false,
97+
errorHandler: sourceMapsUploadOptions.errorHandler,
98+
release: {
99+
name: sourceMapsUploadOptions.release?.name,
100+
...moduleOptions?.unstable_sentryBundlerPluginOptions?.release,
101+
},
96102
_metaOptions: {
97103
telemetry: {
98104
metaFramework: 'nuxt',

0 commit comments

Comments
 (0)