From b2a083ac7c815ff330d93bbeb5a8d7e6b6a1b516 Mon Sep 17 00:00:00 2001 From: Matt Mabrey Date: Wed, 23 Sep 2026 14:46:32 -0700 Subject: [PATCH] T11.6: retire the per-browser Usage report (CR-019) Removes the old "Usage logs" card from admin.html/admin.js (the usage-admin panel + loadUsage(), D5/T7.10) now that T11.5's real, server-side Activity & usage card exists and reads real per-user data instead of per-browser localStorage. wp-usage.js is deleted outright, along with its three diff --git a/html/admin.js b/html/admin.js index e1a5934..4ba4f33 100644 --- a/html/admin.js +++ b/html/admin.js @@ -25,7 +25,6 @@ function reveal(){ loadComments(); loadAudit(); loadActivity(); - loadUsage(); } function showDenied(){ document.getElementById('admin-denied').style.display=''; @@ -754,48 +753,6 @@ async function loadNotifications(){ '').join('')+''; } -// ── usage logs (read from this browser's localStorage) ────────────────────────── -// D5 / T7.10: the report for BOTH tools' recorded usage, in the one place an -// operator-facing readout belongs - behind the same admin gate as this whole -// page (gateByRole() below shows nothing else either). Data comes from -// wp-usage.js, the single implementation; the keys predate the move, so -// everything recorded before it is still here. -function loadUsage(){ - const box = document.getElementById('usage-admin'); - if(!box) return; - const tools = [ - ['Work package creator', WPUsage.KEYS.creator, 'wp-iwp-usage'], - ['SOP wizard', WPUsage.KEYS.wizard, 'wp-suite-usage'], - ]; - let html = ''; - tools.forEach(([label, key, prefix]) => { - const evs = (WPUsage.load(key).events) || []; - html += '

' + uesc(label) + '

'; - if(!evs.length){ - html += '
No usage recorded in this browser yet.
'; - return; - } - const byEvent = {}, sessions = new Set(); - let first = evs[0].ts, last = evs[0].ts; - evs.forEach(e => { - byEvent[e.event] = (byEvent[e.event]||0)+1; - if(e.session) sessions.add(e.session); - if(e.ts < first) first = e.ts; if(e.ts > last) last = e.ts; - }); - const fmt = v => v ? wpFormatDateTime(v) : '—'; - html += ''+ - ''+ - ''+ - '
Sessions'+sessions.size+'
Events'+evs.length+'
Range'+fmt(first)+' → '+fmt(last)+'
'; - html += ''; - Object.keys(byEvent).sort().forEach(k => html += ''); - html += '
EventCount
'+uesc(k)+''+byEvent[k]+'
'; - html += '
'; - }); - box.innerHTML = html; -} - // ── access control: admins only ───────────────────────────────────────────────── // auth-guard.js requires a login and sets window.WP_USER (firing 'wp-auth-ready'). // Show the console for admins; otherwise show the "Admins only" notice. diff --git a/html/work-package-suite-app.js b/html/work-package-suite-app.js index 4829511..34af900 100644 --- a/html/work-package-suite-app.js +++ b/html/work-package-suite-app.js @@ -2207,20 +2207,18 @@ function loadStepComments(){ } } -// ── USAGE ANALYTICS ───────────────────────────────────────────────────────── -// Lightweight usage analytics stored in localStorage so the tool owner can review -// engagement over time. No field VALUES are stored (field-edit events record only -// the field id), keeping captured data non-sensitive. -// D5 / T7.10: the analytics implementation lives in wp-usage.js and the report -// on the admin console. The wizard's own copy of showAnalytics() never had a -// caller here - the button lived on the creator - and once B7 dissolved the -// frame the duplicate sat in the same document as five colliding globals. -// This page only records; dwell tracking keeps its page-local state below. +// ── USAGE ANALYTICS (retired, T11.6) ──────────────────────────────────────── +// This used to write to wp-usage.js's per-browser localStorage log (D5/T7.10), +// read back by the admin console's old "Usage logs" panel. CR-019 replaced +// both with real, server-side, per-user activity (UsageEvent + the Activity & +// usage card) - see decisions-2026-09-17.md for why this per-browser data was +// never a source the new report could adopt. track() is now a no-op; kept +// (rather than deleting its handful of call sites, including the dwell-timer +// plumbing below) so this stays a one-line change instead of touching every +// caller for the same outcome. let _stepEnter = Date.now(); -function track(event, detail){ - WPUsage.track(WPUsage.KEYS.wizard, event, detail); -} +function track(event, detail){ /* retired, T11.6 — see comment above */ } function trackStepDwell(){ const ms = Date.now() - _stepEnter; if(ms > 400 && ms < 1000*60*60) track('step_dwell', {step: currentStep, ms}); diff --git a/html/work-package-suite.html b/html/work-package-suite.html index 29146de..cbd53d1 100644 --- a/html/work-package-suite.html +++ b/html/work-package-suite.html @@ -11,7 +11,6 @@ - diff --git a/html/wp-creation-app.js b/html/wp-creation-app.js index 61c3797..40f762d 100644 --- a/html/wp-creation-app.js +++ b/html/wp-creation-app.js @@ -3993,11 +3993,17 @@ function openSopModal(){ document.getElementById('sop-modal').classList.add('open'); track('view_sop'); } function closeSopModal(){ document.getElementById('sop-modal').classList.remove('open'); } -// D5 / T7.10: the analytics implementation lives in wp-usage.js - ONE copy for -// the whole suite - and its report lives on the admin console, where an -// operator-facing readout belongs. This page only records. Same key, same -// event shape: everything recorded before the move is still readable after it. -function track(event,detail){ if(devMode) return; WPUsage.track(WPUsage.KEYS.creator, event, detail); } +// CR-019 / T11.6 (2026-09-23): this used to write to wp-usage.js's per-browser +// localStorage log (D5/T7.10). Retired along with the admin console's old +// "Usage logs" panel, its only reader - real, server-side, per-user activity +// now exists (UsageEvent, the Activity & usage card, T11.1-T11.5) and this +// data was never reliably tied to a real identity anyway, so it was not a +// source the new report could adopt (decisions-2026-09-17.md). track() stays +// as a no-op rather than deleting its ~35 call sites throughout this file: +// removing every call individually is a much larger, riskier diff for the +// same outcome, and a call site here still documents the moment worth +// recording if usage analytics are ever rebuilt server-side. +function track(event,detail){ /* retired, T11.6 — see comment above */ } // ── COMMENTS ───────────────────────────────────────────────────────────────── const COMMENTS_KEY='wp_iwp_comments_v1'; diff --git a/html/wp-creation-index.html b/html/wp-creation-index.html index 6483cbf..3da788b 100644 --- a/html/wp-creation-index.html +++ b/html/wp-creation-index.html @@ -11,7 +11,6 @@ -