Skip to content

Chore: Adds detailed metrics for failed apps#37120

Closed
gabrielpetry wants to merge 10 commits intorelease-7.11.0from
chore/detail-failed-apps-metric
Closed

Chore: Adds detailed metrics for failed apps#37120
gabrielpetry wants to merge 10 commits intorelease-7.11.0from
chore/detail-failed-apps-metric

Conversation

@gabrielpetry
Copy link

@gabrielpetry gabrielpetry commented Oct 2, 2025

Adds a new metric to track the reasons for app failures.

  • Modifies getAppsStatistics to return detailed data about failed apps, including their names and error messages.
  • Introduces a new Prometheus gauge rocketchat_apps_failed_reason to expose this detailed information.

Summary by CodeRabbit

  • New Features

    • New Livechat REST endpoint to return chats to the queue.
    • Cancelable API requests via AbortSignal.
    • App metrics now report failed apps with reasons.
    • Improved Tags UI semantics and accessibility.
    • Added/updated translations across multiple locales.
  • Bug Fixes

    • Video call action is disabled in archived rooms.
  • Tests

    • New E2E coverage for Omnichannel tags and video conferencing (including archived channels).
  • Chores

    • Dependency patch bumps.
    • Deprecated legacy Livechat method.
    • Added validation failure logging in router.

Copilot AI review requested due to automatic review settings October 2, 2025 13:31
@gabrielpetry gabrielpetry requested review from a team as code owners October 2, 2025 13:31
@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Oct 2, 2025

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project
  • This PR has an invalid title

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Oct 2, 2025

🦋 Changeset detected

Latest commit: b3046ae

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 42 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/rest-typings Patch
@rocket.chat/api-client Patch
@rocket.chat/core-services Patch
@rocket.chat/ddp-client Patch
@rocket.chat/http-router Patch
@rocket.chat/models Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/federation-matrix Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/federation-service Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/livechat Patch
@rocket.chat/mock-providers Patch
@rocket.chat/cron Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch
@rocket.chat/media-calls Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-voip Patch
@rocket.chat/core-typings Patch
@rocket.chat/apps Patch
@rocket.chat/freeswitch Patch
@rocket.chat/model-typings Patch
@rocket.chat/license Patch
@rocket.chat/pdf-worker Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@CLAassistant
Copy link

CLAassistant commented Oct 2, 2025

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 2, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Introduces a new REST endpoint livechat/inquiries.returnAsInquiry, deprecates the Meteor method, updates server validations (including MAC limit and room closed), migrates client hooks to the REST endpoint, adds AbortSignal support to endpoint calls, adjusts metrics/statistics for failed apps, updates ChatInfo tags semantics, expands tests, adds router logging, and updates i18n.

Changes

Cohort / File(s) Summary
Release notes
/.changeset/calm-hounds-look.md, /.changeset/sixty-ladybugs-heal.md
Patch bumps and notes: REST endpoint replaces deprecated method; fix to hide video call button in archived rooms.
Livechat REST: return-as-inquiry
apps/meteor/app/livechat/imports/server/rest/inquiries.ts, apps/meteor/app/livechat/server/lib/rooms.ts, apps/meteor/app/livechat/server/methods/returnAsInquiry.ts
Adds POST livechat/inquiries.returnAsInquiry endpoint, augments room validation (MAC limit, 'Room closed' message), and marks old method deprecated with simplified checks.
Client migration to REST
apps/meteor/client/views/room/Header/Omnichannel/QuickActions/hooks/useReturnChatToQueueMutation.ts, apps/meteor/client/views/room/HeaderV2/Omnichannel/QuickActions/hooks/useReturnChatToQueueMutation.ts
Switches from Meteor method to REST endpoint; payload becomes object { roomId, departmentId? }.
Abortable endpoint calls
apps/meteor/client/providers/ServerProvider.tsx, packages/ui-contexts/src/ServerContext.ts, packages/ui-contexts/src/hooks/useEndpoint.ts, apps/meteor/client/apps/gameCenter/hooks/useExternalComponentsQuery.ts
Adds optional AbortSignal to callEndpoint/useEndpoint and propagates to REST calls; integrates cancellation into getExternalComponents.
Metrics and app statistics
apps/meteor/app/metrics/server/lib/collectMetrics.ts, apps/meteor/app/metrics/server/lib/metrics.ts, apps/meteor/app/statistics/server/lib/getAppsStatistics.ts
Replaces totalFailed with appsFailed array; exposes totalAppsFailed via length and adds appsFailedReason gauge; statistics now return detailed failures.
Omnichannel ChatInfo tags semantics
apps/meteor/client/views/omnichannel/directory/chats/ChatInfo/ChatInfo.tsx
Adds roomId-based labels, improves a11y with aria-labelledby, renders tags as list items.
Video call disabled on archived rooms
apps/meteor/client/hooks/roomActions/useVideoCallRoomAction.tsx, apps/meteor/tests/e2e/video-conference.spec.ts, apps/meteor/tests/e2e/utils/create-target-channel.ts
Disables video call action if room.archived; adds archived-channel tests and utility to create archived channels with cleanup.
Livechat inquiries API tests (REST)
apps/meteor/tests/end-to-end/api/livechat/05-inquiries.ts
Converts tests from methodCall RPC to REST payloads and assertions; removes methodCall/parse helpers usage.
Omnichannel tags E2E and page objects
apps/meteor/tests/e2e/omnichannel/omnichannel-assign-room-tags.spec.ts, apps/meteor/tests/e2e/page-objects/omnichannel-room-info.ts
Adds EE tests for tag visibility/selection; introduces page-object helpers for tag inputs/options and info labels.
HTTP Router logging
packages/http-router/package.json, packages/http-router/src/Router.ts
Adds @rocket.chat/logger dependency; logs schema validation warnings for query/body/response with 400 returns on failures.
REST typings
packages/rest-typings/src/v1/omnichannel.ts
Adds types and validators for POST livechat/inquiries.returnAsInquiry request and success response.
i18n updates
packages/i18n/src/locales/{de,en,fi,hi-IN,hu,nb,nn,pl,pt-BR,ru,sv}.i18n.json
Adds Federation_Description across locales; tweaks en Sidebar_list_mode text and pt-BR message/Sidebar/joined entries; adds _joined.comment in en.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant UI as Client UI
  participant Hook as useEndpoint
  participant Provider as ServerProvider.callEndpoint
  participant Router as HTTP Router
  participant API as Livechat REST Controller
  participant Domain as returnRoomAsInquiry
  participant Models as LivechatRooms

  UI->>Hook: returnChatToQueue({ roomId, departmentId? }, { signal? })
  Hook->>Provider: callEndpoint(POST /v1/livechat/inquiries.returnAsInquiry, payload, signal?)
  Provider->>Router: HTTP POST /v1/livechat/inquiries.returnAsInquiry
  Router-->>Router: Validate query/body schemas
  alt Validation fails
    Router-->>Provider: 400 { error, details }
    Provider-->>Hook: reject
    Hook-->>UI: surface error
  else OK
    Router->>API: handle request
    API->>Models: find room by roomId
    alt Room not found
      API-->>Router: 404/400 failure
    else Found
      API->>Domain: returnRoomAsInquiry(room, departmentId?)
      alt MAC limit exceeded
        Domain-->>API: throw 'error-mac-limit-reached'
        API-->>Router: 400 mapped failure
      else Room closed or other rules
        Domain-->>API: throw with message ('Room closed', etc.)
        API-->>Router: 400 mapped failure
      else Success
        Domain-->>API: true
        API-->>Router: 200 { result: true }
      end
    end
    Router-->>Provider: Response
    Provider-->>Hook: resolve
    Hook-->>UI: onSuccess/invalidate queries
  end
Loading
sequenceDiagram
  autonumber
  participant Comp as Component
  participant Hook as useEndpoint
  participant Provider as callEndpoint
  participant Net as fetch()
  Note over Comp,Net: Abortable endpoint call with AbortSignal
  Comp->>Hook: fn(params, { signal })
  Hook->>Provider: callEndpoint(..., signal)
  Provider->>Net: fetch(url, { signal })
  alt signal.abort()
    Net-->>Provider: AbortError
    Provider-->>Hook: throw AbortError
    Hook-->>Comp: handle cancellation
  else completes
    Net-->>Provider: Response
    Provider-->>Hook: Data
    Hook-->>Comp: Data
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

stat: ready to merge, stat: QA assured

Suggested reviewers

  • ggazzo
  • dougfabris
  • aleksandernsilva

Poem

I thump my paws on shifting logs,
New routes hop in, old methods jog.
Tags line up in tidy queues,
Metrics nibble failed-app news.
Abort!—if storms begin to brew—
Then softly, swiftly, we’re through.
🐇✨

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/detail-failed-apps-metric

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 1d0fc48 and b3046ae.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (35)
  • .changeset/calm-hounds-look.md (1 hunks)
  • .changeset/sixty-ladybugs-heal.md (1 hunks)
  • apps/meteor/app/livechat/imports/server/rest/inquiries.ts (2 hunks)
  • apps/meteor/app/livechat/server/lib/rooms.ts (2 hunks)
  • apps/meteor/app/livechat/server/methods/returnAsInquiry.ts (2 hunks)
  • apps/meteor/app/metrics/server/lib/collectMetrics.ts (1 hunks)
  • apps/meteor/app/metrics/server/lib/metrics.ts (1 hunks)
  • apps/meteor/app/statistics/server/lib/getAppsStatistics.ts (6 hunks)
  • apps/meteor/client/apps/gameCenter/hooks/useExternalComponentsQuery.ts (1 hunks)
  • apps/meteor/client/hooks/roomActions/useVideoCallRoomAction.tsx (1 hunks)
  • apps/meteor/client/providers/ServerProvider.tsx (1 hunks)
  • apps/meteor/client/views/omnichannel/directory/chats/ChatInfo/ChatInfo.tsx (2 hunks)
  • apps/meteor/client/views/room/Header/Omnichannel/QuickActions/hooks/useReturnChatToQueueMutation.ts (2 hunks)
  • apps/meteor/client/views/room/HeaderV2/Omnichannel/QuickActions/hooks/useReturnChatToQueueMutation.ts (2 hunks)
  • apps/meteor/tests/e2e/omnichannel/omnichannel-assign-room-tags.spec.ts (1 hunks)
  • apps/meteor/tests/e2e/page-objects/omnichannel-room-info.ts (1 hunks)
  • apps/meteor/tests/e2e/utils/create-target-channel.ts (1 hunks)
  • apps/meteor/tests/e2e/video-conference.spec.ts (6 hunks)
  • apps/meteor/tests/end-to-end/api/livechat/05-inquiries.ts (7 hunks)
  • packages/http-router/package.json (1 hunks)
  • packages/http-router/src/Router.ts (5 hunks)
  • packages/i18n/src/locales/de.i18n.json (1 hunks)
  • packages/i18n/src/locales/en.i18n.json (3 hunks)
  • packages/i18n/src/locales/fi.i18n.json (1 hunks)
  • packages/i18n/src/locales/hi-IN.i18n.json (1 hunks)
  • packages/i18n/src/locales/hu.i18n.json (1 hunks)
  • packages/i18n/src/locales/nb.i18n.json (1 hunks)
  • packages/i18n/src/locales/nn.i18n.json (1 hunks)
  • packages/i18n/src/locales/pl.i18n.json (1 hunks)
  • packages/i18n/src/locales/pt-BR.i18n.json (4 hunks)
  • packages/i18n/src/locales/ru.i18n.json (1 hunks)
  • packages/i18n/src/locales/sv.i18n.json (1 hunks)
  • packages/rest-typings/src/v1/omnichannel.ts (1 hunks)
  • packages/ui-contexts/src/ServerContext.ts (1 hunks)
  • packages/ui-contexts/src/hooks/useEndpoint.ts (2 hunks)

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.

@gabrielpetry gabrielpetry changed the title Adds detailed metrics for failed apps Chore: Adds detailed metrics for failed apps Oct 2, 2025
@gabrielpetry gabrielpetry deleted the chore/detail-failed-apps-metric branch October 2, 2025 13:32
Copy link
Contributor

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 refactors the Rocket.Chat livechat inquiry return functionality by migrating from Meteor methods to REST endpoints and adds comprehensive metrics tracking for failed apps.

  • Migrates livechat:returnAsInquiry Meteor method to a new REST endpoint /v1/livechat/inquiries.returnAsInquiry
  • Adds detailed metrics for failed apps including names and error messages via a new Prometheus gauge
  • Enhances endpoint infrastructure to support AbortSignal for request cancellation

Reviewed Changes

Copilot reviewed 35 out of 36 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
apps/meteor/app/livechat/imports/server/rest/inquiries.ts Implements new REST endpoint for returning inquiries with proper validation and error handling
apps/meteor/app/livechat/server/methods/returnAsInquiry.ts Adds deprecation warning to existing Meteor method
apps/meteor/app/statistics/server/lib/getAppsStatistics.ts Modifies statistics to return detailed failed app information instead of just counts
apps/meteor/app/metrics/server/lib/metrics.ts Adds new Prometheus gauge for tracking failed app details
packages/ui-contexts/src/hooks/useEndpoint.ts Adds AbortSignal support to endpoint hooks
multiple client files Updates references from Meteor method to new REST endpoint

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

totalActive++;
} else if (status !== AppStatus.MANUALLY_DISABLED) {
totalFailed++;
appsFailed.push({name: app.getInfo().name, error: app.getStatus()});
Copy link

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

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

Missing spaces around object properties. Add spaces around the colon for consistency: { name: app.getInfo().name, error: app.getStatus() }.

Suggested change
appsFailed.push({name: app.getInfo().name, error: app.getStatus()});
appsFailed.push({ name: app.getInfo().name, error: app.getStatus() });

Copilot uses AI. Check for mistakes.
"Features": "Funktionen",
"Federated": "Verbunden",
"Federation": "Verbund",
"Federation_Description": "Verbund ermöglicht es einer begrenzten Anzahl von Arbeitsbereichen, miteinander zu kommunizieren.",
Copy link

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

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

The German translation contains an error. It says 'begrenzten Anzahl' (limited number) but should say 'unbegrenzten Anzahl' (unlimited number) to match the English meaning.

Suggested change
"Federation_Description": "Verbund ermöglicht es einer begrenzten Anzahl von Arbeitsbereichen, miteinander zu kommunizieren.",
"Federation_Description": "Verbund ermöglicht es einer unbegrenzten Anzahl von Arbeitsbereichen, miteinander zu kommunizieren.",

Copilot uses AI. Check for mistakes.
metrics.totalAppsFailed.set(appsFailed.length || 0);

for (const app of appsFailed) {
metrics.appsFailedReason.set({ ...app }, 1);
Copy link

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

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

Using spread operator on app assumes it has the correct structure. Consider explicitly destructuring the expected properties: metrics.appsFailedReason.set({ name: app.name, error: app.error }, 1);

Suggested change
metrics.appsFailedReason.set({ ...app }, 1);
metrics.appsFailedReason.set({ name: app.name, error: app.error }, 1);

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Oct 2, 2025

Codecov Report

❌ Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 67.40%. Comparing base (dca0b3a) to head (b3046ae).
⚠️ Report is 21 commits behind head on release-7.11.0.

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##           release-7.11.0   #37120      +/-   ##
==================================================
+ Coverage           67.38%   67.40%   +0.02%     
==================================================
  Files                3328     3330       +2     
  Lines              113342   113502     +160     
  Branches            20562    20612      +50     
==================================================
+ Hits                76375    76509     +134     
- Misses              34363    34389      +26     
  Partials             2604     2604              
Flag Coverage Δ
unit 71.20% <88.88%> (+0.05%) ⬆️

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

🚀 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants