Skip to content
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
15 changes: 6 additions & 9 deletions packages/sveltekit/src/vite/sentryVitePlugins.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { consoleSandbox } from '@sentry/core';
import { consoleSandbox, warnOnRemovedBuildOptions } from '@sentry/core';
import { sentryOrchestrionPlugin } from '@sentry/server-utils/orchestrion/vite';
import * as fs from 'fs';
import * as path from 'path';
Expand All @@ -25,6 +25,8 @@ const DEFAULT_PLUGIN_OPTIONS: SentrySvelteKitPluginOptions = {
* Make sure, it is registered before the SvelteKit plugin.
*/
export async function sentrySvelteKit(options: SentrySvelteKitPluginOptions = {}): Promise<Plugin[]> {
warnOnRemovedBuildOptions(options, ['unstable_sentryVitePluginOptions']);

const svelteConfig = await loadSvelteConfig();

const mergedOptions = {
Expand Down Expand Up @@ -170,7 +172,7 @@ async function readPackageMajor(

/**
* This function creates the options for the custom Sentry Vite plugin.
* The options are derived from the Sentry SvelteKit plugin options, where the `_unstable` options take precedence.
* The options are derived from the Sentry SvelteKit plugin options.
*
* only exported for testing
*/
Expand All @@ -195,7 +197,6 @@ export function generateVitePluginOptions(
autoUploadSourceMaps: _filtered1,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
autoInstrument: _filtered2,
unstable_sentryVitePluginOptions,
sentryUrl,
...newSvelteKitPluginOptions
} = svelteKitPluginOptions;
Expand All @@ -207,24 +208,20 @@ export function generateVitePluginOptions(

url: sentryUrl,

...unstable_sentryVitePluginOptions,

adapter: svelteKitPluginOptions.adapter,
// override the plugin's debug flag with the one from the top-level options
debug: svelteKitPluginOptions.debug,
};

if (svelteKitPluginOptions.sourcemaps || unstable_sentryVitePluginOptions?.sourcemaps) {
if (svelteKitPluginOptions.sourcemaps) {
sentryVitePluginsOptions.sourcemaps = {
...svelteKitPluginOptions.sourcemaps,
...unstable_sentryVitePluginOptions?.sourcemaps,
};
}

if (svelteKitPluginOptions.release || unstable_sentryVitePluginOptions?.release) {
if (svelteKitPluginOptions.release) {
sentryVitePluginsOptions.release = {
...svelteKitPluginOptions.release,
...unstable_sentryVitePluginOptions?.release,
};
}
}
Expand Down
73 changes: 36 additions & 37 deletions packages/sveltekit/src/vite/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { BuildTimeOptionsBase, UnstableVitePluginOptions } from '@sentry/core';
import type { BuildTimeOptionsBase } from '@sentry/core';
import type { SentryVitePluginOptions } from '@sentry/bundler-plugins/vite';
import type { AutoInstrumentSelection } from './autoInstrument';
import type { SupportedSvelteKitAdapters } from './detectAdapter';
Expand All @@ -9,41 +9,40 @@ export type CustomSentryVitePluginOptions = SentryVitePluginOptions & {
};

/** Options for the Sentry SvelteKit plugin */
export type SentrySvelteKitPluginOptions = BuildTimeOptionsBase &
UnstableVitePluginOptions<Partial<SentryVitePluginOptions>> & {
/**
* The Sentry plugin will automatically instrument certain parts of your SvelteKit application at build time.
* Set this option to `false` to disable this behavior or what is intrumented by passing an object.
*
* Auto instrumentation includes:
* - Universal `load` functions in `+page.(js|ts)` files
* - Server-only `load` functions in `+page.server.(js|ts)` files
*
* @default true (meaning, the plugin will instrument all of the above)
*/
autoInstrument?: boolean | AutoInstrumentSelection;
export type SentrySvelteKitPluginOptions = BuildTimeOptionsBase & {
/**
* The Sentry plugin will automatically instrument certain parts of your SvelteKit application at build time.
* Set this option to `false` to disable this behavior or what is intrumented by passing an object.
*
* Auto instrumentation includes:
* - Universal `load` functions in `+page.(js|ts)` files
* - Server-only `load` functions in `+page.server.(js|ts)` files
*
* @default true (meaning, the plugin will instrument all of the above)
*/
autoInstrument?: boolean | AutoInstrumentSelection;

/**
* Specify which SvelteKit adapter you're using.
* By default, the SDK will attempt auto-detect the used adapter at build time and apply the
* correct config for source maps upload or auto-instrumentation.
*
* Currently, the SDK supports the following adapters:
* - node (@sveltejs/adapter-node)
* - auto (@sveltejs/adapter-auto) only Vercel
* - vercel (@sveltejs/adapter-auto) only Serverless functions, no edge runtime
*
* Set this option, if the SDK detects the wrong adapter or you want to use an adapter
* that is not in this list. If you specify 'other', you'll most likely need to configure
* source maps upload yourself.
*
* @default {} the SDK attempts to auto-detect the used adapter at build time
*/
adapter?: SupportedSvelteKitAdapters;
/**
* Specify which SvelteKit adapter you're using.
* By default, the SDK will attempt auto-detect the used adapter at build time and apply the
* correct config for source maps upload or auto-instrumentation.
*
* Currently, the SDK supports the following adapters:
* - node (@sveltejs/adapter-node)
* - auto (@sveltejs/adapter-auto) only Vercel
* - vercel (@sveltejs/adapter-auto) only Serverless functions, no edge runtime
*
* Set this option, if the SDK detects the wrong adapter or you want to use an adapter
* that is not in this list. If you specify 'other', you'll most likely need to configure
* source maps upload yourself.
*
* @default {} the SDK attempts to auto-detect the used adapter at build time
*/
adapter?: SupportedSvelteKitAdapters;

/**
* If this flag is `true`, the Sentry plugins will automatically upload source maps to Sentry.
* @default true`.
*/
autoUploadSourceMaps?: boolean;
};
/**
* If this flag is `true`, the Sentry plugins will automatically upload source maps to Sentry.
* @default true`.
*/
autoUploadSourceMaps?: boolean;
};
Loading
Loading