Files
linkspin/public/sources.html
T
martbost 211eb5a0e8 Traffic sources: network macros, campaign URLs, per-source postbacks, Reports dimension
A Source is a first-class record of a network a member buys traffic on (PropellerAds,
Zeropark, Adsterra, ExoClick and 25 more from the shipped catalog, or defined by hand).
It remembers the network's macro tokens and conversion postback, attaches to spin links,
builds the exact campaign URL to paste into the network, fires that network's own
postback only for clicks that came through it, and shows up in Reports by source and
by the zone / placement / site the macro carried.

- data/traffic-sources.json: catalog of 29 networks (BeMob template harvest), un-ignored
  via data/* + !data/traffic-sources.json; loader tolerates missing fields, null costModel,
  {{slot}} labels with spaces and parentheses, optional slots, unknown single-brace macros
- sources.js: DATA_DIR/sources.json model, 30 per account, 20 params, key allow-list,
  postbacks.validateUrl on the filled postback; list/create/update/get/urlFor/test
- rotator.js: update() takes sourceId (owner-checked), pub() exposes it, hits and conversions
  are stamped with the source at click time (sr), wider query allow-list (cost, creative,
  site, banner, keyword, geo, os, browser, device, carrier, format, external_id, visitor_id),
  summary() adds sources[] and placements[], sourceCounts(), detachSource()
- postbacks.js: fire() delivers the matching source's postback after the manual ones through
  the same deliver() (guards, retry, rate cap, auto-disable); log rows carry source; convertFor,
  inbound and the page lead path pass sourceId; fill/deliver/logForSource exported
- routes (GET and POST): /api/sources/catalog, /api/my/sources, /api/my/sources/<id>,
  /api/my/sources/<id>/url; /sources screen
- /sources Control Room screen (list + Campaign URL / Postback / Settings tabs, two-step
  New source dialog); Links share kit gets a source select and a "Campaign URL for <network>"
  first row; Reports gets Traffic sources and Placements; rail entry; chatbot canned answer,
  FACTS line and KNOWLEDGE_DATE 2026-10-12
- cr.css: phone rail icons only at 34px so ten entries fit; cache tags bumped to 20261012a

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-12 11:16:24 -05:00

130 lines
9.7 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="robots" content="noindex, nofollow">
<title>Traffic sources · LinkSpin</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@600;700&family=Manrope:wght@400;500;700&family=JetBrains+Mono:wght@500;700&display=swap">
<link rel="stylesheet" href="/assets/cr.css?v=20261012a">
<style>
.ws{display:grid;grid-template-columns:320px minmax(0,1fr);min-height:calc(100vh - 94px)}
.list{border-right:1px solid var(--line);display:flex;flex-direction:column;min-height:0;background:rgba(255,255,255,.55)}
.list .hd{display:flex;justify-content:space-between;align-items:center;padding:12px 16px;border-bottom:1px solid var(--line)}
.list .hd h2{font-family:var(--display);font-size:20px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;margin:0}
.list .flt{padding:8px 16px;border-bottom:1px solid var(--line)}
.list .items{overflow:auto}
.item{display:grid;grid-template-columns:minmax(0,1fr) 72px;gap:8px;padding:11px 16px;border-bottom:1px solid var(--line);border-left:3px solid transparent;cursor:pointer}
.item:hover{background:rgba(31,111,235,.05)} .item.on{background:var(--panel);border-left-color:var(--sig)}
.item .nm{font-weight:700;display:flex;gap:8px;align-items:center;flex-wrap:wrap} .item .cd{font-family:var(--mono);font-size:11px;color:var(--muted)}
.item .rt{display:grid;justify-items:end;gap:3px} .item .rt .n{font-family:var(--mono)}
.detail{display:flex;flex-direction:column;min-width:0}
.dhead{display:flex;align-items:center;gap:14px;padding:12px 24px;border-bottom:1px solid var(--line);background:var(--panel);flex-wrap:wrap}
.dhead h2{font-family:var(--display);font-size:24px;font-weight:700;letter-spacing:.02em;margin:0}
.dbody{padding:16px 24px;display:grid;gap:14px}
.dbody .tiles{grid-template-columns:repeat(auto-fit,minmax(128px,1fr))}
.empty{padding:40px 24px;color:var(--muted);text-align:center;display:grid;gap:10px;justify-items:center}
.empty .lead{max-width:520px}
.urlbox{display:grid;gap:10px;align-content:start}
.urlbox .code{display:block;font-size:12px;line-height:1.6;padding:10px 12px}
.pick{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:10px;align-items:end}
.prm .hd,.prm .rw{grid-template-columns:120px minmax(0,1fr) minmax(0,1fr)}
.pe .hd,.pe .rw{grid-template-columns:150px minmax(0,1.3fr) minmax(0,1fr) 40px}
.pe select.field{width:auto;min-width:130px}
.log .hd,.log .rw{grid-template-columns:150px 90px minmax(0,1fr) 110px 50px}
.chips .chip{user-select:none}
.form{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.form .full{grid-column:1 / -1}
.two{display:grid;grid-template-columns:minmax(0,1fr) 340px;gap:16px}
.catf{margin:4px 0 8px}
.catlist{max-height:46vh;overflow:auto;border:1px solid var(--line);border-radius:8px}
.cat{display:flex;justify-content:space-between;align-items:center;gap:10px;padding:9px 12px;border-bottom:1px solid var(--line);cursor:pointer}
.cat:last-child{border-bottom:0} .cat:hover{background:rgba(31,111,235,.05)} .cat b{display:block} .cat .site{font-family:var(--mono);font-size:11px;color:var(--muted)}
.cat .tags{display:flex;gap:4px;flex-wrap:wrap;justify-content:flex-end}
.prev{background:var(--panel-2);border:1px solid var(--line);border-radius:8px;padding:10px 12px;display:grid;gap:6px;font-size:12px}
.prev .mono{font-size:11px;overflow-wrap:anywhere}
.prev dl{display:grid;grid-template-columns:auto minmax(0,1fr);gap:3px 10px;margin:0} .prev dt{font-family:var(--mono);font-size:11px;color:var(--ink-2)} .prev dd{margin:0;font-family:var(--mono);font-size:11px;overflow-wrap:anywhere}
@media (max-width:900px){.two{grid-template-columns:1fr}.form{grid-template-columns:1fr}.prm .hd,.log .hd,.pe .hd{display:none}.prm .rw{grid-template-columns:1fr}.log .rw{grid-template-columns:1fr 1fr}.pe .rw{grid-template-columns:1fr 1fr}}
@media (max-width:760px){.ws{grid-template-columns:minmax(0,1fr)}.tabs{flex-wrap:wrap}.list{border-right:0;border-bottom:1px solid var(--line);max-height:44vh}.ws.focus .list{display:none}.ws:not(.focus) .detail{display:none}
.dhead{padding:12px 16px}.dbody{padding:12px 16px}.pick{grid-template-columns:1fr}.tiles{grid-template-columns:repeat(2,minmax(0,1fr))}}
</style>
</head>
<body>
<div id="page">
<div class="ws" id="ws">
<div class="list">
<div class="hd"><h2 id="listCount">Sources</h2><span class="muted mono">30 days</span></div>
<div class="flt"><input class="field" id="filter" type="search" placeholder="Filter sources" aria-label="Filter sources"></div>
<div class="items" id="items"></div>
</div>
<div class="detail" id="detail">
<div class="empty" id="noSel">
<div class="h-disp" style="font-size:18px">No traffic sources yet</div>
<div class="muted lead">A source remembers a network's macros and postback so every link you point at it is tracked and the network learns what converts.</div>
<button class="btn pri" type="button" id="newBtn2">+ New source</button>
</div>
<div id="sel" hidden>
<div class="dhead">
<button class="btn sm" type="button" id="backBtn" hidden>&larr; Sources</button>
<h2 id="dName">Source</h2>
<span class="mono muted" id="dNet"></span>
<span class="mono" id="dOn"></span>
<span class="grow"></span>
<button class="btn sm" type="button" id="togBtn">Disable</button>
<button class="btn sm danger" type="button" id="delBtn">Delete</button>
</div>
<div class="dbody">
<div class="tiles" id="tiles"></div>
<div class="tabs" id="tabs">
<button type="button" class="on" data-tab="url">Campaign URL</button>
<button type="button" data-tab="pb">Postback</button>
<button type="button" data-tab="settings">Settings</button>
</div>
<div id="tab-url">
<div class="two">
<div class="panel urlbox">
<h2>Campaign URL</h2>
<div class="pick"><label class="lbl">Which of your links<select class="field" id="urlRot"></select></label><button class="btn pri sm" type="button" id="urlCopy">Copy URL</button></div>
<div class="code" id="urlOut">pick a link</div>
<div class="muted" id="urlNote"></div>
</div>
<div class="panel"><h2>Params on the link</h2><div class="tbl prm"><div class="hd"><span>LinkSpin key</span><span>Network macro</span><span>Meaning</span></div><div id="prmRows"></div></div><div class="muted" style="font-size:11.5px">The network replaces each macro when it sends the click. LinkSpin keeps the values with the click and shows them under Reports and the link's Sources tab.</div></div>
</div>
</div>
<div id="tab-pb" hidden>
<div style="display:grid;gap:16px">
<div class="panel urlbox">
<h2>Postback to the network</h2>
<div class="muted">Fires server to server when a click that came from this source converts. LinkSpin fills <span class="mono">{clickid}</span> with the id the network sent and <span class="mono">{payout}</span> with the value.</div>
<div class="code" id="pbUrl">none set</div>
<div><div class="sec" style="margin-bottom:6px">Fires on</div><div class="chips" id="pbEvents"></div></div>
<div style="display:flex;gap:8px;align-items:center;flex-wrap:wrap"><button class="btn sm" type="button" id="pbTest">Send a test</button><span class="mono muted" id="pbStatus" style="font-size:11px"></span></div>
</div>
<div class="panel"><h2>Recent deliveries</h2><div class="tbl log"><div class="hd"><span>When</span><span>Event</span><span>URL</span><span>Result</span><span class="r">ms</span></div><div id="logRows"></div></div></div>
</div>
</div>
<div id="tab-settings" hidden>
<div class="panel">
<h2>Settings</h2>
<div class="form">
<label class="lbl">Name<input class="field" id="sName" type="text" maxlength="60"></label>
<label class="lbl">Network site<input class="field mono" id="sSite" type="text" maxlength="80" placeholder="network.com"></label>
<label class="lbl">Cost model<input class="field mono" id="sCost" type="text" maxlength="20" placeholder="CPC, CPM, CPV"></label>
<label class="lbl">Postback method<select class="field" id="sMethod"><option value="GET">GET</option><option value="POST">POST</option></select></label>
<label class="lbl full">Postback URL, with {clickid} and {payout} where the network expects them (leave empty for URL tagging and reports only)<input class="field mono" id="sPb" type="text" placeholder="https://network.example/postback?cid={clickid}&payout={payout}"></label>
</div>
<div class="sec">Params</div>
<div class="tbl pe"><div class="hd"><span>LinkSpin key</span><span>Network macro</span><span>Label</span><span></span></div><div id="peRows"></div><div class="ft">clickid is the network's click id; cost is what the click cost; the rest tag the click for reports. Tokens are pasted exactly as the network expands them.</div></div>
<div style="display:flex;gap:8px;flex-wrap:wrap;align-items:center"><button class="btn sm" type="button" id="peAdd">+ Add a param</button><span class="grow"></span><button class="btn pri" type="button" id="sSave">Save settings</button></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="/assets/cr-shell.js?v=20261012a"></script>
<script src="/assets/sources-screen.js?v=20261012a"></script>
</body>
</html>