@@ -363,6 +363,10 @@ export function getEventsWithUnit(
363
363
return events ;
364
364
}
365
365
366
+ type CheckoutData = {
367
+ plan : string ;
368
+ } & Partial < Record < DataCategory , number > > ;
369
+
366
370
function recordAnalytics (
367
371
organization : Organization ,
368
372
subscription : Subscription ,
@@ -371,31 +375,25 @@ function recordAnalytics(
371
375
) {
372
376
trackMarketingEvent ( 'Upgrade' , { plan : data . plan } ) ;
373
377
374
- const currentData = {
375
- // TODO(data categories): BIL-966
378
+ const currentData : CheckoutData = {
376
379
plan : data . plan ,
377
- errors : data . reservedErrors ,
378
- transactions : data . reservedTransactions ,
379
- attachments : data . reservedAttachments ,
380
- replays : data . reservedReplays ,
381
- monitorSeats : data . reservedMonitorSeats ,
382
- spans : data . reservedSpans ,
383
- profileDuration : data . reservedProfileDuration ,
384
- uptime : data . reservedUptime ,
385
380
} ;
386
381
387
- const previousData = {
382
+ Object . keys ( data ) . forEach ( key => {
383
+ if ( key . startsWith ( 'reserved' ) ) {
384
+ const targetKey = key . charAt ( 8 ) . toLowerCase ( ) + key . slice ( 9 ) ;
385
+ ( currentData as any ) [ targetKey ] = data [ key as keyof CheckoutAPIData ] ;
386
+ }
387
+ } ) ;
388
+
389
+ const previousData : CheckoutData = {
388
390
plan : subscription . plan ,
389
- errors : subscription . categories . errors ?. reserved || undefined ,
390
- transactions : subscription . categories . transactions ?. reserved || undefined ,
391
- attachments : subscription . categories . attachments ?. reserved || undefined ,
392
- replays : subscription . categories . replays ?. reserved || undefined ,
393
- monitorSeats : subscription . categories . monitorSeats ?. reserved || undefined ,
394
- profileDuration : subscription . categories . profileDuration ?. reserved || undefined ,
395
- spans : subscription . categories . spans ?. reserved || undefined ,
396
- uptime : subscription . categories . uptime ?. reserved || undefined ,
397
391
} ;
398
392
393
+ Object . entries ( subscription . categories ) . forEach ( ( [ category , value ] ) => {
394
+ ( previousData as any ) [ category ] = value ?. reserved || undefined ;
395
+ } ) ;
396
+
399
397
// TODO(reserved budgets): in future, we should just be able to pass data.selectedProducts
400
398
const selectableProductData = {
401
399
[ SelectableProduct . SEER ] : {
0 commit comments