@@ -8,13 +8,17 @@ import {
8
8
import { DataCategory } from 'sentry/types/core' ;
9
9
10
10
import { OnDemandBudgetMode , type OnDemandBudgets } from 'getsentry/types' ;
11
+ import trackGetsentryAnalytics from 'getsentry/utils/trackGetsentryAnalytics' ;
11
12
import {
12
13
exceedsInvoicedBudgetLimit ,
13
14
getOnDemandBudget ,
14
15
getTotalBudget ,
15
16
parseOnDemandBudgetsFromSubscription ,
17
+ trackOnDemandBudgetAnalytics ,
16
18
} from 'getsentry/views/onDemandBudgets/utils' ;
17
19
20
+ jest . mock ( 'getsentry/utils/trackGetsentryAnalytics' ) ;
21
+
18
22
describe ( 'parseOnDemandBudgetsFromSubscription' , function ( ) {
19
23
it ( 'returns per-category budget for non-AM plans - with on-demand budget' , function ( ) {
20
24
const organization = OrganizationFixture ( ) ;
@@ -548,3 +552,54 @@ describe('getOnDemandBudget', function () {
548
552
expect ( getOnDemandBudget ( budget , DataCategory . LOG_BYTE ) ) . toBe ( 1000 ) ;
549
553
} ) ;
550
554
} ) ;
555
+
556
+ describe ( 'trackOnDemandBudgetAnalytics' , function ( ) {
557
+ it ( 'tracks all budget categories in analytics when budget changes' , function ( ) {
558
+ const organization = OrganizationFixture ( ) ;
559
+
560
+ const previousBudget : OnDemandBudgets = {
561
+ budgetMode : OnDemandBudgetMode . PER_CATEGORY ,
562
+ errorsBudget : 100 ,
563
+ transactionsBudget : 200 ,
564
+ attachmentsBudget : 300 ,
565
+ replaysBudget : 0 ,
566
+ budgets : {
567
+ errors : 100 ,
568
+ transactions : 200 ,
569
+ attachments : 300 ,
570
+ logBytes : 400 ,
571
+ } ,
572
+ } ;
573
+
574
+ const newBudget : OnDemandBudgets = {
575
+ budgetMode : OnDemandBudgetMode . PER_CATEGORY ,
576
+ errorsBudget : 150 ,
577
+ transactionsBudget : 250 ,
578
+ attachmentsBudget : 350 ,
579
+ replaysBudget : 0 ,
580
+ budgets : {
581
+ errors : 150 ,
582
+ transactions : 250 ,
583
+ attachments : 350 ,
584
+ logBytes : 500 ,
585
+ } ,
586
+ } ;
587
+
588
+ trackOnDemandBudgetAnalytics ( organization , previousBudget , newBudget ) ;
589
+
590
+ expect ( trackGetsentryAnalytics ) . toHaveBeenCalledWith (
591
+ 'ondemand_budget_modal.ondemand_budget.update' ,
592
+ expect . objectContaining ( {
593
+ organization,
594
+ error_budget : 150 ,
595
+ transaction_budget : 250 ,
596
+ attachment_budget : 350 ,
597
+ log_byte_budget : 500 ,
598
+ previous_error_budget : 100 ,
599
+ previous_transaction_budget : 200 ,
600
+ previous_attachment_budget : 300 ,
601
+ previous_log_byte_budget : 400 ,
602
+ } )
603
+ ) ;
604
+ } ) ;
605
+ } ) ;
0 commit comments