Skip to content

Commit

Permalink
chore: merged with main
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrishab Srivatsa committed Mar 22, 2024
1 parent 31d51fd commit 7afb9ba
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/App.res
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
@react.component
let make = () => {
let (logger, initTimestamp) = React.useMemo0(() => {
let logger = OrcaLogger.make()
Date.now()
(OrcaLogger.make(), Date.now())
})
let url = RescriptReactRouter.useUrl()
let (integrateError, setIntegrateErrorError) = React.useState(() => false)
Expand Down
7 changes: 4 additions & 3 deletions src/LoaderController.res
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime
})
}
}
let latency = Js.Date.now() -. initTimestamp
let launchTime = dict->Utils.getFloat("launchTime", 0.0)
let latency = Date.now() -. launchTime
logger.setLogInfo(~value=Window.href, ~eventName=APP_RENDERED, ~latency, ())
[
("iframeId", "no-element"->JSON.Encode.string),
Expand All @@ -267,8 +268,8 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime
]->Array.forEach(keyPair => {
dict->CommonHooks.updateKeys(keyPair, setKeys)
})

logger.setLogInfo(~eventName=PAYMENT_OPTIONS_PROVIDED, ~value="", ())
let latency = Date.now() -. initTimestamp
logger.setLogInfo(~eventName=PAYMENT_OPTIONS_PROVIDED, ~latency, ~value="", ())
}
} else if dict->getDictIsSome("paymentOptions") {
let paymentOptions = dict->Utils.getDictFromObj("paymentOptions")
Expand Down
2 changes: 2 additions & 0 deletions src/orca-loader/Elements.res
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ let make = (
let endpoint = ApiEndpoint.getApiEndPoint(~publishableKey, ())
let appearance =
localOptions->Dict.get("appearance")->Option.getOr(Dict.make()->JSON.Encode.object)
let launchTime = localOptions->getFloat("launchTime", 0.0)

let fonts =
localOptions
Expand Down Expand Up @@ -247,6 +248,7 @@ let make = (
("sdkHandleOneClickConfirmPayment", sdkHandleOneClickConfirmPayment->JSON.Encode.bool),
("parentURL", "*"->JSON.Encode.string),
("analyticsMetadata", analyticsMetadata),
("launchTime", launchTime->JSON.Encode.float),
]->Dict.fromArray

let handleApplePayMounted = (event: Types.event) => {
Expand Down
9 changes: 7 additions & 2 deletions src/orca-loader/Hyper.res
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,17 @@ let make = (publishableKey, options: option<JSON.t>, analyticsInfo: option<JSON.

let elements = elementsOptions => {
open Promise
let elementsOptionsDict = elementsOptions->JSON.Decode.object
elementsOptionsDict
->Option.forEach(x => x->Dict.set("launchTime", Date.now()->JSON.Encode.float))
->ignore

let clientSecretId =
elementsOptions
->JSON.Decode.object
elementsOptionsDict
->Option.flatMap(x => x->Dict.get("clientSecret"))
->Option.flatMap(JSON.Decode.string)
->Option.getOr("")
let elementsOptions = elementsOptionsDict->Option.mapOr(elementsOptions, JSON.Encode.object)
clientSecret := clientSecretId
Js.Promise.make((~resolve, ~reject as _) => {
logger.setClientSecret(clientSecretId)
Expand Down

0 comments on commit 7afb9ba

Please sign in to comment.