From 7afb9ba732bf876f099cde52ea605de3b0fddc39 Mon Sep 17 00:00:00 2001 From: Vrishab Srivatsa Date: Fri, 22 Mar 2024 17:43:51 +0530 Subject: [PATCH] chore: merged with main --- src/App.res | 3 +-- src/LoaderController.res | 7 ++++--- src/orca-loader/Elements.res | 2 ++ src/orca-loader/Hyper.res | 9 +++++++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/App.res b/src/App.res index 5b9a43367..4d49e11d9 100644 --- a/src/App.res +++ b/src/App.res @@ -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) diff --git a/src/LoaderController.res b/src/LoaderController.res index be022b707..01b4b4d10 100644 --- a/src/LoaderController.res +++ b/src/LoaderController.res @@ -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), @@ -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") diff --git a/src/orca-loader/Elements.res b/src/orca-loader/Elements.res index 6700963e1..cfe27426e 100644 --- a/src/orca-loader/Elements.res +++ b/src/orca-loader/Elements.res @@ -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 @@ -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) => { diff --git a/src/orca-loader/Hyper.res b/src/orca-loader/Hyper.res index c9756ed76..b584c524a 100644 --- a/src/orca-loader/Hyper.res +++ b/src/orca-loader/Hyper.res @@ -348,12 +348,17 @@ let make = (publishableKey, options: option, analyticsInfo: option { 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)