-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
fix(billing): update conditions for orgStatsBanner to appear #94493
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #94493 +/- ##
==========================================
- Coverage 87.92% 85.64% -2.29%
==========================================
Files 10376 10376
Lines 601024 601024
Branches 23393 23393
==========================================
- Hits 528472 514731 -13741
- Misses 72085 85826 +13741
Partials 467 467 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Null Categories Property Causes TypeError
The code attempts to call Object.values(subscription.categories) without checking if subscription.categories is defined. If subscription.categories is null or undefined, this will throw a TypeError. Subscriptions can exist without the categories property, making this a potential runtime error.
static/gsApp/utils/billing.tsx#L509-L512
sentry/static/gsApp/utils/billing.tsx
Lines 509 to 512 in 1271816
| // paid plans should add events without changing plans | |
| const hasAnyUsageExceeded = Object.values(subscription.categories).some( | |
| category => category.usageExceeded | |
| ); |
Was this report helpful? Give feedback by reacting with 👍 or 👎
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refines when the organization stats banner and usage alerts appear by requiring actual exceeded usage for paid plans and hiding banners for business plans without overages.
- Added a check for
usageExceededingetBestActionToIncreaseEventLimits - Updated
OrgStatsBannerto returnnullif no action text is provided - Extended and adjusted unit tests to cover new conditions
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| static/gsApp/views/subscriptionPage/usageAlert.spec.tsx | Updated test description and added usageExceeded to fixture for the request CTA |
| static/gsApp/utils/billing.tsx | Introduced hasAnyUsageExceeded guard and refined plan‐upgrade logic |
| static/gsApp/utils/billing.spec.tsx | Added tests for business plan scenario in getBestActionToIncreaseEventLimits |
| static/gsApp/hooks/orgStatsBanner.tsx | Early return null when no header/subtext is set |
| static/gsApp/hooks/orgStatsBanner.spec.tsx | Added spec to assert no banner for business plan without exceeded usage |
| static/gsApp/components/gsBanner.spec.tsx | Updated GSBanner spec to include usageExceeded flag |
Comments suppressed due to low confidence (3)
static/gsApp/utils/billing.tsx:520
- Returning an empty string to signal "no action" may be confusing and could break type safety. Consider returning
undefinedor introducing an explicitUsageAction.NONEenum value.
return '';
static/gsApp/utils/billing.spec.tsx:943
- We should add tests for the
send_to_checkoutandrequest_upgradebranches to cover scenarios where a paid non-business plan should upgrade, both with and without billing access.
});
static/gsApp/views/subscriptionPage/usageAlert.spec.tsx:29
- [nitpick] The test description could be clearer by stating "business plan with exceeded usage and without billing access" to match the fixture setup and emphasize the billing permissions check.
it('renders request add events CTA if business, non-billing member, and usage exceeded', function () {
closes https://linear.app/getsentry/issue/RTC-1027/improve-copy-on-over-quota-banner-on-stats-page - Increase your Reserved Quotas banner if a category is exceeded usage - Upgrade to Business banner if subscription is not currently on a Business plan
closes https://linear.app/getsentry/issue/RTC-1027/improve-copy-on-over-quota-banner-on-stats-page