1const nonce = sfTracking.nonce; 2const sfCuidKey = 'sf_cuid'; 3 4(function () { 5 window.sfDataLayer = window.sfDataLayer || []; 6 7 let sfCuid = localStorage.getItem(sfCuidKey) || null; 8 9 // Reuse existing sf_cuid if it exists 10 if (sfCuid) { 11 // Push to sfDataLayer 12 window.sfDataLayer.push({ 13 session: { 14 id: sfCuid, 15 }, 16 }); 17 } else { 18 // If sf_cuid is not in localStorage, fetch it from the REST API 19 fetch(sfTracking.restUrl, { 20 method: 'GET', 21 headers: { 22 'X-WP-Nonce': nonce, 23 }, 24 }) 25 .then((response) => response.json()) 26 .then((data) => { 27 if (typeof data === 'string' && data.length > 0) { 28 sfCuid = data; 29 localStorage.setItem(sfCuidKey, sfCuid); 30 31 // Push to sfDataLayer 32 window.sfDataLayer.push({ 33 session: { 34 id: sfCuid, 35 }, 36 }); 37 } else if (data && typeof data === 'object' && data.code) { 38 console.error('Failed to fetch sf_cuid:', data.message || 'Unknown error', data); 39 } else { 40 console.error('Invalid sf_cuid response:', data); 41 } 42 }) 43 .catch((error) => { 44 console.error('Failed to fetch sf_cuid:', error); 45 }); 46 } 47})();
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.