Conversion tracking fixes (Marty approved 2026-10-26): own clicks are tests on every click type, Banner Spin straight-to-page clicks carry lsclk

1. Own clicks: a goal owner's own click on ANY click type (LinkSpin/InstantAdPay ads, spin links, Banner Spins) is kept as a test, never counted, never fires a goal postback. Own = ad click flagged self for that owner, a spin-link / Banner Spin click marked at click time (signed in as the owner, or from an owner soft key: markOwnClick in server.js), or the clicking or converting browser's soft key is one the owner signs in from. auth.onSeen notes LinkSpin session soft keys (throttled, kept 31 days in convtrack.json S.own); /api/partner/clicks takes owners [{owner, sk, ts}] from InstantAdPay before the clicks, so IAP members' own browsers are known too. Linked positions share the owner's email. X-LS-Result adds ;self. partnerSummary returns selfTests for the IAP card. Conversions screen copy: test with Send a test conversion and the &test=1 page check, own clicks never count (conversions.js ?v=20261026a).
3. Banner Spin: a click whose target is a direct page (not a /r/ spin link) gets ?lsclk=<k click id> when the owner tracks goals (string insert like lsconv.withClickId: params kept, before #hash, an existing lsclk never replaced). convtrack.lookup resolves k ids through bannerspin.clickById; conversions record k:'bspin' with the Banner Spin, banner, page and source; report By Banner Spin, CSV site 'Banner Spin', postback ctx with its sub ids.
Guides: /conversion-tracking (Banner Spin straight to a page now counted, own clicks on every type are tests, By Banner Spin), /refuel tile. Chatbot CANNED + FACTS, KNOWLEDGE_DATE 2026-10-26.
QA: convpixel 77/77 (new: owner soft keys, own ad/spin/Banner Spin/IAP clicks as tests, stranger still counts, own-browser conversion, withClickId, Banner Spin lsclk + By Banner Spin + spin-link banner untouched, selfTests in the IAP summary, no postback for own clicks); lsid 31/31; fuel all pass (engine.js / engine-room.js / kit.js untouched, byte-identical with InstantAdPay); bannerspin 75/75; member walk 0 bugs; public 0 bugs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-26 06:19:54 -05:00
parent 28192b61e9
commit 98e3ed36d8
10 changed files with 206 additions and 48 deletions
+19 -2
View File
@@ -21,6 +21,8 @@
// reloads count once per minute per banner. Clicks are rows like spin-link clicks, with the usual lsid click id
// ('k' + 11 hex, never valid hex so it can never collide with a rotator id), so joins / wallets / purchases and partner
// postbacks credit the banner (rotator.convert falls through to convert() here), and a traffic source's postback fires.
// Since 2026-10-26 a click that goes straight to a page also gets ?lsclk=<click id> when the owner tracks goals, so the
// conversion pixel (convtrack.js, clickById below) counts goals from Banner Spin banners that skip a spin link.
//
// Access. Members with at least one own package of $25 or more. Starter 2 Banner Spins x 5 banners; Builder (level 2
// open, 2 qualifying buyers) 5 x 15; Leader (level 3 open, 5 qualifying buyers) 10 x 25. Facts come from server.js
@@ -68,10 +70,14 @@ const J = { db: null, FILE: () => path.join(DATA_DIR, 'bannerspin.json'),
const C = { db: { v: 1, d: {} }, FILE: () => path.join(DATA_DIR, 'bannerspin-counts.json'),
read() { try { const x = JSON.parse(fs.readFileSync(this.FILE(), 'utf8')); return x && x.d ? x : { v: 1, d: {} }; } catch (e) { return { v: 1, d: {} }; } } };
let PENDING = { d: {} }, DIRTY = false, timer = null, lastPrune = 0;
// conversion pixel (2026-10-26): a click that goes straight to a page (not a spin link) gets ?lsclk=<this click id> when
// the owner tracks goals, the same rule spin links follow. server.js hands in the goal check and convtrack's string insert.
let WANTS_CLICK_ID = () => false, WITH_CLICK_ID = (u) => u;
function init(opts) {
DATA_DIR = opts.dataDir; UPLOADS_DIR = opts.uploadsDir || path.join(DATA_DIR, 'uploads'); rotator = opts.rotator || null; geo = opts.geo || null; SOURCES = opts.sources || null;
OWN_HOSTS = opts.ownHosts || OWN_HOSTS; FACTS = opts.facts || FACTS; ADMIN = norm(opts.adminEmail);
if (opts.wantsClickId) WANTS_CLICK_ID = opts.wantsClickId; if (opts.withClickId) WITH_CLICK_ID = opts.withClickId;
J.load(); C.db = C.read();
if (opts.schedule !== false) { timer = setInterval(() => { flush(); sweep(); }, FLUSH_MS); if (timer.unref) timer.unref(); }
}
@@ -324,8 +330,19 @@ async function click(code, req, reqHost) {
for (const [k, val] of Object.entries(q)) if (vals[k] == null) vals[k] = val;
url = url.replace(/\{([a-z0-9_]{1,24})\}/gi, (mm, k) => encodeURIComponent(vals[k.toLowerCase()] == null ? '' : vals[k.toLowerCase()]));
try { const t = new URL(url); if (OWN_HOSTS().includes(t.hostname.toLowerCase()) && !t.searchParams.has('lsid') && !/^\/r\//.test(t.pathname)) { t.searchParams.set('lsid', id); url = t.toString(); } } catch (e) {}
// straight to a page: the click id rides along for the landing tag (a spin-link target adds its own on the /r/ hop)
if (!bot) { let spinHop = false; try { spinHop = /^\/r\/[a-z0-9]{4,12}$/i.test(new URL(url).pathname); } catch (e) {} if (!spinHop) { try { if (WANTS_CLICK_ID(s.owner)) url = WITH_CLICK_ID(url, id); } catch (e) {} } }
}
return { url, lsid: id, banner: b, matched: m };
return { url, lsid: id, banner: b, matched: m, owner: s.owner };
}
// conversion pixel (2026-10-26): a Banner Spin click by id, with its Banner Spin, banner and where it went
function clickById(id) {
id = String(id || ''); if (!/^k[a-f0-9]{11}$/.test(id)) return null;
const list = J.db.clicks; let c = null; for (let i = list.length - 1; i >= 0; i--) if (list[i].id === id) { c = list[i]; break; }
if (!c) return null;
const s = J.db.spins.find(x => x.id === c.s); if (!s) return null;
const b = c.b ? s.banners.find(x => x.id === c.b) || null : null;
return { click: c, owner: s.owner, spin: { id: s.id, code: s.code, name: s.name || '' }, banner: b ? { id: b.id, label: b.label || '' } : null, destUrl: b && !b.link ? (b.target || '') : (b ? '' : (s.fallback || '')) };
}
// conversions (rotator.convert falls through to here for a 'k' click id): dedupe per click + event
async function convert(lsid, ev, facts) {
@@ -463,4 +480,4 @@ const rawSpins = () => J.db.spins;
const save = () => J.save();
function imageSource(img) { const m = LOCAL_IMG.exec(String(img || '')); return m ? { file: path.join(UPLOADS_DIR, m[1]) } : /^https:\/\//i.test(String(img || '')) ? { url: String(img) } : null; }
const _test = { notes: () => NOTES, flush, vkey, cacheFlag, winnerOf };
module.exports = { init, SIZES, TIERS, MAX_BYTES, tierFor, list, create, update, addBanner, updateBanner, noteImage, dims, image, script, click, convert, stats, summary, adminAll, adminSet, setGlobal, settings, imageRefs, totals, blankPng, readImage, flush, findMine, rawSpins, save, imageSource, live, _test };
module.exports = { init, SIZES, TIERS, MAX_BYTES, tierFor, list, create, update, addBanner, updateBanner, noteImage, dims, image, script, click, clickById, convert, stats, summary, adminAll, adminSet, setGlobal, settings, imageRefs, totals, blankPng, readImage, flush, findMine, rawSpins, save, imageSource, live, _test };