console.log("[Alia app extension] v1.0.3"); const BACKEND_URL = "https://backend.alia-cloudflare.com"; // replaced in CI by inject-backend-url.js window.ALIA_SHOPIFY_EXTENSION_INFO = { customerID: aliaGetCustomerId(), country: "NO", market: "international", language: "en" } if (document.readyState !== "loading") { initAlia(); } else { document.addEventListener("DOMContentLoaded", () => initAlia(), { once: true }); } async function initAlia() { if (window.Shopify.designMode) { console.log("[Alia app extension] Not showing in Shopify theme editor"); return; } const url = BACKEND_URL + "/public/launcher.js?shop=clean-nutraceuticals.myshopify.com"; const script = await fetch(url); if (!script.ok || script.status === 204) return false; loadScript(url); // script content should be cached async function loadScript(url) { return new Promise((resolve, reject) => { const script = document.createElement("script"); script.src = url; script.async = true; script.onload = () => resolve(script); script.onerror = () => reject(new Error("Failed to load Alia script")); document.head.appendChild(script); }); } } function aliaGetCustomerId() { // patch for a weird bug where Shopify was assigning the same customer // id to people on different devices/networks const aliaDisabledCustomerIdMerchants = ["drinkbrez.myshopify.com", "b36a24-2.myshopify.com"]; if (aliaDisabledCustomerIdMerchants.includes("clean-nutraceuticals.myshopify.com")) { console.log(`Alia customer id disabled for this merchant`, "") return ""; } return ""; }