1(function () { 2 const BASE_PATH = "/event-tracker"; 3 4 const urls = { 5 collect: BASE_PATH + "/collect", 6 }; 7 8 const state = { 9 eventTrackerUserUuid: null, 10 }; 11 12 const api = { 13 collect(extra = {}) { 14 return sendWithResponse(urls.collect, { 15 url: window.location.href, 16 referer: document.referrer, 17 ts: Date.now(), 18 ...extra, 19 }).then((response) => { 20 const uuid = response?.data?.event_tracker_user_uuid; 21 22 if (uuid) { 23 state.eventTrackerUserUuid = uuid; 24 window.TradedealerEventTracker.eventTrackerUserUuid = uuid; 25 26 window.dispatchEvent( 27 new CustomEvent("tradedealer:event-tracker-ready", { 28 detail: { 29 eventTrackerUserUuid: uuid, 30 }, 31 }), 32 ); 33 } 34 35 return response; 36 }); 37 }, 38 39 getUserUuid() { 40 return state.eventTrackerUserUuid; 41 }, 42 }; 43 44 function sendWithResponse(url, data) { 45 const payload = JSON.stringify(data); 46 47 return fetch(url, { 48 method: "POST", 49 body: payload, 50 keepalive: true, 51 headers: { 52 "Content-Type": "application/json", 53 }, 54 }).then((response) => response.json()); 55 } 56 57 function send(url, data) { 58 const payload = JSON.stringify(data); 59 60 try { 61 if (navigator.sendBeacon) { 62 const blob = new Blob([payload], { 63 type: "application/json", 64 }); 65 navigator.sendBeacon(url, blob); 66 return; 67 } 68 69 if (window.fetch) { 70 fetch(url, { 71 method: "POST", 72 body: payload, 73 keepalive: true, 74 headers: { 75 "Content-Type": "application/json", 76 }, 77 }); 78 return; 79 } 80 console.error("EventTracker send error: not sending"); 81 } catch (e) { 82 console.error("EventTracker send error: ", e); 83 } 84 } 85 86 window.TradedealerEventTracker = Object.assign( 87 window.TradedealerEventTracker || {}, 88 api, 89 ); 90 91 function init() { 92 api.collect(); 93 } 94 95 if (document.readyState === "loading") { 96 document.addEventListener("DOMContentLoaded", init); 97 } else { 98 init(); 99 } 100})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.