Skip to content

Commit

Permalink
feat: HS-154: Added debug logs for apple pay (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
vsrivatsa-edinburgh authored Nov 9, 2023
1 parent f092e03 commit ce7eef9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions src/orca-loader/Elements.res
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ let make = (
let trustPayScript = Window.createElement("script")
trustPayScript->Window.elementSrc(trustPayScriptURL)
trustPayScript->Window.elementOnerror(err => {
logger.setLogInfo(
~value="ERROR DURING LOADING TRUSTPAY APPLE PAY: " ++
err->toJson->Js.Json.stringify,
~eventName=TRUSTPAY_SCRIPT,
~logType=ERROR,
(),
)
Utils.logInfo(Js.log2("ERROR DURING LOADING TRUSTPAY APPLE PAY", err))
})
Window.body->Window.appendChild(trustPayScript)
Expand Down Expand Up @@ -471,6 +478,7 @@ let make = (
~value="Delayed Session Token Flow",
~eventName=APPLE_PAY_FLOW,
~paymentMethod="APPLE_PAY",
~logType=DEBUG,
(),
)

Expand All @@ -493,6 +501,7 @@ let make = (
~value="TrustPay Connector Flow",
~eventName=APPLE_PAY_FLOW,
~paymentMethod="APPLE_PAY",
~logType=DEBUG,
(),
)
let secrets =
Expand Down Expand Up @@ -521,14 +530,29 @@ let make = (
->Belt.Option.getWithDefault("")

try {
logger.setLogInfo(
~value="Creating TrustpayApi instance",
~eventName=APPLE_PAY_FLOW,
~paymentMethod="APPLE_PAY",
~logType=DEBUG,
(),
)
let trustpay = trustPayApi(secrets)
logger.setLogInfo(
~value="TrustpayApi instance created",
~eventName=APPLE_PAY_FLOW,
~paymentMethod="APPLE_PAY",
~logType=DEBUG,
(),
)
trustpay.finishApplePaymentV2(. payment, paymentRequest)
->then(res => {
logger.setLogInfo(
~value="TrustPay ApplePay Success Response",
~internalMetadata=res->Js.Json.stringify,
~eventName=APPLE_PAY_FLOW,
~paymentMethod="APPLE_PAY",
~logType=DEBUG,
(),
)
let msg =
Expand All @@ -545,6 +569,8 @@ let make = (
~eventName=APPLE_PAY_FLOW,
~paymentMethod="APPLE_PAY",
~value=exceptionMessage,
~logType=ERROR,
~internalMetadata="finishApplePaymentV2 catch",
(),
)
let msg =
Expand All @@ -561,6 +587,8 @@ let make = (
~value=exn->Utils.formatException->Js.Json.stringify,
~eventName=APPLE_PAY_FLOW,
~paymentMethod="APPLE_PAY",
~logType=ERROR,
~internalMetadata="outer catch",
(),
)
let msg =
Expand Down
2 changes: 1 addition & 1 deletion src/orca-log-catcher/OrcaLogger.res
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ let make = (~sessionId=?, ~source: option<source>=?, ~clientSecret=?, ~merchantI
]
arrayOfLogs
->Js.Array2.find(log => {
log.logType === ERROR ||
[ERROR, DEBUG]->Js.Array2.includes(log.logType) ||
(priorityEventNames->Js.Array2.includes(log.eventName) && log.firstEvent)
})
->Belt.Option.isSome || arrayOfLogs->Js.Array2.length > 8
Expand Down

0 comments on commit ce7eef9

Please sign in to comment.