fix(telemetry): only stitch oss identities with evidence of real oss usage
MemoryClient init fired PostHog $identify for anon ids the SDKs had minted themselves (Python: setup_config() at import time; TS: getOrCreateMem0UserId() inside the alias path), so ~90% of stitches merged event-less anon persons into platform users, worst in ephemeral containers. - never create the anon id from platform client paths; Python mints lazily in Memory/AsyncMemory init, gated on MEM0_TELEMETRY - record telemetry.oss_used_at when OSS Memory genuinely initializes (both SDKs, shared ~/.mem0/config.json key) and only stitch the oss user_id when the marker is present; cli anon id stays presence-based - stamp client_version on $identify so fixed-SDK stitches are separable from old-SDK noise in PostHog
This commit is contained in:
@@ -39,7 +39,7 @@ import {
|
||||
} from "./memory.types";
|
||||
import { parse_vision_messages } from "../utils/memory";
|
||||
import { HistoryManager } from "../storage/base";
|
||||
import { captureClientEvent } from "../utils/telemetry";
|
||||
import { captureClientEvent, isTelemetryEnabled } from "../utils/telemetry";
|
||||
import { lemmatizeForBm25 } from "../utils/lemmatization";
|
||||
import {
|
||||
extractEntities,
|
||||
@@ -53,7 +53,7 @@ import {
|
||||
ScoredResult,
|
||||
} from "../utils/scoring";
|
||||
import { getDefaultVectorStoreDbPath } from "../utils/sqlite";
|
||||
import { getOrCreateMem0UserId } from "../../../client/config";
|
||||
import { getOrCreateMem0UserId, markMem0OssUsed } from "../../../client/config";
|
||||
|
||||
// Entity params that must be passed via filters - check both snake_case and camelCase
|
||||
const ENTITY_PARAMS = [
|
||||
@@ -451,6 +451,12 @@ export class Memory {
|
||||
try {
|
||||
await this._getTelemetryId();
|
||||
|
||||
// Record genuine OSS usage so the platform client may stitch this
|
||||
// machine's anon id to a platform email later.
|
||||
if (isTelemetryEnabled()) {
|
||||
await markMem0OssUsed();
|
||||
}
|
||||
|
||||
// Capture initialization event
|
||||
await captureClientEvent("init", this, {
|
||||
api_version: this.apiVersion,
|
||||
|
||||
@@ -126,4 +126,8 @@ async function captureClientEvent(
|
||||
);
|
||||
}
|
||||
|
||||
export { telemetry, captureClientEvent };
|
||||
function isTelemetryEnabled(): boolean {
|
||||
return MEM0_TELEMETRY;
|
||||
}
|
||||
|
||||
export { telemetry, captureClientEvent, isTelemetryEnabled };
|
||||
|
||||
Reference in New Issue
Block a user