MCPcopy
hub / github.com/claude-code-best/claude-code / getTelemetryAttributes

Function getTelemetryAttributes

src/utils/telemetryAttributes.ts:29–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27}
28
29export function getTelemetryAttributes(): Attributes {
30 const userId = getOrCreateUserID()
31 const sessionId = getSessionId()
32
33 const attributes: Attributes = {
34 'user.id': userId,
35 }
36
37 if (shouldIncludeAttribute('OTEL_METRICS_INCLUDE_SESSION_ID')) {
38 attributes['session.id'] = sessionId
39 }
40 if (shouldIncludeAttribute('OTEL_METRICS_INCLUDE_VERSION')) {
41 attributes['app.version'] = MACRO.VERSION
42 }
43
44 // Only include OAuth account data when actively using OAuth authentication
45 const oauthAccount = getOauthAccountInfo()
46 if (oauthAccount) {
47 const orgId = oauthAccount.organizationUuid
48 const email = oauthAccount.emailAddress
49 const accountUuid = oauthAccount.accountUuid
50
51 if (orgId) attributes['organization.id'] = orgId
52 if (email) attributes['user.email'] = email
53
54 if (
55 accountUuid &&
56 shouldIncludeAttribute('OTEL_METRICS_INCLUDE_ACCOUNT_UUID')
57 ) {
58 attributes['user.account_uuid'] = accountUuid
59 attributes['user.account_id'] =
60 process.env.CLAUDE_CODE_ACCOUNT_TAGGED_ID ||
61 toTaggedId('user', accountUuid)
62 }
63 }
64
65 // Add terminal type if available
66 if (envDynamic.terminal) {
67 attributes['terminal.type'] = envDynamic.terminal
68 }
69
70 return attributes
71}

Callers 3

logOTelEventFunction · 0.85
createSpanAttributesFunction · 0.85
addFunction · 0.85

Calls 5

getOrCreateUserIDFunction · 0.85
getSessionIdFunction · 0.85
shouldIncludeAttributeFunction · 0.85
toTaggedIdFunction · 0.85
getOauthAccountInfoFunction · 0.70

Tested by

no test coverage detected