Skip to content

Commit dd73fe3

Browse files
feat(profile hours): add ui profile hours to overage banners
1 parent a5f221d commit dd73fe3

File tree

3 files changed

+61
-3
lines changed

3 files changed

+61
-3
lines changed

static/gsApp/components/addEventsCTA.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export type EventType =
2121
| 'monitorSeat'
2222
| 'span'
2323
| 'profileDuration'
24+
| 'profileDurationUI'
2425
| 'uptime';
2526

2627
type Props = {

static/gsApp/components/gsBanner.spec.tsx

+34-2
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ describe('GSBanner', function () {
331331
attachments: MetricHistoryFixture({usageExceeded: false}),
332332
monitorSeats: MetricHistoryFixture({usageExceeded: false}),
333333
profileDuration: MetricHistoryFixture({usageExceeded: false}),
334+
profileDurationUI: MetricHistoryFixture({usageExceeded: false}),
334335
},
335336
canSelfServe: true,
336337
productTrials: [
@@ -367,6 +368,7 @@ describe('GSBanner', function () {
367368
attachments: MetricHistoryFixture({usageExceeded: false}),
368369
monitorSeats: MetricHistoryFixture({usageExceeded: false}),
369370
profileDuration: MetricHistoryFixture({usageExceeded: false}),
371+
profileDurationUI: MetricHistoryFixture({usageExceeded: false}),
370372
},
371373
canSelfServe: true,
372374
productTrials: [
@@ -528,6 +530,7 @@ describe('GSBanner', function () {
528530
attachments: MetricHistoryFixture({sentUsageWarning: false}),
529531
monitorSeats: MetricHistoryFixture({sentUsageWarning: false}),
530532
profileDuration: MetricHistoryFixture({sentUsageWarning: false}),
533+
profileDurationUI: MetricHistoryFixture({sentUsageWarning: false}),
531534
},
532535
canSelfServe: true,
533536
productTrials: [
@@ -564,8 +567,8 @@ describe('GSBanner', function () {
564567
replays: MetricHistoryFixture({usageExceeded: true}),
565568
attachments: MetricHistoryFixture({sentUsageWarning: false}),
566569
monitorSeats: MetricHistoryFixture({sentUsageWarning: false}),
570+
profileDurationUI: MetricHistoryFixture({sentUsageWarning: false}),
567571
},
568-
canSelfServe: true,
569572
productTrials: [
570573
{
571574
category: 'replays',
@@ -2112,11 +2115,40 @@ describe('GSBanner', function () {
21122115
});
21132116
const subscription = SubscriptionFixture({
21142117
organization,
2115-
plan: 'am1_team',
2118+
plan: 'am3_team',
21162119
categories: {
21172120
errors: MetricHistoryFixture({sentUsageWarning: false}),
21182121
spans: MetricHistoryFixture({sentUsageWarning: false}),
21192122
profileDuration: MetricHistoryFixture({sentUsageWarning: true}), // Warning sent
2123+
profileDurationUI: MetricHistoryFixture({sentUsageWarning: false}),
2124+
replays: MetricHistoryFixture({usageExceeded: false}),
2125+
attachments: MetricHistoryFixture({sentUsageWarning: false}),
2126+
monitorSeats: MetricHistoryFixture({sentUsageWarning: false}),
2127+
},
2128+
canSelfServe: true,
2129+
});
2130+
SubscriptionStore.set(organization.slug, subscription);
2131+
2132+
render(<GSBanner organization={organization} />, {organization});
2133+
2134+
expect(
2135+
await screen.findByRole('button', {name: /increase reserved limits/i})
2136+
).toBeInTheDocument();
2137+
});
2138+
2139+
it('shows overage warning banner for profileDurationUI', async function () {
2140+
const organization = OrganizationFixture({
2141+
access: ['org:billing'],
2142+
slug: 'another-slug-1',
2143+
});
2144+
const subscription = SubscriptionFixture({
2145+
organization,
2146+
plan: 'am3_team',
2147+
categories: {
2148+
errors: MetricHistoryFixture({sentUsageWarning: false}),
2149+
spans: MetricHistoryFixture({sentUsageWarning: false}),
2150+
profileDuration: MetricHistoryFixture({sentUsageWarning: false}),
2151+
profileDurationUI: MetricHistoryFixture({sentUsageWarning: true}),
21202152
replays: MetricHistoryFixture({usageExceeded: false}),
21212153
attachments: MetricHistoryFixture({sentUsageWarning: false}),
21222154
monitorSeats: MetricHistoryFixture({sentUsageWarning: false}),

static/gsApp/components/gsBanner.tsx

+26-1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ const ALERTS_OFF: Record<EventType, boolean> = {
9090
monitorSeat: false,
9191
span: false,
9292
profileDuration: false,
93+
profileDurationUI: false,
9394
uptime: false,
9495
};
9596

@@ -319,6 +320,7 @@ class GSBanner extends Component<Props, State> {
319320
monitorSeat: true,
320321
span: true,
321322
profileDuration: true,
323+
profileDurationUI: true,
322324
uptime: true,
323325
},
324326
overageWarningDismissed: {
@@ -329,6 +331,7 @@ class GSBanner extends Component<Props, State> {
329331
monitorSeat: true,
330332
span: true,
331333
profileDuration: true,
334+
profileDurationUI: true,
332335
uptime: true,
333336
},
334337
productTrialDismissed: {
@@ -339,6 +342,7 @@ class GSBanner extends Component<Props, State> {
339342
monitorSeat: true,
340343
span: true,
341344
profileDuration: true,
345+
profileDurationUI: true,
342346
uptime: true,
343347
},
344348
};
@@ -669,6 +673,7 @@ class GSBanner extends Component<Props, State> {
669673
'monitor_seats_overage_alert',
670674
'spans_overage_alert',
671675
'profile_duration_overage_alert',
676+
'profile_duration_ui_overage_alert',
672677
'uptime_overage_alert',
673678

674679
// warning alerts
@@ -679,6 +684,7 @@ class GSBanner extends Component<Props, State> {
679684
'monitor_seats_warning_alert',
680685
'spans_warning_alert',
681686
'profile_duration_warning_alert',
687+
'profile_duration_ui_warning_alert',
682688
'uptime_warning_alert',
683689

684690
// product trial alerts
@@ -689,6 +695,7 @@ class GSBanner extends Component<Props, State> {
689695
'monitor_seats_product_trial_alert',
690696
'spans_product_trial_alert',
691697
'profile_duration_product_trial_alert',
698+
'profile_duration_ui_product_trial_alert',
692699
'uptime_product_trial_alert',
693700
],
694701
{
@@ -731,6 +738,9 @@ class GSBanner extends Component<Props, State> {
731738
profileDuration: promptIsDismissedForBillingPeriod(
732739
checkResults.profile_duration_overage_alert!
733740
),
741+
profileDurationUI: promptIsDismissedForBillingPeriod(
742+
checkResults.profile_duration_ui_overage_alert!
743+
),
734744
uptime: promptIsDismissedForBillingPeriod(checkResults.uptime_overage_alert!),
735745
},
736746
overageWarningDismissed: {
@@ -749,6 +759,9 @@ class GSBanner extends Component<Props, State> {
749759
profileDuration: promptIsDismissedForBillingPeriod(
750760
checkResults.profile_duration_warning_alert!
751761
),
762+
profileDurationUI: promptIsDismissedForBillingPeriod(
763+
checkResults.profile_duration_ui_warning_alert!
764+
),
752765
uptime: promptIsDismissedForBillingPeriod(checkResults.uptime_warning_alert!),
753766
},
754767

@@ -781,6 +794,10 @@ class GSBanner extends Component<Props, State> {
781794
checkResults.profile_duration_product_trial_alert!,
782795
subscription
783796
),
797+
profileDurationUI: trialPromptIsDismissed(
798+
checkResults.profile_duration_ui_product_trial_alert!,
799+
subscription
800+
),
784801
uptime: trialPromptIsDismissed(
785802
checkResults.uptime_product_trial_alert!,
786803
subscription
@@ -820,6 +837,9 @@ class GSBanner extends Component<Props, State> {
820837
profileDuration:
821838
!this.state.overageAlertDismissed.profileDuration &&
822839
!!subscription.categories.profileDuration?.usageExceeded,
840+
profileDurationUI:
841+
!this.state.overageAlertDismissed.profileDurationUI &&
842+
!!subscription.categories.profileDurationUI?.usageExceeded,
823843
uptime:
824844
!this.state.overageAlertDismissed.uptime &&
825845
!!subscription.categories.uptime?.usageExceeded,
@@ -857,6 +877,9 @@ class GSBanner extends Component<Props, State> {
857877
profileDuration:
858878
!this.state.overageWarningDismissed.profileDuration &&
859879
!!subscription.categories.profileDuration?.sentUsageWarning,
880+
profileDurationUI:
881+
!this.state.overageWarningDismissed.profileDurationUI &&
882+
!!subscription.categories.profileDurationUI?.sentUsageWarning,
860883
uptime:
861884
!this.state.overageWarningDismissed.uptime &&
862885
!!subscription.categories.uptime?.sentUsageWarning,
@@ -924,6 +947,7 @@ class GSBanner extends Component<Props, State> {
924947
monitorSeat: `monitor_seats_${key}_alert`,
925948
span: `spans_${key}_alert`,
926949
profileDuration: `profile_duration_${key}_alert`,
950+
profileDurationUI: `profile_duration_ui_${key}_alert`,
927951
uptime: `uptime_${key}_alert`,
928952
};
929953

@@ -942,6 +966,7 @@ class GSBanner extends Component<Props, State> {
942966
monitorSeat: true,
943967
span: true,
944968
profileDuration: true,
969+
profileDurationUI: true,
945970
uptime: true,
946971
};
947972
// Suppress all warnings and alerts
@@ -1060,7 +1085,7 @@ class GSBanner extends Component<Props, State> {
10601085
})}
10611086
</ExternalLink>
10621087
),
1063-
// TODO: Uncomment when we have a continuous profile doc link
1088+
// TODO(continuous profiling): Uncomment when we have a continuous profile doc link
10641089
// profile: (
10651090
// <ExternalLink
10661091
// key="profiles"

0 commit comments

Comments
 (0)