Skip to content

Conversation

@KevLehman
Copy link
Member

@KevLehman KevLehman commented Jan 14, 2026

Proposed changes (including videos or screenshots)

Issue(s)

Steps to test or reproduce

Further comments

https://rocketchat.atlassian.net/browse/CORE-1715

Summary by CodeRabbit

  • Chores
    • Standardized server logging across backend components to use structured objects (msg + contextual fields) for clearer, richer diagnostics. This only changes log format and wording; no runtime behavior, control flow, public APIs, or user-facing functionality were modified.

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

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Jan 14, 2026

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Jan 14, 2026

⚠️ No Changeset found

Latest commit: f0ae097

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 14, 2026

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

Converts many string-interpolated logger calls to structured-object logging (objects with msg plus contextual fields) across importer, integrations, and livechat server modules; no control-flow, API, or exported-signature changes.

Changes

Cohort / File(s) Summary
Importer
apps/meteor/app/importer/server/classes/converters/MessageConverter.ts
Replaced string warning/error logs with structured objects (msg, roomId, userId, timestamp, importId).
Integrations
apps/meteor/app/integrations/server/lib/triggerHandler.ts
Converted numerous integration/debug/error logs to structured objects (fields like msg, integrationName, event, url, status, waitTime).
Livechat — Queue & Routing
apps/meteor/app/livechat/server/lib/QueueManager.ts, apps/meteor/app/livechat/server/lib/RoutingManager.ts
Swapped string debug logs for structured objects including msg and identifiers (inquiryId, agentUsername, agentId, roomId, department).
Livechat — Room lifecycle
apps/meteor/app/livechat/server/lib/closeRoom.ts, apps/meteor/app/livechat/server/lib/rooms.ts
Converted room-related logs to { msg, ...context } format (roomId, visitorId, attemptsLeft, departmentId, customFieldCount, transferredBy).
Livechat — Contacts & Custom Fields
apps/meteor/app/livechat/server/lib/contacts/migrateVisitorIfMissingContact.ts, apps/meteor/app/livechat/server/lib/contacts/migrateVisitorToContactId.ts, apps/meteor/app/livechat/server/lib/custom-fields.ts, apps/meteor/app/livechat/server/lib/guests.ts
Replaced visitor/contact/custom-field debug logs with structured objects (visitorId, contactId, token, customFieldCount).
Livechat — Supporting services
apps/meteor/app/livechat/server/lib/departmentsLib.ts, apps/meteor/app/livechat/server/lib/service-status.ts, apps/meteor/app/livechat/server/lib/tracking.ts, apps/meteor/app/livechat/server/lib/transfer.ts, apps/meteor/app/livechat/server/lib/webhooks.ts
Standardized logs to structured objects for department ops, agent status, page history, transfers, and webhook retry/error handling (msg plus contextual fields like department, agentsOnline, roomId, webhookUrl).

Sequence Diagram(s)

(omitted — changes are logging-format only, not control-flow or new multi-component interactions)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • sampaiodiego
  • ggazzo

Poem

🐰 I hop through logs with tidy little feet,
Fields in columns now, no tangled string to meet.
"msg" first, context next — all neat and bright,
I nibble old templates and set logs right. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.17% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 accurately describes the main change: converting log messages from string format to structured object format across multiple files in the livechat and importer modules.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 chore/logs-3

🧹 Recent nitpick comments
apps/meteor/app/livechat/server/lib/closeRoom.ts (1)

159-167: LGTM with minor nit.

Structured logging correctly applied for closer identification. Line 159 appropriately uses optional chaining for user?._id.

Minor inconsistency on line 167: uses params.visitor._id instead of the destructured visitor._id from line 166. Not a bug, but could be more consistent.


📜 Recent review details

Configuration used: Organization 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 7fdc1f5 and f0ae097.

📒 Files selected for processing (3)
  • apps/meteor/app/livechat/server/lib/RoutingManager.ts
  • apps/meteor/app/livechat/server/lib/closeRoom.ts
  • apps/meteor/app/livechat/server/lib/departmentsLib.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/meteor/app/livechat/server/lib/departmentsLib.ts
  • apps/meteor/app/livechat/server/lib/RoutingManager.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/app/livechat/server/lib/closeRoom.ts
🧠 Learnings (6)
📚 Learning: 2025-10-28T16:53:42.761Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37205
File: ee/packages/federation-matrix/src/FederationMatrix.ts:296-301
Timestamp: 2025-10-28T16:53:42.761Z
Learning: In the Rocket.Chat federation-matrix integration (ee/packages/federation-matrix/), the createRoom method from rocket.chat/federation-sdk will support a 4-argument signature (userId, roomName, visibility, displayName) in newer versions. Code using this 4-argument call is forward-compatible with planned library updates and should not be flagged as an error.

Applied to files:

  • apps/meteor/app/livechat/server/lib/closeRoom.ts
📚 Learning: 2025-09-25T09:59:26.461Z
Learnt from: Dnouv
Repo: RocketChat/Rocket.Chat PR: 37057
File: packages/apps-engine/src/definition/accessors/IUserRead.ts:23-27
Timestamp: 2025-09-25T09:59:26.461Z
Learning: AppUserBridge.getUserRoomIds in apps/meteor/app/apps/server/bridges/users.ts always returns an array of strings (mapping subscription documents to room IDs), never undefined, even when user has no room subscriptions.

Applied to files:

  • apps/meteor/app/livechat/server/lib/closeRoom.ts
📚 Learning: 2025-09-25T09:59:26.461Z
Learnt from: Dnouv
Repo: RocketChat/Rocket.Chat PR: 37057
File: packages/apps-engine/src/definition/accessors/IUserRead.ts:23-27
Timestamp: 2025-09-25T09:59:26.461Z
Learning: AppUserBridge.getUserRoomIds in apps/meteor/app/apps/server/bridges/users.ts always returns an array of strings by mapping subscription documents to room IDs, never undefined, even when user has no room subscriptions.

Applied to files:

  • apps/meteor/app/livechat/server/lib/closeRoom.ts
📚 Learning: 2025-11-19T18:20:37.116Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37419
File: apps/meteor/server/services/media-call/service.ts:141-141
Timestamp: 2025-11-19T18:20:37.116Z
Learning: In apps/meteor/server/services/media-call/service.ts, the sendHistoryMessage method should use call.caller.id or call.createdBy?.id as the message author, not call.transferredBy?.id. Even for transferred calls, the message should appear in the DM between the two users who are calling each other, not sent by the person who transferred the call.

Applied to files:

  • apps/meteor/app/livechat/server/lib/closeRoom.ts
📚 Learning: 2025-09-25T09:59:26.461Z
Learnt from: Dnouv
Repo: RocketChat/Rocket.Chat PR: 37057
File: packages/apps-engine/src/definition/accessors/IUserRead.ts:23-27
Timestamp: 2025-09-25T09:59:26.461Z
Learning: UserBridge.doGetUserRoomIds in packages/apps-engine/src/server/bridges/UserBridge.ts has a bug where it implicitly returns undefined when the app lacks read permission (missing return statement in the else case of the permission check).

Applied to files:

  • apps/meteor/app/livechat/server/lib/closeRoom.ts
📚 Learning: 2025-11-27T17:56:26.050Z
Learnt from: MartinSchoeler
Repo: RocketChat/Rocket.Chat PR: 37557
File: apps/meteor/client/views/admin/ABAC/AdminABACRooms.tsx:115-116
Timestamp: 2025-11-27T17:56:26.050Z
Learning: In Rocket.Chat, the GET /v1/abac/rooms endpoint (implemented in ee/packages/abac/src/index.ts) only returns rooms where abacAttributes exists and is not an empty array (query: { abacAttributes: { $exists: true, $ne: [] } }). Therefore, in components consuming this endpoint (like AdminABACRooms.tsx), room.abacAttributes is guaranteed to be defined for all returned rooms, and optional chaining before calling array methods like .join() is sufficient without additional null coalescing.

Applied to files:

  • apps/meteor/app/livechat/server/lib/closeRoom.ts
🧬 Code graph analysis (1)
apps/meteor/app/livechat/server/lib/closeRoom.ts (1)
packages/core-typings/src/IRoom.ts (1)
  • isOmnichannelRoom (333-333)
⏰ 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). (3)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🔇 Additional comments (4)
apps/meteor/app/livechat/server/lib/closeRoom.ts (4)

49-50: LGTM!

Good use of structured logging with attemptsLeft field for retry observability.


80-80: LGTM!

Structured logging correctly applied in afterRoomClosed. The "Room was closed" message on line 121 is accurate since it executes after the transaction is committed.

Also applies to: 91-91, 121-121


177-177: LGTM!

Good bracketing of DB operations with clear "Updating DB" and "DB updated" messages for traceability.

Also applies to: 207-207


223-223: LGTM!

Structured logging correctly applied in resolveChatTags and closeOpenChats with appropriate contextual fields.

Also applies to: 284-284

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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 Jan 14, 2026

Codecov Report

❌ Patch coverage is 12.50000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.70%. Comparing base (46383a6) to head (f0ae097).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #38181      +/-   ##
===========================================
- Coverage    70.70%   70.70%   -0.01%     
===========================================
  Files         3147     3147              
  Lines       108851   108851              
  Branches     19625    19582      -43     
===========================================
- Hits         76965    76958       -7     
- Misses       29886    29889       +3     
- Partials      2000     2004       +4     
Flag Coverage Δ
e2e 60.18% <ø> (-0.02%) ⬇️
e2e-api 47.30% <ø> (-1.10%) ⬇️
unit 71.85% <12.50%> (+0.02%) ⬆️

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.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 14, 2026

📦 Docker Image Size Report

➡️ Changes

Service Current Baseline Change Percent
sum of all images 0B 0B 0B
account-service 0B 0B 0B
authorization-service 0B 0B 0B
ddp-streamer-service 0B 0B 0B
omnichannel-transcript-service 0B 0B 0B
presence-service 0B 0B 0B
queue-worker-service 0B 0B 0B
rocketchat 0B 0B 0B

📊 Historical Trend

---
config:
  theme: "dark"
  xyChart:
    width: 900
    height: 400
---
xychart
  title "Image Size Evolution by Service (Last 30 Days + This PR)"
  x-axis ["11/18 22:53", "11/19 23:02", "11/21 16:49", "11/24 17:34", "11/27 22:32", "11/28 19:05", "12/01 23:01", "12/02 21:57", "12/03 21:00", "12/04 18:17", "12/05 21:56", "12/08 20:15", "12/09 22:17", "12/10 23:26", "12/11 21:56", "12/12 22:45", "12/13 01:34", "12/15 22:31", "12/16 22:18", "12/17 21:04", "12/18 23:12", "12/19 23:27", "12/20 21:03", "12/22 18:54", "12/23 16:16", "12/24 19:38", "12/25 17:51", "12/26 13:18", "12/29 19:01", "12/30 20:52", "01/14 20:38 (PR)"]
  y-axis "Size (GB)" 0 --> 0.5
  line "account-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.00]
  line "authorization-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.00]
  line "ddp-streamer-service" [0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.00]
  line "omnichannel-transcript-service" [0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.00]
  line "presence-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.00]
  line "queue-worker-service" [0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.00]
  line "rocketchat" [0.35, 0.35, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.00]
Loading

Statistics (last 30 days):

  • 📊 Average: 1.5GiB
  • ⬇️ Minimum: 1.4GiB
  • ⬆️ Maximum: 1.6GiB
  • 🎯 Current PR: 0B
ℹ️ About this report

This report compares Docker image sizes from this build against the develop baseline.

  • Tag: pr-38181
  • Baseline: develop
  • Timestamp: 2026-01-14 20:38:32 UTC
  • Historical data points: 30

Updated: Wed, 14 Jan 2026 20:38:32 GMT

@KevLehman KevLehman marked this pull request as ready for review January 14, 2026 16:28
@KevLehman KevLehman requested review from a team as code owners January 14, 2026 16:28
@KevLehman KevLehman added this to the 8.1.0 milestone Jan 14, 2026
@KevLehman KevLehman added the stat: QA assured Means it has been tested and approved by a company insider label Jan 14, 2026
@dionisio-bot dionisio-bot bot added stat: ready to merge PR tested and approved waiting for merge stat: QA assured Means it has been tested and approved by a company insider and removed stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge labels Jan 14, 2026
@dionisio-bot dionisio-bot bot added stat: QA assured Means it has been tested and approved by a company insider and removed stat: ready to merge PR tested and approved waiting for merge stat: QA assured Means it has been tested and approved by a company insider labels Jan 14, 2026
@KevLehman KevLehman closed this Jan 14, 2026
@dionisio-bot dionisio-bot bot added stat: ready to merge PR tested and approved waiting for merge stat: QA assured Means it has been tested and approved by a company insider and removed stat: ready to merge PR tested and approved waiting for merge stat: QA assured Means it has been tested and approved by a company insider labels Jan 14, 2026
@KevLehman KevLehman reopened this Jan 14, 2026
Copy link
Contributor

@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: 2

🤖 Fix all issues with AI agents
In `@apps/meteor/app/integrations/server/lib/triggerHandler.ts`:
- Around line 699-701: The log message in triggerHandler.ts is incorrect: inside
the block checking res.status === 410 you call outgoingLogger.error with
'Disabling integration due to 401 status'; update that string to say 'Disabling
integration due to 410 status' (the surrounding code references include the if
block handling 410, outgoingLogger.error call, and trigger.name) so the log
accurately reflects the handled HTTP status.

In `@apps/meteor/app/livechat/server/lib/closeRoom.ts`:
- Line 155: The log message in closeRoom.ts incorrectly states "Room was closed"
before the DB update; update the logger.debug call that logs room._id and
closeData (the line invoking logger.debug) to a message like "Prepared close
data for room" or "Close data prepared for room" so it accurately reflects that
closeData has been prepared but the room has not yet been closed in the
database.
🧹 Nitpick comments (4)
apps/meteor/app/livechat/server/lib/tracking.ts (1)

10-14: Consider extracting token from the message string for consistency.

The msg field at line 11 embeds token via template literal, while line 42 correctly passes token as a separate structured field. For consistent structured logging, consider extracting the token:

 livechatLogger.debug({
-  msg: `Saving page movement history for visitor with token ${token}`,
+  msg: 'Saving page movement history for visitor',
+  token,
   pageInfo,
   roomId,
 });
apps/meteor/app/livechat/server/lib/contacts/migrateVisitorIfMissingContact.ts (1)

12-12: Consider adding contextual fields for better observability.

The structured log would be more useful for debugging if it included the available context:

-logger.debug({ msg: 'Detecting visitor contact ID' });
+logger.debug({ msg: 'Detecting visitor contact ID', visitorId, source: source.type });
apps/meteor/app/livechat/server/lib/service-status.ts (1)

21-24: Inconsistent logging format at Line 23.

Line 21 uses structured object format, but Line 23 still uses a plain string. Consider updating for consistency.

Suggested fix
 	livechatLogger.debug({ msg: 'Checking online agents', department });
 	if (!skipNoAgentSetting && settings.get('Livechat_accept_chats_with_no_agents')) {
-		livechatLogger.debug('Can accept without online agents: true');
+		livechatLogger.debug({ msg: 'Can accept without online agents', canAccept: true });
 		return true;
 	}
apps/meteor/app/livechat/server/lib/rooms.ts (1)

218-218: Consider logging only roomId instead of the entire room object.

Other logging statements in this PR consistently use specific identifiers (e.g., roomId, visitorId) rather than entire objects. Logging the full room object could result in verbose logs and potentially expose sensitive data.

Suggested change
-	livechatLogger.debug({ msg: 'Transferring room to queue', scope: departmentId ? 'department' : undefined, room });
+	livechatLogger.debug({ msg: 'Transferring room to queue', scope: departmentId ? 'department' : undefined, roomId: room._id });
📜 Review details

Configuration used: Organization 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 28a8d39 and 739fa62.

📒 Files selected for processing (15)
  • apps/meteor/app/importer/server/classes/converters/MessageConverter.ts
  • apps/meteor/app/integrations/server/lib/triggerHandler.ts
  • apps/meteor/app/livechat/server/lib/QueueManager.ts
  • apps/meteor/app/livechat/server/lib/RoutingManager.ts
  • apps/meteor/app/livechat/server/lib/closeRoom.ts
  • apps/meteor/app/livechat/server/lib/contacts/migrateVisitorIfMissingContact.ts
  • apps/meteor/app/livechat/server/lib/contacts/migrateVisitorToContactId.ts
  • apps/meteor/app/livechat/server/lib/custom-fields.ts
  • apps/meteor/app/livechat/server/lib/departmentsLib.ts
  • apps/meteor/app/livechat/server/lib/guests.ts
  • apps/meteor/app/livechat/server/lib/rooms.ts
  • apps/meteor/app/livechat/server/lib/service-status.ts
  • apps/meteor/app/livechat/server/lib/tracking.ts
  • apps/meteor/app/livechat/server/lib/transfer.ts
  • apps/meteor/app/livechat/server/lib/webhooks.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/app/livechat/server/lib/RoutingManager.ts
  • apps/meteor/app/livechat/server/lib/departmentsLib.ts
  • apps/meteor/app/livechat/server/lib/service-status.ts
  • apps/meteor/app/livechat/server/lib/QueueManager.ts
  • apps/meteor/app/livechat/server/lib/webhooks.ts
  • apps/meteor/app/livechat/server/lib/guests.ts
  • apps/meteor/app/livechat/server/lib/transfer.ts
  • apps/meteor/app/livechat/server/lib/tracking.ts
  • apps/meteor/app/livechat/server/lib/contacts/migrateVisitorIfMissingContact.ts
  • apps/meteor/app/importer/server/classes/converters/MessageConverter.ts
  • apps/meteor/app/livechat/server/lib/contacts/migrateVisitorToContactId.ts
  • apps/meteor/app/livechat/server/lib/custom-fields.ts
  • apps/meteor/app/livechat/server/lib/closeRoom.ts
  • apps/meteor/app/integrations/server/lib/triggerHandler.ts
  • apps/meteor/app/livechat/server/lib/rooms.ts
🧠 Learnings (12)
📚 Learning: 2025-11-19T18:20:37.116Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37419
File: apps/meteor/server/services/media-call/service.ts:141-141
Timestamp: 2025-11-19T18:20:37.116Z
Learning: In apps/meteor/server/services/media-call/service.ts, the sendHistoryMessage method should use call.caller.id or call.createdBy?.id as the message author, not call.transferredBy?.id. Even for transferred calls, the message should appear in the DM between the two users who are calling each other, not sent by the person who transferred the call.

Applied to files:

  • apps/meteor/app/livechat/server/lib/QueueManager.ts
  • apps/meteor/app/livechat/server/lib/transfer.ts
  • apps/meteor/app/livechat/server/lib/tracking.ts
  • apps/meteor/app/livechat/server/lib/contacts/migrateVisitorIfMissingContact.ts
  • apps/meteor/app/livechat/server/lib/contacts/migrateVisitorToContactId.ts
  • apps/meteor/app/livechat/server/lib/rooms.ts
📚 Learning: 2025-11-19T18:20:07.720Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37419
File: packages/i18n/src/locales/en.i18n.json:918-921
Timestamp: 2025-11-19T18:20:07.720Z
Learning: Repo: RocketChat/Rocket.Chat — i18n/formatting
Learning: This repository uses a custom message formatting parser in UI blocks/messages; do not assume standard Markdown rules. For keys like Call_ended_bold, Call_not_answered_bold, Call_failed_bold, and Call_transferred_bold in packages/i18n/src/locales/en.i18n.json, retain the existing single-asterisk emphasis unless maintainers request otherwise.

Applied to files:

  • apps/meteor/app/livechat/server/lib/webhooks.ts
📚 Learning: 2025-12-18T15:18:31.688Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37773
File: apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx:24-34
Timestamp: 2025-12-18T15:18:31.688Z
Learning: In apps/meteor/client/views/mediaCallHistory/MediaCallHistoryInternal.tsx, for internal call history items, the item.contactId is guaranteed to always match either the caller.id or callee.id in the call data, so the contact resolution in getContact will never result in undefined.

Applied to files:

  • apps/meteor/app/livechat/server/lib/contacts/migrateVisitorIfMissingContact.ts
  • apps/meteor/app/livechat/server/lib/contacts/migrateVisitorToContactId.ts
📚 Learning: 2025-10-28T16:53:42.761Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37205
File: ee/packages/federation-matrix/src/FederationMatrix.ts:296-301
Timestamp: 2025-10-28T16:53:42.761Z
Learning: In the Rocket.Chat federation-matrix integration (ee/packages/federation-matrix/), the createRoom method from rocket.chat/federation-sdk will support a 4-argument signature (userId, roomName, visibility, displayName) in newer versions. Code using this 4-argument call is forward-compatible with planned library updates and should not be flagged as an error.

Applied to files:

  • apps/meteor/app/livechat/server/lib/closeRoom.ts
  • apps/meteor/app/livechat/server/lib/rooms.ts
📚 Learning: 2025-09-25T09:59:26.461Z
Learnt from: Dnouv
Repo: RocketChat/Rocket.Chat PR: 37057
File: packages/apps-engine/src/definition/accessors/IUserRead.ts:23-27
Timestamp: 2025-09-25T09:59:26.461Z
Learning: AppUserBridge.getUserRoomIds in apps/meteor/app/apps/server/bridges/users.ts always returns an array of strings (mapping subscription documents to room IDs), never undefined, even when user has no room subscriptions.

Applied to files:

  • apps/meteor/app/livechat/server/lib/closeRoom.ts
  • apps/meteor/app/livechat/server/lib/rooms.ts
📚 Learning: 2025-09-25T09:59:26.461Z
Learnt from: Dnouv
Repo: RocketChat/Rocket.Chat PR: 37057
File: packages/apps-engine/src/definition/accessors/IUserRead.ts:23-27
Timestamp: 2025-09-25T09:59:26.461Z
Learning: AppUserBridge.getUserRoomIds in apps/meteor/app/apps/server/bridges/users.ts always returns an array of strings by mapping subscription documents to room IDs, never undefined, even when user has no room subscriptions.

Applied to files:

  • apps/meteor/app/livechat/server/lib/closeRoom.ts
  • apps/meteor/app/livechat/server/lib/rooms.ts
📚 Learning: 2025-11-27T17:56:26.050Z
Learnt from: MartinSchoeler
Repo: RocketChat/Rocket.Chat PR: 37557
File: apps/meteor/client/views/admin/ABAC/AdminABACRooms.tsx:115-116
Timestamp: 2025-11-27T17:56:26.050Z
Learning: In Rocket.Chat, the GET /v1/abac/rooms endpoint (implemented in ee/packages/abac/src/index.ts) only returns rooms where abacAttributes exists and is not an empty array (query: { abacAttributes: { $exists: true, $ne: [] } }). Therefore, in components consuming this endpoint (like AdminABACRooms.tsx), room.abacAttributes is guaranteed to be defined for all returned rooms, and optional chaining before calling array methods like .join() is sufficient without additional null coalescing.

Applied to files:

  • apps/meteor/app/livechat/server/lib/rooms.ts
📚 Learning: 2025-09-25T09:59:26.461Z
Learnt from: Dnouv
Repo: RocketChat/Rocket.Chat PR: 37057
File: packages/apps-engine/src/definition/accessors/IUserRead.ts:23-27
Timestamp: 2025-09-25T09:59:26.461Z
Learning: UserBridge.doGetUserRoomIds in packages/apps-engine/src/server/bridges/UserBridge.ts has a bug where it implicitly returns undefined when the app lacks read permission (missing return statement in the else case of the permission check).

Applied to files:

  • apps/meteor/app/livechat/server/lib/rooms.ts
📚 Learning: 2025-11-04T16:49:19.107Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37377
File: apps/meteor/ee/server/hooks/federation/index.ts:86-88
Timestamp: 2025-11-04T16:49:19.107Z
Learning: In Rocket.Chat's federation system (apps/meteor/ee/server/hooks/federation/), permission checks follow two distinct patterns: (1) User-initiated federation actions (creating rooms, adding users to federated rooms, joining from invites) should throw MeteorError to inform users they lack 'access-federation' permission. (2) Remote server-initiated federation events should silently skip/ignore when users lack permission. The beforeAddUserToRoom hook only executes for local user-initiated actions, so throwing an error there is correct. Remote federation events are handled separately by the federation Matrix package with silent skipping logic.

Applied to files:

  • apps/meteor/app/livechat/server/lib/rooms.ts
📚 Learning: 2025-09-16T13:33:49.237Z
Learnt from: cardoso
Repo: RocketChat/Rocket.Chat PR: 36890
File: apps/meteor/tests/e2e/e2e-encryption/e2ee-otr.spec.ts:21-26
Timestamp: 2025-09-16T13:33:49.237Z
Learning: In Rocket.Chat test files, the im.delete API endpoint accepts either a `roomId` parameter (requiring the actual DM room _id) or a `username` parameter (for the DM partner's username). It does not accept slug-like constructions such as concatenating usernames together.

Applied to files:

  • apps/meteor/app/livechat/server/lib/rooms.ts
📚 Learning: 2025-09-16T13:33:49.237Z
Learnt from: cardoso
Repo: RocketChat/Rocket.Chat PR: 36890
File: apps/meteor/tests/e2e/e2e-encryption/e2ee-otr.spec.ts:21-26
Timestamp: 2025-09-16T13:33:49.237Z
Learning: The im.delete API endpoint accepts either a `roomId` parameter (requiring the actual DM room _id) or a `username` parameter (for the DM partner's username). Constructing slug-like identifiers like `user2${Users.userE2EE.data.username}` doesn't work for this endpoint.

Applied to files:

  • apps/meteor/app/livechat/server/lib/rooms.ts
📚 Learning: 2025-09-30T13:00:05.465Z
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 36990
File: apps/meteor/ee/server/apps/storage/AppRealStorage.ts:55-58
Timestamp: 2025-09-30T13:00:05.465Z
Learning: In AppRealStorage (apps/meteor/ee/server/apps/storage/AppRealStorage.ts), the `remove` method is designed to be idempotent and returns `{ success: true }` unconditionally because the goal is to ensure the app is removed, not to distinguish whether this specific call performed the deletion. Database errors will throw exceptions.

Applied to files:

  • apps/meteor/app/livechat/server/lib/rooms.ts
🧬 Code graph analysis (4)
apps/meteor/app/livechat/server/lib/QueueManager.ts (1)
packages/core-typings/src/IInquiry.ts (1)
  • ILivechatInquiryRecord (35-61)
apps/meteor/app/livechat/server/lib/custom-fields.ts (1)
packages/ddp-client/src/livechat/LivechatClientImpl.ts (1)
  • visitor (151-159)
apps/meteor/app/livechat/server/lib/closeRoom.ts (1)
packages/core-typings/src/IRoom.ts (1)
  • isOmnichannelRoom (333-333)
apps/meteor/app/integrations/server/lib/triggerHandler.ts (1)
apps/meteor/app/integrations/server/logger.ts (1)
  • outgoingLogger (6-6)
⏰ 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). (7)
  • GitHub Check: CodeQL-Build
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 8.2 (2/4)
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 8.2 (1/4)
  • GitHub Check: 🔨 Test UI (CE) / MongoDB 8.2 (4/4)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 8.2 coverage (4/5)
  • GitHub Check: 🔨 Test UI (EE) / MongoDB 8.2 coverage (3/5)
🔇 Additional comments (40)
apps/meteor/app/livechat/server/lib/tracking.ts (1)

42-42: LGTM!

The structured log format with msg and token as separate fields aligns well with the PR objective for structured logging.

apps/meteor/app/livechat/server/lib/RoutingManager.ts (2)

98-103: LGTM!

The structured log properly includes all relevant context (routingMethod, department, ignoreAgentId) for debugging agent routing decisions.


122-122: LGTM!

All logging changes consistently use structured object format with appropriate contextual fields (inquiryId, agentId, roomId, userId). The changes maintain good observability without altering control flow.

Also applies to: 149-149, 165-165, 184-184, 251-256, 274-274, 321-325

apps/meteor/app/livechat/server/lib/departmentsLib.ts (1)

218-218: LGTM!

The structured log format with departmentId as a separate field is consistent with the PR's logging standardization effort.

apps/meteor/app/livechat/server/lib/contacts/migrateVisitorToContactId.ts (1)

37-37: LGTM!

Both log statements correctly use structured format with relevant contextual identifiers (visitorId, contactId), improving log searchability and consistency.

Also applies to: 42-42

apps/meteor/app/livechat/server/lib/closeRoom.ts (6)

49-50: LGTM!

Structured logging with attemptsLeft context is clear and consistent with the PR's logging pattern.


80-91: LGTM!

Good use of structured logging with roomId context for tracing room closure flow.


121-121: LGTM!

Consistent structured log format at the end of afterRoomClosed.


131-133: LGTM!

Structured logging with roomId and forceClose context provides good traceability.


143-143: LGTM!

Consistent structured logging throughout the doCloseRoom function with appropriate contextual fields (roomId, userId, visitorId).

Also applies to: 159-159, 167-167, 177-177, 207-207


223-223: LGTM!

Structured logging with contextual identifiers in resolveChatTags and closeOpenChats is consistent with the PR pattern.

Also applies to: 283-284

apps/meteor/app/livechat/server/lib/webhooks.ts (2)

38-47: LGTM!

Good structured error logging with webhookUrl, status, and response context for non-retryable errors.


53-59: LGTM!

Well-structured retry logging with useful context fields. The attempt: 6 - attempts calculation correctly shows the current attempt number (1-5).

apps/meteor/app/livechat/server/lib/guests.ts (2)

51-51: LGTM!

Structured logging with visitorId and livechatData provides good context for debugging custom field operations.


66-70: LGTM!

Good use of customFieldCount instead of logging all custom fields - provides useful summary without verbose output.

apps/meteor/app/livechat/server/lib/service-status.ts (2)

27-36: LGTM!

Structured logging with department and botAgents context is consistent with the PR pattern.


39-41: LGTM!

Good summary log with both department and agentsOnline status.

apps/meteor/app/livechat/server/lib/custom-fields.ts (2)

62-62: LGTM!

Structured logging with token context for visitor custom field operations.


172-172: LGTM!

Consistent structured logging pattern with token extracted from visitor.token.

apps/meteor/app/livechat/server/lib/transfer.ts (3)

25-25: LGTM!

The structured log format with msg, roomId, transferredBy, and scope fields provides good context for debugging transfer history operations.


44-44: LGTM!

Consistent structured logging format for the forward open chats operation.


66-66: LGTM!

Both transfer logging statements use consistent structured object format. The optional chaining on transferredBy?._id at line 66 is appropriate defensive coding since transferData parameter could have undefined transferredBy.

Also applies to: 80-80

apps/meteor/app/livechat/server/lib/rooms.ts (5)

57-57: LGTM!

The getRoom function's logging statements now consistently use structured objects with msg and visitorId fields, improving log searchability and context.

Also applies to: 65-65, 76-76


114-114: LGTM!

The createRoom function's logging progression is well-structured, capturing the visitor journey through department assignment and room creation with appropriate context fields.

Also applies to: 117-117, 123-123, 134-134


160-160: LGTM!

The saveRoomInfo logging correctly captures room context and custom field count for debugging purposes.

Also applies to: 180-184


252-252: LGTM!

Consistent structured logging with relevant transfer context.


268-268: LGTM!

The removeOmnichannelRoom function's logging statements provide appropriate context for both the operation start and error scenarios.

Also applies to: 306-306

apps/meteor/app/importer/server/classes/converters/MessageConverter.ts (2)

45-45: LGTM!

The message import logging statements now use consistent structured objects with appropriate context fields (roomId, userId, timestamp) for improved debugging and log analysis.

Also applies to: 58-58, 74-74


129-129: LGTM!

The mention resolution warnings consistently use importId field to identify the missing room or user reference.

Also applies to: 165-165

apps/meteor/app/livechat/server/lib/QueueManager.ts (4)

198-198: LGTM!

The inquiry processing and verification logging statements provide appropriate context with inquiryId, agentUsername, and roomId fields.

Also applies to: 228-228


262-262: LGTM!

The room creation logging correctly captures visitorId/guestId and roomId for tracking the conversation lifecycle.

Also applies to: 304-304


389-389: LGTM!

The room management and unarchive operations have consistent structured logging with appropriate identifiers.

Also applies to: 430-430, 434-434, 470-470


480-480: LGTM!

Structured logging for inquiry queue notification dispatch.

apps/meteor/app/integrations/server/lib/triggerHandler.ts (7)

72-72: LGTM!

The integration registration logging now includes structured context with integrationName, event, and channels fields.

Also applies to: 82-82


143-143: LGTM!

The message sending flow has appropriate structured logging for user lookup failures and room discovery.

Also applies to: 167-167


236-236: LGTM!

The event argument extraction logging maintains the existing multiline structure while converting to object format.

Also applies to: 241-247


268-268: LGTM!

The event argument mapping warnings consistently include msg and event context for missing data scenarios.

Also applies to: 321-321, 336-336, 353-353


454-454: LGTM!

The trigger execution logging provides comprehensive context including room, trigger count, and eligibility details.

Also applies to: 465-465, 468-473


502-502: LGTM!

The trigger URL execution logging chain provides good observability for debugging integration execution flow.

Also applies to: 506-506, 524-524, 531-531, 554-554


627-629: LGTM!

The HTTP response handling and retry logic logging provides appropriate context for debugging integration failures.

Also applies to: 692-697, 709-713, 749-749

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 15 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="apps/meteor/app/integrations/server/lib/triggerHandler.ts">

<violation number="1" location="apps/meteor/app/integrations/server/lib/triggerHandler.ts:701">
P2: Log message says '401 status' but the code block handles status 410 (Gone). This will create confusing log output.</violation>
</file>

<file name="apps/meteor/app/livechat/server/lib/closeRoom.ts">

<violation number="1" location="apps/meteor/app/livechat/server/lib/closeRoom.ts:131">
P2: Accessing `room._id` before verifying that `room` exists will throw when `params.room` is missing, preventing the intended `error-room-closed` flow.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link
Contributor

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/meteor/app/integrations/server/lib/triggerHandler.ts (1)

332-354: Log message mismatch: checking user but logging "owner data".

Lines 336 and 353 check if (!user) but log 'Integration called without owner data'. This creates confusing logs since the actual missing data is user, not owner. Line 321 correctly uses this message when checking !owner.

Proposed fix
 			case 'roomArchived':
 			case 'roomJoined':
 			case 'roomLeft':
 				if (!user) {
-					outgoingLogger.warn({ msg: 'Integration called without owner data', event });
+					outgoingLogger.warn({ msg: 'Integration called without user data', event });
 					return;
 				}
 			case 'userCreated':
 				if (!user) {
-					outgoingLogger.warn({ msg: 'Integration called without owner data', event });
+					outgoingLogger.warn({ msg: 'Integration called without user data', event });
 					return;
 				}
♻️ Duplicate comments (1)
apps/meteor/app/integrations/server/lib/triggerHandler.ts (1)

692-716: LGTM!

The 410 status code log message is now correct ("Disabling integration due to 410 (Gone) status"). Error logging includes appropriate context for debugging failed requests.

📜 Review details

Configuration used: Organization 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 739fa62 and fd2a2b7.

📒 Files selected for processing (1)
  • apps/meteor/app/integrations/server/lib/triggerHandler.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/app/integrations/server/lib/triggerHandler.ts
🧬 Code graph analysis (1)
apps/meteor/app/integrations/server/lib/triggerHandler.ts (1)
apps/meteor/app/integrations/server/logger.ts (1)
  • outgoingLogger (6-6)
⏰ 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). (3)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🔇 Additional comments (8)
apps/meteor/app/integrations/server/lib/triggerHandler.ts (8)

71-93: LGTM!

The structured logging changes in addIntegration are well-formed, with appropriate field names (integrationName, event, channels) that provide meaningful context for debugging.


142-167: LGTM!

Appropriate structured logging with meaningful context fields. The error level for missing user and debug level for successful room discovery are correctly chosen.


235-248: LGTM!

Good consolidation of event argument data into a single structured debug log with relevant IDs for traceability.


267-268: LGTM!

Appropriate warning with event context for debugging missing room/message scenarios.


454-477: LGTM!

Well-structured debug logs for trigger search and execution flow, providing good traceability with trigger counts and eligibility details.


500-554: LGTM!

Well-organized logging throughout the trigger execution setup with appropriate severity levels and consistent field naming.


626-630: LGTM!

Appropriate logging for HTTP response handling with status and URL context.


749-752: LGTM!

Retry logging includes all relevant context (integration name, URL, and wait time) for debugging retry behavior.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@KevLehman KevLehman added the stat: QA assured Means it has been tested and approved by a company insider label Jan 14, 2026
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Jan 14, 2026
ricardogarim
ricardogarim previously approved these changes Jan 14, 2026
Copy link
Contributor

@ricardogarim ricardogarim left a comment

Choose a reason for hiding this comment

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

Image

sampaiodiego
sampaiodiego previously approved these changes Jan 14, 2026
Co-authored-by: Diego Sampaio <chinello@gmail.com>
@KevLehman KevLehman dismissed stale reviews from sampaiodiego and ricardogarim via 7fdc1f5 January 14, 2026 18:35
@sampaiodiego sampaiodiego merged commit cfca170 into develop Jan 14, 2026
45 checks passed
@sampaiodiego sampaiodiego deleted the chore/logs-3 branch January 14, 2026 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants