Skip to content

Conversation

@imnasnainaec
Copy link
Collaborator

@imnasnainaec imnasnainaec commented Dec 15, 2025

Alternative to #4063

Triggered by any of the following:

  • Login
  • Refresh
  • UI language update in user settings

Also: fixes bug that layout doesn't switch to RTL when user changes UI language to Arabic. (It does switch when the UI language is automatically matching the browser language.)


This change is Reviewable

Summary by CodeRabbit

  • New Features

    • Added automatic UI language preference logging to track user language settings.
    • Language preferences are now recorded when users change their UI language or during app initialization.
  • Improvements

    • Enhanced internationalization support with consistent language preference tracking.

✏️ Tip: You can customize this high-level summary in your review settings.

@imnasnainaec imnasnainaec self-assigned this Dec 15, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 15, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

This change adds UI language logging functionality across the stack. A new POST endpoint /v1/users/uilanguage is added to the backend controller with OTEL tracing. The API client is updated with corresponding methods across all layers. A backend wrapper function is introduced, and i18n integration calls the new endpoint automatically when language changes occur.

Changes

Cohort / File(s) Change Summary
Backend Controller
Backend/Controllers/UserController.cs
Added new UiLanguage POST endpoint at /v1/users/uilanguage that logs the user's current UI language with OTEL activity tracing and returns HTTP 200 OK.
API Client Layers
src/api/api/user-api.ts
Added uiLanguage method across all API layers (AxiosParamCreator, Fp, Factory, and UserApi class). Introduced UserApiUiLanguageRequest interface. Validates required body parameter and constructs POST request to /v1/users/uilanguage.
Backend Wrapper
src/backend/index.ts
Added public uiLanguage(uilang: string) function that delegates to the API. Updated whitelist to include /users/uilanguage path and corrected comment wording.
i18n Integration
src/i18n/index.ts
Updated updateLangFromUser() to call uiLanguage() for logging. Added setDir() function and shortened callback description. Added inline commentary explaining logging behavior.

Sequence Diagram

sequenceDiagram
    participant User
    participant i18n as i18n Module
    participant Backend as Backend Wrapper
    participant Client as API Client
    participant Controller as Backend Controller
    participant OTEL as OTEL Tracing

    User->>i18n: changeLanguage()
    i18n->>i18n: updateLangFromUser()
    i18n->>Backend: uiLanguage(lang)
    Backend->>Client: userApi.uiLanguage(lang)
    Client->>Controller: POST /v1/users/uilanguage
    Controller->>OTEL: Start activity "logging current UI language"
    OTEL->>OTEL: Tag: ui_language = lang
    OTEL->>Controller: Activity recorded
    Controller->>Client: 200 OK
    Client->>Backend: Promise resolved
    Backend->>i18n: void
    i18n->>User: Language updated & logged
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Areas for attention:
    • Verify OTEL activity tracing implementation in backend controller
    • Confirm i18n.dir() returns valid RTL/LTR values for setDir() function
    • Check error handling in backend wrapper function when API call fails
    • Ensure UserApiUiLanguageRequest interface aligns with expected body parameter

Suggested reviewers

  • jasonleenaylor

Poem

🐰 A whisper to the logs we send,
The language choice, our user's friend,
From i18n down the stack we go,
With OTEL tracing all aglow,
Each layer speaks what tongue they know! 📝✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title '[otel] Log UI language from the frontend' directly and accurately reflects the main purpose of the PR: adding OpenTelemetry logging for the UI language from the frontend.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch otel-ui-lang-frontend

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2aac4b0 and df8b3ea.

📒 Files selected for processing (1)
  • src/i18n/index.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/i18n/index.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: tox (3.12)
  • GitHub Check: Analyze (csharp)
  • GitHub Check: test_coverage (22)
  • GitHub Check: docker_build

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Dec 15, 2025

Codecov Report

❌ Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.57%. Comparing base (82bee05) to head (df8b3ea).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
Backend/Controllers/UserController.cs 0.00% 5 Missing ⚠️
src/i18n/index.ts 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4062      +/-   ##
==========================================
- Coverage   74.59%   74.57%   -0.03%     
==========================================
  Files         294      295       +1     
  Lines       10908    10938      +30     
  Branches     1367     1372       +5     
==========================================
+ Hits         8137     8157      +20     
- Misses       2375     2385      +10     
  Partials      396      396              
Flag Coverage Δ
backend 85.59% <0.00%> (-0.07%) ⬇️
frontend 66.02% <0.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@imnasnainaec imnasnainaec marked this pull request as ready for review December 15, 2025 21:52
@imnasnainaec imnasnainaec requested a review from Copilot December 15, 2025 21:52
@imnasnainaec
Copy link
Collaborator Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Dec 15, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
Backend/Controllers/UserController.cs (1)

98-106: Consider validating the uilang parameter.

The endpoint accepts any string for uilang and logs it directly to OTEL telemetry. While this is low-risk since it only affects logging, consider validating against a list of supported languages to ensure cleaner telemetry data and prevent logging of arbitrary/malicious strings.

If validation isn't needed for this use case, this is acceptable as-is.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 82bee05 and c3fa96c.

📒 Files selected for processing (4)
  • Backend/Controllers/UserController.cs (1 hunks)
  • src/api/api/user-api.ts (5 hunks)
  • src/backend/index.ts (1 hunks)
  • src/i18n/index.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
src/backend/index.ts (1)
src/api/api/user-api.ts (3)
  • uiLanguage (890-906)
  • uiLanguage (1094-1098)
  • uiLanguage (1449-1456)
Backend/Controllers/UserController.cs (2)
Backend/Controllers/LiftController.cs (2)
  • HttpGet (346-360)
  • IActionResult (497-504)
Backend/Otel/OtelService.cs (1)
  • OtelService (6-18)
src/i18n/index.ts (2)
src/api/api/user-api.ts (3)
  • uiLanguage (890-906)
  • uiLanguage (1094-1098)
  • uiLanguage (1449-1456)
src/backend/index.ts (1)
  • uiLanguage (731-733)
src/api/api/user-api.ts (1)
src/api/base.ts (2)
  • RequestArgs (38-41)
  • BASE_PATH (20-20)
🔇 Additional comments (2)
src/backend/index.ts (1)

731-733: LGTM!

The function correctly wraps the API call with authentication headers and follows the established patterns in this file.

src/api/api/user-api.ts (1)

1-13: Auto-generated file - no manual review required.

This file is auto-generated by OpenAPI Generator based on the backend API specification. The generated code correctly implements the new uiLanguage endpoint following the existing patterns.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds OpenTelemetry logging for the UI language from the frontend, enabling better tracking of user language preferences. The logging is triggered during login, page refresh, and when users update their UI language in settings.

  • Added a new backend endpoint to log UI language as an OpenTelemetry tag
  • Generated TypeScript API client code for the new endpoint
  • Integrated UI language logging into the language update flow in the i18n module

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
Backend/Controllers/UserController.cs Adds new UiLanguage endpoint that logs the UI language as an OpenTelemetry tag
src/api/api/user-api.ts Auto-generated TypeScript API client code for the new uiLanguage endpoint
src/backend/index.ts Adds wrapper function uiLanguage to call the backend API endpoint
src/i18n/index.ts Updates updateLangFromUser to log the resolved UI language after language changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@imnasnainaec imnasnainaec added the 🟨Medium Medium-priority PR label Dec 15, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
Backend/Controllers/UserController.cs (1)

98-106: LGTM! Endpoint follows established patterns.

The implementation correctly uses POST, creates OTEL activities consistent with other controllers, and properly tags the telemetry data. The dual-tag pattern (operation descriptor + actual language value) provides good observability.

Consider adding basic validation for the uilang parameter to ensure it's a non-empty string and optionally matches expected language code patterns (e.g., 2-3 letter codes). While not critical for a logging endpoint, it would prevent noise in telemetry data:

 public IActionResult UiLanguage([FromBody, BindRequired] string uilang)
 {
+    if (string.IsNullOrWhiteSpace(uilang))
+    {
+        return BadRequest("UI language cannot be empty");
+    }
     using var activity = OtelService.StartActivityWithTag(otelTagName, "logging current UI language");
     activity?.SetTag("ui_language", uilang);
     return Ok();
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c3fa96c and 2b5552f.

📒 Files selected for processing (4)
  • Backend/Controllers/UserController.cs (1 hunks)
  • src/api/api/user-api.ts (5 hunks)
  • src/backend/index.ts (2 hunks)
  • src/i18n/index.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/backend/index.ts
🧰 Additional context used
🧬 Code graph analysis (3)
src/i18n/index.ts (2)
src/api/api/user-api.ts (3)
  • uiLanguage (894-910)
  • uiLanguage (1098-1102)
  • uiLanguage (1453-1460)
src/backend/index.ts (1)
  • uiLanguage (732-734)
Backend/Controllers/UserController.cs (1)
Backend/Otel/OtelService.cs (1)
  • OtelService (6-18)
src/api/api/user-api.ts (1)
src/api/base.ts (2)
  • RequestArgs (38-41)
  • BASE_PATH (20-20)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: test_coverage (22)
  • GitHub Check: Analyze (csharp)
  • GitHub Check: test_build (8.0.x)
  • GitHub Check: docker_build
  • GitHub Check: tox (3.12)
🔇 Additional comments (2)
src/i18n/index.ts (1)

54-60: LGTM! Error handling properly implemented.

The fire-and-forget pattern with .catch() is appropriate for telemetry logging. The console warning provides debugging visibility without blocking the language update flow. This correctly addresses the previous review concern about unhandled promise rejections.

src/api/api/user-api.ts (1)

500-548: LGTM! Auto-generated API client code follows standard patterns.

The generated code correctly implements the UI language endpoint across all API layers (param creator, FP interface, factory, and class). The POST method and request structure align with the backend endpoint definition.

Also applies to: 888-910, 1092-1102, 1241-1253, 1446-1460

@jasonleenaylor
Copy link
Contributor

src/i18n/index.ts line 56 at r2 (raw file):

  // Log the user's current UI language
  const { resolvedLanguage } = i18n;
  if (resolvedLanguage) {

do we want to bother if it wasn't updated?

@imnasnainaec imnasnainaec added bug Something isn't working enhancement New feature or request font/language labels Dec 16, 2025
Copy link
Collaborator Author

@imnasnainaec imnasnainaec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@imnasnainaec reviewed 1 file and made 1 comment.
Reviewable status: 1 of 5 files reviewed, all discussions resolved.


src/i18n/index.ts line 56 at r2 (raw file):

Previously, jasonleenaylor (Jason Naylor) wrote…

do we want to bother if it wasn't updated?

Explanatory comment added.

Copy link
Contributor

@jasonleenaylor jasonleenaylor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@jasonleenaylor reviewed 5 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @imnasnainaec).

@imnasnainaec imnasnainaec merged commit f78ef22 into master Dec 18, 2025
22 of 23 checks passed
@imnasnainaec imnasnainaec deleted the otel-ui-lang-frontend branch December 18, 2025 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend bug Something isn't working enhancement New feature or request font/language frontend 🟨Medium Medium-priority PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants