Click macros (Marty 2026-11-13): a spot's Target link can carry {clickid}, {spot} and {type} (gate/organic), filled on every click, for LinkSpin's Downline Banners source; hint on My Spots, my.js?v=4

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-13 08:25:54 -06:00
parent bdb2aacf27
commit 289fcaf2c8
3 changed files with 9 additions and 4 deletions
+7 -2
View File
@@ -203,12 +203,17 @@ const server = http.createServer(async (req, res) => {
if (/^\/go\/[\w-]+$/.test(p)) {
const ref = p.slice(4); const t = board.target(ref);
if (!t) { res.writeHead(302, { Location: '/' }); return res.end(); }
let kind = 'organic';
if (t.spotId && !isBot(req)) {
const g = gates.get(u.searchParams.get('g') || ''); const gi = Number(u.searchParams.get('i'));
const isGate = g && g.vk === visitorKey(req) && g.steps[gi] && g.steps[gi].ref === ref;
store.addClick(t.spotId, visitorKey(req), isGate ? 'gate' : 'organic');
kind = isGate ? 'gate' : 'organic';
store.addClick(t.spotId, visitorKey(req), kind);
}
const loc = t.link.startsWith('/') ? t.link : t.link;
// tracking macros in a member's link (2026-11-13, LinkSpin's "Downline Banners" source): {clickid} a fresh id per click,
// {spot} the spot number, {type} gate or organic
const loc = !t.spotId || t.link.indexOf('{') < 0 ? t.link : t.link
.replace(/\{clickid\}/g, crypto.randomBytes(8).toString('hex')).replace(/\{spot\}/g, String(t.spotId)).replace(/\{type\}/g, kind);
res.writeHead(302, { Location: loc, 'Cache-Control': 'no-store', 'Referrer-Policy': 'origin' }); return res.end();
}
}