Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Analytics): implement PostHog (#2543)
## π Relevant links - [Preview link](https://dev-portal-git-nels-analyticsadd-posthog-hashicorp.vercel.app/) π - [Asana task](https://app.asana.com/0/1202787000646550/1208027559696437/f) ποΈ ## ποΈ What This PR adds `PostHog` to https://developer.hashicorp.com by loading the PostHog script using our `ConsentManager` component. ### PostHog Installation Method This implementation follows the [`HTML Snippet` PostHog installation](https://posthog.com/docs/libraries/js#option-1-add-the-javascript-snippet-to-your-html-span-classbg-gray-accent-light-darkbg-gray-accent-dark-text-gray-font-semibold-align-middle-text-sm-p-1-roundedrecommendedspan) instead of the Next.js installation. This was done for several reasons: - We follow this method for loading several other scripts via `ConsentManager` - There is talk of migrating to a Consent Management Platform which would likely load scripts via GTM. If that's the case, transitioning to GTM would largely just be a matter of copying the HTML snippet into GTM. That said, I could be missing something so very open to a Next.js-specific implementation! ### PostHog Setup In PostHog, separate projects have been created for [`Development`](https://eu.posthog.com/project/29988) and [`Production`](https://eu.posthog.com/project/29987). This follows [PostHog's recommendation](https://posthog.com/tutorials/multiple-environments#using-multiple-projects) and [matches our Segment implementation for hashicorp.com](https://github.com/hashicorp/web/blob/0f7d2ffc8b2381370e98559d39d430c3a0a826cc/apps/www/next.config.js#L8-L10). Having separate projects enables two things: 1. keeps data from our production instance separate from data in non-production environments 2. allows for testing PostHog in development / preview environments ## π§ͺ Testing If you need access to PostHog, reach out to me and I can send an invite. ### Validate non-production analytics are sent to the PostHog `Development` project - [ ] Navigate to an [the v0.1.0 release notes for Boundary in the preview](https://dev-portal-git-nels-analyticsadd-posthog-hashicorp.vercel.app/boundary/docs/release-notes/v0_1_0) - [ ] Navigate to the activity tab in the [`Development` project in PostHog](https://eu.posthog.com/project/29988/activity/explore) - [ ] Validate that a `Pageview` event is created for the visit to the above page. It should look like this: <details> <summary>Screenshot</summary> </details> - [ ] Navigate to the [`Production` project in PostHog](https://eu.posthog.com/project/29987/products) - [ ] Validate that there is no activity tab and therefore a `Pageview` event is not created
- Loading branch information