From 64487cbf31e0258181e880a0f4d37ad766689e7b Mon Sep 17 00:00:00 2001 From: Mgeeeek Date: Wed, 6 May 2026 01:54:24 +0530 Subject: [PATCH] fix(telemetry): persist alias marker on any HTTP response (TS) 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. --- mem0-ts/src/client/telemetry.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mem0-ts/src/client/telemetry.ts b/mem0-ts/src/client/telemetry.ts index df3a722d4..c13e2c50e 100644 --- a/mem0-ts/src/client/telemetry.ts +++ b/mem0-ts/src/client/telemetry.ts @@ -99,15 +99,16 @@ class UnifiedTelemetry implements TelemetryClient { }); if (!response.ok) { - console.error( - "Telemetry identify capture failed:", - await response.text(), - ); - return false; + console.debug("Telemetry identify capture failed:", response.status); } + // Any HTTP response (2xx / 4xx / 5xx) marks the pair aliased. + // PostHog person-merge is idempotent at the person level, so a + // duplicate $identify on a recovered server is harmless. Only a + // genuine network failure (no response) leaves the marker absent + // so the next init can retry. return true; } catch (error) { - console.error("Telemetry identify capture failed:", error); + console.debug("Telemetry identify capture failed:", error); return false; } }