Skip to content

Commit f823bde

Browse files
Lms24mydea
authored andcommitted
adjust API
1 parent 7be3e56 commit f823bde

File tree

3 files changed

+55
-20
lines changed

3 files changed

+55
-20
lines changed

packages/sveltekit/src/index.types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ export declare function wrapLoadWithSentry<T extends (...args: any) => any>(orig
4141
export declare const Integrations: typeof clientSdk.Integrations & typeof serverSdk.Integrations;
4242

4343
export declare const linkedErrorsIntegration: typeof clientSdk.linkedErrorsIntegration;
44-
export declare const contextLinesIntegration: typeof clientSdk.contextLinesIntegration;
4544

4645
export declare const getDefaultIntegrations: (options: Options) => Integration[];
4746
export declare const defaultStackParser: StackParser;

packages/sveltekit/src/vite/sentryVitePlugins.ts

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,6 @@ type SourceMapsUploadOptions = {
4343
*/
4444
project?: string;
4545

46-
/**
47-
* A glob or an array of globs that specify the build artifacts and source maps that will uploaded to Sentry.
48-
*
49-
* If this option is not specified, sensible defaults based on your adapter and svelte.config.js
50-
* setup will be used. Use this option to override these defaults, for instance if you have a
51-
* customized build setup that diverges from SvelteKit's defaults.
52-
*
53-
* The globbing patterns must follow the implementation of the `glob` package.
54-
* @see https://www.npmjs.com/package/glob#glob-primer
55-
*/
56-
assets?: string | Array<string>;
57-
5846
/**
5947
* If this flag is `true`, the Sentry plugin will collect some telemetry data and send it to Sentry.
6048
* It will not collect any sensitive or user-specific data.
@@ -63,6 +51,43 @@ type SourceMapsUploadOptions = {
6351
*/
6452
telemetry?: boolean;
6553

54+
/**
55+
* Options related to sourcemaps
56+
*/
57+
sourcemaps?: {
58+
/**
59+
* A glob or an array of globs that specify the build artifacts and source maps that will be uploaded to Sentry.
60+
*
61+
* If this option is not specified, sensible defaults based on your adapter and svelte.config.js
62+
* setup will be used. Use this option to override these defaults, for instance if you have a
63+
* customized build setup that diverges from SvelteKit's defaults.
64+
*
65+
* The globbing patterns must follow the implementation of the `glob` package.
66+
* @see https://www.npmjs.com/package/glob#glob-primer
67+
*/
68+
assets?: string | Array<string>;
69+
70+
/**
71+
* A glob or an array of globs that specifies which build artifacts should not be uploaded to Sentry.
72+
*
73+
* @default [] - By default no files are ignored. Thus, all files matching the `assets` glob
74+
* or the default value for `assets` are uploaded.
75+
*
76+
* The globbing patterns follow the implementation of the glob package. (https://www.npmjs.com/package/glob)
77+
*/
78+
ignore?: string | Array<string>;
79+
80+
/**
81+
* A glob or an array of globs that specifies the build artifacts that should be deleted after the artifact
82+
* upload to Sentry has been completed.
83+
*
84+
* @default [] - By default no files are deleted.
85+
*
86+
* The globbing patterns follow the implementation of the glob package. (https://www.npmjs.com/package/glob)
87+
*/
88+
filesToDeleteAfterUpload?: string | Array<string>;
89+
};
90+
6691
/**
6792
* Options related to managing the Sentry releases for a build.
6893
*
@@ -171,12 +196,15 @@ export async function sentrySvelteKit(options: SentrySvelteKitPluginOptions = {}
171196
}
172197

173198
if (mergedOptions.autoUploadSourceMaps && process.env.NODE_ENV !== 'development') {
174-
const pluginOptions = {
175-
...mergedOptions.sourceMapsUploadOptions,
176-
debug: mergedOptions.debug, // override the plugin's debug flag with the one from the top-level options
199+
const sourceMapsUploadOptions = mergedOptions.sourceMapsUploadOptions;
200+
201+
const sentryVitePlugins = await makeCustomSentryVitePlugins({
202+
...sourceMapsUploadOptions,
203+
177204
adapter: mergedOptions.adapter,
178-
};
179-
const sentryVitePlugins = await makeCustomSentryVitePlugins(pluginOptions);
205+
// override the plugin's debug flag with the one from the top-level options
206+
debug: mergedOptions.debug,
207+
});
180208
sentryPlugins.push(...sentryVitePlugins);
181209
}
182210

packages/sveltekit/test/vite/sentrySvelteKitPlugins.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,23 @@ describe('sentrySvelteKit()', () => {
9292
await getSentrySvelteKitPlugins({
9393
debug: true,
9494
sourceMapsUploadOptions: {
95-
assets: ['foo/*.js'],
95+
sourcemaps: {
96+
assets: ['foo/*.js'],
97+
ignore: ['bar/*.js'],
98+
filesToDeleteAfterUpload: ['baz/*.js'],
99+
},
96100
},
97101
autoInstrument: false,
98102
adapter: 'vercel',
99103
});
100104

101105
expect(makePluginSpy).toHaveBeenCalledWith({
102106
debug: true,
103-
assets: ['foo/*.js'],
107+
sourcemaps: {
108+
assets: ['foo/*.js'],
109+
ignore: ['bar/*.js'],
110+
filesToDeleteAfterUpload: ['baz/*.js'],
111+
},
104112
adapter: 'vercel',
105113
});
106114
});

0 commit comments

Comments
 (0)