1. Analyze the Request:
* User: "Build a product analytics consent orchestration service to align tracking scripts, consent states, and data minimization requirements."
* Persona: Neo-Brutalism/Y2K Frontend Expert.
* Constraint: Build a product analytics consent orchestration service. This is a complex, backend/frontend system usually involving databases, APIs, consent management platforms (CMP), tracking scripts (GA, etc.), and logic to enforce data minimization.
* Instruction: "You are ChatGPT... Generate code... executable for demonstration." The user wants a demonstration.
* Conflict: The user asks for a service (which implies backend, database, complex logic) but the persona is a frontend expert who focuses on visual design (Neo-Brutalism/Y2K). I need to interpret this request creatively. The "service" here likely means a UI for such a service, or a simulation of it, built in a single HTML file as per system prompt constraints ("Produce one single HTML document"). The persona is defined by the system prompt: "Code expert... generate accurate and professional responses... generated code is executable... focus on Neo-Brutalism / Y2K aesthetics."
-
Deconstruct the Service Concept (Interpretation):
- Product analytics consent orchestration: This typically means a tool (often a dashboard) where you manage which tracking scripts fire based on user consent, ensure data is minimized (PII scrubbing), and manage the consent lifecycle.
- Frontend Simulation: I will create a single-page dashboard/app that simulates this orchestration platform.
- Features to implement:
- A visual representation of consent states (e.g., checkboxes, toggles) but styled in Neo-Brutalism (hard borders, huge fonts).
- A script management panel: List of tracking scripts (Google Analytics, Facebook Pixel, etc.) with their purposes and data categories.
- Data minimization controls: Sliders/inputs to configure data retention, IP anonymization, etc.
- Real-time "preview" of what data is being passed (a fake data stream).
- A "Simulate User Consent" interface to trigger state changes.
- Technical Stack: Vanilla HTML/CSS/JS within a single file. The persona's style dictates the CSS.
-
Neo-Brutalism/Y2K Design Language:
- Typography: Courier New, Times New Roman mixed with a huge display font (like
Impact, Arial Black, or a pixelated style). Uppercase titles, maybe .
- Color Palette: Acid green, neon pink, electric blue, stark black, white. High contrast.
- Borders: Thick (3px-5px) black borders.
border-style: solid.
- Shapes: Rectangles, no
border-radius.
- Effects: Hard shadows (recessed or raised), maybe CRT scanlines, glitch effects on hover.
- Layout: Overlapping elements, grid-like but slightly chaotic, marquees, pixelated icons (use CSS or base64 SVGs if needed, but simple shapes are fine).
-
Structure of the Dashboard:
- Header: Huge title, maybe animated marquee scrolling "CONSENT ORCHESTRATOR 3000".
- Main Container:
- Section 1: Script Dashboard (The "Stack") Cards for each script: Name (Pixelated), Status (Enabled/Blocked), Data Sensitivity (High/Low), Actions (Toggle).
- Section 2: Consents & Minimization Toggles for specific consent types (Necessary, Analytics, Marketing). Sliders for "Data Anonymization Level", "Retention Days".
- Section 3: Real-time Event Log A terminal window showing fake JSON payloads being sent or blocked based on the settings. This demonstrates the "orchestration".
- Section 4: Simulate User Action A button to "Give All Consents", "Revoke All", or "Random Guest".
- Footer: Credits, maybe a blinking "UNDER CONSTRUCTION" GIF (simulated with CSS).
-
Step-by-Step Implementation Plan:
- HTML Structure:
- Use semantic tags:
<header>, <main>, <section>, <footer>.
- Classes for styling:
.brutal-border, .acid-bg, .neon-text, etc.
- CSS (The Look):
- Reset:
box-sizing: border-box.
- Variables:
--black: #000; --white: #fff; --acid-green: #ccff00; --neon-pink: #ff00ff; --electric-blue: #00ffff;
- Fonts:
font-family: 'Courier New', Courier, monospace; for body, 'Impact', 'Arial Black', sans-serif for headers.
- Borders:
border: 3px solid var(--black); everywhere.
- Shadows: Hard offsets like
box-shadow: 4px 4px 0px var(--black);.
- Marquee: CSS animation moving text.
- Utility classes for positioning (flex, grid).
- JavaScript (The Logic):
- State object:
consents = { necessary: true, analytics: false, marketing: false }, scripts = [...].
- Functions:
renderScripts(): Loop through scripts and create HTML based on state.
updateScriptStatus(): Apply consent rules (if analytics consent false, block analytics scripts).
simulateEvent(): Generate a random event "PageView" or "Click", check consent rules, format JSON, append to log. Show "SENT" (green) or "BLOCKED" (red/strikethrough).
- Event listeners for toggles and sliders.
setInterval to automatically simulate traffic incoming to show the effect.
-
Refining the "Service" Aspect:
- It needs to feel like an orchestration tool. The "Event Log" is key. It should show:
- Timestamp
- Script Name (e.g.,
GA4, FB_PIXEL)
- Payload (fake data:
{event: 'view', page: '/home', ...})
- Decision:
ALLOW or BLOCK (Consent Missing) or MINIMIZED (IP Anon).
- Data Minimization: A slider for "PII Scrubbing" that adds a processing step in the log (e.g.,
>> PII_REMOVED).
-
Drafting the Design Details (Mental Mockup):
- Background: White or very light gray (
#f0f0f0).
- Header: Big black text on Acid Yellow (
#ccff00) background, black border.
- Cards: White bg, black border, sharp corners, floating with shadow.
- Buttons: Black bg, white text, maybe hover reverses colors.
- Scrollbars: Custom thick black scrollbars (via CSS).
- Glitch effect: Maybe on the header using CSS
clip-path or text-shadow shifts.
-
Writing the Code (Iterative refinement):
- Self-Correction during CSS writing: Ensure contrast is high. Ensure marquees don't induce motion sickness but fit the Y2K vibe.
- JS Logic: Keep it simple. An array of script definitions:
let scripts = [
{ id: 'ga4', name: 'GOOGLE ANALYTICS 4', category: 'analytics', active: false, blockedBy: 'consent' },
{ id: 'fb', name: 'FACEBOOK PIXEL', category: 'marketing', active: false, blockedBy: 'consent' },
{ id: 'hub', name: 'HUBSPOT', category: 'marketing', active: false, blockedBy: 'consent' },
{ id: 'hotjar', name: 'HOTJAR', category: 'analytics', active: false, blockedBy: 'consent' },
{ id: 'necessary', name: 'CORE APP TELEMETRY', category: 'necessary', active: true, blockedBy: null } // Always on
];
- Logic: When consent.analytics is false, all analytics scripts are blocked. When consent.analytics is true, they are active unless data minimization settings override. For the demo, "Data Minimization" will just log a message, but maybe also toggles
active if stricter than needed.
- Event Loop: Every 1-2 seconds, pick a random script and generate an event. Check if active. If yes, push to log. If no, push blocked message (maybe strikethrough). Limit log size (e.g., keep last 20 entries).
-
Polishing the Visuals:
- Use CSS Grid for layout:
grid-template-columns: 2fr 1fr for main content.
- "Retro Terminal" for logs: Monospaced, black bg, green text (
#00ff00), border 2px solid black.
- Toggles: Checkboxes styled as big squares or circles with ```
。
- Sliders: Standard range input but with thick thumb (
-webkit-appearance: none) and black border.
-
Final Code Assembly: (This matches the provided solution structure).
- Include
<style> block with all CSS.
- Include HTML body with the specific IDs and classes.
- Include
<script> block with logic.
- Ensure no external dependencies (icons can be emoji or text).
-
Review against Persona:
- Is it Neo-Brutalist? Yes: Bold borders, high contrast, raw fonts.
- Is it functional? Yes, it simulates consent orchestration.
- Is it executable? Yes, single HTML.
-
Final Output Generation. (Proceed to write the HTML).
Here is a complete, single-file HTML solution that implements a Product Analytics Consent Orchestration Service.
This tool is designed with a Neo-Brutalism / Y2K aesthetic (hard borders, acid colors, raw typography) while functioning as a fully interactive dashboard. It simulates the real-time flow of analytics events, enforcing consent rules and data minimization policies.
Key Features:
- Script Stack Management: Visualize which tracking scripts (GA4, Facebook, etc.) are allowed or blocked based on user consent categories.
- Consent Gate: Toggle "Analytics" and "Marketing" consents to immediately see changes in the event stream.
- Data Minimization Controls: Adjust "IP Anonymization" and "PII Scrubbing" sliders to see how payloads are transformed before dispatch.
- Live Event Terminal: A scrolling log showing raw JSON payloads being sent or blocked in real-time.
- Simulation Controls: Buttons to simulate a user revoking or granting all consents at once.
Save the following code as an .html file (e.g., orchestrator.html) and open it in any modern browser.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>NEO-CONSENT // ORCHESTRATION ENGINE</title>
<style>
/* --- NEO-BRUTALISM / Y2K VARIABLES --- */
:root {
--c-black: #000000;
--c-white: #ffffff;
--c-acid-green: #ccff00;
--c-neon-pink: #ff00ff;
--c-electric-blue: #00ffff;
--c-highlight-yellow: #ffff00;
--c-gray: #e0e0e0;
--border-thick: 3px solid var(--c-black);
--shadow-hard: 5px 5px 0px var(--c-black);
--font-display: 'Impact', 'Arial Black', 'Haettenschweiler', 'Franklin Gothic Bold', sans-serif;
--font-mono: 'Courier New', Courier, monospace;
--font-system: 'Times New Roman', Times, serif;
}
/* --- RESET & BASE --- */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
background-color: var(--c-white);
color: var(--c-black);
font-family: var(--font-mono);
overflow-x: hidden;
padding: 20px;
}
/* --- UTILITIES --- */
.brutal-box {
border: var(--border-thick);
background: var(--c-white);
box-shadow: var(--shadow-hard);
position: relative;
}
.brutal-btn {
background: var(--c-white);
border: var(--border-thick);
padding: 10px 20px;
font-family: var(--font-display);
font-size: 1.2rem;
text-transform: uppercase;
cursor: pointer;
box-shadow: var(--shadow-hard);
transition: all 0.1s;
color: var(--c-black);
}
.brutal-btn:active {
transform: translate(3px, 3px);
box-shadow: 2px 2px 0 var(--c-black);
}
.brutal-btn.primary {
background: var(--c-acid-green);
font-weight: bold;
}
.brutal-btn.danger {
background: var(--c-neon-pink);
}
.flex-col { display: flex; flex-direction: column; }
.flex-row { display: flex; flex-direction: row; align-items: center; justify-content: space-between; }
.gap-4 { gap: 1rem; }
.gap-2 { gap: 0.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-4 { margin-bottom: 2rem; }
/* --- HEADER --- */
header {
margin-bottom: 30px;
display: flex;
flex-direction: column;
gap: 10px;
}
h1 {
font-family: var(--font-display);
font-size: clamp(3rem, 8vw, 6rem);
text-transform: uppercase;
line-height: 0.9;
letter-spacing: -2px;
color: var(--c-black);
background: var(--c-highlight-yellow);
border: var(--border-thick);
padding: 10px 20px;
display: inline-block;
box-shadow: var(--shadow-hard);
transform: rotate(-1deg);
}
.marquee-container {
width: 100%;
overflow: hidden;
border: var(--border-thick);
background: var(--c-neon-pink);
padding: 5px 0;
font-weight: bold;
font-size: 1.2rem;
text-transform: uppercase;
white-space: nowrap;
box-shadow: var(--shadow-hard);
}
.marquee-content {
display: inline-block;
animation: scroll 20s linear infinite;
}
@keyframes scroll {
0% { transform: translateX(100vw); }
100% { transform: translateX(-100%); }
}
/* --- LAYOUT GRID --- */
.dashboard {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 30px;
}
@media (max-width: 900px) {
.dashboard { grid-template-columns: 1fr; }
}
/* --- CARDS & PANELS --- */
.panel-title {
font-family: var(--font-display);
font-size: 1.8rem;
margin-bottom: 1rem;
background: var(--c-electric-blue);
display: inline-block;
padding: 2px 10px;
border: var(--border-thick);
transform: skewX(-10deg);
}
.panel-content {
font-size: 1rem;
line-height: 1.5;
}
/* --- SCRIPT LIST --- */
.script-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 15px;
margin-bottom: 10px;
border: var(--border-thick);
background: var(--c-white);
position: relative;
}
.script-item.disabled {
background: repeating-linear-gradient(
45deg,
var(--c-white),
var(--c-white) 5px,
var(--c-gray) 5px,
var(--c-gray) 10px
);
opacity: 0.7;
}
.script-name {
font-family: var(--font-display);
font-size: 1.2rem;
text-transform: uppercase;
}
.script-meta {
font-size: 0.8rem;
color: #555;
}
.status-badge {
font-weight: bold;
padding: 5px 10px;
border: 2px solid black;
text-transform: uppercase;
}
.status-active { background: var(--c-acid-green); }
.status-blocked { background: var(--c-neon-pink); color: white; }
/* --- CONSENT CONTROLS --- */
.control-group {
border: var(--border-thick);
padding: 20px;
margin-bottom: 20px;
background: var(--c-white);
}
.control-label {
font-family: var(--font-display);
font-size: 1.5rem;
margin-bottom: 10px;
display: block;
text-transform: uppercase;
}
/* Toggle Switch (Raw CSS) */
.toggle-switch {
position: relative;
display: inline-block;
width: 80px;
height: 40px;
}
.toggle-switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: var(--c-gray);
border: var(--border-thick);
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 0;
bottom: 0;
background-color: var(--c-white);
border: var(--border-thick);
transition: 0.4s;
}
input:checked + .slider {
background-color: var(--c-acid-green);
}
input:checked + .slider:before {
transform: translateX(40px);
}
/* Range Slider */
.range-slider {
-webkit-appearance: none;
width: 100%;
height: 25px;
background: var(--c-gray);
border: var(--border-thick);
outline: none;
margin-top: 10px;
}
.range-slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 30px;
height: 30px;
background: var(--c-black);
border: var(--border-thick);
cursor: pointer;
box-shadow: var(--shadow-hard);
}
/* --- TERMINAL / LOGS --- */
.terminal-window {
background: var(--c-black);
color: var(--c-acid-green);
padding: 15px;
height: 400px;
overflow-y: scroll;
font-family: var(--font-mono);
border: var(--border-thick);
box-shadow: var(--shadow-hard);
position: relative;
}
.terminal-header {
background: var(--c-gray);
color: black;
padding: 5px;
margin: -15px -15px 15px -15px;
font-weight: bold;
border-bottom: var(--border-thick);
display: flex;
justify-content: space-between;
}
.log-entry {
border-bottom: 1px dashed #333;
padding: 5px 0;
font-size: 0.9rem;
white-space: pre-wrap;
word-break: break-all;
}
.log-entry.blocked { color: var(--c-neon-pink); text-decoration: line-through; }
.log-entry.sanitized { color: var(--c-highlight-yellow); }
.log-time { color: #888; margin-right: 10px; }
/* --- FOOTER --- */
footer {
margin-top: 50px;
text-align: center;
font-family: var(--font-system);
font-size: 0.8rem;
border-top: var(--border-thick);
padding-top: 20px;
}
/* Decorative blink */
.blink {
animation: blinker 1s linear infinite;
}
@keyframes blinker {
50% { opacity: 0; }
}
</style>
</head>
<body>
<header>
<div class="flex-row mb-4" style="flex-wrap: wrap; gap: 10px;">
<h1>CONSENT <span style="color: var(--c-neon-pink);">ORCH</span>ESTRATOR</h1>
<div style="margin-left: auto; align-self: center; font-family: var(--font-mono); font-weight: bold; background: var(--c-black); color: var(--c-white); padding: 5px 10px;">v2.0.77</div>
</div>
<div class="marquee-container">
<div class="marquee-content">
*** SYSTEM ONLINE *** WAITING FOR CONSENT INPUT *** MAINTAINING DATA MINIMIZATION PROTOCOLS *** NO PII LEAKS DETECTED *** TRACKING STACK: ACTIVE ***
</div>
</div>
</header>
<main class="dashboard">
<!-- LEFT COLUMN: CONTROLS & SCRIPTS -->
<section class="flex-col gap-4">
<!-- Consent Gate -->
<div class="brutal-box" style="padding: 20px;">
<div class="panel-title">01 // CONSENT GATE</div>
<div class="panel-content flex-col gap-4">
<div class="control-group flex-row">
<span class="control-label" style="margin:0;">ANALYTICS</span>
<label class="toggle-switch">
<input type="checkbox" id="consent-analytics" checked>
<span class="slider"></span>
</label>
</div>
<div class="control-group flex-row">
<span class="control-label" style="margin:0;">MARKETING</span>
<label class="toggle-switch">
<input type="checkbox" id="consent-marketing">
<span class="slider"></span>
</label>
</div>
<div class="control-group flex-row" style="align-items: flex-start;">
<span class="control-label" style="margin:0;">NECESSARY</span>
<div style="font-size: 0.9rem; max-width: 60%;">
<span class="status-badge status-active">ALWAYS ACTIVE</span><br>
Core telemetry required for infrastructure.
</div>
</div>
</div>
</div>
<!-- Minimization Settings -->
<div class="brutal-box" style="padding: 20px;">
<div class="panel-title">02 // MINIMIZATION ENGINE</div>
<div class="panel-content flex-col gap-4">
<div>
<label class="control-label">IP ANONYMIZATION</label>
<input type="range" min="0" max="255" value="0" class="range-slider" id="ip-anon-level">
<div class="flex-row" style="font-size: 0.8rem; margin-top: 5px;">
<span>OFF</span>
<span>FULL</span>
</div>
</div>
<div>
<label class="control-label">PII SCRUBBING</label>
<input type="range" min="0" max="100" value="0" class="range-slider" id="pii-scrub-level">
<div class="flex-row" style="font-size: 0.8rem; margin-top: 5px;">
<span>OFF</span>
<span>AGGRESSIVE</span>
</div>
</div>
<div>
<label class="control-label">DATA RETENTION (DAYS)</label>
<input type="range" min="1" max="365" value="90" class="range-slider" id="retention-days">
<div style="text-align: right; font-weight: bold;" id="retention-val">90d</div>
</div>
</div>
</div>
<!-- Active Scripts Inventory -->
<div class="brutal-box" style="padding: 20px;">
<div class="panel-title">03 // SCRIPT INVENTORY</div>
<div class="panel-content flex-col gap-2" id="script-list">
<!-- JS will populate -->
</div>
</div>
</section>
<!-- RIGHT COLUMN: REAL-TIME ORCHESTRATION -->
<section class="flex-col gap-4">
<!-- Simulation Controls -->
<div class="brutal-box" style="padding: 20px;">
<div class="panel-title">04 // SIMULATOR</div>
<div class="panel-content flex-row gap-4 mb-4">
<button class="brutal-btn primary" onclick="simulateUserAction('grant')">GRANT ALL</button>
<button class="brutal-btn danger" onclick="simulateUserAction('revoke')">REVOKE ALL</button>
<button class="brutal-btn" onclick="clearLogs()">CLEAR LOG</button>
</div>
<p style="font-size: 0.9rem;">
The system receives simulated "PageView" and "UserAction" events every 1.5 seconds. Observe how the traffic is filtered or modified based on your settings above.
</p>
</div>
<!-- Event Stream Terminal -->
<div class="brutal-box" style="padding: 0; overflow: hidden; display: flex; flex-direction: column; height: calc(100vh - 300px);">
<div class="terminal-header">
<span>root@orchestrator:~# tail -f /var/log/events</span>
<span class="blink">_</span>
</div>
<div class="terminal-window" id="event-log">
<!-- Logs go here -->
</div>
</div>
</section>
</main>
<footer>
<p>© 2024 NEO-BRUTAL ANALYTICS INC. // NO COOKIES COOKED HERE // DESIGNED FOR MAXIMUM IMPACT //</p>
<p style="margin-top:5px; font-size: 0.7rem; color: #666;">[WARNING: HIGH VOLTAGE VISUALS]</p>
</footer>
<script>
/* --- CONFIG & STATE --- */
const scripts = [
{ id: 'ga4', name: 'GOOGLE ANALYTICS 4', category: 'analytics', desc: 'Standard web analytics' },
{ id: 'hotjar', name: 'HOTJAR', category: 'analytics', desc: 'Heatmaps & session recordings' },
{ id: 'fbpixel', name: 'FACEBOOK PIXEL', category: 'marketing', desc: 'Meta conversion tracking' },
{ id: 'ga_ads', name: 'GOOGLE ADS', category: 'marketing', desc: 'Ad performance tracking' },
{ id: 'necessary', name: 'CORE TELEMETRY', category: 'necessary', desc: 'Server health & uptime' }
];
let state = {
consent: {
necessary: true,
analytics: false,
marketing: false
},
minimization: {
ipAnon: 0, // 0-255
piiScrub: 0 // 0-100
}
};
const EVENT_INTERVAL = 1500; // ms
let eventLoopId = null;
/* --- DOM ELEMENTS --- */
const elScriptList = document.getElementById('script-list');
const elEventLog = document.getElementById('event-log');
const elConsentAnalytics = document.getElementById('consent-analytics');
const elConsentMarketing = document.getElementById('consent-marketing');
const elIpAnon = document.getElementById('ip-anon-level');
const elPiiScrub = document.getElementById('pii-scrub-level');
const elRetention = document.getElementById('retention-days');
const elRetentionVal = document.getElementById('retention-val');
/* --- INITIALIZATION --- */
function init() {
renderScripts();
startEventSimulation();
// Event Listeners
elConsentAnalytics.addEventListener('change', (e) => {
state.consent.analytics = e.target.checked;
renderScripts();
logSystem(`Consent updated: ANALYTICS = ${e.target.checked}`);
});
elConsentMarketing.addEventListener('change', (e) => {
state.consent.marketing = e.target.checked;
renderScripts();
logSystem(`Consent updated: MARKETING = ${e.target.checked}`);
});
elIpAnon.addEventListener('input', (e) => {
state.minimization.ipAnon = parseInt(e.target.value);
});
elPiiScrub.addEventListener('input', (e) => {
state.minimization.piiScrub = parseInt(e.target.value);
});
elRetention.addEventListener('input', (e) => {
elRetentionVal.textContent = `${e.target.value}d`;
});
}
/* --- CORE LOGIC: SCRIPT STATUS --- */
function isScriptAllowed(script) {
if (script.category === 'necessary') return true;
if (!state.consent[script.category]) return false;
// Data minimization overrides
// Example: if aggressive PII scrubbing is on, we might still track but reduce data
// But for this demo, consent is the primary gate.
return true;
}
function getBlockedReason(script) {
if (script.category === 'necessary') return null;
if (!state.consent[script.category]) return `Consent Missing (${script.category.toUpperCase()})`;
return null;
}
/* --- RENDERING --- */
function renderScripts() {
elScriptList.innerHTML = '';
scripts.forEach(script => {
const allowed = isScriptAllowed(script);
const reason = getBlockedReason(script);
const div = document.createElement('div');
div.className = `script-item ${!allowed ? 'disabled' : ''}`;
const metaText = allowed
? `<span class="status-badge status-active">ACTIVE</span>`
: `<span class="status-badge status-blocked">BLOCKED</span> <small>${reason}</small>`;
div.innerHTML = `
<div>
<div class="script-name">${script.name}</div>
<div class="script-meta">${script.desc}</div>
</div>
${metaText}
`;
elScriptList.appendChild(div);
});
}
function logSystem(msg) {
const time = new Date().toISOString().split('T')[1].split('.')[0];
const entry = document.createElement('div');
entry.className = 'log-entry';
entry.innerHTML = `<span class="log-time">[${time}]</span> <strong style="color:var(--c-electric-blue)">SYSTEM:</strong> ${msg}`;
elEventLog.appendChild(entry);
scrollToBottom();
}
function logEvent(scriptName, payload, status) {
const time = new Date().toISOString().split('T')[1].split('.')[0];
const entry = document.createElement('div');
let colorClass = '';
if (status === 'BLOCKED') colorClass = 'blocked';
if (status === 'MINIMIZED') colorClass = 'sanitized';
if (status === 'SENT') colorClass = '';
entry.className = `log-entry ${colorClass}`;
// Format JSON prettily inline
const jsonStr = JSON.stringify(payload);
entry.innerHTML = `<span class="log-time">[${time}]</span> <strong>${status}</strong> <span style="color:var(--c-neon-pink)">[${scriptName}]</span>: ${jsonStr}`;
elEventLog.appendChild(entry);
scrollToBottom();
}
function scrollToBottom() {
elEventLog.scrollTop = elEventLog.scrollHeight;
}
function clearLogs() {
elEventLog.innerHTML = '';
logSystem('Log cleared.');
}
/* --- SIMULATION ENGINE --- */
function startEventSimulation() {
// Run initial log
logSystem('Orchestration engine initialized.');
// Loop
eventLoopId = setInterval(() => {
const eventTypes = ['page_view', 'user_click', 'add_to_cart', 'purchase'];
const randomEvent = eventTypes[Math.floor(Math.random() * eventTypes.length)];
const randomScript = scripts[Math.floor(Math.random() * scripts.length)];
// Build Base Payload
let payload = {
event: randomEvent,
page: window.location.pathname,
user_id: 'user_12345', // Fake ID
timestamp: new Date().toISOString(),
session_id: 'sess_98765',
device: { type: 'desktop', os: 'Windows', browser: 'Chrome' },
ip: '192.168.1.' + Math.floor(Math.random() * 255),
// Simulated PII
email: 'john.doe@example.com',
full_name: 'John Doe'
};
// Check if this script is allowed
const allowed = isScriptAllowed(randomScript);
const reason = getBlockedReason(randomScript);
if (allowed) {
// Apply Minimization transformations in-log for visualization
let isModified = false;
// IP Anonymization
if (state.minimization.ipAnon > 0) {
// Simulate masking part of IP
payload.ip = payload.ip.split('.').map((part, idx) => idx < state.minimization.ipAnon ? 'xxx' : part).join('.');
isModified = true;
}
// PII Scrubbing
if (state.minimization.piiScrub > 30) {
delete payload.email;
delete payload.full_name;
payload.user_id = 'ANONYMIZED';
isModified = true;
} else if (state.minimization.piiScrub > 10) {
// Mask email partially
const [user, domain] = payload.email.split('@');
payload.email = user.substring(0,2) + '***@' + domain;
isModified = true;
}
const status = isModified ? 'MINIMIZED' : 'SENT';
logEvent(randomScript.name, payload, status);
} else {
// Logic: Create a "blocked" payload entry showing what WOULD have been sent (or just a generic blocked msg)
// For effect, show original payload but crossed out
payload.blocked_reason = reason;
logEvent(randomScript.name, payload, 'BLOCKED');
}
}, EVENT_INTERVAL);
}
/* --- USER ACTIONS SIMULATION --- */
window.simulateUserAction = function(action) {
if (action === 'grant') {
state.consent.analytics = true;
state.consent.marketing = true;
elConsentAnalytics.checked = true;
elConsentMarketing.checked = true;
logSystem('USER ACTION: Consent Granted (All Categories)');
} else if (action === 'revoke') {
state.consent.analytics = false;
state.consent.marketing = false;
elConsentAnalytics.checked = false;
elConsentMarketing.checked = false;
logSystem('USER ACTION: Consent Revoked (Non-Essential)');
}
renderScripts();
};
// Start
init();
</script>
</body>
</html>