Skip to content

Commit 2641389

Browse files
committed
feat(svelte): add switch for configuring with Svelte v5
1 parent c5c9adf commit 2641389

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,7 @@ 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 v3-v4} {filename: main.js} {"onboardingOptions": {"performance": "10, 13-20", "session-replay": "11, 23-29"}}
4848
import "./app.css";
4949
import App from "./App.svelte";
5050

@@ -83,6 +83,46 @@ const app = new App({
8383
export default app;
8484
```
8585

86+
```javascript {tabTitle: Svelte v5+} {filename: main.js} {"onboardingOptions": {"performance": "11, 14-21", "session-replay": "12, 24-30"}}
87+
import { mount } from "svelte";
88+
import "./app.css";
89+
import App from "./App.svelte";
90+
91+
import * as Sentry from "@sentry/svelte";
92+
93+
// Initialize the Sentry SDK here
94+
Sentry.init({
95+
dsn: "___PUBLIC_DSN___",
96+
integrations: [
97+
Sentry.browserTracingIntegration(),
98+
Sentry.replayIntegration(),
99+
],
100+
101+
// Set tracesSampleRate to 1.0 to capture 100%
102+
// of transactions for tracing.
103+
// We recommend adjusting this value in production
104+
// Learn more at
105+
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
106+
tracesSampleRate: 1.0,
107+
108+
// Set `tracePropagationTargets` to control for which URLs trace propagation should be enabled
109+
tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/],
110+
111+
// Capture Replay for 10% of all sessions,
112+
// plus 100% of sessions with an error
113+
// Learn more at
114+
// https://docs.sentry.io/platforms/javascript/session-replay/configuration/#general-integration-configuration
115+
replaysSessionSampleRate: 0.1,
116+
replaysOnErrorSampleRate: 1.0,
117+
});
118+
119+
const app = mount(App, {
120+
target: document.getElementById("app"),
121+
});
122+
123+
export default app;
124+
```
125+
86126
Once you've done this, the SDK will automatically capture unhandled errors and promise rejections, and monitor performance in the client. You can also [manually capture errors](/platforms/javascript/guides/svelte/usage).
87127

88128
<PlatformContent includePath="getting-started-sourcemaps" />

0 commit comments

Comments
 (0)