Skip to content

Commit

Permalink
feat: log href without including search params
Browse files Browse the repository at this point in the history
  • Loading branch information
vsrivatsa-juspay committed Jun 12, 2024
1 parent a3526d2 commit 6489aa6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
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

0 comments on commit 6489aa6

Please sign in to comment.