Skip to content

Commit

Permalink
fix: HS-165: custom backend url fix with prelim check on sentry url (#27
Browse files Browse the repository at this point in the history
)

Co-authored-by: arun.mishra <[email protected]>
  • Loading branch information
arun-mi and arun.mishra authored Nov 17, 2023
1 parent 970f5d6 commit e0a420b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
3 changes: 1 addition & 2 deletions src/orca-loader/Elements.res
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ let make = (
let savedPaymentElement = Js.Dict.empty()
let localOptions = options->Js.Json.decodeObject->Belt.Option.getWithDefault(Js.Dict.empty())
let clientSecretId = localOptions->getRequiredString("clientSecret", "", ~logger)
let testMode = publishableKey->Js.String2.startsWith("pk_snd_")
let endpoint = testMode ? "https://sandbox.hyperswitch.io" : "https://api.hyperswitch.io"
let endpoint = ApiEndpoint.getApiEndPoint(~publishableKey, ())
let appearance =
localOptions
->Js.Dict.get("appearance")
Expand Down
31 changes: 19 additions & 12 deletions src/orca-loader/Hyper.res
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,25 @@ let checkAndAppend = (selector, child) => {
}
}

if Window.querySelectorAll(`script[src="${GlobalVars.sentryScriptUrl}"]`)->Js.Array2.length === 0 {
let script = Window.createElement("script")
script->Window.elementSrc(GlobalVars.sentryScriptUrl)
script->Window.elementOnerror(err => {
Js.log2("ERROR DURING LOADING Sentry on HyperLoader", err)
})
script->Window.elementOnload(() => {
Sentry.initiateSentryJs(~dsn=GlobalVars.sentryDSN)
})
Window.window->Window.windowOnload(_ => {
Window.body->Window.appendChild(script)
})
if (
Window.querySelectorAll(`script[src="${GlobalVars.sentryScriptUrl}"]`)->Js.Array2.length === 0 &&
Js.typeof(GlobalVars.sentryScriptUrl) !== "undefined"
) {
try {
let script = Window.createElement("script")
script->Window.elementSrc(GlobalVars.sentryScriptUrl)
script->Window.elementOnerror(err => {
Js.log2("ERROR DURING LOADING Sentry on HyperLoader", err)
})
script->Window.elementOnload(() => {
Sentry.initiateSentryJs(~dsn=GlobalVars.sentryDSN)
})
Window.window->Window.windowOnload(_ => {
Window.body->Window.appendChild(script)
})
} catch {
| e => Js.log("Sentry load exited")
}
}

let preloadFile = (~type_, ~href=``, ()) => {
Expand Down

0 comments on commit e0a420b

Please sign in to comment.