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

[MM-57348] Support notification metrics from the Desktop App client #2998

Merged
merged 2 commits into from
Apr 5, 2024

Conversation

devinbinnie
Copy link
Member

Summary

This PR enables the Desktop App to return data around whether a notification was successful or not. It relays that data back to the web clients that support it, and the web client will push that data through the websocket as needed.

Ticket Link

https://mattermost.atlassian.net/browse/MM-57348

NONE

Copy link
Contributor

@larkox larkox left a comment

Choose a reason for hiding this comment

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

Looks great. Just two minor considerations.

Comment on lines -1 to -2
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the linter complain since we are removing this header?

Copy link
Member Author

Choose a reason for hiding this comment

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

I turned it off for this - I don't really wanna fight with having it in the built types, it should just be in our source code.

@@ -97,10 +78,33 @@ class NotificationManager {
this.allActiveNotifications.delete(mention.uId);
});

mention.on('failed', () => {
this.allActiveNotifications.delete(mention.uId);
return new Promise((resolve) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if there is any chance this promise never gets resolved. I mean... are we positive by calling mention.show either the show or the failed code is going to execute? Is there any chance they won't (or take a worrying amount of time)?

If that were the case, we could add some timeout to resolve this if it takes longer than X (30s?).

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking that, and that would indicate a clear failure, but wouldn't really add more information in terms of metrics. If we never get an ACK as a result of this Promise not returning, then we can count that as a missed notification since we can't guarantee that show() was called or finished correctly. I think the failed() callback handles most of that, but the lack of an ACK should be just as good of an indication that something went wrong, and the metrics will reflect that as part of notification health.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not so much worried about the metrics, but the memory leak of promises being created and never getting resolved.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh, that's a good point. In that case I think a timeout is warranted.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is now a "purist nit", so feel free to ignore.

Resolve is supposed to be used when the promise ends correctly. In theory, when it fails, we should reject the promise.

Nevertheless, I was trying to look in the internet some good reason to do it one way or another, and I think in this case would only add unneeded boilerplate to it :P

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah also reject commonly causes an error state which is sort of the case, but not what we're trying to achieve here.

Copy link
Contributor

@streamer45 streamer45 left a comment

Choose a reason for hiding this comment

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

Makes sense, nothing blocking 👍

@@ -32,19 +32,19 @@ class NotificationManager {

if (!Notification.isSupported()) {
log.error('notification not supported');
return;
return {result: 'error', reason: 'notification_api', data: 'notification not supported'};
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we consider "codifying" the reasons so that other sides (e.g. web client, server) can understand them? Maybe a common enum type or something could be an option.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm thinking of doing that once I have a final final decision on how to track everything. I'll probably do that in the phase where I actually start adding metrics around this stuff :P

@devinbinnie devinbinnie added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core committer labels Apr 5, 2024
@devinbinnie devinbinnie merged commit e7cf7a8 into mattermost:master Apr 5, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4: Reviews Complete All reviewers have approved the pull request release-note-none
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants