Banner Spin engine (phase 1): /i/ image with no-store + fresh ETag, /c/ click matching (visitor key + placement host note, 15 min) with fallback, /s/ exact-match script embed, impression counters flushed every 5 s (read-add-write), banner clicks with lsid conversions + source postbacks, tiers ($25 own package; Starter 2x5, Builder 5x15, Leader 10x25), member + admin API, admin kill switch per Banner Spin / per banner / global, Banner Spins in admin Member content

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-18 10:58:44 -05:00
parent e0e0bde1f9
commit 406113bc03
6 changed files with 507 additions and 11 deletions
+4 -2
View File
@@ -187,8 +187,10 @@ async function resolve(code, req) {
return { url: out, dest: d, rotation: r, lsid: id };
}
// conversions: record an event against the click that brought the person (dedupe per click + event)
// Banner Spin clicks (bannerspin.js, 2026-10-18) carry their own click ids ('k' + 11 hex); an id we do not know is handed to it
let EXT_CONVERT = null; function setExternalConvert(fn) { EXT_CONVERT = fn; }
async function convert(lsid, ev, facts) {
const h = J.db.hits.find(x => x.id === String(lsid)); if (!h) return null;
const h = J.db.hits.find(x => x.id === String(lsid)); if (!h) return EXT_CONVERT ? EXT_CONVERT(lsid, ev, facts) : null;
const r = J.db.rotations.find(x => x.id === h.r); if (!r) return null;
if (!J.db.conv.some(c => c.lsid === h.id && c.ev === ev)) { J.db.conv.push({ lsid: h.id, r: r.id, d: h.d, ev, ts: Date.now(), value: Number(facts && facts.payout || 0) || 0, label: facts && facts.label ? String(facts.label).slice(0, 40) : undefined, sr: h.sr || undefined }); if (J.db.conv.length > 100000) J.db.conv = J.db.conv.slice(-80000); J.save(); }
return { owner: r.owner, code: r.code, rotationId: r.id, q: h.q || {}, s: h.s, c: h.c, dv: h.dv, sourceId: h.sr || '' };
@@ -293,4 +295,4 @@ function adminAll() {
hits: o.hits, hits7: o.hits7, bots: o.bots, conversions: cv[r.id] || 0 }; });
}
module.exports = { init, adminAll, list, get, create, update, remove, addDest, updateDest, resolve, stats, totals, convert, summary, createDemo, claim, sweepDemos, servedToday,
pub, rawRotations, save, findMine, PRESETS, cleanHours, cleanTz, cellAt, zoneFor, isOn, COUNTRY_TZ, sourceCounts, detachSource };
pub, rawRotations, save, findMine, setExternalConvert, PRESETS, cleanHours, cleanTz, cellAt, zoneFor, isOn, COUNTRY_TZ, sourceCounts, detachSource };