Skip to content

[usage] More useful notification #13406

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

Merged
merged 1 commit into from
Sep 30, 2022
Merged

[usage] More useful notification #13406

merged 1 commit into from
Sep 30, 2022

Conversation

laushinka
Copy link
Contributor

@laushinka laushinka commented Sep 28, 2022

Description

Shows:

  1. The team/user attributed in the billing.
  2. The link to the relevant billing page.
REACHED 80%
Screenshot 2022-09-29 at 20 36 00 Screenshot 2022-09-30 at 12 47 09

Related Issue(s)

Fixes #13166

How to test

Preview env

  1. Join this team.
  2. You should see the notification already.

Release Notes

NONE

Documentation

Werft options:

  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-payment
  • /werft with-integration-tests=all
    Valid options are all, workspace, webapp, ide

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-lau-notifications-13166.7 because the annotations in the pull request description changed
(with .werft/ from main)

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-lau-notifications-13166.8 because the annotations in the pull request description changed
(with .werft/ from main)

@roboquat roboquat added size/S and removed size/XS labels Sep 28, 2022
@laushinka
Copy link
Contributor Author

laushinka commented Sep 28, 2022

/werft run

👍 started the job as gitpod-build-lau-notifications-13166.10
(with .werft/ from main)

@laushinka laushinka force-pushed the lau/notifications-13166 branch 2 times, most recently from 8c7d1ab to a9aedd8 Compare September 29, 2022 15:17
@laushinka laushinka marked this pull request as ready for review September 29, 2022 15:21
@laushinka laushinka requested a review from a team September 29, 2022 15:21
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Sep 29, 2022
@jldec
Copy link
Contributor

jldec commented Sep 29, 2022

Let's change the first sentence to

Your team ‘[team-name]’ has reached its usage limit.

Thanks for that suggestion @laushinka.

@jldec
Copy link
Contributor

jldec commented Sep 29, 2022

And for the personal usage account.

You have reached your usage limit.

@laushinka laushinka force-pushed the lau/notifications-13166 branch 2 times, most recently from 287581d to 33ffda2 Compare September 29, 2022 17:00
@laushinka laushinka requested a review from jldec September 29, 2022 18:37
@laushinka
Copy link
Contributor Author

laushinka commented Sep 29, 2022

@jldec Changes done 🚀

@easyCZ
Copy link
Member

easyCZ commented Sep 29, 2022

Would it make sense to include in the warning message that 80% has been reached? Right now it says almost reached, but doesn't specify how urgent or how close the user is.
See internal thread

@laushinka
Copy link
Contributor Author

Would it make sense to include in the warning message that 80% has been reached? See internal thread

@easyCZ Thanks! I can see how the uncertainty of the word "almost" can create some panic. If we specify a number with a wording like "Your team has reached 80% of its usage limit", we would have to commit reflecting the actual percentage, won't we? For example today I see the banner, but then I keep racking up the usage without increasing the limit, tomorrow or the next it wouldn't be 80% anymore.

@easyCZ
Copy link
Member

easyCZ commented Sep 30, 2022

We could also include the actual percentage in the message. We already check for 0.8 * usage limit so we know how much it is.

className="gp-link hover:text-gray-600"
href={
notifications.length > 1
? `${gitpodHostUrl}t/${notifications[notifications.length - 1]}/billing`
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to use the topNotification variable here? It would avoid us having to do the lookup.

Copy link
Member

Choose a reason for hiding this comment

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

Do we actually need the gitpodHostURL? I think we could make the URL relative which would avoid having to specify it here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it possible to use the topNotification variable here?

How do you mean? topNotification is the first sentence that includes the team name. The second entry in the array is the Manage billing link.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, my bad. I misread the contents of those.

Comment on lines 2258 to 2283
switch (limit.attributionId.kind) {
case "user": {
if (limit.reached) {
result.unshift(`You have reached your usage limit.`);
} else if (limit.almostReached) {
result.unshift(`You have almost reached your usage limit.`);
}
break;
}
case "team": {
teamOrUser = await this.teamDB.findTeamById(limit.attributionId.teamId);
if (teamOrUser) {
result.push(teamOrUser?.slug);
if (limit.reached) {
result.unshift(`Your team '${teamOrUser?.name}' has reached its usage limit.`);
} else if (limit.almostReached) {
result.unshift(`Your team '${teamOrUser?.name}' has almost reached its usage limit.`);
}
}
break;
}
Copy link
Member

Choose a reason for hiding this comment

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

The nesting here makes it quite hard to follow the main flow of the method. What if we refactored this block into a separate method and do something like

const usageNotification = getUsageNotificationForAttributionID(...)
if usageNotification.length > 0 { ... }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry @easyCZ I was refactoring this but forgot to hold and now it's merged!

@laushinka
Copy link
Contributor Author

laushinka commented Sep 30, 2022

@jldec also prefers putting 80% so I will replace the almost sentences with "... has reached 80% of its usage limit.'

@easyCZ
Copy link
Member

easyCZ commented Sep 30, 2022

I think you should say 80% or more as it starts showing at 80%, but continues to show even above that

@laushinka
Copy link
Contributor Author

I think you should say 80% or more as it starts showing at 80%, but continues to show even above that

Yes, nice suggestion!

@jldec
Copy link
Contributor

jldec commented Sep 30, 2022

@laushinka I just tested this in a preview env .
After adding a team and configuring a test payment method for UBP I was immediately shown this notification.

Screenshot 2022-09-30 at 10 43 06

@laushinka
Copy link
Contributor Author

@laushinka I just tested this in a preview env . After adding a team and configuring a test payment method for UBP I was immediately shown this notification.

Aha, thanks!

@laushinka laushinka force-pushed the lau/notifications-13166 branch from 33ffda2 to a3d9767 Compare September 30, 2022 09:40
@laushinka laushinka force-pushed the lau/notifications-13166 branch from a3d9767 to 6dd22ea Compare September 30, 2022 10:27
Copy link
Contributor

@jldec jldec left a comment

Choose a reason for hiding this comment

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

LGTM
Screenshot 2022-09-30 at 13 08 35

@roboquat roboquat merged commit 51adca1 into main Sep 30, 2022
@roboquat roboquat deleted the lau/notifications-13166 branch September 30, 2022 11:12
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note-none size/M team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve content of notifications when the Usage Limit is reached
4 participants