{"_id":"@activescott/analytics","_rev":"7-f6270cac4c7b1acf64891e73e36cf21e","name":"@activescott/analytics","dist-tags":{"latest":"0.3.4"},"versions":{"0.2.0":{"name":"@activescott/analytics","version":"0.2.0","keywords":["posthog","analytics","react-router","spa","pageview","proxy"],"author":{"name":"Scott Willeke"},"license":"MIT","_id":"@activescott/analytics@0.2.0","maintainers":[{"name":"activescott","email":"scott@willeke.com"}],"homepage":"https://github.com/activescott/js-utils#readme","bugs":{"url":"https://github.com/activescott/js-utils/issues"},"dist":{"shasum":"5c4da1cfee7e125b4cbd51a734bbd448386e767b","tarball":"https://registry.npmjs.org/@activescott/analytics/-/analytics-0.2.0.tgz","fileCount":22,"integrity":"sha512-7VnmR1qAWVvEkY4mXM2qR+Gwca25mQhHqeJRmC//5dcKE70Mp7VmNBC+lCBhO7nxYpeRUmjLBuIxt0W+EHttcw==","signatures":[{"sig":"MEUCIQDVEASNPUvZflkLTu2Aeu4VcRC8Hx+J6GjHIQrjqCfnxQIgGlvNUeAU96ZffsmlfvurX9E+161diQkrxJVmac8oWlo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":30341},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./proxy":{"types":"./dist/proxy.d.ts","import":"./dist/proxy.js"}},"gitHead":"8ac3c8b3585e92a617d695335f708c8ec76cf341","scripts":{"test":"vitest run","build":"tsc -p tsconfig.build.json","typecheck":"tsc --noEmit"},"_npmUser":{"name":"activescott","email":"scott@willeke.com"},"repository":{"url":"git+https://github.com/activescott/js-utils.git","type":"git","directory":"packages/analytics"},"_npmVersion":"10.9.8","description":"PostHog analytics integration for React Router apps — provider, SPA pageview tracking, user identification, and reverse proxy helper","directories":{},"_nodeVersion":"22.23.2","_hasShrinkwrap":false,"devDependencies":{"react":"^19.2.4","vitest":"4.1.10","posthog-js":"^1.351.4","typescript":"^5.9.3","@types/node":"^22","@types/react":"^19.2.14","react-router":"^7.10.1"},"peerDependencies":{"react":">=18","posthog-js":"^1.200.0","react-router":"^7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/analytics_0.2.0_1789002192023_0.3186367049287595","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"@activescott/analytics","version":"0.2.1","keywords":["posthog","analytics","react-router","spa","pageview","proxy"],"author":{"name":"Scott Willeke"},"license":"MIT","_id":"@activescott/analytics@0.2.1","maintainers":[{"name":"activescott","email":"scott@willeke.com"}],"homepage":"https://github.com/activescott/js-utils#readme","bugs":{"url":"https://github.com/activescott/js-utils/issues"},"dist":{"shasum":"4322b05f9501148f9845137c6e277dc375101ada","tarball":"https://registry.npmjs.org/@activescott/analytics/-/analytics-0.2.1.tgz","fileCount":22,"integrity":"sha512-ogF/7Z+LlEgmn74BQucLanhaTTaqokkNxyxUk1D15BIm+tUIuVKQLZYJCSL5i3RWK3UCp/mhCZTjQwOZeTywng==","signatures":[{"sig":"MEQCIGuqNdQyztWT5KufA5snwyn5Ly1zk7YK6H5lny30qfV6AiBT1xeQU5JUUpkBDEX35cjRoxEW2xo4Bj8bTReZuPwlyA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@activescott%2fanalytics@0.2.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":31307},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./proxy":{"types":"./dist/proxy.d.ts","import":"./dist/proxy.js"}},"gitHead":"1311bcd562487c70edcd8a8caab2776f86b6e822","scripts":{"test":"vitest run","build":"tsc -p tsconfig.build.json","typecheck":"tsc --noEmit"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:e21a7151-183d-4cd9-8cd9-a72a9b22fe21"}},"repository":{"url":"git+https://github.com/activescott/js-utils.git","type":"git","directory":"packages/analytics"},"_npmVersion":"11.19.0","description":"PostHog analytics integration for React Router apps — provider, SPA pageview tracking, user identification, and reverse proxy helper","directories":{},"_nodeVersion":"24.20.0","_hasShrinkwrap":false,"devDependencies":{"react":"^19.2.4","vitest":"4.1.10","posthog-js":"^1.351.4","typescript":"^5.9.3","@types/node":"^22","@types/react":"^19.2.14","react-router":"^7.10.1"},"peerDependencies":{"react":">=18","posthog-js":"^1.200.0","react-router":"^7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/analytics_0.2.1_1789003512437_0.43910901384482837","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@activescott/analytics","version":"0.3.0","keywords":["posthog","analytics","react-router","spa","pageview","proxy"],"author":{"name":"Scott Willeke"},"license":"MIT","_id":"@activescott/analytics@0.3.0","maintainers":[{"name":"activescott","email":"scott@willeke.com"}],"homepage":"https://github.com/activescott/js-utils#readme","bugs":{"url":"https://github.com/activescott/js-utils/issues"},"dist":{"shasum":"13ae32f0fd9d31780a907897a5ba588c828a7fa1","tarball":"https://registry.npmjs.org/@activescott/analytics/-/analytics-0.3.0.tgz","fileCount":46,"integrity":"sha512-szQXejM5/IU5IdRPzniMZn/ijd+27E9NGTUSE9kZN4/qnG6LXxtzymg/TOlfRhkp6gx9Y/NfIRJs0Hqocgkbxg==","signatures":[{"sig":"MEUCIQDfnwUe1VhQKwUfO22gxkiajLfUa7+3QGrYLTu1EVhQowIgUhhhF7Dskkf6eq0Tdm59ldEyPpSsRWevzTZxUOfAbO8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@activescott%2fanalytics@0.3.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":49297},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./hosts":{"types":"./dist/hosts.d.ts","import":"./dist/hosts.js"},"./proxy":{"types":"./dist/proxy.d.ts","import":"./dist/proxy.js"}},"gitHead":"ce539957c0241c16a5f44bdb7ade397a1aecadc7","scripts":{"test":"vitest run","build":"tsc -p tsconfig.build.json","typecheck":"tsc --noEmit"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:e21a7151-183d-4cd9-8cd9-a72a9b22fe21"}},"repository":{"url":"git+https://github.com/activescott/js-utils.git","type":"git","directory":"packages/analytics"},"_npmVersion":"11.19.0","description":"PostHog analytics integration for React Router apps — provider, SPA pageview tracking, user identification, and reverse proxy helper","directories":{},"_nodeVersion":"24.20.0","_hasShrinkwrap":false,"devDependencies":{"jsdom":"^27.4.0","react":"19.2.8","vitest":"4.1.10","react-dom":"19.2.8","posthog-js":"^1.351.4","typescript":"^5.9.3","@types/node":"^22","@types/react":"^19.2.14","react-router":"^7.10.1","@testing-library/dom":"^10.4.1","@testing-library/react":"^16.3.2"},"peerDependencies":{"react":">=18","posthog-js":"^1.200.0","react-router":"^7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/analytics_0.3.0_1789007926211_0.8549150084988535","host":"s3://npm-registry-packages-npm-production"}},"0.3.1":{"name":"@activescott/analytics","version":"0.3.1","keywords":["posthog","analytics","react-router","spa","pageview","proxy"],"author":{"name":"Scott Willeke"},"license":"MIT","_id":"@activescott/analytics@0.3.1","maintainers":[{"name":"activescott","email":"scott@willeke.com"}],"homepage":"https://github.com/activescott/js-utils#readme","bugs":{"url":"https://github.com/activescott/js-utils/issues"},"dist":{"shasum":"5fc8ec784e5f62a1dbbadc38839d68e02ccab8c5","tarball":"https://registry.npmjs.org/@activescott/analytics/-/analytics-0.3.1.tgz","fileCount":50,"integrity":"sha512-P9MaXmaXrkAKENX5wTsGv7LkadzaO/tKVz5U+y0V0FDWKmDBKgMRQD2UmN0BrsSlveojtm+R0Gnhk3gN9GML5Q==","signatures":[{"sig":"MEQCIG07LKSkhbJReRUOhEaX40JmEMUbmcQ5w6RFGtvC5i2IAiAQcx7m1d+wQXlZ3F/R3RWnpo7lJG3knrxbowBwrM9zQw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@activescott%2fanalytics@0.3.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":51276},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./lazy":{"types":"./dist/lazy.d.ts","import":"./dist/lazy.js"},"./hosts":{"types":"./dist/hosts.d.ts","import":"./dist/hosts.js"},"./proxy":{"types":"./dist/proxy.d.ts","import":"./dist/proxy.js"}},"gitHead":"44c4baf3cca891c412c35121c5fa27bc7c090131","scripts":{"test":"vitest run","build":"tsc -p tsconfig.build.json","typecheck":"tsc --noEmit"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:e21a7151-183d-4cd9-8cd9-a72a9b22fe21"}},"repository":{"url":"git+https://github.com/activescott/js-utils.git","type":"git","directory":"packages/analytics"},"_npmVersion":"11.19.0","description":"PostHog analytics integration for React Router apps — provider, SPA pageview tracking, user identification, and reverse proxy helper","directories":{},"sideEffects":false,"_nodeVersion":"24.20.0","_hasShrinkwrap":false,"devDependencies":{"jsdom":"^27.4.0","react":"19.2.8","vitest":"4.1.10","react-dom":"19.2.8","posthog-js":"^1.351.4","typescript":"^5.9.3","@types/node":"^22","@types/react":"^19.2.14","react-router":"^7.10.1","@testing-library/dom":"^10.4.1","@testing-library/react":"^16.3.2"},"peerDependencies":{"react":">=18","posthog-js":"^1.200.0","react-router":"^7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/analytics_0.3.1_1789010390709_0.8227726214593971","host":"s3://npm-registry-packages-npm-production"}},"0.3.2":{"name":"@activescott/analytics","version":"0.3.2","keywords":["posthog","analytics","react-router","spa","pageview","proxy"],"author":{"name":"Scott Willeke"},"license":"MIT","_id":"@activescott/analytics@0.3.2","maintainers":[{"name":"activescott","email":"scott@willeke.com"}],"homepage":"https://github.com/activescott/js-utils#readme","bugs":{"url":"https://github.com/activescott/js-utils/issues"},"dist":{"shasum":"6fbd14d91ae4e6cdb5dc60f239fbf79b22fe0470","tarball":"https://registry.npmjs.org/@activescott/analytics/-/analytics-0.3.2.tgz","fileCount":50,"integrity":"sha512-RkfzkHOwnz44RG+km8mEKEBwkipV+OenPoGxthfTFa9mX5fgLg46ZeXWucNHnI/an6cOwu8zXG1UDUSh2Xo83A==","signatures":[{"sig":"MEYCIQDfSQIkwo3ofXXL3zRGWBylSOQwnpl6xZdvJ0FaM/WksAIhANNTlZ+ySXT0/7ygPUwFKxTFDau7jrOS9wTnaEfsMAX1","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@activescott%2fanalytics@0.3.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":52116},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./lazy":{"types":"./dist/lazy.d.ts","import":"./dist/lazy.js"},"./hosts":{"types":"./dist/hosts.d.ts","import":"./dist/hosts.js"},"./proxy":{"types":"./dist/proxy.d.ts","import":"./dist/proxy.js"}},"gitHead":"0ad3267857a460f804bc42f07c01c3700c473545","scripts":{"test":"vitest run","build":"tsc -p tsconfig.build.json","typecheck":"tsc --noEmit"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:e21a7151-183d-4cd9-8cd9-a72a9b22fe21"}},"repository":{"url":"git+https://github.com/activescott/js-utils.git","type":"git","directory":"packages/analytics"},"_npmVersion":"11.19.0","description":"PostHog analytics integration for React Router apps — provider, SPA pageview tracking, user identification, and reverse proxy helper","directories":{},"sideEffects":false,"_nodeVersion":"24.20.0","_hasShrinkwrap":false,"devDependencies":{"jsdom":"^27.4.0","react":"19.2.8","vitest":"4.1.10","react-dom":"19.2.8","posthog-js":"^1.351.4","typescript":"^5.9.3","@types/node":"^22","@types/react":"^19.2.14","react-router":"^7.10.1","@testing-library/dom":"^10.4.1","@testing-library/react":"^16.3.2"},"peerDependencies":{"react":">=18","posthog-js":"^1.200.0","react-router":"^7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/analytics_0.3.2_1789016805625_0.04996851153880666","host":"s3://npm-registry-packages-npm-production"}},"0.3.3":{"name":"@activescott/analytics","version":"0.3.3","keywords":["posthog","analytics","react-router","spa","pageview","proxy"],"author":{"name":"Scott Willeke"},"license":"MIT","_id":"@activescott/analytics@0.3.3","maintainers":[{"name":"activescott","email":"scott@willeke.com"}],"homepage":"https://github.com/activescott/js-utils#readme","bugs":{"url":"https://github.com/activescott/js-utils/issues"},"dist":{"shasum":"bd2e32ca90fca08af66c95ddc4b5323220ad35fa","tarball":"https://registry.npmjs.org/@activescott/analytics/-/analytics-0.3.3.tgz","fileCount":50,"integrity":"sha512-PMdgMg/+zsoRlsqVmaDHDLni/UyZdEPOQU7AfQ9prVi9vLOYZWEnEgC9mwrwejYgmEDyU6SRx3CJEH7S2Ad9Vw==","signatures":[{"sig":"MEUCIC3WIC4TSzUbmPMCUMzRNjVi5Vf2sFZA12k4cLoWpJkIAiEAjVy6kh6KuZU++HlqhzhI90lvF6/3+wCKVPDZljIa/Nw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@activescott%2fanalytics@0.3.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":52318},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./lazy":{"types":"./dist/lazy.d.ts","import":"./dist/lazy.js"},"./hosts":{"types":"./dist/hosts.d.ts","import":"./dist/hosts.js"},"./proxy":{"types":"./dist/proxy.d.ts","import":"./dist/proxy.js"}},"gitHead":"06461dff172e7c5df2928085683cd6a7b4c21ced","scripts":{"test":"vitest run","build":"tsc -p tsconfig.build.json","typecheck":"tsc --noEmit"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:e21a7151-183d-4cd9-8cd9-a72a9b22fe21"}},"repository":{"url":"git+https://github.com/activescott/js-utils.git","type":"git","directory":"packages/analytics"},"_npmVersion":"11.19.0","description":"PostHog analytics integration for React Router apps — provider, SPA pageview tracking, user identification, and reverse proxy helper","directories":{},"sideEffects":false,"_nodeVersion":"24.20.0","_hasShrinkwrap":false,"devDependencies":{"jsdom":"^27.4.0","react":"19.2.8","vitest":"4.1.10","react-dom":"19.2.8","posthog-js":"^1.351.4","typescript":"^5.9.3","@types/node":"^22","@types/react":"^19.2.14","react-router":"^7.10.1","@testing-library/dom":"^10.4.1","@testing-library/react":"^16.3.2"},"peerDependencies":{"react":">=18","posthog-js":"^1.200.0","react-router":"^7.0.0"},"_npmOperationalInternal":{"tmp":"tmp/analytics_0.3.3_1789022062041_0.4800434007769807","host":"s3://npm-registry-packages-npm-production"}},"0.3.4":{"name":"@activescott/analytics","version":"0.3.4","description":"PostHog analytics integration for React Router apps — provider, SPA pageview tracking, user identification, and reverse proxy helper","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./proxy":{"types":"./dist/proxy.d.ts","import":"./dist/proxy.js"},"./lazy":{"types":"./dist/lazy.d.ts","import":"./dist/lazy.js"},"./hosts":{"types":"./dist/hosts.d.ts","import":"./dist/hosts.js"}},"sideEffects":false,"scripts":{"build":"tsc -p tsconfig.build.json","typecheck":"tsc --noEmit","test":"vitest run"},"keywords":["posthog","analytics","react-router","spa","pageview","proxy"],"author":{"name":"Scott Willeke"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/activescott/js-utils.git","directory":"packages/analytics"},"peerDependencies":{"posthog-js":"^1.200.0","react":">=18","react-router":"^7.0.0"},"devDependencies":{"@testing-library/dom":"^10.4.1","@testing-library/react":"^16.3.2","@types/node":"^22","@types/react":"^19.2.14","jsdom":"^27.4.0","posthog-js":"^1.351.4","react":"19.2.8","react-dom":"19.2.8","react-router":"^7.10.1","typescript":"^5.9.3","vitest":"4.1.10"},"gitHead":"4500c2f5acf5e5b4ad483ac9dc12849e9ffd76f1","_id":"@activescott/analytics@0.3.4","bugs":{"url":"https://github.com/activescott/js-utils/issues"},"homepage":"https://github.com/activescott/js-utils#readme","_nodeVersion":"24.20.0","_npmVersion":"11.19.0","dist":{"integrity":"sha512-Fcb8dQ4okzFdTtDcHo+cKKJLni9hV0Wfg12Ryy15Xj/JIceKCi10/jtx95W/ntOTOnSv5g2jbtxyzrBi92fpbw==","shasum":"8889910672e9a94640e6539100fa14ded46f2fec","tarball":"https://registry.npmjs.org/@activescott/analytics/-/analytics-0.3.4.tgz","fileCount":50,"unpackedSize":52843,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@activescott%2fanalytics@0.3.4","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHspN3SmI98QJCUeSCLGY7Iap0MQs3J4xDZr5NPug/NwAiB21iJrlRUU9Hq6AvNN1AHH/+gZyAb7CCtVhyMDAOfXbQ=="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:e21a7151-183d-4cd9-8cd9-a72a9b22fe21"}},"directories":{},"maintainers":[{"name":"activescott","email":"scott@willeke.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/analytics_0.3.4_1789022736183_0.9714805156735555"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-10T01:03:11.877Z","modified":"2026-09-10T06:45:36.727Z","0.2.0":"2026-09-10T01:03:12.157Z","0.2.1":"2026-09-10T01:25:12.582Z","0.3.0":"2026-09-10T02:38:46.346Z","0.3.1":"2026-09-10T03:19:50.843Z","0.3.2":"2026-09-10T05:06:45.764Z","0.3.3":"2026-09-10T06:34:22.187Z","0.3.4":"2026-09-10T06:45:36.312Z"},"bugs":{"url":"https://github.com/activescott/js-utils/issues"},"author":{"name":"Scott Willeke"},"license":"MIT","homepage":"https://github.com/activescott/js-utils#readme","keywords":["posthog","analytics","react-router","spa","pageview","proxy"],"repository":{"type":"git","url":"git+https://github.com/activescott/js-utils.git","directory":"packages/analytics"},"description":"PostHog analytics integration for React Router apps — provider, SPA pageview tracking, user identification, and reverse proxy helper","maintainers":[{"name":"activescott","email":"scott@willeke.com"}],"readme":"# @activescott/analytics\n\nPostHog analytics integration for React Router apps — SPA pageview tracking, user identification, and a reverse proxy helper to avoid ad blockers.\n\n## Install\n\n```bash\nnpm install @activescott/analytics posthog-js\n```\n\n`posthog-js` is a peer dependency so consumers control its version. When\nbumping the peer floor, check the\n[posthog-js changelog](https://github.com/PostHog/posthog-js/releases) for\nbreaking changes to `PostHogConfig` or the `posthog-js/react` exports, then\nrelease a matching minor of this package.\n\n## Quick Start\n\n### 1. Add the provider to your app\n\nMount it where loader data is available (in React Router v7, that means `App`,\nnot `Layout` — `Layout` renders with undefined loader data on error\nboundaries, and error pages intentionally get no pageview).\n\nFor zero bundle cost when disabled, use `LazyPostHogProvider`: it renders\nnull unless enabled with a key, otherwise suspense-loads the initialized\ntree with posthog-js in its own chunk. Mount it as a STABLE SIBLING of your\nUI — never as a conditional wrapper around it, which would remount the whole\nsubtree once the chunk loads:\n\n```tsx\n// app/root.tsx\nimport { LazyPostHogProvider } from \"@activescott/analytics\"\n\nexport function App() {\n  const { posthogKey, isAdmin, user } = useLoaderData<typeof loader>()\n  return (\n    <>\n      <LazyPostHogProvider\n        enabled={posthogKey !== \"\" && !isAdmin}\n        apiKey={posthogKey || undefined}\n        options={{ api_host: \"/ph\", ui_host: \"https://us.posthog.com\" }}\n        user={user ? { distinctId: user.id } : undefined}\n      />\n      <Outlet />\n    </>\n  )\n}\n```\n\nIdentify by stable id only — never pass emails, phone numbers, or other PII in\n`properties` unless your privacy policy explicitly covers it.\n\n`PostHogProvider` (same props plus `children`) remains for apps that prefer\na static import and a wrapping provider.\n\n### Custom events\n\nCapture through `captureAnalyticsEvent` or the `useAnalyticsCapture` hook —\nboth read the client the provider registers on init, so they work anywhere\nwithout a provider ancestor, and drop while disabled or still loading:\n\n```tsx\nimport { useAnalyticsCapture } from \"@activescott/analytics\"\n\nconst capture = useAnalyticsCapture()\ncapture(\"search_results_shown\", { result_count: 2 })\n```\n\n### 2. Add the reverse proxy route\n\nCreate `app/routes/ph.$.ts`:\n\n```ts\nimport { createPostHogProxy } from \"@activescott/analytics/proxy\"\n\nexport const { loader, action } = createPostHogProxy({\n  apiHost: \"https://us.i.posthog.com\",\n  assetsHost: \"https://us-assets.i.posthog.com\",\n  // Opt in only if your privacy policy covers it: forwards the ingress-set\n  // X-Forwarded-For chain so PostHog sees client IPs for geoIP.\n  forwardIp: true,\n})\n```\n\nRegister the route in `app/routes.ts`:\n\n```ts\nroute(\"ph/*\", \"routes/ph.$.ts\"),\n```\n\nThe proxy hardens the relay for you: upstream origins are fixed at\nconfiguration time, `Cookie`/`Authorization` (and everything but content-type +\nuser-agent) are stripped, `Set-Cookie` is stripped from responses, request\nbodies are capped (default 1 MiB), the upstream call has a timeout (default\n10s), and only known PostHog path prefixes (`e`, `batch`, `decide`, `flags`,\n`s`, `surveys`, `array`, `static`) are proxied. IP forwarding is deliberately\nabsent — `X-Forwarded-For` passthrough vs `?ip=` is a privacy decision for you\nto make explicitly.\n\nThat's it! PostHog will now:\n\n- Track pageviews on every client-side navigation\n- Identify logged-in users by id\n- Receive events through your own domain (`/ph/*`)\n\n### Deriving sibling origins\n\n`@activescott/analytics/hosts` exports the pure helpers `posthogAssetsHost`\nand `posthogUiHost`, which map a PostHog API origin to its assets and app-UI\nsiblings (`<region>.i.posthog.com` → `<region>-assets.i.posthog.com` /\n`<region>.posthog.com`; anything else passes through unchanged) — so a\ndeployment carries one host knob instead of three.\n\n## Versioning\n\nIndependent plain-npm versions with git tags of the form `analytics@<version>`\n(see repo README). Consumers pin the versioned package normally — lockfile,\nDependabot, and Docker all work unchanged.\n","readmeFilename":"README.md"}