Skip to content

feat: add PostHog analytics to frontend#1563

Merged
gugu merged 1 commit intomainfrom
feat/add-posthog-analytics
Feb 5, 2026
Merged

feat: add PostHog analytics to frontend#1563
gugu merged 1 commit intomainfrom
feat/add-posthog-analytics

Conversation

@gugu
Copy link
Contributor

@gugu gugu commented Feb 5, 2026

No description provided.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 5, 2026 13:05
@gugu gugu enabled auto-merge (squash) February 5, 2026 13:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds PostHog analytics integration to the frontend application. PostHog is an open-source product analytics platform that will enable tracking user behavior and product usage.

Changes:

  • Added posthog-js package dependency (version ^1.341.0) and its transitive dependencies
  • Initialized PostHog in the main application bootstrap file with API key and host configuration

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

File Description
frontend/package.json Added posthog-js dependency to project dependencies
frontend/yarn.lock Added posthog-js and all its transitive dependencies including OpenTelemetry packages, protobuf, and utility libraries
frontend/src/main.ts Imported posthog-js and initialized PostHog analytics with API key and configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


posthog.init('phc_VPnWHIMj9UjhRLPr7shATjgL0J4KrWWOHkK3JwZbnkw', {
api_host: 'https://us.i.posthog.com',
defaults: '2025-11-30',
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The configuration option 'defaults' with value '2025-11-30' appears to be invalid. PostHog's init method does not have a 'defaults' configuration option documented in their API. This may have been intended to be 'person_profiles' or another valid configuration option. Additionally, the date '2025-11-30' is in the past (current date is February 2026), which suggests this may be a placeholder or incorrect value. Please verify the intended configuration option and its correct value.

Suggested change
defaults: '2025-11-30',

Copilot uses AI. Check for mistakes.
Comment on lines +87 to +90
posthog.init('phc_VPnWHIMj9UjhRLPr7shATjgL0J4KrWWOHkK3JwZbnkw', {
api_host: 'https://us.i.posthog.com',
defaults: '2025-11-30',
});
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

PostHog initialization should be conditional based on environment, similar to how Sentry is initialized only when the saas flag is true (lines 73-85). Currently, PostHog will initialize in all environments including local development, which may not be desired and could lead to test/development data being sent to PostHog.

Copilot uses AI. Check for mistakes.
Comment on lines +87 to +91
posthog.init('phc_VPnWHIMj9UjhRLPr7shATjgL0J4KrWWOHkK3JwZbnkw', {
api_host: 'https://us.i.posthog.com',
defaults: '2025-11-30',
});

Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The PostHog API key is hardcoded directly in the source code. This is a security concern as the key will be visible in version control history and to anyone with access to the repository. Consider moving this to environment configuration files or a secure configuration service, following the same pattern used for Stripe keys (lines 64-67) or Sentry DSN (line 75).

Suggested change
posthog.init('phc_VPnWHIMj9UjhRLPr7shATjgL0J4KrWWOHkK3JwZbnkw', {
api_host: 'https://us.i.posthog.com',
defaults: '2025-11-30',
});
const posthogApiKey = (environment as any).posthogApiKey;
if (posthogApiKey) {
posthog.init(posthogApiKey, {
api_host: 'https://us.i.posthog.com',
defaults: '2025-11-30',
});
}

Copilot uses AI. Check for mistakes.
@gugu gugu merged commit 4395b28 into main Feb 5, 2026
23 checks passed
@gugu gugu deleted the feat/add-posthog-analytics branch February 5, 2026 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant