From 6489aa6f8f1230d8f1f5b72b1e07a64d24d1f9aa Mon Sep 17 00:00:00 2001 From: vsrivatsa-juspay Date: Wed, 12 Jun 2024 16:17:49 +0530 Subject: [PATCH] feat: log href without including search params --- src/LoaderController.res | 2 +- src/Window.res | 7 ++++++- src/orca-loader/Hyper.res | 19 ++++++++++++++----- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/LoaderController.res b/src/LoaderController.res index a22245d5f..a0b9e4402 100644 --- a/src/LoaderController.res +++ b/src/LoaderController.res @@ -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, (), diff --git a/src/Window.res b/src/Window.res index 16e00bab9..6224f3e33 100644 --- a/src/Window.res +++ b/src/Window.res @@ -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" @@ -140,3 +143,5 @@ module Location = { module Element = { @get external clientWidth: Dom.element => int = "clientWidth" } + +let hrefWithoutSearch = origin ++ pathname diff --git a/src/orca-loader/Hyper.res b/src/orca-loader/Hyper.res index 45e741b28..8379fa373 100644 --- a/src/orca-loader/Hyper.res +++ b/src/orca-loader/Hyper.res @@ -128,7 +128,12 @@ let make = (publishableKey, options: option, analyticsInfo: option { 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:" @@ -137,8 +142,8 @@ let make = (publishableKey, options: option, analyticsInfo: optionArray.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) => { @@ -404,7 +409,7 @@ let make = (publishableKey, options: option, analyticsInfo: optionthen(_ => { - logger.setLogInfo(~value=Window.href, ~eventName=ORCA_ELEMENTS_CALLED, ()) + logger.setLogInfo(~value=Window.hrefWithoutSearch, ~eventName=ORCA_ELEMENTS_CALLED, ()) resolve() }) ->ignore @@ -544,7 +549,11 @@ let make = (publishableKey, options: option, analyticsInfo: optionthen(_ => { - logger.setLogInfo(~value=Window.href, ~eventName=PAYMENT_SESSION_INITIATED, ()) + logger.setLogInfo( + ~value=Window.hrefWithoutSearch, + ~eventName=PAYMENT_SESSION_INITIATED, + (), + ) resolve() }) ->ignore