Skip to content

Commit c0110ae

Browse files
feat(svelte): add switch for configuring with Svelte v5 (#13141)
1 parent c5c9adf commit c0110ae

File tree

1 file changed

+41
-1
lines changed
  • docs/platforms/javascript/guides/svelte

1 file changed

+41
-1
lines changed

docs/platforms/javascript/guides/svelte/index.mdx

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,47 @@ Configuration should happen as early as possible in your application's lifecycle
4444

4545
To use the SDK, initialize it in your Svelte entry point before bootstrapping your app. In a typical Svelte project, that is your `main.js` or `main.ts` file.
4646

47-
```javascript {filename: main.js} {"onboardingOptions": {"performance": "10, 13-20", "session-replay": "11, 23-29"}}
47+
```javascript {tabTitle: Svelte v5+} {filename: main.js} {"onboardingOptions": {"performance": "11, 14-21", "session-replay": "12, 24-30"}}
48+
import { mount } from "svelte";
49+
import "./app.css";
50+
import App from "./App.svelte";
51+
52+
import * as Sentry from "@sentry/svelte";
53+
54+
// Initialize the Sentry SDK here
55+
Sentry.init({
56+
dsn: "___PUBLIC_DSN___",
57+
integrations: [
58+
Sentry.browserTracingIntegration(),
59+
Sentry.replayIntegration(),
60+
],
61+
62+
// Set tracesSampleRate to 1.0 to capture 100%
63+
// of transactions for tracing.
64+
// We recommend adjusting this value in production
65+
// Learn more at
66+
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
67+
tracesSampleRate: 1.0,
68+
69+
// Set `tracePropagationTargets` to control for which URLs trace propagation should be enabled
70+
tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/],
71+
72+
// Capture Replay for 10% of all sessions,
73+
// plus 100% of sessions with an error
74+
// Learn more at
75+
// https://docs.sentry.io/platforms/javascript/session-replay/configuration/#general-integration-configuration
76+
replaysSessionSampleRate: 0.1,
77+
replaysOnErrorSampleRate: 1.0,
78+
});
79+
80+
const app = mount(App, {
81+
target: document.getElementById("app"),
82+
});
83+
84+
export default app;
85+
```
86+
87+
```javascript {tabTitle: Svelte v3-v4} {filename: main.js} {"onboardingOptions": {"performance": "10, 13-20", "session-replay": "11, 23-29"}}
4888
import "./app.css";
4989
import App from "./App.svelte";
5090

0 commit comments

Comments
 (0)