diff --git a/src/orca-loader/Elements.res b/src/orca-loader/Elements.res index 08d803f41..ff9b6d3f9 100644 --- a/src/orca-loader/Elements.res +++ b/src/orca-loader/Elements.res @@ -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") diff --git a/src/orca-loader/Hyper.res b/src/orca-loader/Hyper.res index d24915789..ec020c3da 100644 --- a/src/orca-loader/Hyper.res +++ b/src/orca-loader/Hyper.res @@ -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=``, ()) => {