1/* FlowDirect Growth Engine â copy-experiment harness (hotel #0). 2 * Elements opt in with data-exp="<name>". For each, we read the PostHog 3 * feature flag "exp-<name>"; if its payload JSON contains {"text": "..."} 4 * the element's text is swapped. PostHog records exposure automatically 5 * ($feature_flag_called), so experiment results attribute themselves. 6 * 7 * Anti-flicker: tagged elements are hidden until flags resolve, with an 8 * 800ms fail-open timeout (control shows if PostHog is slow/blocked). 9 * Include AFTER the PostHog snippet: <script src="/js/fd-exp.js" defer></script> 10 */ 11(function () { 12 "use strict"; 13 try { 14 var els = document.querySelectorAll("[data-exp]"); 15 if (!els.length) return; 16 17 var style = document.createElement("style"); 18 style.textContent = "[data-exp]:not([data-exp-ready]){visibility:hidden}"; 19 document.head.appendChild(style); 20 21 var done = false; 22 function reveal() { 23 if (done) return; 24 done = true; 25 document.querySelectorAll("[data-exp]").forEach(function (el) { 26 el.setAttribute("data-exp-ready", "1"); 27 }); 28 } 29 30 function apply() { 31 try { 32 els.forEach(function (el) { 33 var key = "exp-" + el.getAttribute("data-exp"); 34 var variant = window.posthog.getFeatureFlag(key); 35 if (variant && variant !== "control") { 36 var payload = window.posthog.getFeatureFlagPayload(key); 37 if (payload && typeof payload.text === "string") { 38 el.textContent = payload.text; // textContent only: no HTML injection 39 } 40 } 41 }); 42 } catch (e) { /* fail open to control */ } 43 reveal(); 44 } 45 46 if (window.posthog && typeof window.posthog.onFeatureFlags === "function") { 47 window.posthog.onFeatureFlags(apply); 48 } 49 setTimeout(reveal, 800); // fail-open: never hold the page hostage 50 } catch (e) { 51 try { 52 document.querySelectorAll("[data-exp]").forEach(function (el) { 53 el.setAttribute("data-exp-ready", "1"); 54 }); 55 } catch (e2) { /* noop */ } 56 } 57})();
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.