{"_id":"@addilytics/sveltekit","name":"@addilytics/sveltekit","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@addilytics/sveltekit","version":"0.0.1","description":"SvelteKit server analytics and bundled navigation tracking.","type":"module","license":"MIT","publishConfig":{"access":"public"},"engines":{"node":">=20"},"main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./browser":{"types":"./dist/browser.d.ts","default":"./dist/browser.js"}},"dependencies":{"addilytics":"0.0.1"},"peerDependencies":{"@sveltejs/kit":"^2.0.0","svelte":"^4.0.0 || ^5.0.0"},"devDependencies":{"@sveltejs/kit":"^2.63.0","svelte":"^5.0.0","typescript":"^6.0.3"},"scripts":{"build":"tsc -p tsconfig.json","check":"tsc -p tsconfig.json --noEmit","test":"pnpm build && node --test test/*.test.mjs"},"_nodeVersion":"26.0.0","_id":"@addilytics/sveltekit@0.0.1","dist":{"integrity":"sha512-mfzjXDHjithhMaTYWeCdDFzVCnxwY3nlSVqHlgbfnEjwLft3vooJVtWxmZb1dMUW8vV2MZx5PxgIy9ahUQnBug==","shasum":"4069b8b912fa922cabf082ad9f77520a2d799e40","tarball":"https://registry.npmjs.org/@addilytics/sveltekit/-/sveltekit-0.0.1.tgz","fileCount":8,"unpackedSize":11283,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHLOVx0gaeH/ql9sXu0lYAVw2ru55R/ZbhIEzI/puvqzAiEAlp56c3YQF6Yiu+QdqPXeBoHqsq1/ej2M++a2xGDVW1Y="}]},"_npmUser":{"name":"embedvr","email":"npm@helium.email"},"directories":{},"maintainers":[{"name":"embedvr","email":"npm@helium.email"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sveltekit_0.0.1_1789127078995_0.5667944113131198"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-11T11:44:38.762Z","0.0.1":"2026-09-11T11:44:39.139Z","modified":"2026-09-11T11:44:39.433Z"},"maintainers":[{"name":"embedvr","email":"npm@helium.email"}],"description":"SvelteKit server analytics and bundled navigation tracking.","license":"MIT","readme":"# @addilytics/sveltekit\n\n```ts\n// src/hooks.server.ts\nimport { addilytics } from '@addilytics/sveltekit';\nimport { env } from '$env/dynamic/private';\n\nexport const handle = addilytics({\n\tendpoint: 'https://addilytics.example',\n\tsiteKey: env.ADDILYTICS_KEY\n});\n```\n\nCompose with `sequence()` if you already have a handle. Put authentication or session handles first,\nthen Addilytics, then application handles that route requests or change responses.\n\n```ts\nimport { sequence } from '@sveltejs/kit/hooks';\n\nconst analyticsHandle = addilytics({\n\t...options,\n\tuser: (event) => event.locals.userId\n});\n\nexport const handle = sequence(sessionHandle, analyticsHandle, applicationHandle);\n```\n\nThis order matters in hybrid and client modes. The Addilytics handle answers relay requests itself,\nso handles after it do not run for `POST /__addilytics`. Resolve identity from `event.locals` only\nwhen an earlier handle populates it. A resolver that reads the raw request can stay inside the\nAddilytics options.\n\nSet `trustProxy: true` only when your hosting platform overwrites forwarded IP and country headers.\nSvelteKit's `getClientAddress()` remains the preferred IP source.\n\nThe handle records every eligible HTML document request that reaches SvelteKit, not only the first\nrequest in a session. Reloads and full-page navigations count on the server. Prerendered pages, CDN\ncache hits, client-side route changes that don't request HTML, and browser back-forward cache\nrestores don't run it.\n\n## Client-side navigation\n\nUse hybrid mode to keep the initial document on the server and record later client-side navigation:\n\n```ts\n// src/hooks.server.ts\nimport { addilytics } from '@addilytics/sveltekit';\nimport { env } from '$env/dynamic/private';\n\nexport const handle = addilytics({\n\tendpoint: 'https://addilytics.example',\n\tmode: 'hybrid',\n\tsiteKey: env.ADDILYTICS_KEY\n});\n```\n\nThe handle intercepts `POST /__addilytics` before calling `resolve`. Register the browser helper\nonce in the root layout. It uses SvelteKit's `afterNavigate` hook, which runs after navigation has\ncommitted.\n\n```svelte\n<!-- src/routes/+layout.svelte -->\n<script lang=\"ts\">\n\timport { trackAddilyticsNavigations } from '@addilytics/sveltekit/browser';\n\n\ttrackAddilyticsNavigations({ mode: 'hybrid' });\n</script>\n\n<slot />\n```\n\nUse `mode: 'client'` in both files when the browser should record the initial view too. Client mode\nturns off automatic server pageviews while keeping custom server events available. The server and\nbrowser modes must match. If the server uses `relayPath`, pass the same path as `endpoint` to the\nbrowser helper.\n\nYour app bundles the browser helper; Addilytics does not load a hosted or CDN script. The browser\nsends only a generated event ID, timestamp, path, campaign query, and referrer to the same-origin\nrelay. The site key remains in `hooks.server.ts`. The relay rejects cross-origin requests,\nunexpected methods and content types, malformed fields, oversized bodies, and stale timestamps.\n\nBack-forward cache restores are recorded. Hash-only changes are ignored unless you set\n`trackHashChanges: true`.\n","readmeFilename":"","_rev":"1-5c34420805f8763b4fd285be2f113e9c"}