024788c823
omo_claude_daily_active event + omo-claude: distinct-id salt; PostHog key/host/ LEGACY_PARENT_PACKAGE kept identical (shared project). platform + tmp-fallback derived from constants (no literals). 4-flag opt-out incl inherited OMO_*. cross-package-equivalence + cross-product distinctness tests (RED->GREEN). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import {
|
|
DEFAULT_POSTHOG_API_KEY,
|
|
DEFAULT_POSTHOG_HOST,
|
|
} from "./product-identity.js"
|
|
|
|
function normalizeEnvValue(value: string | undefined): string | undefined {
|
|
return value?.trim().toLowerCase()
|
|
}
|
|
|
|
function isDisableFlag(value: string | undefined): boolean {
|
|
const normalized = normalizeEnvValue(value)
|
|
return normalized === "1" || normalized === "true"
|
|
}
|
|
|
|
function isTelemetryOptOutFlag(value: string | undefined): boolean {
|
|
const normalized = normalizeEnvValue(value)
|
|
return normalized === "0" || normalized === "false" || normalized === "no"
|
|
}
|
|
|
|
export function shouldDisablePostHog(): boolean {
|
|
return (
|
|
isDisableFlag(process.env["OMO_DISABLE_POSTHOG"]) ||
|
|
isTelemetryOptOutFlag(process.env["OMO_SEND_ANONYMOUS_TELEMETRY"]) ||
|
|
isDisableFlag(process.env["OMO_CLAUDE_DISABLE_POSTHOG"]) ||
|
|
isTelemetryOptOutFlag(process.env["OMO_CLAUDE_SEND_ANONYMOUS_TELEMETRY"])
|
|
)
|
|
}
|
|
|
|
export function getPostHogApiKey(): string {
|
|
const explicit = process.env["POSTHOG_API_KEY"]
|
|
if (explicit === undefined) {
|
|
return DEFAULT_POSTHOG_API_KEY
|
|
}
|
|
return explicit.trim()
|
|
}
|
|
|
|
export function hasPostHogApiKey(): boolean {
|
|
return getPostHogApiKey().length > 0
|
|
}
|
|
|
|
export function getPostHogHost(): string {
|
|
return process.env["POSTHOG_HOST"]?.trim() || DEFAULT_POSTHOG_HOST
|
|
}
|