MCPcopy
hub / github.com/Fission-AI/OpenSpec / getOrCreateAnonymousId

Function getOrCreateAnonymousId

src/telemetry/index.ts:69–86  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

67 * Lazily generates a UUID on first call and persists it.
68 */
69export async function getOrCreateAnonymousId(): Promise<string> {
70 // Return cached value if available
71 if (anonymousId) {
72 return anonymousId;
73 }
74
75 // Try to load from config
76 const config = await getTelemetryConfig();
77 if (config.anonymousId) {
78 anonymousId = config.anonymousId;
79 return anonymousId;
80 }
81
82 // Generate new UUID and persist
83 anonymousId = randomUUID();
84 await updateTelemetryConfig({ anonymousId });
85 return anonymousId;
86}
87
88/**
89 * Get the PostHog client instance.

Callers 1

trackCommandFunction · 0.85

Calls 2

getTelemetryConfigFunction · 0.85
updateTelemetryConfigFunction · 0.85

Tested by

no test coverage detected