You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
5. To catch errors and performance data in your universal `load` functions (e.g. in `+page.(js|ts)`), wrap our `wrapLoadWithSentry` function around your load code:
132
+
Add `sentrySvelteKit` to your Vite plugins in `vite.config.(js|ts)` file so that the Sentry SDK can apply build-time features.
133
+
Make sure that it is added _before_ the `sveltekit` plugin:
6. To catch errors and performance data in your server `load`functions (e.g. in`+page.server.(js|ts)`), wrap our `wrapServerLoadWithSentry`function around your load code:
144
-
145
-
```javascript
146
-
// +page.server.(js|ts)
147
-
import { wrapServerLoadWithSentry } from '@sentry/sveltekit';
1. Add our `sentrySvelteKit` plugins to your `vite.config.(js|ts)` file so that the Sentry SDK can apply build-time features.
157
-
Make sure that it is added before the `sveltekit` plugin:
140
+
exportdefault {
141
+
plugins: [sentrySvelteKit(), sveltekit()],
142
+
// ... rest of your Vite config
143
+
};
144
+
```
158
145
159
-
```javascript
160
-
// vite.config.(js|ts)
161
-
import { sveltekit } from '@sveltejs/kit/vite';
162
-
import { sentrySvelteKit } from '@sentry/sveltekit';
163
-
164
-
export default {
165
-
plugins: [sentrySvelteKit(), sveltekit()],
166
-
// ... rest of your Vite config
167
-
};
168
-
```
146
+
This adds the [Sentry Vite Plugin](https://github.com/getsentry/sentry-javascript-bundler-plugins/tree/main/packages/vite-plugin) to your Vite config to automatically upload source maps to Sentry.
169
147
170
-
This adds the [Sentry Vite Plugin](https://github.com/getsentry/sentry-javascript-bundler-plugins/tree/main/packages/vite-plugin) to your Vite config to automatically upload source maps to Sentry.
148
+
---
171
149
172
150
## Uploading Source Maps
173
151
@@ -252,14 +230,87 @@ export default {
252
230
};
253
231
```
254
232
233
+
## Configure Auto-Instrumentation
234
+
235
+
The SDK mostly relies on [SvelteKit's hooks](https://kit.svelte.dev/docs/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 add a Sentry wrapper to each function manually. Auto-instrumentation is enabled by default, as soon as you add the `sentrySvelteKit()` function call to your `vite.config.(js|ts)`. However, you can customize the behavior, or disable it entirely. In this case, you can still manually wrap specific `load` functions with the `withSentry` function.
236
+
237
+
Note: The SDK will only auto-instrument `load` functions in `+page` or `+layout` files that do not yet contain any Sentry code.
238
+
If you already have custom Sentry code in such files, you'll have to [manually](#instrument-load-functions-manually) add our wrapper to your `load` functions.
239
+
240
+
241
+
### Customize Auto-instrumentation
242
+
243
+
By passing the `autoInstrument` option to `sentrySvelteKit` you can disable auto-instrumentation entirely, or customize which `load` functions should be instrumented:
If you set the `autoInstrument` option to `false`, the SDK won't auto-instrument any `load` function. You can still [manually instrument](#instrument-load-functions-manually) specific `load` functions.
0 commit comments