78 lines
1.8 KiB
JavaScript
78 lines
1.8 KiB
JavaScript
(function () {
|
|
"use strict";
|
|
|
|
const ALLOWED_HOSTNAME = "bookly.codyborders.com";
|
|
const DATADOG_AGENT_URL =
|
|
"https://www.datadoghq-browser-agent.com/us1/v6/datadog-rum.js";
|
|
const RUM_CONFIG = Object.freeze({
|
|
applicationId: "ad60336f-85fe-4631-9469-973180243552",
|
|
clientToken: "pube161402da279b685acbb640a4366129b",
|
|
site: "datadoghq.com",
|
|
service: "csb",
|
|
env: "prod",
|
|
version: "0.1",
|
|
sessionSampleRate: 100,
|
|
sessionReplaySampleRate: 100,
|
|
trackResources: true,
|
|
trackUserInteractions: true,
|
|
trackLongTasks: true,
|
|
defaultPrivacyLevel: "allow",
|
|
});
|
|
|
|
function initializeRum(win) {
|
|
if (win.__booklyRumStarted === true) {
|
|
return;
|
|
}
|
|
|
|
if (!win.DD_RUM) {
|
|
console.error("Datadog RUM agent was not available after loading.");
|
|
return;
|
|
}
|
|
|
|
win.DD_RUM.init(RUM_CONFIG);
|
|
win.__booklyRumStarted = true;
|
|
win.__booklyRumLoading = false;
|
|
}
|
|
|
|
function loadRumAgent(doc, win) {
|
|
const headEl = doc.head;
|
|
if (!headEl) {
|
|
console.error("Datadog RUM was not loaded because document.head is missing.");
|
|
return;
|
|
}
|
|
|
|
const scriptEl = doc.createElement("script");
|
|
scriptEl.src = DATADOG_AGENT_URL;
|
|
scriptEl.async = true;
|
|
scriptEl.addEventListener("load", function () {
|
|
initializeRum(win);
|
|
});
|
|
scriptEl.addEventListener("error", function () {
|
|
win.__booklyRumLoading = false;
|
|
console.error("Datadog RUM agent failed to load.");
|
|
});
|
|
|
|
win.__booklyRumLoading = true;
|
|
headEl.appendChild(scriptEl);
|
|
}
|
|
|
|
if (window.location.hostname !== ALLOWED_HOSTNAME) {
|
|
return;
|
|
}
|
|
|
|
if (window.__booklyRumStarted === true) {
|
|
return;
|
|
}
|
|
|
|
if (window.__booklyRumLoading === true) {
|
|
return;
|
|
}
|
|
|
|
if (window.DD_RUM) {
|
|
initializeRum(window);
|
|
return;
|
|
}
|
|
|
|
loadRumAgent(document, window);
|
|
})();
|