Michael Camire fixes + hub shells in the tank (Marty 2026-11-14, LinkSpin Support)
1. Top-up across positions: an ad burns from ONE position, and topUpCampaign only looked at the ad's
own position (or the main one when the list row had no memberId), so credits bought on a linked
position could never top up the ad. Ported from InstantAdPay 2026-09-27 (Jim Watts): the ad's real
member id is read from the campaign row; when it cannot cover, the refusal names where the free
credits are and offers switchOptions; with the member's yes (switchTo, only a position on the
account) moveFunding settles what the ad already ran up on the OLD position, moves the ad, then
tops up. Ads screen asks in-page (own dialog) and retries. Create already had the largest-position guard.
2. Toasts: errors stay until closed (close button, role=alert), other notes 3.5 to 9 s by length.
3. Banner Spin per-banner clicks: his 3 clicks were all unmatched (no view on record for that browser),
so they landed on the fallback row and every banner said 0. Click matching now also tries the same
connection (daily-salted IP-only hash) when the browser key finds nothing (mail/exchange app view,
click opened in the phone browser), view notes last 60 min instead of 15, and the stats split
'Fallback shown' from 'Clicks not tied to a banner' so the rows add up to the total. History is not
backfilled: views were never stored per visitor, so old clicks cannot be tied reliably.
4. Holding tank: hub-made waiting accounts with no sponsor are in the tank (waiting, rescue, readyTick
read listAll with { shells: true }; 'hub-shell' no longer holds anyone back). Locked / sponsored /
unknown, grace, 2-adoption cap unchanged; readyTick still never switches a shell on;
accounts.listAll default unchanged (mailings skip shells).
Assets: cr.css, cr-shell.js, ads-screen.js ?v=20261114tu, banner-spin.js ?v=20261114bc.
QA: walk member 0 bugs (36 ok), netconv 57/57, networksso ALL PASSED, tank-hold all passed (new hub
shell part), profile policy 16/16, new topup-positions 8/8, new bannerspin-attrib 7/7, bannerspin e2e
75/75, hubsync 15 checks, tank-cap 15/15, sponsorfollow 30/30.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+13
-5
@@ -51,7 +51,7 @@ const TIERS = {
|
||||
};
|
||||
const ORDER = ['starter', 'builder', 'leader'];
|
||||
const MAX_BYTES = 150 * 1024, MAX_BANNERS = 25;
|
||||
const NOTE_TTL = 15 * 60000, DEDUPE_MS = 60000, FLUSH_MS = 5000, UNIQ_CAP = 500, HOSTS_CAP = 200;
|
||||
const NOTE_TTL = 60 * 60000, DEDUPE_MS = 60000, FLUSH_MS = 5000, UNIQ_CAP = 500, HOSTS_CAP = 200;
|
||||
const BOT = /bot|crawl|spider|slurp|facebookexternalhit|preview|telegrambot|whatsapp|curl|wget|python-requests|headless/i;
|
||||
const norm = e => String(e || '').trim().toLowerCase();
|
||||
const CT_FMT = new Intl.DateTimeFormat('en-CA', { timeZone: 'America/Chicago', year: 'numeric', month: '2-digit', day: '2-digit' });
|
||||
@@ -92,6 +92,12 @@ const ipOf = req => String(req.headers['x-forwarded-for'] || (req.socket && req.
|
||||
const vkey = (req, ts) => crypto.createHash('sha256').update(new Date(ts || Date.now()).toISOString().slice(0, 10) + '|' + ipOf(req) + '|' + String(req.headers['user-agent'] || '')).digest('hex').slice(0, 16);
|
||||
// keys to try for a click: today's, and yesterday's for the first 15 minutes after UTC midnight (a note made at 23:59 still matches)
|
||||
function vkeys(req) { const now = Date.now(); const k = [vkey(req, now)]; if (now % DAY < NOTE_TTL) k.push(vkey(req, now - DAY)); return k; }
|
||||
// Second chance for a click (Michael Camire 2026-11-14: 3 clicks on his Banner Spin, every one unmatched, so no banner got
|
||||
// credit): the same daily-salted hash WITHOUT the browser. A mail app or a traffic-exchange app shows the image in its own
|
||||
// viewer and opens the click in the phone's or PC's browser: same IP, different user agent, so the full key never matches.
|
||||
// Only used when the full key finds nothing; the most recent view of this Banner Spin from that IP wins.
|
||||
const ipkey = (req, ts) => 'i' + crypto.createHash('sha256').update(new Date(ts || Date.now()).toISOString().slice(0, 10) + '|ip|' + ipOf(req)).digest('hex').slice(0, 15);
|
||||
function ipkeys(req) { if (!ipOf(req)) return []; const now = Date.now(); const k = [ipkey(req, now)]; if (now % DAY < NOTE_TTL) k.push(ipkey(req, now - DAY)); return k; }
|
||||
const isBot = req => { const ua = String(req.headers['user-agent'] || ''); return !ua || BOT.test(ua); };
|
||||
const isPrefetch = req => /prefetch|prerender|preview/i.test([req.headers.purpose, req.headers['sec-purpose'], req.headers['x-purpose'], req.headers['x-moz']].filter(Boolean).join(' '));
|
||||
// a server fetching the image, not a browser (phase 3, 2026-10-20): mail image proxies and plain HTTP libraries. Kept out of
|
||||
@@ -279,7 +285,7 @@ function choose(s, req, opts) {
|
||||
const kind = loaderKind(req); rawLoad(String(s.id), hostOf(req), v, kind);
|
||||
if (!kind) {
|
||||
const bid = b ? b.id : 0; const host = hostOf(req);
|
||||
note(v, s.id, host, bid);
|
||||
note(v, s.id, host, bid); if (ipOf(req)) note(ipkey(req), s.id, host, bid);
|
||||
const k = v + '|' + s.id + '|' + bid; const last = SEEN.get(k);
|
||||
if (!last || Date.now() - last >= DEDUPE_MS) { SEEN.set(k, Date.now()); bump(String(s.id), bid, host, v); }
|
||||
}
|
||||
@@ -313,7 +319,7 @@ async function click(code, req, reqHost) {
|
||||
let b = null, m = 'none';
|
||||
if (!live() || s.adminOff) m = 'off';
|
||||
else if (xs != null && /^\d{1,4}$/.test(xs)) { b = Number(xs) ? s.banners.find(q => q.id === Number(xs) && !q.adminOff) || null : null; m = 'exact'; }
|
||||
else { const n = findNote(keys, s.id, h); if (n) { b = n.b ? s.banners.find(q => q.id === n.b && !q.adminOff) || null : null; m = 'note'; } }
|
||||
else { let n = findNote(keys, s.id, h), how = 'note'; if (!n) { n = findNote(ipkeys(req), s.id, h); how = 'ip'; } if (n) { b = n.b ? s.banners.find(q => q.id === n.b && !q.adminOff) || null : null; m = how; } }
|
||||
// where to: the banner's target (its spin link, on the same link domain), else the fallback
|
||||
let url = null;
|
||||
if (b) { if (b.link) { const r = rotator && rotator.rawRotations ? rotator.rawRotations().find(x => x.id === b.link && x.owner === s.owner) : null; url = r ? 'https://' + (reqHost || 'linkspin.app') + '/r/' + r.code : null; } else url = b.target; }
|
||||
@@ -383,7 +389,7 @@ function agg(spins, sinceTs) {
|
||||
if (!ids.has(c.s) || (sinceTs && c.ts < sinceTs)) continue;
|
||||
const dd = at(days, ctDay(c.ts));
|
||||
if (c.bot) { T.botClicks++; dd.botClicks++; continue; }
|
||||
const ok = c.m === 'exact' || c.m === 'note';
|
||||
const ok = c.m === 'exact' || c.m === 'note' || c.m === 'ip';
|
||||
for (const o of [at(per, c.s + ':' + c.b), at(hosts, c.h || '(none)'), dd, T]) { o.clicks++; if (ok) o.matched++; else if (c.m === 'none') o.unmatched++; }
|
||||
const k = c.c || '(none)'; country[k] = (country[k] || 0) + 1; const dv = c.dv || '(none)'; device[dv] = (device[dv] || 0) + 1;
|
||||
}
|
||||
@@ -419,7 +425,9 @@ async function stats(owner, id) {
|
||||
const win = winnerOf(banners.filter(b => b.active)); for (const b of banners) b.winner = b.id === win;
|
||||
const fb = A.per[s.id + ':0'] || z;
|
||||
return { spin: pub(s), totals: { imps: A.T.imps, clicks: A.T.clicks, ctr: ctrOf(A.T), matchRate: mrOf(A.T), matched: A.T.matched, unmatched: A.T.unmatched, uniquesSampled: A.T.uniq, conversions: A.T.conv, bots: A.T.botClicks, botLoads: A.T.bots, serverLoads: A.T.srv },
|
||||
banners, winner: win, winMin: WIN_MIN, fallback: { imps: fb.imps, clicks: fb.clicks, ctr: ctrOf(fb) },
|
||||
// fallback = the fallback was SHOWN (views + the clicks matched to those views); unmatched = clicks we could not tie to any view,
|
||||
// listed on their own row so the banner rows + these two add up to the Banner Spin's totals
|
||||
banners, winner: win, winMin: WIN_MIN, fallback: { imps: fb.imps, clicks: fb.clicks - fb.unmatched, ctr: ctrOf({ imps: fb.imps, clicks: fb.clicks - fb.unmatched }) }, unmatched: { clicks: fb.unmatched },
|
||||
placements: placementRows(A.hosts), days: dayRows(A.days, ctDay(Date.now() - 30 * DAY)), country: listOf(A.country), device: listOf(A.device),
|
||||
conversions: Object.entries(A.convBy).sort((a, b) => b[1] - a[1]).map(([k, n]) => ({ k, n })) };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user