Skip to content

Conversation

@lucas-a-pelegrino
Copy link
Contributor

@lucas-a-pelegrino lucas-a-pelegrino commented Mar 21, 2025

Proposed changes (including videos or screenshots)

This PR aims to increment the logic of .setCustomFields(), updating the customFields from the visitor's Contact entity when applicable.

When Contact.customFields is nullish and/or overwrite is true, it inserts the customFields accordingly. If Contact.customFields is not nullish and overwrite is false, it will save it as a conflict.

Issue(s)

CTZ-17

Steps to test or reproduce

  1. Open Livechat widget
  2. Call setCustomField API method
  3. Start a new chat
  4. call setCustomField again with a different value

Further comments


This pull request introduces enhancements and bug fixes related to the handling of custom fields in the Rocket.Chat Livechat module. The key changes include:

  1. Functionality Update: The setCustomFields function is updated to correctly update the Context's customFields property, ensuring that custom fields are managed accurately.

  2. Livechat Bridge Enhancement: Implementation for setting custom fields is added to the AppLivechatBridge class, with a note for future refactoring.

  3. Visitor Registration Enhancement: The visitor registration endpoint (POST livechat/visitor) is enhanced to update custom fields for associated Livechat contacts when a visitor's custom fields are updated. This is achieved by introducing the LivechatContacts model and using the updateContactsCustomFields function to perform updates in parallel.

  4. Custom Fields Refactoring: The setCustomFields function is refactored to handle updates for associated livechat contacts when the scope is not 'room'. A new helper function, updateContactsCustomFields, is introduced to manage update logic, including handling overwrites and conflicts. This involves fetching the visitor, identifying associated contacts, and updating them concurrently.

  5. Error Handling Removal: Error handling for custom field operations is removed, which may potentially hide failures during these operations.

These changes aim to improve the robustness and functionality of custom field management within the Livechat module.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Mar 21, 2025

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 Mar 21, 2025

🦋 Changeset detected

Latest commit: 9e70f13

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

This PR includes changesets to release 36 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/freeswitch Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/license Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/models Patch
@rocket.chat/network-broker Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-voip Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/instance-status 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

@github-actions
Copy link
Contributor

github-actions bot commented Mar 21, 2025

PR Preview Action v1.6.1

🚀 View preview at
https://RocketChat.github.io/Rocket.Chat/pr-preview/pr-35580/

Built to branch gh-pages at 2025-04-18 03:48 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@codecov
Copy link

codecov bot commented Mar 21, 2025

Codecov Report

Attention: Patch coverage is 6.66667% with 14 lines in your changes missing coverage. Please review.

Project coverage is 61.19%. Comparing base (1c839a3) to head (9e70f13).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #35580      +/-   ##
===========================================
+ Coverage    61.16%   61.19%   +0.02%     
===========================================
  Files         2971     3119     +148     
  Lines        70838    73822    +2984     
  Branches     16184    16481     +297     
===========================================
+ Hits         43325    45172    +1847     
- Misses       24564    25620    +1056     
- Partials      2949     3030      +81     
Flag Coverage Δ
e2e 57.69% <ø> (+0.02%) ⬆️
unit 75.57% <6.66%> (-0.04%) ⬇️

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.

@scuciatto scuciatto added this to the 7.6.0 milestone Mar 31, 2025
@lucas-a-pelegrino lucas-a-pelegrino marked this pull request as ready for review April 2, 2025 20:20
@lucas-a-pelegrino lucas-a-pelegrino requested review from a team as code owners April 2, 2025 20:20
Copy link
Member

@KevLehman KevLehman left a comment

Choose a reason for hiding this comment

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

Can u add a changeset?

@lucas-a-pelegrino lucas-a-pelegrino requested a review from a team as a code owner April 16, 2025 18:48
@kody-ai
Copy link

kody-ai bot commented Apr 16, 2025

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@kody-ai
Copy link

kody-ai bot commented Apr 16, 2025

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@kody-ai
Copy link

kody-ai bot commented Apr 16, 2025

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@kody-ai
Copy link

kody-ai bot commented Apr 17, 2025

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@renatobecker renatobecker added the stat: QA assured Means it has been tested and approved by a company insider label Apr 17, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Apr 17, 2025
@lucas-a-pelegrino lucas-a-pelegrino dismissed KevLehman’s stale review April 17, 2025 20:53

Dismissed as Kevin is OOO.

@sampaiodiego sampaiodiego changed the title feat: Contact's custom fields on setCustomFields fix: Update Contact's custom fields when updating visitor custom fields Apr 17, 2025
@kodiakhq kodiakhq bot merged commit 3309dac into develop Apr 18, 2025
48 checks passed
@kodiakhq kodiakhq bot deleted the bugfix/CTZ-17 branch April 18, 2025 05:05
@scuciatto
Copy link
Member

/backport 7.5.2

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Jun 5, 2025

Sorry, I couldn't do that backport because of conflicts. Could you please solve them?

you can do so by running the following commands:

git fetch
git checkout backport-7.5.2-35580
git cherry-pick 3309dac86aaa331af0eeaba4a9a2620d8bd74423
// solve the conflict
git push

after that just run /backport 7.5.2 again

@lucas-a-pelegrino
Copy link
Contributor Author

/backport 7.5.2

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Jun 5, 2025

Pull request #36170 added to Project: "Patch 7.5.2"

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.

6 participants