Build Options
Learn about the build-time configuration options available for the SvelteKit SDK.
The Sentry SvelteKit SDK supports automatic code instrumentation and source map upload during your app's build process using the sentrySvelteKit
Vite plugins in your vite.config.(js|ts)
file.
sourceMapsUploadOptions.org
Type | string |
---|
The slug of the Sentry organization associated with the app.
sourceMapsUploadOptions.project
Type | string |
---|
The slug of the Sentry project associated with the app.
sourceMapsUploadOptions.authToken
Type | string |
---|
The authentication token to use for all communication with Sentry. Can be obtained from https://sentry.io/orgredirect/organizations/:orgslug/settings/auth-tokens/.
sourceMapsUploadOptions.url
Type | string |
---|---|
Default | https://sentry.io/ |
The base URL of your Sentry instance. Only relevant if you're using a self-hosted or Sentry instance other than sentry.io.
adapter
Type | string |
---|
By default, sentrySvelteKit
will try to detect your SvelteKit adapter to configure the source maps upload correctly. If you're not using one of the supported adapters or the wrong one is detected, you can override the adapter detection using the adapter
option.
autoUploadSourceMaps
Type | boolean |
---|
Disable automatic source maps upload by setting autoUploadSourceMaps
to false
.
The SDK primarily uses SvelteKit's hooks to collect error and performance data. However, SvelteKit doesn't yet offer a hook for universal or server-only load
function calls. Therefore, the SDK uses a Vite plugin to auto-instrument load
functions so that you don't have to manually add a Sentry wrapper to each function.
Auto-instrumentation is enabled by default when you add the sentrySvelteKit()
function call to your vite.config.(js|ts)
. However, you can customize the behavior or disable it entirely.
The SDK will only auto-instrument load
functions in +page
or +layout
files that don't contain any Sentry-related code. If you have custom Sentry code in these files, you'll have to manually add a Sentry wrapper to your load
functions.
autoInstrument
Type | boolean | object |
---|---|
Default | true |
Set autoInstrument
to false
to disable auto-instrumentation of any load
functions. You can still manually instrument specific load
functions.
vite.config.(js|ts)
import { sveltekit } from '@sveltejs/kit/vite';
import { sentrySvelteKit } from '@sentry/sveltekit';
export default {
plugins: [
sentrySvelteKit({
autoInstrument: false;
}),
sveltekit(),
],
// ... rest of your Vite config
};
Alternatively, you can provide autoInstrument
with an object to customize which load
functions should be instrumented.
autoInstrument.load
Type | boolean |
---|---|
Default | true |
Set to false
to disable auto-instrumentation of load
functions inside +page.(js|ts)
or +layout.(js|ts)
.
vite.config.(js|ts)
import { sveltekit } from "@sveltejs/kit/vite";
import { sentrySvelteKit } from "@sentry/sveltekit";
export default {
plugins: [
sentrySvelteKit({
autoInstrument: {
load: false,
},
}),
sveltekit(),
],
// ... rest of your Vite config
};
autoInstrument.serverLoad
Type | boolean |
---|---|
Default | true |
Set to false
to disable auto-instrumentation of server-only load
functions inside +page.server.(js|ts)
or +layout.server.(js|ts)
.
vite.config.(js|ts)
import { sveltekit } from "@sveltejs/kit/vite";
import { sentrySvelteKit } from "@sentry/sveltekit";
export default {
plugins: [
sentrySvelteKit({
autoInstrument: {
serverLoad: false,
},
}),
sveltekit(),
],
// ... rest of your Vite config
};
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").