Skip to content

Add PostHog Analytics and Event Tracking#705

Open
AshutoshDash1999 wants to merge 3 commits into
Coder-s-OG-s:mainfrom
AshutoshDash1999:feat/posthog-setup
Open

Add PostHog Analytics and Event Tracking#705
AshutoshDash1999 wants to merge 3 commits into
Coder-s-OG-s:mainfrom
AshutoshDash1999:feat/posthog-setup

Conversation

@AshutoshDash1999

Copy link
Copy Markdown

Summary

  • This PR introduces PostHog analytics to track user interactions and events within the application.
  • It includes configuration updates, new tracking scripts, and event captures across multiple components.
  • The Content Security Policy (CSP) was also updated to include necessary URLs for PostHog tracking.

Type of Change

  • Bug fix
  • New feature
  • UI / UX improvement
  • Refactor
  • Documentation
  • Other

Related Issue

Closes #388

What was changed?

  • Added NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN and NEXT_PUBLIC_POSTHOG_HOST to .env.example for PostHog analytics configuration.
  • Created instrumentation-client.ts to initialize PostHog tracking.
  • Updated next.config.js to include PostHog tracking URLs in the CSP.
  • Added posthog-js to package.json dependencies.
  • Added core-js and dompurify to package-lock.json.
  • Introduced query-selector-shadow-dom and web-vitals to package-lock.json.
  • Updated rec-cards.tsx, verify-button.tsx, leaderboard-content.tsx, invite-contributor-button.tsx, and LandingPage.tsx to capture events using PostHog.
  • Added events.ts and helpers.ts for PostHog event definitions and helper functions.

Screenshots

image

Checklist

  • My code follows the project structure and conventions
  • I tested this locally (npm run dev)
  • No hardcoded secrets or credentials
  • I have updated documentation if needed

@vercel

vercel Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

@AshutoshDash1999 is attempting to deploy a commit to the codersogs-3057's projects Team on Vercel.

A member of the Team first needs to authorize it.

Comment thread next.config.js
"img-src 'self' data: https: blob:",
"font-src 'self' data:",
`connect-src 'self' https://api.github.com https://github.com https://*.supabase.co https://vitals.vercel-insights.com${isDev ? " http://localhost:* http://127.0.0.1:* ws://localhost:* ws://127.0.0.1:*" : ""}`,
`connect-src 'self' https://api.github.com https://github.com https://*.supabase.co https://vitals.vercel-insights.com https://us.i.posthog.com https://us-assets.i.posthog.com${isDev ? " http://localhost:* http://127.0.0.1:* ws://localhost:* ws://127.0.0.1:*" : ""}`,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaults: '2026-05-30' turns on autocapture + pageview tracking for every visitor by default, not just the events you added. we don't disclose any analytics in /privacy right now. either turn autocapture/pageview off and keep just the manual events, or update the privacy page first.

also the ! on NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN will run this unconditionally even when the token's unset (which is the .env.example default), guard it with an if.

@jakharmonika364 jakharmonika364 added the Needs author reply Author need to reply label Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs author reply Author need to reply

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] : Posthog integration for tracking user and generate analytics

2 participants