|
| 1 | +To use the SDK, initialize it in your Solid entry point before bootstrapping your app. (In a typical Solid project that's the render-client.js, or render-client.tsx.) |
| 2 | + |
| 3 | +<SignInNote /> |
| 4 | + |
| 5 | +```javascript {filename: render-client.jsx} |
| 6 | +import { render } from "solid-js/web"; |
| 7 | +import App from "./app"; |
| 8 | +import * as Sentry from "@sentry/browser"; |
| 9 | +import { DEV } from "solid-js"; |
| 10 | + |
| 11 | +// this will only initialize your Sentry client in production builds. |
| 12 | +if (!DEV) { |
| 13 | + Sentry.init({ |
| 14 | + dsn: "<Sentry DSN>", |
| 15 | + integrations: [new Sentry.BrowserTracing(), new Sentry.Replay()], |
| 16 | + |
| 17 | + // Set tracesSampleRate to 1.0 to capture 100% |
| 18 | + // of transactions for performance monitoring. |
| 19 | + // We recommend adjusting this value in production |
| 20 | + tracesSampleRate: 1.0, |
| 21 | + |
| 22 | + // Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled |
| 23 | + tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/], |
| 24 | + |
| 25 | + // Capture Replay for 10% of all sessions, |
| 26 | + // plus 100% of sessions with an error |
| 27 | + replaysSessionSampleRate: 0.1, |
| 28 | + replaysOnErrorSampleRate: 1.0, |
| 29 | + }); |
| 30 | +} |
| 31 | + |
| 32 | +const app = document.getElementById("app"); |
| 33 | + |
| 34 | +if (!app) throw new Error("No #app element found in the DOM."); |
| 35 | + |
| 36 | +render(() => <App />, app); |
| 37 | +``` |
| 38 | + |
| 39 | +Once you've done this, the SDK will automatically capture unhandled errors and promise rejections, and monitor performance in the client. |
| 40 | + |
| 41 | +It's also possible to add Client-Side routing to your app with [Solid-Router](https://docs.solidjs.com/guides/how-to-guides/routing-in-solid/solid-router) without changing any additional settings. As long as you use the default HTML History API to handle routing. |
| 42 | + |
| 43 | +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/solid/usage). |
0 commit comments