Skip to content

chore(analytics): adopt posthog-js defaults 2026-05-30#2788

Open
pauldambra wants to merge 4 commits into
mainfrom
posthog-code/posthog-js-defaults-2026-05-30
Open

chore(analytics): adopt posthog-js defaults 2026-05-30#2788
pauldambra wants to merge 4 commits into
mainfrom
posthog-code/posthog-js-defaults-2026-05-30

Conversation

@pauldambra

@pauldambra pauldambra commented Jun 19, 2026

Copy link
Copy Markdown
Member

Problem

The browser SDK was running without the defaults config flag, so it stayed on legacy posthog-js behavior instead of the current recommended defaults.

Changes

  • Set defaults: "2026-05-30" on the browser posthog.init call in posthogAnalyticsImpl.ts, opting into the latest posthog-js default behaviors, with a comment documenting that it's a named epoch (not a date) and requires posthog-js >= 1.378.0.
  • The 2026-05-30 defaults value was introduced in posthog-js 1.378.0, so bump the dependency from ^1.283.0 to ^1.378.0 (lockfile now resolves to 1.386.6).
  • Set capture_pageview: false. The epoch flips capture_pageview to "history_change", but this app routes via createHashHistory() — the route lives in the URL hash and $pathname is identical for every screen, so automatic pageviews would collapse all routes into one and corrupt route-level analytics. Opt out and rely on explicit instrumentation. (If route-level pageviews are wanted later, a before_send that rewrites $pathname/$current_url from the hash is the path.)

Capture delta from adopting the epoch (for the record): session_recording.strictMinimumDuration, external_scripts_inject_target: head, persistence_save_debounce_ms: 250, split_storage, detect_google_search_app, and content-masking ignorelist tweaks. No new autocapture/network instrumentation; automatic pageviews explicitly disabled.

How did you test this?

  • pnpm --filter @posthog/ui typecheck passes (confirms defaults: "2026-05-30" and capture_pageview: false are valid config in the bumped SDK).
  • ⚠️ Not yet verified at runtime: that session recording still starts after the ~95-minor posthog-js bump (import paths unchanged, but a manual smoke test of the Electron app is worth doing before merge).

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code from a Slack thread

Set the `defaults: "2026-05-30"` config flag on the browser posthog.init call so the app opts into the latest posthog-js default behaviors. This value was introduced in posthog-js 1.378.0, so bump the dependency from ^1.283.0 to ^1.378.0 (lockfile resolves to 1.386.6).

Generated-By: PostHog Code
Task-Id: 9b346513-66e9-4766-a449-e2c158abf8d5
@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 398fedc.

@greptile-apps

greptile-apps Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "chore(analytics): adopt posthog-js defau..." | Re-trigger Greptile

@pauldambra pauldambra marked this pull request as ready for review June 19, 2026 20:54

@pauldambra pauldambra left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Note

🤖 Automated comment by QA Swarm — not written by a human

QA Swarm review complete. See inline comments.

Comment thread packages/ui/src/shell/posthogAnalyticsImpl.ts
Comment thread packages/ui/src/shell/posthogAnalyticsImpl.ts
Comment thread packages/ui/src/shell/posthogAnalyticsImpl.ts
Comment thread packages/ui/package.json

Copy link
Copy Markdown
Member Author

Note

🤖 Automated comment by QA Swarm — not written by a human

Multi-perspective review: paul-reviewer, xp-reviewer, security-audit (qa-team skipped — not available on disk)

Verdict: 💬 APPROVE WITH NITS

No blockers. The whole change is one defaults: "2026-05-30" epoch flag plus the matching posthog-js floor bump — minimal and correct. The asks are about documenting and verifying what the new defaults epoch turns on, not about correctness.

Key findings

🟡 MEDIUM

  • The defaults: "2026-05-30" magic string is an opaque posthog-js epoch, silently coupled to the ^1.378.0 floor, and overlaps options set explicitly below it. Confirm precedence (esp. capture_exceptions in dev) and add a one-line comment naming what it pins + the version it needs.
  • Behaviour-change-to-everyone with no flag, while the motivation is "feels slow" — new defaults may add capture overhead. Note the expected before/after capture diff; consider whether a flag is warranted.

🟢 LOW

  • Recording is now asserted three ways (epoch + disable_session_recording: false + startSessionRecording() in loaded); prune or annotate the redundant ones.
  • ~95-minor jump (1.283 → 1.386.6): sanity-check the specifically-pinned recorder bundle still starts recording on the running app.

Convergence

Both paul and xp independently flagged (a) the opaque epoch string / version coupling and (b) that the epoch may make neighboring explicit options redundant — highest-confidence items.

Reviewer summaries

Reviewer Assessment
👤 paul approve-with-comments: document the epoch interaction, treat as a behaviour-change rollout, verify the recorder still works after the big version jump
📐 xp clean minimal opt-in, no behaviour bug; two expressiveness nits — opaque epoch string and possibly-redundant neighboring options
🛡 security-audit 0 findings — privacy-neutral config flag + first-party SDK bump; defaults epoch does not loosen input masking

Automated by QA Swarm — not a human review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 23ecb810d8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/ui/src/shell/posthogAnalyticsImpl.ts
Address convergent qa-swarm review feedback (paul + xp): the bare `defaults: "2026-05-30"` reads as an opaque date. Document that it's a named posthog-js defaults epoch, that it requires posthog-js >= 1.378.0 (kept in sync with package.json's floor), and that the explicit options below intentionally override it (posthog-js merges the epoch first, explicit config last).

Generated-By: PostHog Code
Task-Id: 9b346513-66e9-4766-a449-e2c158abf8d5
The 2026-05-30 defaults epoch sets capture_pageview to "history_change", which auto-captures a pageview on every history change. The app routes via createHashHistory(), so the route lives in the URL hash and $pathname is identical across every screen — automatic pageviews would collapse all routes into one and corrupt route-level analytics. Set capture_pageview: false to opt out.

Addresses Codex review finding (P2).

Generated-By: PostHog Code
Task-Id: 9b346513-66e9-4766-a449-e2c158abf8d5
@pauldambra pauldambra added the Stamphog This will request an autostamp by stamphog on small changes label Jun 19, 2026 — with PostHog

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Gates denied: this is a dependency version bump (~100 minor versions of posthog-js) which requires human review. Additionally, there is an unresolved inline comment explicitly flagging that session recording correctness needs a manual runtime smoke test before merge, which the automated reviewer deferred to a human.

@stamphog stamphog Bot removed the Stamphog This will request an autostamp by stamphog on small changes label Jun 19, 2026
Comment thread packages/ui/src/shell/posthogAnalyticsImpl.ts Outdated
@pauldambra pauldambra requested a review from a team June 19, 2026 21:49
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