Commit Graph
16 Commits
Author SHA1 Message Date
Mgeeeek 4176293cc9 fix(telemetry): downgrade TS telemetry-failure logs to debug
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).
2026-05-06 01:55:47 +05:30
Mgeeeek 64487cbf31 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.
2026-05-06 01:54:24 +05:30
Younes Slaoui 12bb2588f0 fix: stitch oss and platform telemetry identities python sdk and typescript sdk 2026-05-05 00:19:15 -07:00
gabrielstein-mem0 8a9915d3fe refactor(telemetry): tighten alias helpers and gate on MEM0_TELEMETRY
Review pass on the PostHog identity-stitching fix:

- Gate _maybe_alias_anon_to_email and _maybeAliasAnonToEmail on telemetry
  being enabled. Previous version still read ~/.mem0/config.json and
  persisted telemetry.aliased_to even when MEM0_TELEMETRY=false, which
  meant re-enabling telemetry later would skip identity merging forever.
  Python checks client_telemetry.posthog; TS exports a new
  isTelemetryEnabled() getter from telemetry.ts.
- Trim capture_identify properties to {$anon_distinct_id, client_source}.
  The full platform metadata duplicated capture_event's payload and is
  not needed for $identify; PostHog enriches the person profile from
  subsequent events anyway.
- Flatten config.ts: drop the four-helper structure (loadNodeModules /
  configPath / loadRawConfig / read+write) into one getNodeFs() + a
  shared loadConfig(). Same behaviour, ~30 fewer lines, easier to read.
- Drop the tautological Mem0AnonIds shape test and the
  void createMockFetch hack at the end of the TS test file.
- Add tests for the new telemetry-disabled gate (Python + TS).

Logic traced end-to-end: 114 Python tests + 590 TS tests pass. Ruff and
Prettier clean. Zero new typecheck errors.
2026-04-30 17:01:58 -07:00
gabrielstein-mem0 789122bbea fix(telemetry): stitch PostHog identities on MemoryClient init
The Python sync/async MemoryClient and the TS MemoryClient were silently
switching their PostHog distinct_id from an anonymous on-disk UUID to the
user's email post-ping, without sending the merge instruction. PostHog
ended up tracking each user as 2-3 disconnected personas (OSS UUID, CLI
anon UUID, email), and only ~4 $create_alias events fired across ~300K
users. The Python CLI does this correctly today; this change ports the
same pattern to MemoryClient.

- mem0/memory/setup.py: make setup_config() idempotent so it backfills a
  top-level user_id for CLI-first users (the CLI writes
  telemetry.anonymous_id, not user_id, which left OSS telemetry silently
  dropped). Add read_anon_ids() and mark_aliased() helpers.
- mem0/memory/telemetry.py: add AnonymousTelemetry.capture_identify() that
  posts a PostHog $identify event with $anon_distinct_id. Add "$identify"
  to _LIFECYCLE_EVENTS so it bypasses the 90% sampling drop.
- mem0/client/main.py: at the end of __init__ for both MemoryClient and
  AsyncMemoryClient, fire $identify for each unaliased anon ID and
  persist telemetry.aliased_to so the alias only happens once per
  (anon_id, email) pair, ever. All telemetry calls swallow exceptions.
- mem0-ts/src/client/telemetry.ts: mirror with captureIdentify().
- mem0-ts/src/client/config.ts (new): node-only readMem0AnonIds() and
  markMem0Aliased() using async dynamic imports of fs/path/os, gated on
  process.versions.node so browsers no-op cleanly.
- mem0-ts/src/client/mem0.ts: call _maybeAliasAnonToEmail() inside
  _initializeClient after ping resolves the email.

Tests cover the matrix (OSS-only, CLI-only, both, already-aliased) plus
failure modes (malformed JSON, read-only fs, posthog errors, browser
env). Telemetry never raises.
2026-04-30 16:47:52 -07:00
Saket AryanandGitHub 00695e3113 ci(sdk): require changelog entry on version bump + harden TS telemetry (#4900) 2026-04-20 18:09:03 +05:30
Saket AryanandGitHub 7b6790bafb fix(ts-sdk): inject SDK version into telemetry at build time (#4897) 2026-04-20 17:29:29 +05:30
Saket AryanandGitHub ec9b0688d8 Add structured_data_schema to MemoryOptions interface (#3125) 2025-07-08 10:07:44 -07:00
Saket AryanandGitHub 842903b1b1 feat: Memory Exports (#3117) 2025-07-08 11:34:49 +05:30
Saket AryanandGitHub b4b27f099e Add immutable param to add method and bump version (#3022) 2025-06-24 05:03:35 +05:30
Saket AryanandGitHub 2754f45387 Make V2 Add as Default (#2997) 2025-06-20 16:56:42 +05:30
Saket AryanandGitHub 8048e0b32f fix(ts-sdk): Fixed Types from Message Interface (#2763) 2025-05-22 21:56:45 +05:30
Saket AryanandGitHub 05f9607282 Adds Azure OpenAI LLM to Mem0 TS SDK (#2536) 2025-04-11 20:09:20 +05:30
Saket AryanandGitHub 309c8c18a6 Add user_id in TS OSS SDK (#2514) 2025-04-09 10:24:56 -07:00
Saket AryanandGitHub bc4ab3db77 Add Infer Property (#2452) 2025-03-27 21:18:42 +05:30
Saket AryanandGitHub d200691e9b Added Mem0 TS Library (#2270) 2025-02-27 15:19:17 -08:00