feat(store): add PostHog analytics and conversion tracking #149

Closed
opened 2026-09-29 12:05:35 +00:00 by yuris · 0 comments
Owner

Goal

Integrate PostHog product analytics into the static export store (apps/store), track client route changes and core conversion events (add_to_cart, whatsapp_checkout_clicked), and configure secret passing for CI builds.

Acceptance Criteria

  • Add posthog-js dependency to apps/store with core-js: false in pnpm-workspace.yaml allowBuilds.
  • Add NEXT_PUBLIC_POSTHOG_KEY and NEXT_PUBLIC_POSTHOG_HOST to secretspec.toml (default and dev profiles) and apps/store/.env.example.
  • Pass NEXT_PUBLIC_POSTHOG_KEY and NEXT_PUBLIC_POSTHOG_HOST in the Build step in .forgejo/workflows/deploy-store.yml.
  • Mount <PostHogProvider /> in apps/store/app/layout.tsx with person_profiles: "identified_only" and capture_pageview: "history_change". Must safely no-op if key is absent.
  • Provide trackEvent helper in apps/store/lib/analytics.ts that safely no-ops in non-browser/SSR environments, verified by a unit test.
  • Track whatsapp_checkout_clicked on the checkout link in apps/store/app/cart/cart-view.tsx.
  • Track add_to_cart in apps/store/app/products/[slug]/add-to-cart.tsx.
  • Verification passes: pnpm --filter garage-store test, pnpm --filter garage-store lint, and pnpm --filter garage-store exec tsc --noEmit.
# Goal Integrate PostHog product analytics into the static export store (`apps/store`), track client route changes and core conversion events (`add_to_cart`, `whatsapp_checkout_clicked`), and configure secret passing for CI builds. # Acceptance Criteria - [ ] Add `posthog-js` dependency to `apps/store` with `core-js: false` in `pnpm-workspace.yaml` `allowBuilds`. - [ ] Add `NEXT_PUBLIC_POSTHOG_KEY` and `NEXT_PUBLIC_POSTHOG_HOST` to `secretspec.toml` (default and dev profiles) and `apps/store/.env.example`. - [ ] Pass `NEXT_PUBLIC_POSTHOG_KEY` and `NEXT_PUBLIC_POSTHOG_HOST` in the `Build` step in `.forgejo/workflows/deploy-store.yml`. - [ ] Mount `<PostHogProvider />` in `apps/store/app/layout.tsx` with `person_profiles: "identified_only"` and `capture_pageview: "history_change"`. Must safely no-op if key is absent. - [ ] Provide `trackEvent` helper in `apps/store/lib/analytics.ts` that safely no-ops in non-browser/SSR environments, verified by a unit test. - [ ] Track `whatsapp_checkout_clicked` on the checkout link in `apps/store/app/cart/cart-view.tsx`. - [ ] Track `add_to_cart` in `apps/store/app/products/[slug]/add-to-cart.tsx`. - [ ] Verification passes: `pnpm --filter garage-store test`, `pnpm --filter garage-store lint`, and `pnpm --filter garage-store exec tsc --noEmit`.
yuris closed this issue 2026-09-29 12:22:38 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
yuris/garage#149
No description provided.