@@ -87,7 +87,7 @@ type SaleContextValues = SaleContextProps & {
8787 paymentMethod ?: SalePaymentTypes | undefined ,
8888 data ?: Record < string , unknown >
8989 ) => void ;
90- goToErrorView : ( type : SaleErrorTypes , data ?: Record < string , string > ) => void ;
90+ goToErrorView : ( type : SaleErrorTypes , data ?: Record < string , unknown > ) => void ;
9191 goToSuccessView : ( data ?: Record < string , unknown > ) => void ;
9292 fundingRoutes : FundingRoute [ ] ;
9393 disabledPaymentTypes : SalePaymentTypes [ ] ;
@@ -284,14 +284,21 @@ export function SaleContextProvider(props: {
284284 ) ;
285285
286286 const goToErrorView = useCallback (
287- ( errorType : SaleErrorTypes , data : Record < string , string > = { } ) => {
287+ (
288+ errorType : SaleErrorTypes ,
289+ data : Record < string , unknown > & { vendorError ?: { code : string ; message ?: string } } = { } ,
290+ ) => {
288291 errorRetries . current += 1 ;
289292 if ( errorRetries . current > MAX_ERROR_RETRIES ) {
290293 errorRetries . current = 0 ;
291294 setPaymentMethod ( undefined ) ;
292295 }
293296
294- trackError ( 'commerce' , 'saleError' , new Error ( errorType ) , data ) ;
297+ const { vendorError, ...errorData } = data ;
298+ trackError ( 'commerce' , 'saleError' , new Error ( errorType ) , {
299+ ...errorData ,
300+ ...( vendorError ? { vendorCode : vendorError . code , vendorMessage : vendorError . message || '' } : { } ) ,
301+ } ) ;
295302
296303 viewDispatch ( {
297304 payload : {
0 commit comments