Installation
Install the SvelteKit SDK, add the Vite plugin, and wire server hooks. Use adapter-node on a long-running Node process. The plugin instruments SSR for the runtime recorder.
- 1
Install the package
Add the SvelteKit SDK to your app. It covers the Vite plugin and server hooks.
npm install @rasputin-ai/sveltekit - 2
Add the Vite plugin
Add the plugin before
sveltekit(). It instruments SSR modules. PassprojectApiKeyso the plugin can upload the server instrumentation manifest.How to set the release at build timeimport { sveltekit } from '@sveltejs/kit/vite'; import { defineConfig } from 'vite'; import { rasputin } from '@rasputin-ai/sveltekit/vite'; export default defineConfig(({ command }) => ({ plugins: [ rasputin({ enabled: command === 'build', release: process.env.RASPUTIN_RELEASE!, projectApiKey: process.env.RASPUTIN_PROJECT_API_KEY, }), sveltekit(), ], })); - 3
Add server hooks
hooks.server.tsreports errors and scopes HTTP. Passbuildingduring prerender. Forward existinginit,handle, orhandleErrorvia the matching options.import { rasputinServerHooks } from '@rasputin-ai/sveltekit'; import { node } from '@rasputin-ai/sveltekit/runtime/node'; import { building } from '$app/environment'; const server = node({ dsn: process.env.RASPUTIN_DSN!, projectApiKey: process.env.RASPUTIN_PROJECT_API_KEY!, release: process.env.RASPUTIN_RELEASE!, environment: 'production', }); const rasputin = rasputinServerHooks({ server, building, }); export const init = rasputin.init; export const handle = rasputin.handle; export const handleError = rasputin.handleError; - 4
That's it
Unexpected errors report from server hooks. HTTP is already instrumented for the runtime recorder. Production needs adapter-node. Serverless adapters are not supported.
Tune the runtime recorder
