LOG_LEVEL=DEBUG was writing the user's plaintext email to stderr/log
handlers, contradicting the PR's no-plaintext-email-on-disk stance.
The exception object alone is enough debug signal.
Telemetry is best-effort by contract — every PostHog hiccup or
network blip would print red error lines on user stderr otherwise.
Python uses logger.debug for the same paths; this restores parity.
Keeps console.error only at sites that surface a real user-facing
failure (e.g., MemoryClient init ping failed).
Previously captureIdentify returned true only on response.ok, so a
stable PostHog 4xx (api-key revocation, schema mismatch) or any 5xx
caused every MemoryClient init to re-fire $identify forever. PostHog
person-merge is idempotent, so it is safe to mark aliased on any
response received. Only genuine network failures leave the marker
absent so the next init naturally retries.
Also downgrades the failure log lines to console.debug and stops
echoing the PostHog response body to stderr.
The default posthog client enqueues events on a background thread, so
capture() returning a UUID does NOT mean the event was delivered. After
PR #5040 this caused mark_aliased to persist a marker even when PostHog
rejected the payload, permanently severing the anon->email merge.
Use a separate lazy-singleton Posthog(sync_mode=True) client for
$identify only. Check result is not None to handle both posthog<7
(raises on failure) and posthog>=7 (@no_throw catches and returns
None). Keeps the async client for everything else.
Also drops the email from the failure-path debug log.
Followup to ec5baaba: the previous commit dropped the unset/empty
telemetryId fallback. Restoring it preserves behavioral parity with
pre-PR code in case telemetryId is ever externally mutated to a
falsy value (the type permits "" even if normal flow never sets it).
Stop overwriting a stable vector-store UUID with the shared SDK
user_id. Existing OSS users were having their telemetry identity
silently swapped on next init, orphaning every prior PostHog event
tagged with the old id (the same regression class as the bug PR
#5040 set out to fix).
The shared SDK id is now adopted only when the vector store reports
"anonymous" / "anonymous-supabase" (fresh-install signals).