MCPcopy Create free account
hub / github.com/Noumena-Network/code / buildTelemetryIdentityAttributes

Function buildTelemetryIdentityAttributes

src/utils/telemetryAttributes.ts:44–79  ·  view source on GitHub ↗
(
  session: TelemetryIdentitySession,
)

Source from the content-addressed store, hash-verified

42 | undefined
43
44export function buildTelemetryIdentityAttributes(
45 session: TelemetryIdentitySession,
46): Attributes {
47 const telemetrySession =
48 session == null
49 ? {
50 isOauthBackedFirstPartySession: false,
51 subscriptionType: null,
52 isEnterpriseOrTeam: false,
53 }
54 : buildTelemetrySessionState(session)
55
56 if (!telemetrySession.isOauthBackedFirstPartySession) {
57 return {}
58 }
59
60 const attributes: Attributes = {}
61 const orgId = session?.identity.organizationUuid ?? null
62 const email = session?.identity.email ?? null
63 const accountUuid = session?.identity.accountUuid ?? null
64
65 if (orgId) attributes['organization.id'] = orgId
66 if (email) attributes['user.email'] = email
67
68 if (
69 accountUuid &&
70 shouldIncludeAttribute('OTEL_METRICS_INCLUDE_ACCOUNT_UUID')
71 ) {
72 attributes['user.account_uuid'] = accountUuid
73 attributes['user.account_id'] =
74 process.env.CLAUDE_CODE_ACCOUNT_TAGGED_ID ||
75 toTaggedId('user', accountUuid)
76 }
77
78 return attributes
79}
80
81export function getTelemetryAttributes(): Attributes {
82 const userId = getOrCreateUserID()

Callers 2

getTelemetryAttributesFunction · 0.85

Calls 3

shouldIncludeAttributeFunction · 0.85
toTaggedIdFunction · 0.85

Tested by

no test coverage detected