Closed pacholoamit closed 2 months ago
Implement a Leafly environment in the mediajel-tracker...
const isTrackerLoaded = (callback) => { const intervalId = setInterval(() => { if (window.tracker) { callback(); clearInterval(intervalId); } }, 100); }; function pollForElement(selector, callback, interval = 100, timeout = 30000) { const startTime = Date.now(); const poller = setInterval(() => { const element = document.querySelector(selector); if (element) { clearInterval(poller); callback(element); } else if (Date.now() - startTime >= timeout) { clearInterval(poller); console.error(`Timeout reached: element with selector "${selector}" not found.`); } }, interval); } const elements = ["div.jsx-1636262898.content.open p.font-bold.mt-md", ".price .font-bold.text-md", ]; pollForElement(elements, () => { if (window.location.href.includes("/order-status")) { console.log("Inside order-status"); const idElement = document.querySelector("div.jsx-1636262898.content.open p.font-bold.mt-md"); const totalElement = document.querySelector(".price .font-bold.text-md"); var id = idElement.textContent.match(/#(\d+)/)[1]; var total = totalElement.textContent.replace("$", ""); isTrackerLoaded(() => { window.tracker("addTrans", id.toString(), "N/A", parseFloat(total), 0, 0, "N/A", "N/A", "N/A", "USD"); window.tracker("trackTrans"); }); } });
Update: Research on identifying per advertiser on leafly
Status: For QA PR: https://github.com/MediaJel/mediajel-tracker/pull/433
Description
Implement a Leafly environment in the mediajel-tracker...