{"_id":"@14four/analytics","_rev":"6-bbc57d90010dad0d79f0c40c44481422","name":"@14four/analytics","dist-tags":{"latest":"0.2.1"},"versions":{"0.1.1":{"name":"@14four/analytics","version":"0.1.1","_id":"@14four/analytics@0.1.1","maintainers":[{"name":"14four-technical","email":"technical@14four.com"}],"dist":{"shasum":"cbde2268db30531d9f586e3b19bf8c37b697ccad","tarball":"https://registry.npmjs.org/@14four/analytics/-/analytics-0.1.1.tgz","fileCount":5,"integrity":"sha512-SLsCdqP4EpYxKskgXFjAfz8VXwRbNDD8snSKyJDyZgZZVrmJlfQUrAzYLXFyz6y/0U6mmfhaqQM+GR9QMlW/Jg==","signatures":[{"sig":"MEMCIF1miejYXHARyezWDRxRMT90cJBBoqcwvwUxAcv2QzlwAh8VcmL/NayPEGs4AdQS5xSSFgztXHopKE/+t0HR0G7l","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":14596},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"97c75ba5dbc658fb8aeab9fdca8d463abcdc8b55","scripts":{"build":"tsup","prepare":"tsup","release":"npm run build && npm publish --access public"},"_npmUser":{"name":"14four-technical","email":"technical@14four.com"},"_npmVersion":"10.9.2","description":"14four Analytics SDK — works in Node.js and browser","directories":{},"_nodeVersion":"23.10.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/analytics_0.1.1_1776116150630_0.35554381101355315","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@14four/analytics","version":"0.1.2","_id":"@14four/analytics@0.1.2","maintainers":[{"name":"14four-technical","email":"technical@14four.com"}],"dist":{"shasum":"71f54f5185e54f2aa713cf8a1f11388baac3fcd1","tarball":"https://registry.npmjs.org/@14four/analytics/-/analytics-0.1.2.tgz","fileCount":5,"integrity":"sha512-RoNUvyjTVRWf5EEBVWBBjci99p/ahvRfZeNJfaWgcpQH7kC+km+JkQVmirCwR3JNek6hrhZHqt7l7gUVlgqfqQ==","signatures":[{"sig":"MEQCICb8tCQyAes5A3sDdH+Lug4Zxb59LLCZ1FC52I069NuhAiBWCDFmxzHd+S0ynCwbu4b5ao3e1mZ9jrSKmD3JDeDdJQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":14272},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"a65d75d5ed75c5319c1977723faf73b9cc1532b7","scripts":{"build":"tsup","prepare":"tsup","release":"npm run build && npm publish --access public"},"_npmUser":{"name":"14four-technical","email":"technical@14four.com"},"_npmVersion":"10.9.2","description":"14four Analytics SDK — works in Node.js and browser","directories":{},"_nodeVersion":"23.10.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/analytics_0.1.2_1776273814246_0.9048291996565556","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"@14four/analytics","version":"0.1.3","_id":"@14four/analytics@0.1.3","maintainers":[{"name":"14four-technical","email":"technical@14four.com"}],"dist":{"shasum":"f6597be95218c136079ce358ce5e428a2d50a5a7","tarball":"https://registry.npmjs.org/@14four/analytics/-/analytics-0.1.3.tgz","fileCount":5,"integrity":"sha512-9nWVVcoQy1LHlA9/P/wKkqafNk8BPiJ+nJmQWbFvUv2qwmNBFZxwTsWR0gf1cXUy3FVUbfLHNYesFEVszVrZfw==","signatures":[{"sig":"MEQCIHhbffNfln1ftFROLs1U0szXANGRKHUVAPgEzJ2E5Xt5AiBvG11zZZYCjgXEdXbbrrecXQoMmybwHMiEGrqaPKxS9w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":15658},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"fd7ba36f3d350274985353ac74e76943b9df67d5","scripts":{"build":"tsup","prepare":"tsup","release":"npm run build && npm publish --access public"},"_npmUser":{"name":"14four-technical","email":"technical@14four.com"},"_npmVersion":"10.9.2","description":"14four Analytics SDK — works in Node.js and browser","directories":{},"_nodeVersion":"23.10.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/analytics_0.1.3_1776356648743_0.26818536836516693","host":"s3://npm-registry-packages-npm-production"}},"0.1.4":{"name":"@14four/analytics","version":"0.1.4","_id":"@14four/analytics@0.1.4","maintainers":[{"name":"14four-technical","email":"technical@14four.com"}],"dist":{"shasum":"64d38ec4aa7fe73dc9dfe4208a6a5cea374347ef","tarball":"https://registry.npmjs.org/@14four/analytics/-/analytics-0.1.4.tgz","fileCount":5,"integrity":"sha512-FLnSyZbqtKt7yC+4PFW1+gM9OVtoJ8ifZw9ogdXpEZDP+HGth/vN9eitQiEN382D4/pPx8Sa0ave8LSiOCOl0A==","signatures":[{"sig":"MEUCIQDRIb1qtLEMhcZl0q80kl1d7I3t7F9+ltmuAseuwWiarQIgXQBBcdSJ46/LGpKnMw0bWvBaeYg7CRrYDTtKmbXacmA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":15632},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"498dac0c3f31df8a75011b90add1200cf4dde84b","scripts":{"build":"tsup","prepare":"tsup","release":"npm run build && npm publish --access public"},"_npmUser":{"name":"14four-technical","email":"technical@14four.com"},"_npmVersion":"10.9.2","description":"14four Analytics SDK — works in Node.js and browser","directories":{},"_nodeVersion":"23.10.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/analytics_0.1.4_1776359306388_0.23899177460762155","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@14four/analytics","version":"0.2.0","_id":"@14four/analytics@0.2.0","maintainers":[{"name":"14four-technical","email":"technical@14four.com"}],"dist":{"shasum":"e3c8dfadb8392c400001a948107e7a1f7124246d","tarball":"https://registry.npmjs.org/@14four/analytics/-/analytics-0.2.0.tgz","fileCount":5,"integrity":"sha512-q6jutPbJ7tk4CVxDmUgqS5oq6Pwu9adnwR7VWWxGjnziOz7TX9u8AaVrPFeIsKB8oVw2eLjqaDzbI7U0vQ03Vg==","signatures":[{"sig":"MEYCIQCZURi6E/Kow/CgJkmFpudyYWpDDNCh++CCaktBeBsSygIhALtDQbADLWBmrJE9wFHwqEG14HXlAjb/g6RC8M+4SwuZ","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18948},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"47d9d4a0a0b44855249d95873b021e75e9d56668","scripts":{"build":"tsup","prepare":"tsup","release":"npm run build && npm publish --access public"},"_npmUser":{"name":"14four-technical","email":"technical@14four.com"},"_npmVersion":"10.9.2","description":"14four Analytics SDK — works in Node.js and browser","directories":{},"_nodeVersion":"23.10.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/analytics_0.2.0_1780676055983_0.4277497094258569","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"@14four/analytics","version":"0.2.1","description":"14four Analytics SDK — works in Node.js and browser","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"scripts":{"build":"tsup","prepare":"tsup","release":"npm run build && npm publish --access public"},"publishConfig":{"access":"public"},"devDependencies":{"tsup":"^8.0.0","typescript":"^5.0.0"},"_id":"@14four/analytics@0.2.1","gitHead":"47d9d4a0a0b44855249d95873b021e75e9d56668","_nodeVersion":"23.10.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-WCk4X2e9QzoSRwbL1O3ub2NkoIkOREBL30tMS/jloGkhNuKkrvVU8g/18x+BCzIksDlY/SfbmXUERHphD74mNw==","shasum":"811be13863fcca3705922606af0f96765fcdb601","tarball":"https://registry.npmjs.org/@14four/analytics/-/analytics-0.2.1.tgz","fileCount":6,"unpackedSize":25155,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBrtYh1KxOgI+d2hYaPr4iCzM5gKsrYRNzsWmQHMw6CDAiEAuFtqoDtU19GJ6h0HxVQzA9gMEJ53V3fnrFuO6Tqa0uk="}]},"_npmUser":{"name":"14four-technical","email":"technical@14four.com"},"directories":{},"maintainers":[{"name":"14four-technical","email":"technical@14four.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/analytics_0.2.1_1780676997015_0.05255379999793708"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-13T21:35:50.534Z","modified":"2026-06-05T16:29:57.318Z","0.1.1":"2026-04-13T21:35:50.752Z","0.1.2":"2026-04-15T17:23:34.377Z","0.1.3":"2026-04-16T16:24:08.895Z","0.1.4":"2026-04-16T17:08:26.533Z","0.2.0":"2026-06-05T16:14:16.111Z","0.2.1":"2026-06-05T16:29:57.154Z"},"description":"14four Analytics SDK — works in Node.js and browser","maintainers":[{"name":"14four-technical","email":"technical@14four.com"}],"readme":"# @14four/analytics\n\nPrivacy-first analytics SDK for Node.js and the browser. No cookies, no persistent identifiers.\n\n## Installation\n\n```bash\nnpm install @14four/analytics\n```\n\n---\n\n## Browser usage\n\nPass your public `appId` to instantiate. The SDK auto-collects referrer, screen dimensions, page title, language, and UTM parameters on every event.\n\n```ts\nimport Analytics from \"@14four/analytics\";\n\nconst analytics = new Analytics({\n  appId: \"your_app_id\",\n  baseUrl: \"https://your-ingest-url.com\", // optional, defaults to same-origin\n});\n\n// Basic pageview\nanalytics.track(\"page_view\");\n\n// With custom properties\nanalytics.track(\"cta_click\", {\n  props: { button: \"hero\", variant: \"A\" },\n});\n\n// Override the URL (useful for SPAs with virtual pageviews)\nanalytics.track(\"page_view\", {\n  url: \"/virtual/route\",\n});\n```\n\n### Browser auto-collected fields\n\nThese are always captured automatically — no configuration required:\n\n| Field | Source |\n|---|---|\n| `url` | `window.location.href` |\n| `referrer` | `document.referrer` |\n| `screen_width` | `window.screen.width` |\n| `screen_height` | `window.screen.height` |\n| `page_title` | `document.title` |\n| `language` | `navigator.language` |\n| `utm_source` | URL search params |\n| `utm_medium` | URL search params |\n| `utm_campaign` | URL search params |\n| `utm_term` | URL search params |\n| `utm_content` | URL search params |\n| `engagement_time_msec` | Accumulated visible time since last track call |\n\nThe SDK also fires an automatic `engagement` event via `navigator.sendBeacon` when the page unloads, capturing total time the page was visible.\n\n### Browser track options\n\n```ts\nanalytics.track(\"event_name\", {\n  url?: string;                        // Override auto-collected URL\n  props?: Record<string, string>;      // Custom properties (see below)\n});\n```\n\n---\n\n## Node.js (server-side) usage\n\nPass your secret API key to instantiate. The `user_id` field is required on every server-side event and is used directly as the visitor identifier (no hashing).\n\n```ts\nimport Analytics from \"@14four/analytics\";\n\nconst analytics = new Analytics({\n  apiKey: \"sk_live_...\",\n  baseUrl: \"https://your-ingest-url.com\", // optional\n});\n\n// Basic event\nawait analytics.track(\"signup\", { user_id: \"u_123\" });\n\n// With all available options\nawait analytics.track(\"purchase\", {\n  user_id: \"u_123\",\n  app_id: \"your_app_id\",   // required if your key covers multiple apps\n  url: \"https://example.com/checkout\",\n  referrer: \"https://google.com\",\n  utm_source: \"newsletter\",\n  utm_medium: \"email\",\n  utm_campaign: \"spring_sale\",\n  utm_term: \"analytics\",\n  utm_content: \"banner\",\n  props: { plan: \"pro\", seats: \"5\" },\n});\n```\n\n### Server track options\n\n```ts\nanalytics.track(\"event_name\", {\n  user_id: string;           // Required — used as the visitor identifier\n  app_id?: string;           // App ID (if key covers multiple apps)\n  url?: string;\n  referrer?: string;\n  utm_source?: string;\n  utm_medium?: string;\n  utm_campaign?: string;\n  utm_term?: string;\n  utm_content?: string;\n  props?: Record<string, string>;\n});\n```\n\n---\n\n## Custom properties\n\nBoth browser and server modes support a `props` object for attaching arbitrary metadata to events. Values must be strings.\n\n```ts\nanalytics.track(\"video_played\", {\n  // browser: user_id not needed\n  props: {\n    video_id: \"abc123\",\n    duration_sec: \"142\",\n    quality: \"1080p\",\n  },\n});\n```\n\nLimits: max 20 keys, key length ≤ 50 chars, value length ≤ 500 chars.\n\n---\n\n## Dev mode\n\nPass `dev: true` to suppress all network requests and log events to the console instead. Useful during local development to verify your instrumentation without polluting production data.\n\n```ts\nconst analytics = new Analytics({\n  appId: \"your_app_id\",\n  dev: true,\n});\n\nanalytics.track(\"page_view\");\n// [Analytics Dev] \"page_view\" (browser)\n// ┌──────────────────┬──────────────────────────┐\n// │     (index)      │          Values          │\n// ├──────────────────┼──────────────────────────┤\n// │   event_name     │       'page_view'        │\n// │     app_id       │      'your_app_id'       │\n// │       url        │  'http://localhost:3000/' │\n// │    referrer      │           ''             │\n// │  screen_width    │          '1512'          │\n// └──────────────────┴──────────────────────────┘\n```\n\nDev mode works for both `appId` (browser) and `apiKey` (server) instantiation.\n","readmeFilename":"README.md"}