Skip to content

Commit 9641728

Browse files
1 parent 567fe72 commit 9641728

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

static/gsApp/views/amCheckout/utils.tsx

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,10 @@ export function getEventsWithUnit(
363363
return events;
364364
}
365365

366+
type CheckoutData = {
367+
plan: string;
368+
} & Partial<Record<DataCategory, number>>;
369+
366370
function recordAnalytics(
367371
organization: Organization,
368372
subscription: Subscription,
@@ -371,31 +375,25 @@ function recordAnalytics(
371375
) {
372376
trackMarketingEvent('Upgrade', {plan: data.plan});
373377

374-
const currentData = {
375-
// TODO(data categories): BIL-966
378+
const currentData: CheckoutData = {
376379
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,
385380
};
386381

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 = {
388390
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,
397391
};
398392

393+
Object.entries(subscription.categories).forEach(([category, value]) => {
394+
(previousData as any)[category] = value?.reserved || undefined;
395+
});
396+
399397
// TODO(reserved budgets): in future, we should just be able to pass data.selectedProducts
400398
const selectableProductData = {
401399
[SelectableProduct.SEER]: {

0 commit comments

Comments
 (0)