Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: app rendered event latency calculation #273

Merged
merged 3 commits into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions src/LoaderController.res
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime
showCardFormByDefault && Utils.checkPriorityList(paymentMethodOrder) ? SemiLoaded : Loading
| x => x
}
let finalLoadLatency = Date.now() -. launchTime
let finalLoadLatency = if launchTime <= 0.0 {
-1.0
} else {
Date.now() -. launchTime
}
switch updatedState {
| Loaded(_) =>
logger.setLogInfo(~value="Loaded", ~eventName=LOADER_CHANGED, ~latency=finalLoadLatency, ())
Expand Down Expand Up @@ -263,8 +267,9 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime
})
}
}
setLaunchTime(_ => dict->Utils.getFloat("launchTime", 0.0))
let initLoadlatency = Date.now() -. launchTime
let newLaunchTime = dict->Utils.getFloat("launchTime", 0.0)
setLaunchTime(_ => newLaunchTime)
let initLoadlatency = Date.now() -. newLaunchTime
logger.setLogInfo(
~value=Window.href,
~eventName=APP_RENDERED,
Expand Down Expand Up @@ -357,7 +362,11 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime
}
if dict->getDictIsSome("paymentMethodList") {
let list = dict->getJsonObjectFromDict("paymentMethodList")
let finalLoadlatency = Date.now() -. launchTime
let finalLoadLatency = if launchTime <= 0.0 {
-1.0
} else {
Date.now() -. launchTime
}
let updatedState: PaymentType.loadType =
list == Dict.make()->JSON.Encode.object
? LoadError(list)
Expand All @@ -375,14 +384,14 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime
logger.setLogInfo(
~value="Loaded",
~eventName=LOADER_CHANGED,
~latency=finalLoadlatency,
~latency=finalLoadLatency,
(),
)
| LoadError(x) =>
logger.setLogError(
~value="LoadError: " ++ x->JSON.stringify,
~eventName=LOADER_CHANGED,
~latency=finalLoadlatency,
~latency=finalLoadLatency,
(),
)
| _ => ()
Expand All @@ -398,7 +407,7 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime
? logger.setLogInfo(
~value="Loaded",
~eventName=LOADER_CHANGED,
~latency=finalLoadlatency,
~latency=finalLoadLatency,
(),
)
: evalMethodsList()
Expand All @@ -414,22 +423,26 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime
...prev,
customerPaymentMethods,
})
let finalLoadlatency = Date.now() -. launchTime
let finalLoadLatency = if launchTime <= 0.0 {
-1.0
} else {
Date.now() -. launchTime
}

let evalMethodsList = () =>
switch paymentlist {
| Loaded(_) =>
logger.setLogInfo(
~value="Loaded",
~eventName=LOADER_CHANGED,
~latency=finalLoadlatency,
~latency=finalLoadLatency,
(),
)
| LoadError(x) =>
logger.setLogError(
~value="LoadError: " ++ x->JSON.stringify,
~eventName=LOADER_CHANGED,
~latency=finalLoadlatency,
~latency=finalLoadLatency,
(),
)

Expand All @@ -443,7 +456,7 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime
? logger.setLogInfo(
~value="Loaded",
~eventName=LOADER_CHANGED,
~latency=finalLoadlatency,
~latency=finalLoadLatency,
(),
)
: evalMethodsList()
Expand Down
Loading