Skip to content

ref(billing): dynamic gsBanner #91035

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 8 commits into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 111 additions & 4 deletions static/gsApp/components/gsBanner.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,7 @@ describe('GSBanner Overage Alerts', function () {

expect(
await screen.findByTestId(
'overage-banner-error-transaction-replay-attachment-monitorSeat'
'overage-banner-error-transaction-attachment-replay-monitorSeat'
)
).toBeInTheDocument();

Expand Down Expand Up @@ -1601,7 +1601,7 @@ describe('GSBanner Overage Alerts', function () {

expect(
await screen.findByTestId(
'overage-banner-error-transaction-replay-attachment-monitorSeat-span-profileDuration'
'overage-banner-error-transaction-attachment-replay-span-monitorSeat-profileDuration'
)
).toBeInTheDocument();

Expand Down Expand Up @@ -2047,7 +2047,7 @@ describe('GSBanner Overage Alerts', function () {

expect(
await screen.findByTestId(
'overage-banner-error-transaction-attachment-monitorSeat-span-uptime'
'overage-banner-error-transaction-attachment-span-monitorSeat-uptime'
)
).toBeInTheDocument();
});
Expand Down Expand Up @@ -2097,8 +2097,115 @@ describe('GSBanner Overage Alerts', function () {

expect(
await screen.findByTestId(
'overage-banner-error-transaction-attachment-monitorSeat-span-uptime'
'overage-banner-error-transaction-attachment-span-monitorSeat-uptime'
)
).toBeInTheDocument();
});

it('checks prompts for all billed categories on plan', async function () {
const organization = OrganizationFixture();
const subscription = SubscriptionFixture({
organization,
plan: 'am3_team',
});
subscription.planDetails.categories = [...subscription.planDetails.categories];
const promptsMock = MockApiClient.addMockResponse({
method: 'GET',
url: `/organizations/${organization.slug}/prompts-activity/`,
});
SubscriptionStore.set(organization.slug, subscription);

render(<GSBanner organization={organization} />, {
organization,
deprecatedRouterMocks: true,
});
await act(tick);

const overagePrompts = [];
const warningPrompts = [];
const productTrialPrompts = [];
for (const category of [
'errors',
'attachments',
'replays',
'spans',
'monitor_seats',
'profile_duration',
'profile_duration_ui',
'uptime',
]) {
overagePrompts.push(`${category}_overage_alert`);
warningPrompts.push(`${category}_warning_alert`);
if (
['profile_duration', 'replays', 'spans', 'profile_duration_ui'].includes(category)
) {
productTrialPrompts.push(`${category}_product_trial_alert`);
}
}

expect(promptsMock).toHaveBeenCalledWith(
`/organizations/${organization.slug}/prompts-activity/`,
expect.objectContaining({
query: {
feature: [
'deactivated_member_alert',
...overagePrompts,
...warningPrompts,
...productTrialPrompts,
],
organization_id: organization.id,
},
})
);
});

it('does not show banner for non-billed categories', async function () {
const organization = OrganizationFixture();
const subscription = SubscriptionFixture({
organization,
plan: 'am3_t',
categories: {
// this would never happen in practice, but we're asserting that we properly filter out non-billed categories
logBytes: MetricHistoryFixture({usageExceeded: true}),
logItems: MetricHistoryFixture({usageExceeded: true}),
profileChunks: MetricHistoryFixture({usageExceeded: true}),
},
});
subscription.planDetails.categories = [
...subscription.planDetails.categories,
DataCategory.LOG_BYTE,
DataCategory.LOG_ITEM,
DataCategory.PROFILE_CHUNKS,
];
SubscriptionStore.set(organization.slug, subscription);

const promptsMock = MockApiClient.addMockResponse({
method: 'GET',
url: `/organizations/${organization.slug}/prompts-activity/`,
});

render(<GSBanner organization={organization} />, {
organization,
deprecatedRouterMocks: true,
});

const {container} = render(<GSBanner organization={organization} />, {
organization,
deprecatedRouterMocks: true,
});

await act(tick);
expect(container).toBeEmptyDOMElement();
const lastCall = promptsMock.mock.lastCall;
const nonBilledOveragePrompts = [
'log_bytes_overage_alert',
'log_items_overage_alert',
'profile_chunks_overage_alert',
];
expect(
(lastCall[1].query.feature as string[]).some(prompt =>
nonBilledOveragePrompts.includes(prompt)
)
).toBe(false);
});
});
Loading
Loading