Skip to content

Commit d690da5

Browse files
committed
Log token counts instead of tracking events
1 parent c90f8e0 commit d690da5

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

web/src/app/api/v1/token-count/_post.ts

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,15 @@ export async function postTokenCount(params: {
8383
logger,
8484
})
8585

86-
trackEvent({
87-
event: AnalyticsEvent.TOKEN_COUNT_REQUEST,
86+
logger.info({
8887
userId,
89-
properties: {
90-
messageCount: messages.length,
91-
hasSystem: !!system,
92-
model: model ?? 'claude-opus-4-5-20251101',
93-
inputTokens,
94-
},
95-
logger,
96-
})
88+
messageCount: messages.length,
89+
hasSystem: !!system,
90+
model: model ?? 'claude-opus-4-5-20251101',
91+
tokenCount: inputTokens,
92+
},
93+
`Token count: ${inputTokens}`
94+
)
9795

9896
return NextResponse.json({ inputTokens })
9997
} catch (error) {
@@ -102,15 +100,6 @@ export async function postTokenCount(params: {
102100
'Failed to count tokens via Anthropic API',
103101
)
104102

105-
trackEvent({
106-
event: AnalyticsEvent.TOKEN_COUNT_ERROR,
107-
userId,
108-
properties: {
109-
error: error instanceof Error ? error.message : 'Unknown error',
110-
},
111-
logger,
112-
})
113-
114103
return NextResponse.json(
115104
{ error: 'Failed to count tokens' },
116105
{ status: 500 },

0 commit comments

Comments
 (0)