✨ feat(langfuse): add LANGFUSE_TRACE_DATA support for trace field map…#13375
✨ feat(langfuse): add LANGFUSE_TRACE_DATA support for trace field map…#13375WindSpiritSR wants to merge 1 commit intolobehub:canaryfrom
Conversation
…ping Signed-off-by: WindSpiritSR <[email protected]>
|
@WindSpiritSR is attempting to deploy a commit to the LobeHub OSS Team on Vercel. A member of the Team first needs to authorize it. |
|
@nekomeowww @tjx666 - This PR adds LANGFUSE_TRACE_DATA support for Langfuse trace field mapping, touching backend API, env config, trace module, and self-hosting docs. Please coordinate on review. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0cdbbef9a3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| }; | ||
|
|
||
| const originalUserId = traceData?.userId ?? tracePayload?.userId; | ||
| const traceUserId = traceDataMap[LANGFUSE_TRACE_DATA.userId] ?? originalUserId; |
There was a problem hiding this comment.
Fallback to original userId when mapped value is empty
When LANGFUSE_TRACE_DATA is set to map userId from email, the expression traceDataMap[LANGFUSE_TRACE_DATA.userId] ?? originalUserId treats an empty string as a valid value. In deployments with legacy or imported users that have email: '', this sends a blank Langfuse userId instead of falling back to the original ID, which breaks trace attribution and contradicts the documented "empty value falls back" behavior.
Useful? React with 👍 / 👎.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## canary #13375 +/- ##
=======================================
Coverage 66.94% 66.95%
=======================================
Files 1903 1903
Lines 153684 153724 +40
Branches 15534 15539 +5
=======================================
+ Hits 102889 102927 +38
- Misses 50675 50677 +2
Partials 120 120
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
💻 Change Type
🔗 Related Issue
Related to observability and Langfuse trace metadata customization.
🔀 Description of Change
This PR adds support for LANGFUSE_TRACE_DATA to control how user fields are mapped into Langfuse trace fields.
userId:userId(default)userId:email🧪 How to Test
Validation scenarios:
Default behavior without LANGFUSE_TRACE_DATA uses userId:userId
LANGFUSE_TRACE_DATA=userId:email maps trace userId to user email when available
Invalid values (for example userId:unknown_field) fall back to userId:userId
Tested locally
Added/updated tests
No tests needed
📸 Screenshots / Videos
📝 Additional Information