From e6b1151ace0481149ceb30521b7fa592212ef820 Mon Sep 17 00:00:00 2001 From: martbost Date: Sat, 29 Aug 2026 05:08:04 -0500 Subject: [PATCH] Traffic Desk: stop the network's counter drift showing as nonsense MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Marty spotted rows where "left" exceeded "bought" — 3,521 remaining on a 2,500-impression purchase, with "served" reading 0 across those rows. Reproduced against the network: on 11 of 26 campaigns the ad app's own assigned/remaining counters have grown past what we inserted. We write assigned = remaining = the purchased amount; later both sit higher. Actively serving campaigns still reconcile exactly (served + remaining = bought), so our arithmetic is right and the inputs are drifting. The cause is inside the ionCube-encoded ad application, so there is nothing to fix at source. Direction matters: this is OVER-delivery. Members receive more impressions than their allowance and the ledger still only charges what they asked for, so nobody loses anything. The table now clamps both columns to what was actually bought, so a row always reconciles: served + left = bought. Showing a member more impressions remaining than they purchased reads as broken software, which costs more trust than the bonus impressions are worth. Co-Authored-By: Claude Fable 5 --- public/suite-traffic.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/public/suite-traffic.js b/public/suite-traffic.js index 7ac7d2a..d1fa0f0 100644 --- a/public/suite-traffic.js +++ b/public/suite-traffic.js @@ -175,6 +175,16 @@ var l = byId[c.adId] || {}; var tr = document.createElement('tr'); var served = l.served != null ? l.served : 0; + // The ad network's own counters sometimes drift ABOVE what we bought — + // its remaining has been observed at 3,521 on a 2,500 purchase. The cause + // is inside the ionCube-encoded ad app, so we cannot fix it at source; we + // can stop it rendering as nonsense. Clamp to what the member actually + // bought so the row always reconciles: served + left = bought. Any genuine + // over-delivery is a bonus to them and needs no explanation on this table. + var bought = Number(c.bought != null ? c.bought : c.impressions) || 0; + var rawLeft = l.remaining != null ? Number(l.remaining) : null; + var left = rawLeft == null ? null : Math.max(0, Math.min(rawLeft, bought)); + var servedShown = left == null ? Number(served) : Math.max(0, bought - left); var statusCell = c.stopped ? 'stopped (' + Number(c.refunded || 0).toLocaleString() + ' returned)' : (l.live ? 'running' : 'finished'); @@ -184,8 +194,8 @@ tr.innerHTML = '' + label + '' + '' + (c.target.indexOf('/p/') !== -1 ? 'personal page' : 'invite page') + '' + '' + Number(c.bought != null ? c.bought : c.impressions).toLocaleString() + '' + - '' + Number(c.stopped ? (c.served || 0) : served).toLocaleString() + '' + - '' + (c.stopped ? '—' : (l.remaining != null ? Number(l.remaining).toLocaleString() : '—')) + '' + + '' + Number(c.stopped ? (c.served || 0) : servedShown).toLocaleString() + '' + + '' + (c.stopped ? '—' : (left != null ? left.toLocaleString() : '—')) + '' + '' + (l.hits != null ? l.hits : '—') + '' + '' + statusCell + ''; var act = document.createElement('td');