MCPcopy
hub / github.com/lingodotdev/lingo.dev / determineDistinctId

Function determineDistinctId

packages/cli/src/cli/utils/observability.ts:17–51  ·  view source on GitHub ↗
(user: UserIdentity)

Source from the content-addressed store, hash-verified

15} | null;
16
17function determineDistinctId(user: UserIdentity): {
18 distinct_id: string;
19 distinct_id_source: string;
20 org_id: string | null;
21} {
22 const orgId = getOrgId();
23
24 if (user) {
25 return {
26 distinct_id: user.id,
27 distinct_id_source: "database_id",
28 org_id: orgId,
29 };
30 }
31
32 if (orgId) {
33 return {
34 distinct_id: orgId,
35 distinct_id_source: "git_org",
36 org_id: orgId,
37 };
38 }
39
40 const deviceId = `device-${machineIdSync()}`;
41 if (process.env.DEBUG === "true") {
42 console.warn(
43 "[Tracking] Using device ID fallback. Consider using git repository for consistent tracking.",
44 );
45 }
46 return {
47 distinct_id: deviceId,
48 distinct_id_source: "device",
49 org_id: null,
50 };
51}
52
53export default function trackEvent(
54 user: UserIdentity,

Callers 1

trackEventFunction · 0.85

Calls 2

getOrgIdFunction · 0.90
warnMethod · 0.80

Tested by

no test coverage detected