diff --git a/src/services/initUsersnap.ts b/src/services/initUsersnap.ts index 4a00796ff..d677380fc 100644 --- a/src/services/initUsersnap.ts +++ b/src/services/initUsersnap.ts @@ -1,4 +1,4 @@ -import EnvVariables from "helpers/EnvVariables"; +import EnvVariables from 'helpers/EnvVariables'; declare global { interface Window { @@ -7,7 +7,7 @@ declare global { } export const initUserSnap = () => { - const apiKey = EnvVariables.configFor("USER_SNAP_API_KEY"); + const apiKey = EnvVariables.configFor('USER_SNAP_API_KEY'); if (!apiKey) { return; @@ -17,8 +17,19 @@ export const initUserSnap = () => { api.init(); }; - const script = document.createElement("script"); - script.async = true; - script.src = `https://widget.usersnap.com/load/${apiKey}?onload=onUsersnapCXLoad`; - document.head.append(script); + fetch(`https://widget.usersnap.com/load/${apiKey}?onload=onUsersnapCXLoad`, { + body: null, + method: 'GET', + mode: 'cors', + credentials: 'omit', + }) + .then(() => { + const script = document.createElement('script'); + script.async = true; + script.src = `https://widget.usersnap.com/load/${apiKey}?onload=onUsersnapCXLoad`; + document.head.append(script); + }) + .catch((error: any) => { + console.log(error.message); + }); };