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
ref(svelte): Update component tracking docs with new withSentryConfig approach (#5649)
This patch updates the Svelte component tracking docs with usage instructions for the new approach we recently introduced to the Svelte SDK. Instead of manually adding a preprocessor to their svelte config, users can now simply wrap their config with a Sentry wrapper function that takes care of adding this preprocessor for them. This new approach allows us to make more changes to the config in the future without asking our users every time to change something in their config.
// To disable component initialization spans, set this to `false`.
30
-
// (defaults to `true`)
31
-
trackInit:true,
32
-
// To disable component update spans, set this to `false`
33
-
// (defaults to `true`)
34
-
trackUpdates:false,
35
-
}),
36
-
// ...
37
-
],
38
-
// ...
22
+
// Your svelte config
23
+
compilerOptions: {...},
39
24
};
40
25
41
-
exportdefaultconfig;
26
+
exportdefaultwithSentryConfig(config);
42
27
```
43
28
44
-
This preprocessor is called at application build time. It inserts a function call to a function in the Sentry SDK into the `<script>` tag of your components before your app is compiled and bundled. The called function takes care of recording the spans by using the Svelte component's lifecycle hooks.
29
+
This wrapper will insert Sentry's component tracking preprocessor into your config. The preprocessor inserts a function call to a function in the Sentry SDK into the `<script>` tag of your components before your app is compiled and bundled.
30
+
31
+
### Configuration
32
+
33
+
Once you add `withSentryConfig` around your Svelte config, our SDK will track all your components by default. If you want to customize which components or lifecycle events should be tracked, you can pass additional options to `withSentryConfig`:
34
+
35
+
```javascript {tabTitle: svelte.config.js}
36
+
import { withSentryConfig } from"@sentry/svelte";
37
+
38
+
constconfig= {
39
+
// Your svelte config
40
+
compilerOptions: {...},
41
+
};
42
+
43
+
constsentryOptions= {
44
+
// Groups all component tracking-related options
45
+
// (optional)
46
+
componentTracking: {
47
+
// Add the components you want to be tracked to this array.
48
+
// Specificy `true` to track all components or `false` to disable
This feature adds the following spans to the ongoing transaction:
47
67
@@ -55,7 +75,7 @@ This feature adds the following spans to the ongoing transaction:
55
75
56
76
## Alternative Usage
57
77
58
-
If you don't want to use our preprocessor to automatically insert the function call at build time, you can call the tracking function manually in every component you would like to see tracked:
78
+
If you don't want to use our `withSentryConfig` wrapper to automatically instrument your components at build time, you can call the tracking function manually in every component you would like to see tracked:
0 commit comments