Skip to content

Commit

Permalink
chore: removed logInfo and added log api
Browse files Browse the repository at this point in the history
  • Loading branch information
sakksham7 committed Dec 3, 2024
1 parent 621d539 commit 082f4db
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 17 deletions.
8 changes: 7 additions & 1 deletion src/Payments/GPay.res
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion src/Payments/PaypalSDK.res
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
8 changes: 7 additions & 1 deletion src/Payments/PlaidSDKIframe.res
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
}
}

Expand Down
14 changes: 10 additions & 4 deletions src/Utilities/ApplePayHelpers.res
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions src/Utilities/Utils.res
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/hyper-loader/Elements.res
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 12 additions & 2 deletions src/hyper-loader/Hyper.res
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,12 @@ let make = (publishableKey, options: option<JSON.t>, analyticsInfo: option<JSON.
let googlePayScript = Window.createElement("script")
googlePayScript->Window.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)
Expand All @@ -278,7 +283,12 @@ let make = (publishableKey, options: option<JSON.t>, analyticsInfo: option<JSON.
let samsungPayScript = Window.createElement("script")
samsungPayScript->Window.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(_ =>
Expand Down
3 changes: 0 additions & 3 deletions src/hyper-log-catcher/HyperLogger.res
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 082f4db

Please sign in to comment.