{"_id":"@allstak/svelte","name":"@allstak/svelte","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@allstak/svelte","version":"0.1.0","description":"Official AllStak SDK for Svelte and SvelteKit — automatic error tracking, structured logs, distributed tracing, and observability on the client and the server (SSR).","keywords":["svelte","sveltekit","observability","error-tracking","logging","monitoring","tracing","ssr","allstak"],"type":"module","homepage":"https://allstak.sa","repository":{"type":"git","url":"git+https://github.com/AllStak/allstak-svelte.git"},"bugs":{"url":"https://github.com/AllStak/allstak-svelte/issues"},"license":"MIT","author":{"name":"AllStak","email":"sdk@allstak.sa"},"main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./hooks/client":{"types":"./dist/hooks/client.d.ts","import":"./dist/hooks/client.js","require":"./dist/hooks/client.cjs"},"./hooks/server":{"types":"./dist/hooks/server.d.ts","import":"./dist/hooks/server.js","require":"./dist/hooks/server.cjs"},"./vite":{"types":"./dist/vite.d.ts","import":"./dist/vite.js","require":"./dist/vite.cjs"},"./package.json":"./package.json"},"scripts":{"build":"tsup","typecheck":"tsc --noEmit","test":"vitest run"},"peerDependencies":{"svelte":"^4.0.0 || ^5.0.0","@sveltejs/kit":"^1.0.0 || ^2.0.0","vite":">=4.0.0"},"peerDependenciesMeta":{"svelte":{"optional":true},"@sveltejs/kit":{"optional":true},"vite":{"optional":true}},"dependencies":{"@allstak/js":"^0.3.0"},"devDependencies":{"@sveltejs/kit":"^2.5.0","@types/node":"^22.0.0","svelte":"^5.0.0","tsup":"^8.0.0","typescript":"^5.4.0","vite":"^5.4.0","vitest":"^2.1.0"},"publishConfig":{"access":"public","provenance":true,"registry":"https://registry.npmjs.org/"},"_id":"@allstak/svelte@0.1.0","_integrity":"sha512-4tkJ9+x7G0BCTcnn8w4yR345fPQnC8Ss8gWjBgSaJk3cLeX/sqZzjP4b9sgJ1KpTggj6nzOzccCx9GCnxpepqA==","_resolved":"/home/runner/work/allstak-svelte/allstak-svelte/pack/allstak-svelte-0.1.0.tgz","_from":"file:/home/runner/work/allstak-svelte/allstak-svelte/pack/allstak-svelte-0.1.0.tgz","_nodeVersion":"20.20.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-4tkJ9+x7G0BCTcnn8w4yR345fPQnC8Ss8gWjBgSaJk3cLeX/sqZzjP4b9sgJ1KpTggj6nzOzccCx9GCnxpepqA==","shasum":"92fe89ff0a4a6b82afc55d1a1127a0b7d7ad1b88","tarball":"https://registry.npmjs.org/@allstak/svelte/-/svelte-0.1.0.tgz","fileCount":38,"unpackedSize":209319,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@allstak%2fsvelte@0.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIFsE+It2iwMtL96y2jJ0g8X+WZg1Etqej7Fhz9BrPbbKAiEAi087o0ye8OPakGsJE/Jz/E89ADhSf+ETOv6Y/FVAUmg="}]},"_npmUser":{"name":"allstak-","email":"hello@allstak.sa"},"directories":{},"maintainers":[{"name":"allstak-","email":"hello@allstak.sa"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/svelte_0.1.0_1780101728977_0.8346735597826211"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-30T00:42:08.779Z","0.1.0":"2026-05-30T00:42:09.157Z","modified":"2026-05-30T00:42:09.635Z"},"maintainers":[{"name":"allstak-","email":"hello@allstak.sa"}],"description":"Official AllStak SDK for Svelte and SvelteKit — automatic error tracking, structured logs, distributed tracing, and observability on the client and the server (SSR).","homepage":"https://allstak.sa","keywords":["svelte","sveltekit","observability","error-tracking","logging","monitoring","tracing","ssr","allstak"],"repository":{"type":"git","url":"git+https://github.com/AllStak/allstak-svelte.git"},"author":{"name":"AllStak","email":"sdk@allstak.sa"},"bugs":{"url":"https://github.com/AllStak/allstak-svelte/issues"},"license":"MIT","readme":"# @allstak/svelte\n\nOfficial AllStak SDK for **Svelte** and **SvelteKit** — automatic error\ntracking, structured logs, distributed tracing, HTTP monitoring, breadcrumbs,\nsessions, and Core Web Vitals on both the client and the server (SSR).\n\nIt is a thin, high-quality wrapper over [`@allstak/js`](https://www.npmjs.com/package/@allstak/js):\nafter a two-file setup plus one Vite line you get automatic instrumentation,\nand the full manual API stays available for the cases that need it.\n\n## Install\n\n```bash\nnpm install @allstak/svelte @allstak/js\n# or: pnpm add @allstak/svelte @allstak/js\n# or: yarn add @allstak/svelte @allstak/js\n```\n\n## Setup (2 hook files + 1 Vite line)\n\nYou get full client + server observability by wiring two SvelteKit hook files\nand adding one plugin to your Vite config.\n\n### 1. `src/hooks.client.ts`\n\n```ts\nimport { initAllStak, handleErrorWithAllStak } from '@allstak/svelte/hooks/client';\n\ninitAllStak({\n  apiKey: import.meta.env.VITE_ALLSTAK_API_KEY,\n  environment: import.meta.env.MODE,\n  release: import.meta.env.VITE_APP_VERSION,\n});\n\nexport const handleError = handleErrorWithAllStak();\n```\n\n`initAllStak` boots the SDK, stamps the Svelte identity, and starts Core Web\nVitals automatically. `handleError` reports unhandled client errors with route\ncontext.\n\n### 2. `src/hooks.server.ts`\n\n```ts\nimport { allstakHandle, handleErrorWithAllStak } from '@allstak/svelte/hooks/server';\n\nexport const handle = allstakHandle();\nexport const handleError = handleErrorWithAllStak();\n```\n\n`allstakHandle` initializes the server SDK once — reading `ALLSTAK_API_KEY`\n(and optional `ALLSTAK_HOST`, `ALLSTAK_ENVIRONMENT`, `ALLSTAK_RELEASE`) from the\nenvironment — then for every request it opens an `http.server` span, records an\ninbound HTTP request, continues the caller's distributed trace, and sets a\nresponse trace header.\n\nCompose it with your own hooks using SvelteKit's `sequence`:\n\n```ts\nimport { sequence } from '@sveltejs/kit/hooks';\nimport { allstakHandle } from '@allstak/svelte/hooks/server';\n\nexport const handle = sequence(allstakHandle(), myOwnHandle);\n```\n\n### 3. `vite.config.ts`\n\n```ts\nimport { sveltekit } from '@sveltejs/kit/vite';\nimport { defineConfig } from 'vite';\nimport { allstakSvelteKit } from '@allstak/svelte/vite';\n\nexport default defineConfig({\n  plugins: [\n    sveltekit(),\n    allstakSvelteKit({\n      // optional: upload source maps so production stack traces are readable\n      sourceMaps: {\n        enabled: true,\n        release: process.env.APP_VERSION,\n        token: process.env.ALLSTAK_UPLOAD_TOKEN,\n      },\n    }),\n  ],\n});\n```\n\nThe plugin injects SSR trace markers so the browser continues the server's\ntrace, exposes a tree-shakeable `__ALLSTAK_TRACING__` flag, and (when\n`sourceMaps.enabled`) wires source-map debug-id injection and upload.\n\n## Navigation spans + breadcrumbs\n\n`$app/navigation` is only importable inside the component tree, so wire\nnavigation instrumentation once from your root layout:\n\n```svelte\n<!-- src/routes/+layout.svelte -->\n<script lang=\"ts\">\n  import { beforeNavigate, afterNavigate } from '$app/navigation';\n  import { instrumentNavigation } from '@allstak/svelte';\n\n  instrumentNavigation({ beforeNavigate, afterNavigate });\n</script>\n\n<slot />\n```\n\nEvery navigation now drops a breadcrumb and opens a `navigation` span finished\nwhen the next page settles.\n\n## Error boundaries (Svelte 5)\n\n```svelte\n<script lang=\"ts\">\n  import { createErrorBoundaryHandler } from '@allstak/svelte';\n  const onerror = createErrorBoundaryHandler({ source: 'Dashboard' });\n</script>\n\n<svelte:boundary {onerror}>\n  <RiskyWidget />\n  {#snippet failed(error, reset)}\n    <button onclick={reset}>Try again</button>\n  {/snippet}\n</svelte:boundary>\n```\n\nFor Svelte 4, or any manual `try/catch`, use `captureComponentError(error)`.\n\n## Manual API\n\nThe full `@allstak/js` surface is re-exported, so anything you can do with the\ncore SDK you can do from `@allstak/svelte`:\n\n```ts\nimport { AllStak, setUser, setTag } from '@allstak/svelte';\n\nsetUser({ id: 'u-123', email: 'user@example.com' });\nsetTag('plan', 'pro');\n\nAllStak.captureMessage('checkout started', 'info');\nAllStak.addBreadcrumb({ type: 'ui.click', message: 'Pay now', level: 'info' });\n\nconst span = AllStak.startSpan('checkout.flow', { description: 'review → pay' });\nspan.setTag('flow', 'web');\nspan.finish('ok');\n\nawait AllStak.flush();\n```\n\nInside a `+page.server.ts` `load` or a `+server.ts` endpoint, import the same\nAPI and add custom spans, logs, or DB-query telemetry — they are correlated\nwith the active request's trace automatically:\n\n```ts\nimport { AllStak } from '@allstak/svelte';\n\nexport async function load() {\n  AllStak.log.info('loading dashboard');\n  // ... your work; outbound HTTP / DB calls join the request trace\n  return { ok: true };\n}\n```\n\n## What you get automatically\n\n| Signal | Client | Server (SSR) |\n| --- | --- | --- |\n| Uncaught errors / unhandled rejections | ✅ (`handleError` + core globals) | ✅ (`handleError`) |\n| Inbound HTTP requests | — | ✅ (per-request row) |\n| Outbound HTTP requests | ✅ (core fetch instrumentation) | ✅ (core fetch instrumentation) |\n| Spans / distributed traces | ✅ (navigation) | ✅ (`http.server` per request) |\n| Trace propagation | ✅ (continues SSR trace) | ✅ (`traceparent` in/out) |\n| Logs | ✅ | ✅ |\n| Breadcrumbs | ✅ (navigation, clicks) | ✅ |\n| Sessions | ✅ | ✅ |\n| Core Web Vitals | ✅ | — |\n| DB queries | — | ✅ (manual / core DB integration) |\n\nEvery piece is individually toggleable and on by default. Optional framework\npieces degrade gracefully — a missing key, a missing `$app/navigation`, or a\nstatic build never throws.\n\n## Configuration\n\n`initAllStak` / `allstakHandle` accept every `@allstak/js` `init` option\n(`apiKey`, `host`, `environment`, `release`, `dist`, sampling, filters, offline\nqueue, `beforeSend`, …). The default ingest host is `https://api.allstak.sa`\nand can be overridden with the `host` option.\n\n## License\n\nMIT © AllStak\n","readmeFilename":"README.md","_rev":"1-36fd92f781bc9f6123428b142b431337"}