@imtbl/checkout-widgets 2.4.8 → 2.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/browser/{AddTokensWidget-CjsKM-T9.js → AddTokensWidget-gPCHh2Ic.js} +3 -3
  2. package/dist/browser/{BridgeWidget-DVD0vbXw.js → BridgeWidget-C2AnJL2L.js} +6 -6
  3. package/dist/browser/{CommerceWidget-6Bk4VqFB.js → CommerceWidget-Bon1WPUM.js} +13 -13
  4. package/dist/browser/{FeesBreakdown-DJ8ernNZ.js → FeesBreakdown-BNkqVKYc.js} +1 -1
  5. package/dist/browser/{OnRampWidget-70zEixzs.js → OnRampWidget-Ba7XEaRM.js} +3 -3
  6. package/dist/browser/{SaleWidget-POpNJFz2.js → SaleWidget-Ce4OMBRa.js} +18 -15
  7. package/dist/browser/{SpendingCapHero-C1OAzZ0n.js → SpendingCapHero-Cmwrbg-6.js} +1 -1
  8. package/dist/browser/{SwapWidget-BhBc76QL.js → SwapWidget-BJvQaEbm.js} +6 -6
  9. package/dist/browser/{TokenImage-9_8xOVNs.js → TokenImage-CixR6p0s.js} +1 -1
  10. package/dist/browser/{TopUpView-DpVUPPQE.js → TopUpView-g2N3l1FD.js} +1 -1
  11. package/dist/browser/{WalletApproveHero-BHSPmZJh.js → WalletApproveHero-BJBaS3y3.js} +2 -2
  12. package/dist/browser/{WalletWidget-JvUIuAdq.js → WalletWidget-B5fy8R-_.js} +3 -3
  13. package/dist/browser/{auto-track-Qz7LJ7YA.js → auto-track-Btn0BfZf.js} +1 -1
  14. package/dist/browser/{index-JULMMCb5.js → index-3bxYWHDa.js} +1 -1
  15. package/dist/browser/{index-o1Wg1vKu.js → index-4JGLO2ei.js} +1 -1
  16. package/dist/browser/{index-nyzac6M7.js → index-BocMnTiW.js} +1 -1
  17. package/dist/browser/{index-BLySvWQF.js → index-BztHQqBz.js} +2 -2
  18. package/dist/browser/{index-OzMQ0nH8.js → index-Cn2sD74R.js} +1 -1
  19. package/dist/browser/{index-DDEez-8b.js → index-DIJKO8W0.js} +30 -21
  20. package/dist/browser/{index-BFdJZ7kd.js → index-DWGkoLls.js} +1 -1
  21. package/dist/browser/{index-B8U0yV6w.js → index-ZSdOzTZK.js} +1 -1
  22. package/dist/browser/index.js +1 -1
  23. package/dist/browser/{index.umd-DdybBYbs.js → index.umd-C7iLXK2f.js} +1 -1
  24. package/dist/browser/{useInterval-CKXa8zia.js → useInterval-CGRBrs4H.js} +1 -1
  25. package/dist/types/lib/primary-sales.d.ts +1 -1
  26. package/dist/types/lib/utils.d.ts +1 -0
  27. package/dist/types/widgets/sale/context/SaleContextProvider.d.ts +1 -1
  28. package/dist/types/widgets/sale/hooks/useQuoteOrder.d.ts +1 -1
  29. package/dist/types/widgets/sale/types.d.ts +1 -1
  30. package/package.json +7 -7
  31. package/src/lib/hooks/useSignOrder.ts +2 -2
  32. package/src/lib/primary-sales.ts +1 -1
  33. package/src/lib/utils.ts +11 -0
  34. package/src/widgets/sale/context/SaleContextProvider.tsx +5 -2
  35. package/src/widgets/sale/hooks/useQuoteOrder.ts +5 -5
  36. package/src/widgets/sale/hooks/useSignOrder.ts +2 -1
  37. package/src/widgets/sale/types.ts +1 -1
  38. package/src/widgets/sale/views/OrderSummary.tsx +5 -3
  39. package/src/widgets/sale/views/PayWithCoins.tsx +2 -2
package/src/lib/utils.ts CHANGED
@@ -240,6 +240,17 @@ export function removeSpace(str: string): string {
240
240
  return str.replace(/\s/g, '');
241
241
  }
242
242
 
243
+ export const errorToString = (error: unknown) => {
244
+ if (error instanceof Error) {
245
+ return error.message;
246
+ }
247
+ if (typeof error === 'string') {
248
+ return error;
249
+ }
250
+
251
+ return JSON.stringify(error);
252
+ };
253
+
243
254
  export const filterAllowedTransactions = async (
244
255
  transactions: SignedTransaction[],
245
256
  provider: WrappedBrowserProvider,
@@ -16,6 +16,7 @@ import {
16
16
  useState,
17
17
  } from 'react';
18
18
  import { Environment } from '@imtbl/config';
19
+ import { trackError } from '@imtbl/metrics';
19
20
  import { ConnectLoaderState } from '../../../context/connect-loader-context/ConnectLoaderContext';
20
21
  import { SaleWidgetViews } from '../../../context/view-context/SaleViewContextTypes';
21
22
  import {
@@ -88,7 +89,7 @@ type SaleContextValues = SaleContextProps & {
88
89
  paymentMethod?: SalePaymentTypes | undefined,
89
90
  data?: Record<string, unknown>
90
91
  ) => void;
91
- goToErrorView: (type: SaleErrorTypes, data?: Record<string, unknown>) => void;
92
+ goToErrorView: (type: SaleErrorTypes, data?: Record<string, string>) => void;
92
93
  goToSuccessView: (data?: Record<string, unknown>) => void;
93
94
  fundingRoutes: FundingRoute[];
94
95
  disabledPaymentTypes: SalePaymentTypes[];
@@ -306,13 +307,15 @@ export function SaleContextProvider(props: {
306
307
  );
307
308
 
308
309
  const goToErrorView = useCallback(
309
- (errorType: SaleErrorTypes, data: Record<string, unknown> = {}) => {
310
+ (errorType: SaleErrorTypes, data: Record<string, string> = {}) => {
310
311
  errorRetries.current += 1;
311
312
  if (errorRetries.current > MAX_ERROR_RETRIES) {
312
313
  errorRetries.current = 0;
313
314
  setPaymentMethod(undefined);
314
315
  }
315
316
 
317
+ trackError('commerce', 'saleError', new Error(errorType), data);
318
+
316
319
  viewDispatch({
317
320
  payload: {
318
321
  type: ViewActions.UPDATE_VIEW,
@@ -1,7 +1,7 @@
1
1
  import { useState, useEffect, useRef } from 'react';
2
2
  import { Environment } from '@imtbl/config';
3
3
  import { WrappedBrowserProvider, SaleItem } from '@imtbl/checkout-sdk';
4
- import { compareStr } from '../../../lib/utils';
4
+ import { compareStr, errorToString } from '../../../lib/utils';
5
5
  import { PRIMARY_SALES_API_BASE_URL } from '../utils/config';
6
6
 
7
7
  import { OrderQuote, OrderQuoteCurrency, SaleErrorTypes } from '../types';
@@ -26,7 +26,7 @@ export const defaultOrderQuote: OrderQuote = {
26
26
 
27
27
  export type ConfigError = {
28
28
  type: SaleErrorTypes;
29
- data?: Record<string, unknown>;
29
+ data?: Record<string, string>;
30
30
  };
31
31
 
32
32
  export const useQuoteOrder = ({
@@ -46,7 +46,7 @@ export const useQuoteOrder = ({
46
46
  ConfigError | undefined
47
47
  >(undefined);
48
48
 
49
- const setError = (error: unknown) => {
49
+ const setError = (error: string) => {
50
50
  setOrderQuoteError({
51
51
  type: SaleErrorTypes.SERVICE_BREAKDOWN,
52
52
  data: { reason: 'Error fetching settlement currencies', error },
@@ -69,7 +69,7 @@ export const useQuoteOrder = ({
69
69
 
70
70
  setQueryParams(params.toString());
71
71
  } catch (error) {
72
- setError(error);
72
+ setError(errorToString(error));
73
73
  }
74
74
  })();
75
75
  }, [items, provider]);
@@ -102,7 +102,7 @@ export const useQuoteOrder = ({
102
102
  );
103
103
  setOrderQuote(config);
104
104
  } catch (error) {
105
- setError(error);
105
+ setError(errorToString(error));
106
106
  } finally {
107
107
  fetching.current = false;
108
108
  }
@@ -17,6 +17,7 @@ import {
17
17
  import { PRIMARY_SALES_API_BASE_URL } from '../utils/config';
18
18
  import { hexToText } from '../functions/utils';
19
19
  import { filterAllowedTransactions } from '../functions/signUtils';
20
+ import { errorToString } from '../../../lib/utils';
20
21
 
21
22
  type SignApiTransaction = {
22
23
  contract_address: string;
@@ -249,7 +250,7 @@ export const useSignOrder = (input: SignOrderInput) => {
249
250
  }
250
251
  const error: SignOrderError = {
251
252
  type: errorType,
252
- data: { error: err },
253
+ data: { error: errorToString(err) },
253
254
  };
254
255
  setSignError(error);
255
256
  return [undefined, error];
@@ -59,7 +59,7 @@ export type SignOrderInput = {
59
59
 
60
60
  export type SignOrderError = {
61
61
  type: SaleErrorTypes;
62
- data?: Record<string, unknown>;
62
+ data?: Record<string, string>;
63
63
  };
64
64
 
65
65
  export type ExecutedTransaction = {
@@ -32,7 +32,7 @@ import {
32
32
  import { HandoverTarget } from '../../../context/handover-context/HandoverContext';
33
33
  import { ViewContext, ViewActions, SharedViews } from '../../../context/view-context/ViewContext';
34
34
  import { useHandover } from '../../../lib/hooks/useHandover';
35
- import { getRemoteRive } from '../../../lib/utils';
35
+ import { errorToString, getRemoteRive } from '../../../lib/utils';
36
36
 
37
37
  type OrderSummaryProps = {
38
38
  subView: OrderSummarySubViews;
@@ -202,8 +202,10 @@ export function OrderSummary({ subView }: OrderSummaryProps) {
202
202
  },
203
203
  },
204
204
  });
205
- } catch (error: any) {
206
- goToErrorView(SaleErrorTypes.SERVICE_BREAKDOWN, error);
205
+ } catch (error: unknown) {
206
+ goToErrorView(SaleErrorTypes.SERVICE_BREAKDOWN, {
207
+ error: errorToString(error),
208
+ });
207
209
  }
208
210
  }, [fundingBalances, loadingBalances, fundingBalancesResult]);
209
211
 
@@ -16,7 +16,7 @@ import { HandoverTarget } from '../../../context/handover-context/HandoverContex
16
16
  import { HandoverContent } from '../../../components/Handover/HandoverContent';
17
17
  import { SaleWidgetViews } from '../../../context/view-context/SaleViewContextTypes';
18
18
  import { isPassportProvider } from '../../../lib/provider';
19
- import { getRemoteRive } from '../../../lib/utils';
19
+ import { errorToString, getRemoteRive } from '../../../lib/utils';
20
20
  import { HandoverDuration } from '../../../context/handover-context/HandoverProvider';
21
21
 
22
22
  interface StepConfig {
@@ -120,7 +120,7 @@ export function PayWithCoins() {
120
120
  onTxnStepExecuteNextTransaction,
121
121
  );
122
122
  } catch (error) {
123
- goToErrorView(SaleErrorTypes.SERVICE_BREAKDOWN, { error });
123
+ goToErrorView(SaleErrorTypes.SERVICE_BREAKDOWN, { error: errorToString(error) });
124
124
  }
125
125
  };
126
126