fix(telemetry): preserve existing vector-store id in OSS init
Stop overwriting a stable vector-store UUID with the shared SDK user_id. Existing OSS users were having their telemetry identity silently swapped on next init, orphaning every prior PostHog event tagged with the old id (the same regression class as the bug PR #5040 set out to fix). The shared SDK id is now adopted only when the vector store reports "anonymous" / "anonymous-supabase" (fresh-install signals).
This commit is contained in:
@@ -463,16 +463,21 @@ export class Memory {
|
|||||||
private async _getTelemetryId() {
|
private async _getTelemetryId() {
|
||||||
try {
|
try {
|
||||||
if (
|
if (
|
||||||
!this.telemetryId ||
|
|
||||||
this.telemetryId === "anonymous" ||
|
this.telemetryId === "anonymous" ||
|
||||||
this.telemetryId === "anonymous-supabase"
|
this.telemetryId === "anonymous-supabase"
|
||||||
) {
|
) {
|
||||||
this.telemetryId =
|
const existing = await this.vectorStore.getUserId();
|
||||||
(await getOrCreateMem0UserId()) ||
|
if (existing && !existing.startsWith("anonymous")) {
|
||||||
(await this.vectorStore.getUserId());
|
// Preserve a real vector-store UUID so prior PostHog events stay
|
||||||
try {
|
// tied to this user's identity. Cross-surface stitching with
|
||||||
await this.vectorStore.setUserId(this.telemetryId);
|
// CLI/Python OSS for these existing users is deferred.
|
||||||
} catch {}
|
this.telemetryId = existing;
|
||||||
|
} else {
|
||||||
|
this.telemetryId = (await getOrCreateMem0UserId()) || existing;
|
||||||
|
try {
|
||||||
|
await this.vectorStore.setUserId(this.telemetryId);
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return this.telemetryId;
|
return this.telemetryId;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user