Skip to content

Commit 77b9e05

Browse files
fix(billing): don't use seat category for usage stats link (#95675)
Fixes JAVASCRIPT-32AZ
1 parent 8566bef commit 77b9e05

File tree

2 files changed

+77
-9
lines changed

2 files changed

+77
-9
lines changed

static/gsApp/components/gsBanner.spec.tsx

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2168,4 +2168,67 @@ describe('GSBanner Overage Alerts', function () {
21682168
)
21692169
).toBe(false);
21702170
});
2171+
2172+
it('shows see usage button for overages that are not strictly seat-based', async function () {
2173+
const organization = OrganizationFixture();
2174+
const subscription = SubscriptionFixture({
2175+
organization,
2176+
plan: 'am3_team',
2177+
categories: {
2178+
monitorSeats: MetricHistoryFixture({usageExceeded: true}),
2179+
profileDuration: MetricHistoryFixture({usageExceeded: true}),
2180+
},
2181+
onDemandPeriodStart: '2025-01-01',
2182+
onDemandPeriodEnd: '2025-01-31',
2183+
});
2184+
SubscriptionStore.set(organization.slug, subscription);
2185+
2186+
const {router} = render(<GSBanner organization={organization} />, {
2187+
organization,
2188+
});
2189+
2190+
expect(
2191+
await screen.findByTestId('overage-banner-monitorSeat-profileDuration')
2192+
).toBeInTheDocument();
2193+
2194+
const seeUsageButton = await screen.findByRole('button', {name: 'See Usage'});
2195+
await userEvent.click(seeUsageButton);
2196+
2197+
expect(router.location).toEqual(
2198+
expect.objectContaining({
2199+
pathname: `/organizations/${organization.slug}/stats/`,
2200+
query: {
2201+
dataCategory: 'profileDuration', // doesn't use monitorSeat because it does not have a stats page
2202+
pageStart: '2025-01-01',
2203+
pageEnd: '2025-01-31',
2204+
pageUtc: 'true',
2205+
},
2206+
})
2207+
);
2208+
});
2209+
2210+
it('does not show see usage button for overages that are strictly seat-based', async function () {
2211+
const organization = OrganizationFixture();
2212+
const subscription = SubscriptionFixture({
2213+
organization,
2214+
plan: 'am3_team',
2215+
categories: {
2216+
monitorSeats: MetricHistoryFixture({usageExceeded: true}),
2217+
uptime: MetricHistoryFixture({usageExceeded: true}),
2218+
},
2219+
onDemandPeriodStart: '2025-01-01',
2220+
onDemandPeriodEnd: '2025-01-31',
2221+
});
2222+
SubscriptionStore.set(organization.slug, subscription);
2223+
2224+
render(<GSBanner organization={organization} />, {
2225+
organization,
2226+
});
2227+
2228+
expect(
2229+
await screen.findByTestId('overage-banner-monitorSeat-uptime')
2230+
).toBeInTheDocument();
2231+
2232+
expect(screen.queryByRole('button', {name: 'See Usage'})).not.toBeInTheDocument();
2233+
});
21712234
});

static/gsApp/components/gsBanner.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -902,14 +902,10 @@ class GSBanner extends Component<Props, State> {
902902
.map(([key, _]) => key as EventType);
903903

904904
// Make an exception for when only seat-based categories have an overage to disable the See Usage button
905-
strictlySeatOverage =
906-
eventTypes.length <= 2 &&
907-
every(eventTypes, eventType =>
908-
[
909-
DATA_CATEGORY_INFO.monitor_seat.singular as EventType,
910-
DATA_CATEGORY_INFO.uptime.singular as EventType,
911-
].includes(eventType)
912-
);
905+
strictlySeatOverage = every(
906+
eventTypes,
907+
eventType => getCategoryInfoFromEventType(eventType)?.tallyType === 'seat'
908+
);
913909

914910
// Make an exception for when only crons has an overage to change the language to be more fitting and hide See Usage
915911
if (strictlySeatOverage) {
@@ -946,6 +942,15 @@ class GSBanner extends Component<Props, State> {
946942
return null;
947943
}
948944

945+
// we should only ever specify an event type that has an external stats page
946+
// in the stats link
947+
const eventTypeForStatsPage = strictlySeatOverage
948+
? null
949+
: (eventTypes.find(
950+
eventType =>
951+
getCategoryInfoFromEventType(eventType)?.statsInfo.showExternalStats
952+
) ?? null);
953+
949954
return (
950955
<Alert
951956
system
@@ -957,7 +962,7 @@ class GSBanner extends Component<Props, State> {
957962
{!strictlySeatOverage && (
958963
<LinkButton
959964
size="xs"
960-
to={`/organizations/${organization.slug}/stats/?dataCategory=${eventTypes[0]}s&pageStart=${subscription.onDemandPeriodStart}&pageEnd=${subscription.onDemandPeriodEnd}&pageUtc=true`}
965+
to={`/organizations/${organization.slug}/stats/?${eventTypeForStatsPage ? `dataCategory=${eventTypeForStatsPage}&` : ''}pageStart=${subscription.onDemandPeriodStart}&pageEnd=${subscription.onDemandPeriodEnd}&pageUtc=true`}
961966
onClick={() => {
962967
trackGetsentryAnalytics('quota_alert.clicked_see_usage', {
963968
organization,

0 commit comments

Comments
 (0)