Skip to content

fix(www): skip PostHog when api key is missing#924

Merged
Yeom-JinHo merged 1 commit intomagicuidesign:mainfrom
Yeom-JinHo:fix/posthog-api-key
Mar 17, 2026
Merged

fix(www): skip PostHog when api key is missing#924
Yeom-JinHo merged 1 commit intomagicuidesign:mainfrom
Yeom-JinHo:fix/posthog-api-key

Conversation

@Yeom-JinHo
Copy link
Copy Markdown
Member

Description

This PR makes PostHog optional in the www app when NEXT_PUBLIC_POSTHOG_API_KEY is not configured.
It prevents local contributor environments from hitting PostHog initialization errors while preserving analytics behavior when a key is present.
It also routes analytics events through a shared helper so missing-key environments fail gracefully.

Changes

  • Added a shared PostHog utility to centralize enablement checks, one-time initialization, and guarded event capture.
  • Updated the PostHog provider to skip initialization and provider wrapping when the API key is missing.
  • Replaced direct posthog.capture(...) calls in banner and sidebar CTA components with the shared event path.
  • Extended the tracked event schema to include the affected CTA and banner events.
  • Added rel="noopener noreferrer" to the external links touched by this change.

Motivation

Contributors running the app without a local PostHog key currently hit analytics-related errors while navigating the site.
This change improves the local development experience by making analytics opt-in based on environment configuration instead of assuming the key is always available.

Breaking Changes

None.

@Yeom-JinHo Yeom-JinHo self-assigned this Mar 17, 2026
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 17, 2026

@Yeom-JinHo is attempting to deploy a commit to the product-studio Team on Vercel.

A member of the Team first needs to authorize it.

@Yeom-JinHo Yeom-JinHo force-pushed the fix/posthog-api-key branch from f1d3304 to 5cc898b Compare March 17, 2026 12:08
@Yeom-JinHo Yeom-JinHo merged commit 8d4b733 into magicuidesign:main Mar 17, 2026
5 of 6 checks passed
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.

[Contibution]: Disable Posthog initialization when API key is missing to prevent errors for contributors

1 participant