{"_id":"@alitycs/browser-snippet","name":"@alitycs/browser-snippet","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.3":{"name":"@alitycs/browser-snippet","version":"1.0.3","description":"Ultra-lightweight analytics snippet (~1KB) for drop-in integration","main":"dist/snippet.js","types":"dist/snippet.d.ts","scripts":{"build":"cd ../.. && bun run scripts/build-snippet-with-cdn.ts && cd sdks/browser-snippet && bun run build:types","build:dev":"cd ../.. && bun run scripts/build-snippet-with-cdn.ts","build:prod":"cd ../.. && bun run scripts/build-snippet-with-cdn.ts","build:types":"tsc -p tsconfig.build.json","build:watch":"bun build src/snippet.ts --outfile=dist/snippet.js --target=browser --format=iife --sourcemap=inline --watch","test":"bun run build:prod && bun test","test:coverage":"bun run build:prod && bun test --coverage","test:watch":"bun test --watch","test:size":"bun test tests/size.test.ts","dev":"bun run build:watch","type-check":"tsc --noEmit","clean":"rm -rf dist","lint":"eslint src/**/*.ts tests/**/*.ts","lint:fix":"eslint src/**/*.ts tests/**/*.ts --fix","format":"prettier --write src/**/*.ts tests/**/*.ts","format:check":"prettier --check src/**/*.ts tests/**/*.ts"},"keywords":["analytics","snippet","tracking","loader","lightweight","alitycs"],"author":{"name":"Alitycs Team"},"license":"MIT","devDependencies":{"@eslint/js":"^10.0.1","@types/node":"^26.2.0","bun-types":"^1.3.10","eslint":"^10.8.1","globals":"^17.11.0","happy-dom":"^20.11.2","prettier":"^3.9.6","typescript-eslint":"^8.67.0","typescript":"^5.9.3"},"repository":{"type":"git","url":"git+https://github.com/alitycs/alitycs-sdk-js.git","directory":"sdks/browser-snippet"},"homepage":"https://github.com/alitycs/alitycs-sdk-js/tree/main/sdks/browser-snippet#readme","bugs":{"url":"https://github.com/alitycs/alitycs-sdk-js/issues"},"publishConfig":{"access":"public","provenance":true},"_id":"@alitycs/browser-snippet@1.0.3","_integrity":"sha512-xfRaRwbFSzr2zJ2VH162eLSas2QC1sP0H6fr1/GGVQdyfPgFi2udbEPpGXyB+cikzYR270fFIp2Q1Qbh4Nsxkw==","_resolved":"/Volumes/External/alitycs/.codex-tmp/npm-release-v1.0.3/alitycs-browser-snippet-1.0.3.tgz","_from":"file:/Volumes/External/alitycs/.codex-tmp/npm-release-v1.0.3/alitycs-browser-snippet-1.0.3.tgz","_nodeVersion":"24.14.0","_npmVersion":"11.18.0","dist":{"integrity":"sha512-xfRaRwbFSzr2zJ2VH162eLSas2QC1sP0H6fr1/GGVQdyfPgFi2udbEPpGXyB+cikzYR270fFIp2Q1Qbh4Nsxkw==","shasum":"60204fe7e06fdcba5368818ac12823e08eb86f36","tarball":"https://registry.npmjs.org/@alitycs/browser-snippet/-/browser-snippet-1.0.3.tgz","fileCount":19,"unpackedSize":53163,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCLURSH8UBBrHYfUwQCTnt0iELvcs1SGVfBrY7jdPG+VQIhAPdzGJF1vV//aZrDH6YlD0XhK2WMzlRZzl12LceMaheh"}]},"_npmUser":{"name":"alitycs","email":"traivy.tech@gmail.com"},"directories":{},"maintainers":[{"name":"alitycs","email":"traivy.tech@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/browser-snippet_1.0.3_1788087412500_0.6776641025260444"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-30T10:56:52.284Z","1.0.3":"2026-08-30T10:56:52.637Z","modified":"2026-08-30T10:56:52.929Z"},"maintainers":[{"name":"alitycs","email":"traivy.tech@gmail.com"}],"description":"Ultra-lightweight analytics snippet (~1KB) for drop-in integration","homepage":"https://github.com/alitycs/alitycs-sdk-js/tree/main/sdks/browser-snippet#readme","keywords":["analytics","snippet","tracking","loader","lightweight","alitycs"],"repository":{"type":"git","url":"git+https://github.com/alitycs/alitycs-sdk-js.git","directory":"sdks/browser-snippet"},"author":{"name":"Alitycs Team"},"bugs":{"url":"https://github.com/alitycs/alitycs-sdk-js/issues"},"license":"MIT","readme":"# `@alitycs/browser-snippet`\n\nA small, dependency-free browser loader for Alitycs. It installs a temporary `window.alitycs`\nfunction, queues calls made before the full browser SDK is ready, and replays them after loading.\n\n## Installation\n\nBuild from source:\n\n```bash\nbun install --frozen-lockfile\nbun run build\n```\n\nThe generated files are `dist/snippet.js` and `dist/snippet.min.js`. Versioned archives are also\nattached to [GitHub Releases](https://github.com/alitycs/alitycs-sdk-js/releases).\n\nHost `snippet.min.js` on your site or CDN, then include it with a publishable API key:\n\n```html\n<script src=\"/assets/alitycs/snippet.min.js\" data-api-key=\"pk_live_replace_me\" data-auto-capture=\"true\" async></script>\n```\n\nThe loader's default full-SDK URL is pinned at build time to the released browser version:\n`https://cdn.jsdelivr.net/npm/@alitycs/browser@1.0.3/dist/browser.min.js`. Set\n`data-sdk-url` when self-hosting the browser bundle.\n\n## Usage\n\nCalls are safe immediately, even before the full SDK has loaded:\n\n```html\n<script>\n  alitycs('identify', 'usr_123', { plan: 'pro' });\n  alitycs('track', 'signup_completed', { source: 'docs' });\n  alitycs('page', 'Pricing');\n  alitycs('captureError', 'checkout_failed', { provider: 'stripe' });\n</script>\n```\n\nMethod helpers are chainable:\n\n```js\nalitycs.track('cta_clicked', { placement: 'hero' }).page('Checkout');\n```\n\n## Configuration\n\n| Attribute           | Default                          | Description                                                     |\n| ------------------- | -------------------------------- | --------------------------------------------------------------- |\n| `data-api-key`      | required                         | Publishable Alitycs key                                         |\n| `data-sdk-url`      | Alitycs browser CDN URL          | Full browser SDK URL                                            |\n| `data-endpoint`     | `https://api.alitycs.com/events` | Custom worker ingestion endpoint                                |\n| `data-auto-track`   | `true`                           | Queue the initial page event                                    |\n| `data-auto-capture` | `false`                          | Capture the initial page and SPA navigations in the browser SDK |\n| `data-debug`        | `false`                          | Enable loader diagnostics                                       |\n\nThe snippet never calls `/v1/*`; those routes belong to the authenticated analytics read API.\n\n## Loading behavior\n\n1. Parse the current script's `data-*` configuration.\n2. Preserve any calls buffered by an inline bootstrap.\n3. Install the queueing stub and optionally enqueue the initial page event.\n4. Load the full browser SDK immediately when calls are queued, or lazily on interaction/idle.\n5. Replay queued calls once and replace the stub with the real browser API.\n\n## Development\n\n```bash\nbun run type-check\nbun run lint\nbun run format:check\nbun test\nbun run build\n```\n\nThe bundle-size test enforces the compressed size budget, and coverage is gated at 90% lines and\n85% functions.\n\n## License\n\n[MIT](LICENSE)\n","readmeFilename":"README.md","_rev":"1-1eac7bccc58ecd13935801b642e7d02d"}