SvelteKit Support #5838
Replies: 19 comments 81 replies
-
I would like a lot the aforementioned SvelteKit support :) Until then, do you have a small quick-n-dirty howto to get it running economy class style? |
Beta Was this translation helpful? Give feedback.
-
Would be great to have SvelteKit support! |
Beta Was this translation helpful? Give feedback.
-
SvelteKit is in release candidate phase for 1.0. Once this is out, and stable, I think it is fair for us/Sentry to consider providing first class support. So we would just need to define what that is exactly. Should it work through the node package, similar to NextJS?
These are all with a question mark. Curious what would be the most important/most valuable for Svelte devs to see in Sentry |
Beta Was this translation helpful? Give feedback.
-
I was also wondering atleast a small guide to enable sourcemaps & a clean client + server setup for sveltekit. Hopefully I'll make one if I get some time in the coming weeks. |
Beta Was this translation helpful? Give feedback.
-
For those who are following this issue and need help with sourcemaps, we recently revamped our support here. We now have bundler plugins for https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/ |
Beta Was this translation helpful? Give feedback.
-
SvelteKit 1.0 has been announced! |
Beta Was this translation helpful? Give feedback.
-
Hey folks, I had some time over the holidays and managed to come up with some first strategies on how to use the current Sentry SDKs for SvelteKit. So here are some instructions on how to get started. DisclaimerPlease keep in mind that this is not yet complete and that there's no guarantee that this works in every situation. There are probably some things we could do better here, so please feel free to share your experiences. Also, I've only used what's publicly available, so this is not a new SDK something that goes into this direction. Get StartedInstall the Svelte and Node SDKs: npm install --save @sentry/svelte @sentry/node Initializing the SDKsHere, one of the challenges is to initialize the SDK as early as possible, both on client and server. The best I came up with was to leverage SvelteKit's hooks, to initialize the SDKs and catch errors: Server-sideHere we can initialize the Node SDK for the server side:
import * as SentryNode from '@sentry/node';
import '@sentry/tracing';
SentryNode.init({
dsn: '__DSN__',
tracesSampleRate: 1.0,
// Add the Http integration for tracing
integrations: [new SentryNode.Integrations.Http()]
});
SentryNode.setTag('svelteKit', 'server');
// use handleError to report errors during server-side data loading
export const handleError = (({ error, event }) => {
SentryNode.captureException(error, { contexts: { sveltekit: { event } } });
return {
message: error.message,
};
}) satisfies HandleServerError; Client-sideHere we can intialize the Svelte SDK which will only run on the client: import * as SentrySvelte from '@sentry/svelte';
import { BrowserTracing } from '@sentry/tracing';
SentrySvelte.init({
dsn: '__DSN__',
integrations: [new BrowserTracing()],
tracesSampleRate: 1.0,
});
SentrySvelte.setTag('svelteKit', 'browser');
// This will catch errors in `load` functions from `+page.ts` files
export const handleError = (({ error, event }) => {
SentrySvelte.captureException(error, { contexts: { sveltekit: { event } } });
return {
message: error.message
};
}) satisfies HandleClientError; LimitationsThis should give you error monitoring in most situations. However, source maps are currently not yet working correctly. I didn't have time to look into this, yet but the high-level plan would be to configure Vite to generate source maps, which should then be uploaded to Sentry. For this, You can use the Sentry Vite Plugin. @ambiguous48 already posted some hints what might be necessary for this to work. |
Beta Was this translation helpful? Give feedback.
-
Yes please! |
Beta Was this translation helpful? Give feedback.
-
Waiting for Sveltekit support in Sentry |
Beta Was this translation helpful? Give feedback.
-
Can't wait for native support for SvelteKit |
Beta Was this translation helpful? Give feedback.
-
Hey folks - need some of your opinions. We're starting to add features to the SDK and wanted to know if we should be automatically hooking into the If we do decide to automatically instrument these, do you want to see errors coming from both (one generated from the server from the I'm leaning toward only instrumenting the When we eventually add performance monitoring, we can link a distributed trace between the execution of an erroring load function and the rendering of a |
Beta Was this translation helpful? Give feedback.
-
Hello everyone, we just released version 7.44.0 with the first alpha version of We'd really appreciate feedback, be it bug reports, UX/DX opinions, or of course thanks and praises 😄 Feel free to reach out in the Sveltekit SDK github issue, or in case of a bug report, please open a new issue. Thanks! |
Beta Was this translation helpful? Give feedback.
-
Hi folks, while working on the SDK, we had a couple of ideas for additional hooks in SvelteKit. I opened a few issues on the SvelteKit repo with more details and a PoC PR:
Please feel free to leave your thoughts in these issues! The bottom line is that with these new hooks, it would be significantly easier for users to integrate the Sentry SDK into their apps. |
Beta Was this translation helpful? Give feedback.
-
Update Time (7.46.0)Hi everyone, we released 7.46.0 today with a bunch of new features for the SvelteKit SDK: Performance Monitoring SupportWith this release, the SDK adds support for performance monitoring in SvelteKit! All it takes to get started is to add a few handlers to SvelteKit hooks and to wrap your The SDK will capture and connect performance data on the client and on the server. This will help you inspect the performance of your page loads, navigations, server responses, API routes, Client-side pageload transaction: Server-side
|
Beta Was this translation helpful? Give feedback.
-
I've followed the instructions to integrate the new SvelteKit plugin and I am seeing the following warning in my console (locally, running the dev server):
The readme or the docs don't say anything about this. What do I need to do? Can I ignore this? |
Beta Was this translation helpful? Give feedback.
-
Hi everyone, I'm adding sentry to a standard sveltekit application hosted on Vercel. The sentry wizard creates/populates hooks.server and hooks.client files, all good. However, the wizard does NOT populate Environment and Release varaibles in Sentry.Init() for hooks.server.ts the solution was easy enough:
However, I am completely stuck on how to achieve the same in hooks.client.js For the environment, I can work around it by manually adding a PUBLIC_ENVIRONMENT variable and populating as needed. Anyone got any ideas or dealt with this recently? |
Beta Was this translation helpful? Give feedback.
-
Is there any update on getting this to work in an edge computing runtime? Eg: on Vercel's edge functions? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Hi all, I am new in the domain and I need your help on this issue. I am making a to-do list and when I check the box on one of my items it is supposed to send it to another folder in my project called 'Completed' client side navigation(SPA) . For info, I am working on Sveltekit. C:/Users/unknow/OneDrive/Desktop/Javascript console/unknow work 2024/javascript-project/sveltekit/todolist/src/routes/+page.svelte:6:9 4 | import { goto } from '$app/navigation'; Also the $app/navigation is highlight in red. Thank you for your help. |
Beta Was this translation helpful? Give feedback.
-
Update: The Sentry SvelteKit SDK has been released!
Hey! Sentry has released a Svelte SDK, but the SDK doesn't have first class support for SvelteKit. If you would like to see this happen, please leave a comment/reaction to this post!
Svelte SDK: https://www.npmjs.com/package/@sentry/svelte
Svelte SDK Initial Roadmap: #5492
Coming Soon Page for SvelteKit
TLDR: Below how to set up with Svelte and Node SDKs
Beta Was this translation helpful? Give feedback.
All reactions