feat(cli): send metadata to vNext localization endpoint#2020
feat(cli): send metadata to vNext localization endpoint#2020cherkanovart merged 3 commits intomainfrom
Conversation
Add sessionId, triggerType, and file path metadata to the vNext localization API requests for improved request logging and analytics. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughAdds file path metadata propagation through CLI localization flow and augments the vNext engine requests with sessionId and triggerType. Updates type definitions, extends localizer method signatures, adjusts request payload (adds metadata and params.fast, removes workflowId), and documents the change via a new changeset. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User/CLI
participant EX as Execute.ts
participant LZ as Localizer (VNext)
participant EN as VNext Engine
participant API as vNext Endpoint
U->>EX: run localize
EX->>LZ: localize({ data, filePath, ... })
LZ->>EN: localizeObject(..., filePath)
loop chunk over data
EN->>API: POST /localize { dataChunk, params:{fast}, sessionId, triggerType, metadata:{filePath} }
API-->>EN: 200 { translations }
end
EN-->>LZ: merged translations
LZ-->>EX: result
EX-->>U: output
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/cli/src/cli/localizer/lingodotdev-vnext.ts (1)
81-86: The hardcodedwhoamiresponse is intentional but represents an architectural difference that should be documented.vNext uses a different authentication model than the standard Lingo.dev provider. While all other implementations validate authentication through a server-side
/whoamiAPI call with Bearer tokens, vNext'swhoamimethod returns static mock data without server validation. This is intentional (as indicated by the code comment), but it means:
- Authentication status is determined solely by API key presence in the localization endpoint calls, not by server-side verification
- The hardcoded user identity (
"vnext-user") cannot be updated without code changescheckAuth()will always returnauthenticated: trueif the method succeeds, regardless of API key validityConsider clarifying the purpose and security implications of this design in the code comment.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/cli/src/cli/localizer/lingodotdev-vnext.ts` around lines 81 - 86, Update the comment above the async whoami(...) method in lingodotdev-vnext.ts to clearly document that this implementation intentionally returns static/mock identity data (email: "vnext-user", id: config.processId) and does not perform server-side validation, explain that authentication is determined by API key presence on localization endpoint calls (not by whoami), note that checkAuth() will always report authenticated:true if whoami() succeeds regardless of API key validity, and call out the maintenance implication that the hardcoded identity cannot be changed without code modifications so consumers should not rely on dynamic user identity or server verification for security.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/cli/src/cli/localizer/lingodotdev-vnext.ts`:
- Around line 81-86: Update the comment above the async whoami(...) method in
lingodotdev-vnext.ts to clearly document that this implementation intentionally
returns static/mock identity data (email: "vnext-user", id: config.processId)
and does not perform server-side validation, explain that authentication is
determined by API key presence on localization endpoint calls (not by whoami),
note that checkAuth() will always report authenticated:true if whoami() succeeds
regardless of API key validity, and call out the maintenance implication that
the hardcoded identity cannot be changed without code modifications so consumers
should not rely on dynamic user identity or server verification for security.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
.changeset/send-metadata-to-endpoint.mdpackages/cli/src/cli/cmd/run/execute.tspackages/cli/src/cli/localizer/_types.tspackages/cli/src/cli/localizer/lingodotdev-vnext.ts
* feat(cli): send metadata to vNext localization endpoint Add sessionId, triggerType, and file path metadata to the vNext localization API requests for improved request logging and analytics. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: add changeset for metadata endpoint feature Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Summary
sessionId(unique per CLI invocation),triggerType("cli"or"ci"), andmetadata: { filePath }to vNext localization API requestsworkflowIdfrom request paramsfastinparamsfor potential future useCloses ENG-415
Test plan
pnpm turbo build --filter=lingo.dev)sessionId,triggerType, andmetadata.filePathCI=trueand verifytriggerTypeis"ci"🤖 Generated with Claude Code
Summary by CodeRabbit