Sentry SDK for SolidJS #5552
Replies: 7 comments 16 replies
-
@AbhiPrasad are there any updates on this? Would love to see a Sentry SDK built for SolidJS! It's definitely gaining in popularity and this would boost its ecosystem growth. |
Beta Was this translation helpful? Give feedback.
-
Would be great to have Sentry SDK for Solidjs. |
Beta Was this translation helpful? Give feedback.
-
Any updates or roadmaps? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
@davedbase , @AbhiPrasad: if this looks decent enough as a first iteration, let me know and I'll put it in a PR. Solid
This documentation refers to Sentry's SDK version On this page, we get you up and running with Sentry's SDK. Install
ConfigureConfiguration should happen as early as possible in your application's lifecycle. To use the SDK, initialize it in your Solid entry point before bootstrapping your app. In a typical Solid project that is the import { render } from "solid-js/web";
import Entry from "./entry";
import * as Sentry from "@sentry/browser";
import { DEV } from "solid-js";
// this will only initialize your Sentry client in production builds.
if (!DEV) {
Sentry.init({
dsn: "<Sentry DSN>",
integrations: [new Sentry.BrowserTracing(), new Sentry.Replay()],
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,
// Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled
tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/],
// Capture Replay for 10% of all sessions,
// plus for 100% of sessions with an error
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
});
}
const app = document.getElementById("app");
if (!app) throw new Error("No #app element found in the DOM.");
render(
() => (<Entry />),
app
); Once you've done this, the SDK will automatically capture unhandled errors and promise rejections, and monitor performance in the client. It is also possible to add Client-Side routing to your app with Solid-Router without any additional setting. As long as you use the default HTML History API to handle routing. Addd Readable Stack Traces to Errors-- this section should be the exact same -- VerifyThis snippet includes an intentional error, so you can test that everything is working as soon as you set it up. <button
type="button"
onClick={() => {
throw new Error("Sentry Frontend Error");
}}
>
Throw error
</button> This snippet adds a button that throws an error in any Solid component you choose. It is useful for testing. It is recommended to base wrap your app within an Error Boundary: import { ErrorBoundary } from "solid-js";
import Routes from './routes.tsx';
import ErrorFallbackComponent from "./components/error-fallback";
import * as Sentry from "@sentry/browser";
export default function Entry() {
const Routes = useRoutes(ROUTES);
return (
<ErrorBoundary
fallback={(error) => {
Sentry.captureException(error);
return <ErrorFallbackComponent />;
}}
>
<Routes />
</ErrorBoundary>
);
} This will push any caught exceptions within your app to Sentry while allowing your app to display a user-friendly feedback and to recover from it. |
Beta Was this translation helpful? Give feedback.
-
@AbhiPrasad do you have any plans on adding SolidStart, now that it has reached v1.0 (RC)? |
Beta Was this translation helpful? Give feedback.
-
Lovely to see work on this, and also for SolidStart. Just got back into webdev and decided to go for SolidStart/SolidJS and it is ridiculously easy to work with and works astoundingly well for such an early project, and after a long time of react I finally feel I found something that is superior. Sentry should really, really prioritize Solid and SolidStart, it is a sound business decision and good strategical place to be. |
Beta Was this translation helpful? Give feedback.
-
Update: We are working on this! See #12142
https://www.solidjs.com/
Publish an offical SolidJS Sentry SDK -
@sentry/solid-js
All the goodies you expect out of a Sentry SDK.
Update: @atilafassina wrote some docs for Sentry for using Solid - please give it a read.
Tracking issue for SolidStart support #11293
Please comment/react to this post if you would like to see this - that helps us prioritize this work.
Beta Was this translation helpful? Give feedback.
All reactions