Files
mem0/mem0-ts
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
..
2025-02-27 15:19:17 -08:00
2025-02-27 15:19:17 -08:00

Mem0 - The Memory Layer for Your AI Apps

Mem0 is a self-improving memory layer for LLM applications, enabling personalized AI experiences that save costs and delight users. We offer both cloud and open-source solutions to cater to different needs.

See the complete OSS Docs. See the complete Platform API Reference.

1. Installation

For the open-source version, you can install the Mem0 package using npm:

npm i mem0ai

2. API Key Setup

For the cloud offering, sign in to Mem0 Platform to obtain your API Key.

3. Client Features

Cloud Offering

The cloud version provides a comprehensive set of features, including:

  • Memory Operations: Perform CRUD operations on memories.
  • Search Capabilities: Search for relevant memories using advanced filters.
  • Memory History: Track changes to memories over time.
  • Error Handling: Robust error handling for API-related issues.
  • Async/Await Support: All methods return promises for easy integration.

Open-Source Offering

The open-source version includes the following top features:

  • Memory Management: Add, update, delete, and retrieve memories.
  • Vector Store Integration: Supports various vector store providers for efficient memory retrieval.
  • LLM Support: Integrates with multiple LLM providers for generating responses.
  • Customizable Configuration: Easily configure memory settings and providers.
  • SQLite Storage: Use SQLite for memory history management.

4. Memory Operations

Mem0 provides a simple and customizable interface for performing memory operations. You can create long-term and short-term memories, search for relevant memories, and manage memory history.

5. Error Handling

The MemoryClient throws errors for any API-related issues. You can catch and handle these errors effectively.

6. Using with async/await

All methods of the MemoryClient return promises, allowing for seamless integration with async/await syntax.

7. Testing the Client

To test the MemoryClient in a Node.js environment, you can create a simple script to verify the functionality of memory operations.

Getting Help

If you have any questions or need assistance, please reach out to us: