Skip to content

Instantly share code, notes, and snippets.

View thyngster's full-sized avatar

David Vallejo thyngster

View GitHub Profile
@thyngster
thyngster / dataLayerMonitor.js
Created February 6, 2026 02:31
dataLayer Integrity Monitor
(function protectDataLayer() {
window._internalDataLayer = window.dataLayer || [];
// Wrap the array in a Proxy to detect internal changes
const dataLayerProxy = new Proxy(window._internalDataLayer, {
set(target, prop, value, receiver) {
console.log(`[dataLayer] Change detected: "${prop}" set to`, value);
return Reflect.set(target, prop, value, receiver);
},
get(target, prop, receiver) {
@thyngster
thyngster / gtm_load_performance.js
Created February 6, 2026 08:38
GTM Load Performance
(function() {
const targetScript = "gtm.js";
function fmt(ms) { return ms.toFixed(2) + "ms"; }
// Poll performance entries until we find GTM.js
const checkInterval = 50; // ms
const maxAttempts = 100; // ~5 seconds max
let attempts = 0;