1export default class MediaEvents { 2 3 constructor(document, eventsUrl) { 4 this.document = document 5 this.eventsUrl = eventsUrl 6 this.lastProgressReport = Date.now() - 2000 7 const element = this.document.head.querySelector(`meta[name="csrf-token"]`) 8 this.csrfToken = element.getAttribute("content") 9 } 10 11 withProgressGate(callback, skipGate = false) { 12 if (!skipGate && (Date.now() - this.lastProgressReport < 2000)) return 13 this.lastProgressReport = Date.now() 14 15 callback() 16 } 17 18 reportEvent(name, data) { 19 fetch(this.eventsUrl, { 20 method: 'POST', 21 headers: { 22 'Content-Type': 'application/json', 23 'X-CSRF-Token': this.csrfToken, 24 }, 25 body: JSON.stringify({ event: name, event_data: data }) 26 }) 27 } 28}
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.