1/** 2 * @file 3 * Handles Mapp tracking in the browser. 4 */ 5 6(function dplMapp(once) { 7 const pushEvent = function pushEvent(eventId, eventData) { 8 console.debug('DPL Mapp: Pushing %s event %o', eventId, eventData); 9 10 // Ensure that the Mapp object is defined before pushing event. 11 if (typeof window.wts !== 'undefined') { 12 window.wts.push(['send', eventId, eventData]); 13 } 14 }; 15 16 Drupal.behaviors.dpl_mapp = { 17 attach(context) { 18 // Send Mapp events attached through the HTML. 19 once('js-dpl-mapp', '.js-dpl-mapp', context).forEach( 20 function elementHandler(el) { 21 el.addEventListener('click', function clickHandler() { 22 const eventId = this.dataset.dplMappEventId || 'click'; 23 const eventDataString = this.dataset.dplMappEventData; 24 let eventData = {}; 25 try { 26 eventData = JSON.parse(eventDataString); 27 } catch (e) { 28 console.debug( 29 'DPL Mapp: Event data not recognized as JSON: %s', 30 eventDataString, 31 ); 32 } 33 34 pushEvent(eventId, eventData); 35 }); 36 }, 37 ); 38 }, 39 }; 40})(once);
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.