-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[MAINTENANCE] Fix PostHog pageview tracking and configuration. #11093
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Disable automatic pageview capture to prevent duplicates - Add custom NavigationTracker component for SPA navigation - Configure PostHog to run debug in development
This reverts commit d175a26.
✅ Deploy Preview for niobium-lead-7998 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## develop #11093 +/- ##
========================================
Coverage 81.03% 81.03%
========================================
Files 497 497
Lines 41293 41293
========================================
Hits 33461 33461
Misses 7832 7832 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
docs/docusaurus/docusaurus.config.js
Outdated
['0.18']: { | ||
label: '0.18.21', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this not being used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, this may been a relic from a merge with main, I'll double check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it was actually from running the linter, but I've restored it to the previous state anyway.
Were you able to smoke test the page views, and was this helpful feedback in Posthog and JIRA? |
@josectobar I'm not sure what you mean by feedback in Posthog and JIRA, but when turning on |
I think there's a way to test this locally in Posthog but I'm not going to block this PR if it's not working. |
Root Cause:
The root cause of the analytics issue was the
dotenv
library loading API keys from the previously committed.env
file (which contained a dummy value). This unintentionally overwrote the correct keys provided via CI secrets/environment variables. Removing the committed.env
file then caused build failures because the config previously relied on the object returned bydotenv.config()
, which only contains keys parsed from the file. However,dotenv
also loads keys from the.env
file intoprocess.env
. By switching the configuration to read directly fromprocess.env
, we ensure the correct key is used in CI (from secrets/env vars) while still allowing local overrides via a.env
file.Summary:
This PR fixes PostHog pageview tracking, associated console errors, and resulting CI build failures.
Changes:
posthog-docusaurus
plugin for initialization while simplifying theNavigationTracker
for manual$pageview
capture.docusaurus.config.js
to readPOSTHOG_API_KEY
directly fromprocess.env
, fixing CI build failures and ensuring CI secrets/environment variables are used correctly, while still supporting local.env
files viadotenv
..env.example
, updated the README with local setup instructions, and ensured.env
is correctly ignored and untracked by Git.Outcome:
This should restore reliable PostHog tracking, fix CI/CD build failures, and clarify the local development setup process.
invoke lint
(usesruff format
+ruff check
)For more information about contributing, visit our community resources.
After you submit your PR, keep the page open and monitor the statuses of the various checks made by our continuous integration process at the bottom of the page. Please fix any issues that come up and reach out on Slack if you need help. Thanks for contributing!