# How Does Mem0 Handle Telemetry and Data Collection? (Opt-Out Guide)

> Discover how Mem0 handles telemetry and data collection. Learn to easily disable anonymous usage statistics by setting the MEM0_TELEMETRY environment variable to a falsy value.

- Repository: [Mem0/mem0](https://github.com/mem0ai/mem0)
- Tags: how-to-guide
- Published: 2026-03-07

---

**Mem0 ships with built-in, opt-out telemetry that records anonymous usage statistics via PostHog and sends them to the project's analytics endpoint, which can be completely disabled by setting the `MEM0_TELEMETRY` environment variable to any falsy value before importing the library.**

Mem0 (the memory layer for AI applications) includes a telemetry system to help maintainers understand adoption patterns and component usage. According to the `mem0ai/mem0` source code, this system is designed to collect only non-identifying metadata while providing a straightforward mechanism to disable all data collection entirely.

## How Mem0 Telemetry Works

The telemetry architecture centers around the **`AnonymousTelemetry`** class in [`mem0/memory/telemetry.py`](https://github.com/mem0ai/mem0/blob/main/mem0/memory/telemetry.py). When you import any Mem0 module, the system immediately evaluates whether to initialize the PostHog client or operate in no-op mode based on environment configuration.

### The Environment Variable Toggle

Lines 11-18 of [`mem0/memory/telemetry.py`](https://github.com/mem0ai/mem0/blob/main/mem0/memory/telemetry.py) implement the toggle logic:

```python
MEM0_TELEMETRY = os.environ.get("MEM0_TELEMETRY", "True").lower() in ("true", "1", "yes")

```

The code reads `MEM0_TELEMETRY` and defaults to `"True"` if the variable is missing. Strings `"true"`, `"1"`, or `"yes"` enable telemetry; any other value disables it.

### The AnonymousTelemetry Class Constructor

The constructor (lines 25-31) determines the behavior for the entire session. If telemetry is disabled, the class sets `self.posthog = None` and skips user ID generation. This ensures that all subsequent calls to `capture_event()` execute an early return without instantiating the PostHog client or generating network traffic.

### Global Singleton Instance

Line 60 of [`mem0/memory/telemetry.py`](https://github.com/mem0ai/mem0/blob/main/mem0/memory/telemetry.py) creates a global `client_telemetry` singleton at module import time:

```python
client_telemetry = AnonymousTelemetry()

```

This means the telemetry decision happens immediately when the library loads, making pre-import environment configuration critical.

## What Data Mem0 Collects (When Enabled)

When telemetry is active, the `capture_event()` and `capture_client_event()` functions (lines 73-84) assemble a payload containing only anonymous metadata:

- **PostHog project key**: `phc_hgJkUVJFYtmaJqrvf6CYN67TIQ8yhXAkWzUn9AMU4yX` (routes events to the Mem0 project)
- **Anonymous `user_id`**: A UUID generated once per installation
- **Runtime details**: Python version, OS type/version, processor architecture, machine type
- **Component configuration**: Vector store type, graph store, LLM provider, embedding model, and API version

Notably, the payload excludes user queries, documents, conversation history, or any personal data.

### User ID Generation and Storage

The stable identifier is created in [`mem0/memory/setup.py`](https://github.com/mem0ai/mem0/blob/main/mem0/memory/setup.py) (lines 35-56) via `get_or_create_user_id()`. This UUID is stored locally in `~/.mem0/config.json` and is never tied to personal information or PII.

## How to Disable Mem0 Telemetry

You have three methods to stop data collection, depending on your deployment constraints.

### Method 1: Environment Variable (Recommended)

Set `MEM0_TELEMETRY` before launching Python to prevent the PostHog client from ever being instantiated:

```bash
export MEM0_TELEMETRY=False   # "false", "0", or "no" also work

python your_app.py

```

The variable must be defined **before** the first import of `mem0.memory.telemetry` (i.e., before any `mem0` modules load).

### Method 2: Programmatic Disabling

For CI environments or unit testing, set the variable in Python before importing the library:

```python
import os
os.environ["MEM0_TELEMETRY"] = "False"

import mem0

# Telemetry is now completely disabled

```

### Method 3: Runtime Override

If you must disable telemetry after import (e.g., in a running application), monkey-patch the module flag:

```python
from mem0.memory import telemetry
telemetry.MEM0_TELEMETRY = False

```

After this assignment, the global `client_telemetry` singleton continues to exist but all `capture_event()` and `capture_client_event()` calls return immediately at the early-exit check (lines 63-66), guaranteeing no network traffic.

## Verification and Testing

The test suite in [`tests/test_telemetry.py`](https://github.com/mem0ai/mem0/blob/main/tests/test_telemetry.py) (lines 6-16 and 23-31) validates the opt-out behavior. These tests confirm that when `MEM0_TELEMETRY` is set to `False`, no PostHog client is created and `capture_event()` becomes a no-op.

## Summary

- Mem0 uses **opt-out telemetry** via PostHog to collect anonymous usage statistics, defaulting to enabled unless configured otherwise.
- Set **`MEM0_TELEMETRY=False`** before importing the library to disable all data collection and prevent PostHog client instantiation.
- When disabled, **`AnonymousTelemetry`** sets `posthog=None` and all capture methods execute immediate returns with zero network overhead.
- Collected data includes only **runtime metadata** (Python version, OS, component types) and an **anonymous UUID**, never user content or conversations.
- The anonymous user ID is stored locally in **`~/.mem0/config.json`** and is not linked to personal data.

## Frequently Asked Questions

### Is Mem0 telemetry enabled by default?

Yes. According to [`mem0/memory/telemetry.py`](https://github.com/mem0ai/mem0/blob/main/mem0/memory/telemetry.py) lines 11-18, if the `MEM0_TELEMETRY` environment variable is not set, the system defaults to `"True"` (enabled). The code converts this string to a boolean, meaning telemetry runs unless explicitly disabled.

### Can I disable telemetry after importing Mem0?

Yes, though it requires monkey-patching the module. You can set `telemetry.MEM0_TELEMETRY = False` after importing `mem0.memory.telemetry`, which triggers the early-exit logic in `capture_event()`. However, setting the environment variable before import is the only way to guarantee the PostHog client is never instantiated.

### Does Mem0 collect conversation content or personal data?

No. The payload construction in [`mem0/memory/telemetry.py`](https://github.com/mem0ai/mem0/blob/main/mem0/memory/telemetry.py) lines 73-84 includes only anonymous metadata such as Python version, operating system details, and component configurations. The system explicitly excludes user queries, document content, and conversation text from all telemetry events.

### Where is the anonymous user ID stored?

The UUID is generated once per installation and persisted in a local JSON file at `~/.mem0/config.json`, as implemented in [`mem0/memory/setup.py`](https://github.com/mem0ai/mem0/blob/main/mem0/memory/setup.py) lines 35-56. Optionally, it may also be stored in the configured vector store metadata, but it remains strictly anonymous and is never linked to personal identifiers or email addresses.