From 3bfb8053ce7d5e86ddaeedf5cbd0f9005ed1eb2a Mon Sep 17 00:00:00 2001 From: Joshua Kiwiet-Pantaleoni Date: Mon, 4 Dec 2023 15:51:53 -0800 Subject: [PATCH] fix: catch errors that may occur during transaction tracking data fetch --- @kiva/kv-shop/src/oneTimeCheckout.ts | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/@kiva/kv-shop/src/oneTimeCheckout.ts b/@kiva/kv-shop/src/oneTimeCheckout.ts index 0c1c62c5..e82942f6 100644 --- a/@kiva/kv-shop/src/oneTimeCheckout.ts +++ b/@kiva/kv-shop/src/oneTimeCheckout.ts @@ -141,18 +141,24 @@ async function trackSuccess( checkoutId: string, paymentType: string, ) { - // get transaction data - const transactionData = await getCheckoutTrackingData( - apollo, - checkoutId, - paymentType, - ); + try { + // get transaction data + const transactionData = await getCheckoutTrackingData( + apollo, + checkoutId, + paymentType, + ); - // track transaction - trackTransaction(transactionData); + // track transaction + trackTransaction(transactionData); - // wait long enough for tracking to complete - await wait(800); + // wait long enough for tracking to complete + await wait(800); + } catch (e) { + // eslint-disable-next-line no-console + console.error('Error tracking transaction', e); + // TODO: send error to sentry + } } export interface OneTimeCheckoutOptions {