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

feat: log href without including search params #439

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/LoaderController.res
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ let make = (~children, ~paymentMode, ~setIntegrateErrorError, ~logger, ~initTime
setLaunchTime(_ => newLaunchTime)
let initLoadlatency = Date.now() -. newLaunchTime
logger.setLogInfo(
~value=Window.href,
~value=Window.hrefWithoutSearch,
~eventName=APP_RENDERED,
~latency=initLoadlatency,
(),
Expand Down
7 changes: 6 additions & 1 deletion src/Window.res
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,14 @@ external sendBeacon: (string, string) => unit = "sendBeacon"
external hostname: string = "hostname"

@val @scope(("window", "location"))
external href: string = "href"
external origin: string = "origin"

@val @scope(("window", "location"))
external protocol: string = "protocol"

@val @scope(("window", "location"))
external pathname: string = "pathname"

let isSandbox = hostname === "beta.hyperswitch.io"

let isInteg = hostname === "dev.hyperswitch.io"
Expand All @@ -140,3 +143,5 @@ module Location = {
module Element = {
@get external clientWidth: Dom.element => int = "clientWidth"
}

let hrefWithoutSearch = origin ++ pathname
19 changes: 14 additions & 5 deletions src/orca-loader/Hyper.res
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@ let make = (publishableKey, options: option<JSON.t>, analyticsInfo: option<JSON.
() => {
logger.setMerchantId(publishableKey)
logger.setSessionId(sessionID)
logger.setLogInfo(~value=Window.href, ~eventName=APP_INITIATED, ~timestamp=sdkTimestamp, ())
logger.setLogInfo(
~value=Window.hrefWithoutSearch,
~eventName=APP_INITIATED,
~timestamp=sdkTimestamp,
(),
)
}
}->Sentry.sentryLogger
let isSecure = Window.protocol === "https:"
Expand All @@ -137,8 +142,8 @@ let make = (publishableKey, options: option<JSON.t>, analyticsInfo: option<JSON.
->Array.find(url => Window.hostname->String.includes(url))
->Option.isSome
if !isSecure && !isLocal {
manageErrorWarning(HTTP_NOT_ALLOWED, ~dynamicStr=Window.href, ~logger, ())
Exn.raiseError("Insecure domain: " ++ Window.href)
manageErrorWarning(HTTP_NOT_ALLOWED, ~dynamicStr=Window.hrefWithoutSearch, ~logger, ())
Exn.raiseError("Insecure domain: " ++ Window.hrefWithoutSearch)
}
switch Window.getHyper->Nullable.toOption {
| Some(hyperMethod) => {
Expand Down Expand Up @@ -404,7 +409,7 @@ let make = (publishableKey, options: option<JSON.t>, analyticsInfo: option<JSON.
resolve(JSON.Encode.null)
})
->then(_ => {
logger.setLogInfo(~value=Window.href, ~eventName=ORCA_ELEMENTS_CALLED, ())
logger.setLogInfo(~value=Window.hrefWithoutSearch, ~eventName=ORCA_ELEMENTS_CALLED, ())
resolve()
})
->ignore
Expand Down Expand Up @@ -544,7 +549,11 @@ let make = (publishableKey, options: option<JSON.t>, analyticsInfo: option<JSON.
resolve(JSON.Encode.null)
})
->then(_ => {
logger.setLogInfo(~value=Window.href, ~eventName=PAYMENT_SESSION_INITIATED, ())
logger.setLogInfo(
~value=Window.hrefWithoutSearch,
~eventName=PAYMENT_SESSION_INITIATED,
(),
)
resolve()
})
->ignore
Expand Down
Loading