Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: engagement dashboard message and hourly activity charts #35019

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

MartinSchoeler
Copy link
Contributor

@MartinSchoeler MartinSchoeler commented Jan 23, 2025

Proposed changes (including videos or screenshots)

Fixes issue with hourly chat activity chart not accounting for utc, also restores some missing data visualizers on the messages chart

About tests, this is a similar situation as this one #34113 (comment)

Issue(s)

SUP-676

Copy link
Contributor

dionisio-bot bot commented Jan 23, 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 targeting the wrong base branch. It should target 7.4.0, but it targets 7.3.0

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

Copy link

changeset-bot bot commented Jan 23, 2025

🦋 Changeset detected

Latest commit: feebcfa

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

This PR includes changesets to release 35 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/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

@MartinSchoeler MartinSchoeler added this to the 7.4.0 milestone Jan 23, 2025
Copy link

codecov bot commented Jan 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 59.18%. Comparing base (0858ce5) to head (feebcfa).
Report is 9 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop   #35019   +/-   ##
========================================
  Coverage    59.17%   59.18%           
========================================
  Files         2822     2822           
  Lines        68118    68116    -2     
  Branches     15145    15144    -1     
========================================
  Hits         40312    40312           
+ Misses       24975    24973    -2     
  Partials      2831     2831           
Flag Coverage Δ
unit 75.00% <ø> (ø)

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

Copy link
Contributor

github-actions bot commented Jan 23, 2025

PR Preview Action v1.6.0

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

Built to branch gh-pages at 2025-01-24 18:23 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@MartinSchoeler MartinSchoeler marked this pull request as ready for review January 23, 2025 19:22
@MartinSchoeler MartinSchoeler requested a review from a team as a code owner January 23, 2025 19:22
tickSize: 0,
// TODO: Get it from theme
tickPadding: 4,
tickRotation: 0,
format: (date): string => moment(date).format('dddd'),
format: (date): string => moment(date).format('dddd').substring(0, 3),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
format: (date): string => moment(date).format('dddd').substring(0, 3),
format: (date): string => moment(date).format('ddd'),

I think this has the same effect you're looking for.

Comment on lines 24 to 32
if (utc) {
response.hours = response.hours.map((hours) => {
const newDay = moment().hour(hours.hour).subtract(displacement, 'days').toDate();
return {
hour: moment.utc(newDay, 'HH').hour(),
users: hours.users,
};
});
}
Copy link
Member

Choose a reason for hiding this comment

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

I found this a little strange, since the data should be coming correctly from the BE.

During investigation, I think I figured out what is happening: We're sending the correct dates to the backend. When set to local timezone, we send the start parameter as midnight of the day in the current timezone, converted to an ISO string (ISO strings afaik are UTC). For example, GMT -3 end of day is '2025-01-24T02:59:59.999Z', and UTC end of day is '2025-01-23T23:59:59.999Z', meaning GMT -3 midnight is 3 hours after UTC midnight. So the parameter is correct.

The issue is that in the DB, the dates for loginAt are saved in UTC, and then we extract the hour (which is in UTC time), and sort it. When we show the data, we are not taking that into account, so the value for 12 am for example is actually the value for 12 am UTC, instead of GMT-3. The graph is interpreting the data as as GMT, when it's actually UTC time.

What we need to do is get those hours and convert them to GMT. I think we can do that in the format property of the ResponsiveBar component in the ContentForHours component (or maybe here if that doesn't work).

---
"@rocket.chat/meteor": patch
---
Fixes issue with some charts on engagement dashboard not using utc and missing data visualizers
Copy link
Member

Choose a reason for hiding this comment

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

Remember to update the changeset when the other requested changes are complete

@gabriellsh
Copy link
Member

I've also noticed that we're displacing the days in the graph by 1 day. For example today (Thu, 23rd Jan), we are requesting data starting from 23 Jan 23:59, instead of 23 Jan 00:00

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants