Use runtime agent src when fetching script and remove HelloSkip message
cgen-a13954061bf944a283ed11c8503b098e
This commit is contained in:
parent
3d47081be1
commit
b3ef9f52d3
1 changed files with 8 additions and 5 deletions
|
|
@ -379,19 +379,22 @@ const loadSkipAgent = async (): Promise<void> => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const agentSrc = getAgentSrc();
|
||||||
|
if (!agentSrc) {
|
||||||
|
throw new Error("No agent source configured");
|
||||||
|
}
|
||||||
|
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
const timeout = window.setTimeout(() => controller.abort(), 5000);
|
const timeout = window.setTimeout(() => controller.abort(), 5000);
|
||||||
const response = await fetch(SKIP_AGENT_SRC, { signal: controller.signal });
|
const response = await fetch(agentSrc, { signal: controller.signal });
|
||||||
window.clearTimeout(timeout);
|
window.clearTimeout(timeout);
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error("Failed to download HelloSkip agent script");
|
throw new Error("Failed to download agent script");
|
||||||
}
|
}
|
||||||
|
|
||||||
const scriptText = await response.text();
|
const scriptText = await response.text();
|
||||||
const blobUrl = URL.createObjectURL(
|
const blobUrl = URL.createObjectURL(new Blob([scriptText], { type: "application/javascript" }));
|
||||||
new Blob([scriptText], { type: "application/javascript" }),
|
|
||||||
);
|
|
||||||
|
|
||||||
const script = document.createElement("script");
|
const script = document.createElement("script");
|
||||||
script.id = SKIP_AGENT_SCRIPT_ID;
|
script.id = SKIP_AGENT_SCRIPT_ID;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue