Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: catch errors that may occur during transaction tracking data fetch #325

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions @kiva/kv-shop/src/oneTimeCheckout.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ApolloClient } from '@apollo/client/core';
import { gql } from '@apollo/client/core';
import { trackTransaction } from '@kiva/kv-analytics';

Check failure on line 3 in @kiva/kv-shop/src/oneTimeCheckout.ts

View workflow job for this annotation

GitHub Actions / build

Unable to resolve path to module '@kiva/kv-analytics'
import numeral from 'numeral';
import type { DropInWrapper } from './useBraintreeDropIn';
import { pollForFinishedCheckout } from './checkoutStatus';
Expand Down Expand Up @@ -141,18 +141,24 @@
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 {
Expand Down
Loading