refactor: simplify Langfuse integration with AI SDK 6 (#375)

- Remove manual token attribute setting (AI SDK 6 telemetry auto-reports)
- Use totalTokens directly instead of inputTokens + outputTokens calculation
- Fix sessionId bug in log-save/log-feedback (prevents wrong trace attachment)
- Hash IP addresses for privacy instead of storing raw IPs
- Fix isLangfuseEnabled() to check both keys for consistency
This commit is contained in:
Dayuan Jiang
2025-12-23 16:26:45 +09:00
committed by GitHub
parent 9aec7eda79
commit 5ec05eb100
5 changed files with 42 additions and 60 deletions

View File

@@ -27,6 +27,11 @@ export async function POST(req: Request) {
const { filename, format, sessionId } = data
// Skip logging if no sessionId - prevents attaching to wrong user's trace
if (!sessionId) {
return Response.json({ success: true, logged: false })
}
try {
const timestamp = new Date().toISOString()