{"_id":"@airtame/analytics-plugin-posthog","name":"@airtame/analytics-plugin-posthog","dist-tags":{"latest":"1.3.0"},"versions":{"1.3.0":{"name":"@airtame/analytics-plugin-posthog","description":"Plugin for the analytics package which sends analytics events to posthog","version":"1.3.0","type":"module","main":"./dist/posthog.js","scripts":{"dev":"vite","build":"tsc && vite build","test":"vitest","test:ui":"vitest --ui # open browser dashboard","prettier":"prettier --check 'src' '*.md'","eslint":"eslint --max-warnings 0 'src'"},"devDependencies":{"@typescript-eslint/eslint-plugin":"6.9.0","@vitest/ui":"0.34.6","analytics":"0.8.9","eslint":"8.52.0","eslint-config-prettier":"9.0.0","eslint-import-resolver-typescript":"3.6.1","eslint-plugin-import":"2.29.0","eslint-plugin-unicorn":"48.0.1","prettier":"3.0.3","typescript":"5.2.2","vite":"4.5.0","vite-plugin-dts":"3.6.3","vitest":"0.34.6"},"dependencies":{"posthog-js":"1.90.1"},"_id":"@airtame/analytics-plugin-posthog@1.3.0","gitHead":"c28bcb5c0774c1a2e45a47fa49e2b4b9521eeb07","types":"./dist/posthog.d.ts","_nodeVersion":"20.9.0","_npmVersion":"10.1.0","dist":{"integrity":"sha512-W7M/i6Z1erRQF4kNiruPSYzdliDgKZ96y7qSO3V4Z9Bl0+HiVfSMQBjrEjnZ8BH0bH1ZBvH8PJkgCoyVvZr4Cw==","shasum":"90a03c932f1c7018cad19a36455df02fe53b8d99","tarball":"https://registry.npmjs.org/@airtame/analytics-plugin-posthog/-/analytics-plugin-posthog-1.3.0.tgz","fileCount":4,"unpackedSize":153790,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDaHZN0EntSYlcGESkeQZry/cQKgvrKSUn9yzMtKIf3KwIgERv5aHVEuZpR6ykRtZ/88ULl6me0SvlYFNd3+y2L91s="}]},"_npmUser":{"name":"airtame-ops","email":"devops@airtame.com"},"directories":{},"maintainers":[{"name":"rene-airtame","email":"rene.hansen@airtame.com"},{"name":"airtame-ops","email":"devops@airtame.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/analytics-plugin-posthog_1.3.0_1711299708543_0.9294794111085787"},"_hasShrinkwrap":false}},"time":{"created":"2024-03-24T17:01:48.431Z","1.3.0":"2024-03-24T17:01:48.707Z","modified":"2024-03-24T17:01:49.310Z"},"maintainers":[{"name":"rene-airtame","email":"rene.hansen@airtame.com"},{"name":"airtame-ops","email":"devops@airtame.com"}],"description":"Plugin for the analytics package which sends analytics events to posthog","readme":"# analytics-plugin-posthog\n\nIntegration with [PostHog] for\n[analytics](https://www.npmjs.com/package/analytics).\n\nThis analytics plugin will enable sending of custom events, page views etc. to\n[PostHog].\n\n## Installation\n\n```bash\nnpm install analytics\nnpm install @airtame/analytics-plugin-posthog\n```\n\n## How to use\n\nTo use, install the package, include in your project and initialize the plugin\nwith [analytics](https://www.npmjs.com/package/analytics).\n\nBelow is an example of how to use the browser plugin.\n\n```js\nimport Analytics from 'analytics';\nimport posthog from '@airtame/analytics-plugin-posthog';\n\nconst analytics = Analytics({\n  app: 'awesome-app',\n  plugins: [\n    posthog({\n      applicationId: 'phc_CuJorYJYdWoPM3y...',\n      applicationVersion: 'v1.2.3',\n    }),\n  ],\n});\n\n// Identify the session\n// Corresponds to https://posthog.com/docs/libraries/js#identifying-users\nanalytics.identify('some unique id');\n\n/* Track a page view */\nanalytics.page();\n\n/* Track a custom event */\nanalytics.track('cartCheckout', {\n  item: 'pink socks',\n  price: 20,\n});\n```\n\nAfter initializing `analytics` with the `posthog` plugin and calling\n[identify](https://getanalytics.io/api/#analyticsidentify), data will be sent\ninto PostHog whenever\n[analytics.page](https://getanalytics.io/api/#analyticspage), or\n[analytics.track](https://getanalytics.io/api/#analyticstrack) are called.\nCalling `identify()` is not strictly required, but events will not be tied to a\nspecific user in that case.\n\n## Browser usage\n\nThe PostHog client side browser plugin works with these analytic api methods:\n\n- **[analytics.identify](https://getanalytics.io/api/#analyticsidentify)** -\n  Identify against PostHog in order to link events to specific users.\n- **[analytics.page](https://getanalytics.io/api/#analyticspage)** - Sends page\n  views into PostHog\n- **[analytics.track](https://getanalytics.io/api/#analyticstrack)** - Track\n  custom events and send to PostHog\n\n### Configuration options\n\n| Option                                          | description                                                                                                                                   |\n| :---------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------- |\n| `apiHost` <br/>**optional** - string            | API url for PostHog. defaults to 'https://eu.posthog.com'.                                                                                    |\n| `projectAPIKey` <br/>**required** - string      | The API key for the project. Found at [https://eu.posthog.com/settings/project#variables](https://eu.posthog.com/settings/project#variables). |\n| `applicationVersion` <br/>**optional** - string | Semantic version of the application                                                                                                           |\n\n## Build\n\nTo build the library:\n\n```bash\n# Install the dependencies\nnpm install\n\n# Run the build script\nnpm run build\n```\n\nAfter that you have the artifacts in the `dist/` folder.\n\n## [CHANGELOG](./CHANGELOG.md)\n\n[posthog]: https://posthog.com/\n","readmeFilename":"README.md"}