diff --git a/src/Payments/GPay.res b/src/Payments/GPay.res index 2ea74b97..7ec6ec08 100644 --- a/src/Payments/GPay.res +++ b/src/Payments/GPay.res @@ -190,7 +190,13 @@ let make = ( syncPayment() } } catch { - | _ => logInfo(Console.log("Error in syncing GooglePay Payment")) + | err => + loggerState.setLogError( + ~value="Error in syncing GooglePay Payment", + ~eventName=GOOGLE_PAY_FLOW, + ~internalMetadata=err->formatException->JSON.stringify, + ~paymentMethod="GOOGLE_PAY", + ) } } Window.addEventListener("message", handleGooglePayMessages) diff --git a/src/Payments/PaypalSDK.res b/src/Payments/PaypalSDK.res index 17852695..82abecc8 100644 --- a/src/Payments/PaypalSDK.res +++ b/src/Payments/PaypalSDK.res @@ -140,7 +140,13 @@ let make = (~sessionObj: SessionsType.token, ~paymentType: CardThemeType.mode) = } } } catch { - | _err => Utils.logInfo(Console.log("Error loading Paypal")) + | err => + loggerState.setLogError( + ~value="Error loading Paypal", + ~eventName=PAYPAL_SDK_FLOW, + ~internalMetadata=err->Utils.formatException->JSON.stringify, + ~paymentMethod="PAYPAL_SDK", + ) } None }, [stateJson]) diff --git a/src/Payments/PlaidSDKIframe.res b/src/Payments/PlaidSDKIframe.res index 45b9c1b3..e69a3612 100644 --- a/src/Payments/PlaidSDKIframe.res +++ b/src/Payments/PlaidSDKIframe.res @@ -78,7 +78,13 @@ let make = () => { } messageParentWindow([("fullscreen", false->JSON.Encode.bool)]) } catch { - | e => logInfo(Console.log2("Retrieve Failed", e)) + | err => + logger.setLogError( + ~value="Retrieve failed via Plaid", + ~eventName=PLAID_SDK, + ~internalMetadata=err->formatException->JSON.stringify, + ~paymentMethod="PLAID", + ) } } diff --git a/src/Utilities/ApplePayHelpers.res b/src/Utilities/ApplePayHelpers.res index 3a342cac..cee2cef9 100644 --- a/src/Utilities/ApplePayHelpers.res +++ b/src/Utilities/ApplePayHelpers.res @@ -189,10 +189,9 @@ let startApplePaySession = ( let payment = event.payment payment->callBackFunc } - ssn.oncancel = _ev => { + ssn.oncancel = _ => { applePaySessionRef := Nullable.null - logInfo(Console.log("Apple Pay Payment Cancelled")) - logger.setLogInfo( + logger.setLogError( ~value="Apple Pay Payment Cancelled", ~eventName=APPLE_PAY_FLOW, ~paymentMethod="APPLE_PAY", @@ -218,6 +217,7 @@ let useHandleApplePayResponse = ( let options = Recoil.useRecoilValueFromAtom(RecoilAtoms.optionAtom) let {publishableKey} = Recoil.useRecoilValueFromAtom(RecoilAtoms.keys) let paymentMethodListValue = Recoil.useRecoilValueFromAtom(PaymentUtils.paymentMethodListValue) + let logger = Recoil.useRecoilValueFromAtom(RecoilAtoms.loggerAtom) let (stateJson, setStatesJson) = React.useState(_ => JSON.Encode.null) @@ -279,7 +279,13 @@ let useHandleApplePayResponse = ( syncPayment() } } catch { - | _ => logInfo(Console.log("Error in parsing Apple Pay Data")) + | err => + logger.setLogError( + ~value="Error in parsing Apple Pay Data", + ~eventName=APPLE_PAY_FLOW, + ~paymentMethod="APPLE_PAY", + ~internalMetadata=err->formatException->JSON.stringify, + ) } } Window.addEventListener("message", handleApplePayMessages) diff --git a/src/Utilities/Utils.res b/src/Utilities/Utils.res index b5241366..c2c0cd32 100644 --- a/src/Utilities/Utils.res +++ b/src/Utilities/Utils.res @@ -764,10 +764,6 @@ let snakeToTitleCase = str => { ->Array.joinWith(" ") } -let logInfo = log => { - Window.isProd ? () : log -} - let formatIBAN = iban => { let formatted = iban->String.replaceRegExp(%re(`/[^a-zA-Z0-9]/g`), "") let countryCode = formatted->String.substring(~start=0, ~end=2)->String.toUpperCase diff --git a/src/hyper-loader/Elements.res b/src/hyper-loader/Elements.res index 133c4d16..8650fc59 100644 --- a/src/hyper-loader/Elements.res +++ b/src/hyper-loader/Elements.res @@ -182,7 +182,11 @@ let make = ( logger.setLogInfo(~value="TrustPay Script Loading", ~eventName=TRUSTPAY_SCRIPT) trustPayScript->Window.elementSrc(trustPayScriptURL) trustPayScript->Window.elementOnerror(err => { - logInfo(Console.log2("ERROR DURING LOADING TRUSTPAY APPLE PAY", err)) + logger.setLogError( + ~value="ERROR DURING LOADING TRUSTPAY APPLE PAY", + ~eventName=TRUSTPAY_SCRIPT, + ~internalMetadata=err->formatException->JSON.stringify, + ) }) trustPayScript->Window.elementOnload(_ => { logger.setLogInfo(~value="TrustPay Script Loaded", ~eventName=TRUSTPAY_SCRIPT) diff --git a/src/hyper-loader/Hyper.res b/src/hyper-loader/Hyper.res index 6fc9a80c..f8750ac6 100644 --- a/src/hyper-loader/Hyper.res +++ b/src/hyper-loader/Hyper.res @@ -265,7 +265,12 @@ let make = (publishableKey, options: option, analyticsInfo: optionWindow.elementSrc(googlePayScriptURL) googlePayScript->Window.elementOnerror(err => { - logInfo(Console.log2("ERROR DURING LOADING GOOGLE PAY SCRIPT", err)) + logger.setLogError( + ~value="ERROR DURING LOADING GOOGLE PAY SCRIPT", + ~eventName=GOOGLE_PAY_SCRIPT, + ~internalMetadata=err->formatException->JSON.stringify, + ~paymentMethod="GOOGLE_PAY", + ) }) Window.body->Window.appendChild(googlePayScript) logger.setLogInfo(~value="GooglePay Script Loaded", ~eventName=GOOGLE_PAY_SCRIPT) @@ -278,7 +283,12 @@ let make = (publishableKey, options: option, analyticsInfo: optionWindow.elementSrc(samsungPayScriptUrl) samsungPayScript->Window.elementOnerror(err => { - logInfo(Console.log2("ERROR DURING LOADING SAMSUNG PAY SCRIPT", err)) + logger.setLogError( + ~value="ERROR DURING LOADING SAMSUNG PAY SCRIPT", + ~eventName=SAMSUNG_PAY_SCRIPT, + ~internalMetadata=err->formatException->JSON.stringify, + ~paymentMethod="SAMSUNG_PAY", + ) }) Window.body->Window.appendChild(samsungPayScript) samsungPayScript->Window.elementOnload(_ => diff --git a/src/hyper-log-catcher/HyperLogger.res b/src/hyper-log-catcher/HyperLogger.res index 0a782b08..afe7fc62 100644 --- a/src/hyper-log-catcher/HyperLogger.res +++ b/src/hyper-log-catcher/HyperLogger.res @@ -107,9 +107,6 @@ let toSnakeCaseWithSeparator = (str, separator) => { type maskableDetails = Email | CardDetails type source = Loader | Elements(CardThemeType.mode) | Headless -let logInfo = log => { - Window.isProd ? () : log -} type logFile = { timestamp: string,