fix(posthog): make OMO_DISABLE_POSTHOG env parsing case-insensitive and trim-tolerant (refs #4368)#4485
Merged
code-yeongyu merged 1 commit intoJun 2, 2026
Conversation
…nd trim-tolerant (fixes code-yeongyu#4368) Users following the documented opt-out (OMO_DISABLE_POSTHOG=1 / OMO_SEND_ANONYMOUS_TELEMETRY=0) report telemetry still firing on some setups. Root cause: shouldDisablePostHog() compared OMO_DISABLE_POSTHOG with the strict string literals 'true' and '1', so case-variant or whitespace-padded values such as 'TRUE', 'True', 'Yes', ' 1 ', ' true ' were silently treated as 'do not disable'. Shell environments and config files commonly emit such values. Fix: normalize the env value with .trim().toLowerCase() before matching (mirroring how OMO_SEND_ANONYMOUS_TELEMETRY is already handled), and accept 'true' / '1' / 'yes' as truthy via a new helper isTruthy() that is symmetric with the existing isFalsy(). Verified by 12 new regression tests in posthog.test.ts covering case-variants and surrounding whitespace for both env vars; all 16 posthog.test.ts cases plus the 25 telemetry-related tests across cli-installer/run/index pass.
Collaborator
Author
|
I have read the CLA Document and I hereby sign the CLA |
code-yeongyu
approved these changes
Jun 2, 2026
Owner
code-yeongyu
left a comment
There was a problem hiding this comment.
[sisyphus-dev] Reviewed and QA verified. The exact #4368 env values are already honored on current dev, so this is not a guaranteed root-cause fix for that report, but the PR is a clean narrow hardening change: it normalizes case/whitespace for opt-out values without adding config surface or changing telemetry payloads. Local QA on a merge with current dev: telemetry regression suite passed, typecheck passed, build passed.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hardens telemetry env-var parsing so case-variant and whitespace-padded values are honored. The behavior change is strictly additive: every value already disabled today (
true,1,0,false,no) is still disabled; only previously-ignored variants (TRUE,Yes,1,true, etc.) are now respected.Scope clarification (re: #4368)
Issue #4368 reports
OMO_DISABLE_POSTHOG=1not disabling telemetry. The pre-fix code already strictly matched=== "1", so this PR is NOT a guaranteed fix for that specific reproduction — the user's reported value already worked under the old code. A full codebase audit (everynew PostHog(...), everycapture(), everytrackActive(), every CLI entrypoint) confirmed there is no telemetry capture path that bypassesshouldDisablePostHog(), so the residual cause in #4368 is most likely environment-side (env var not propagated to the spawned bun process, or a broken plugin install — theoh-my-openagent unknownin their doctor output is consistent with a missing~/.cache/opencode/node_modules/oh-my-openagent).Keeping
Refs #4368rather thanFixes #4368so the issue stays open until the reporter's actual root cause is identified. The robustness improvement here closes the door on a related class of failures (case/whitespace mismatch on shell/CI env vars) that other users will eventually hit.Root Cause
shouldDisablePostHog()insrc/shared/posthog.tspreviously comparedOMO_DISABLE_POSTHOGagainst the strict string literals"true"and"1". Shell environments and config tooling frequently emit case-variant or padded values such asTRUE,True,Yes,1, ortrue; those values silently fell through to the default "capture telemetry" branch, even though the user clearly intended to opt out.The companion var
OMO_SEND_ANONYMOUS_TELEMETRYwas already normalized via.trim().toLowerCase()beforeisFalsy()— the disable path just never received the same treatment.Changes
src/shared/posthog.tsisTruthy()helper; normalizeOMO_DISABLE_POSTHOGwith.trim().toLowerCase()before matching (mirror of the existingOMO_SEND_ANONYMOUS_TELEMETRYpath)src/shared/posthog.test.tsDiff: +67 / −1 across 2 files.
fix()only — no behavior change for values already handled (true,1,0,false,no).Reproduction (before fix)
Verification (after fix)
Test
src/shared/posthog.test.ts(12 new cases underdescribe("posthog disable env var parsing"))bun test src/shared/posthog{,-activity-state}.test.ts src/cli/cli-installer.telemetry.test.ts src/cli/run/runner.telemetry.test.ts src/index.telemetry.test.ts— 25 passbun run typecheck— cleanRefs #4368