LinkSpin tracked links for text ads (Marty 2026-11-15): lstrack.js asks LinkSpin (POST LS_URL/api/partner/vab/links, net.v1 with NETWORK_SSO_SECRET, by network username) for a tracked link on the member's own LinkSpin account when they save their ad; /go/<ad> sends through it while it points at the ad's current link. "Track with LinkSpin" toggle on the ad form (default on), {clickid}/{placement} links not tracked, LinkSpin clicks on My page, counters in admin status. Fails soft (plain link) until LinkSpin ships the endpoint; a 2-minute sweep retries. Smoke 179/179 (17 new LinkSpin checks against a stand-in that starts down).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-11-15 06:20:32 -06:00
parent b71284e5c9
commit 4efc1239b0
18 changed files with 200 additions and 35 deletions
+15 -2
View File
@@ -24,6 +24,18 @@
const vlink = tx => '<a href="' + esc(ex) + '/tx/' + esc(tx) + '" target="_blank" rel="noopener">verify</a>';
const stat = (label, val, note, cls) => '<div class="stat' + (cls ? ' ' + cls : '') + '"><span>' + label + '</span><b>' + val + '</b>' + (note ? '<em>' + note + '</em>' : '') + '</div>';
let counted = false;
// LinkSpin tracking of the ad (server lstrack.js): the tracked link and its clicks as LinkSpin counts them, or why there is none
const lsLine = ls => {
if (!ls || !ls.on) return '';
const why = { off: 'Tracking is off for this ad: visitors go straight to your link.', macros: 'Your link has {clickid} or {placement} codes, so it goes out as it is (not through LinkSpin).',
pending: 'Your LinkSpin tracked link is being set up. Until then visitors go straight to your link.', 'no-username': 'Sign in through InstantAdPay or LinkSpin once to link your LinkSpin account.',
'no-account': 'No LinkSpin account was found for your network username yet. Visitors go straight to your link.' }[ls.state];
if (ls.state !== 'tracked') return '<p class="lsline small">' + esc(why || '') + '</p>';
const c = ls.clicks;
return '<p class="lsline small">Tracked with LinkSpin: <b>' + esc(ls.link.replace(/^https?:\/\//, '').replace(/\?.*$/, '')) + '</b>'
+ (c ? ' · ' + VAB.n(c.hits) + ' clicks in all, ' + VAB.n(c.hits30) + ' in 30 days (' + VAB.n(c.unique30) + ' unique)' : ' · clicks show in your LinkSpin Reports')
+ ' · <a href="https://linkspin.app/ads" target="_blank" rel="noopener">Open LinkSpin</a></p>';
};
async function load() {
const d = await VAB.getJSON('/api/my'); if (d.error) { VAB.status(d.error, 'err'); return; }
$('dash').hidden = false;
@@ -52,6 +64,7 @@
// my text ad: badges, preview, the form (folded behind "Edit ad" once the ad exists)
$('adBadges').innerHTML = a ? (a.status === 'live' ? '<span class="chip live">LIVE</span>' : '<span class="chip idle">' + esc(a.status.toUpperCase()) + '</span>') + (active.length ? ' <span class="chip gold">★ BOOSTED</span>' : '') : '';
$('adPrev').innerHTML = a ? '<div class="adprev' + (active.length ? ' star' : '') + '">' + (active.length ? '<span class="tag">★ BOOSTED</span>' : '') + '<b>' + esc(a.headline) + '</b><span>' + esc(a.line1) + '</span>' + (a.line2 ? '<span>' + esc(a.line2) + '</span>' : '') + '<a href="' + esc(a.link) + '" target="_blank" rel="noopener nofollow">' + esc(a.link.replace(/^https?:\/\//, '').slice(0, 60)) + '</a></div>'
+ lsLine(d.linkspin)
+ '<div class="row" style="margin-top:14px"><button type="button" class="btn-line" id="editAd">Edit ad</button>' + (d.page ? '<a class="btn-soft" href="' + esc(d.page) + '" target="_blank" rel="noopener">Preview my page</a>' : '') + '</div>' : '';
if (!d.netVerified) {
$('adNote').innerHTML = 'Text ads are free for network members. This wallet is not in the network yet: <a href="' + esc(d.joinUrl) + '" target="_blank" rel="noopener">join InstantAdPay free</a>, link this wallet there, then sign in here through InstantAdPay.';
@@ -59,7 +72,7 @@
} else {
$('adForm').hidden = !!a; $('adNote').hidden = !!a;
if ($('editAd')) $('editAd').onclick = () => { const h = !$('adForm').hidden; $('adForm').hidden = h; $('adNote').hidden = h; $('editAd').textContent = h ? 'Edit ad' : 'Close the editor'; if (!h) $('fHead').focus(); };
if (a) { $('adHead').textContent = 'My text ad'; $('fHead').value = a.headline; $('fL1').value = a.line1; $('fL2').value = a.line2 || ''; $('fLink').value = a.link; $('adSave').textContent = 'Save changes'; }
if (a) { $('adHead').textContent = 'My text ad'; $('fHead').value = a.headline; $('fL1').value = a.line1; $('fL2').value = a.line2 || ''; $('fLink').value = a.link; $('fTrack').checked = a.track !== false; $('adSave').textContent = 'Save changes'; }
if (!counted) { counter($('fHead'), $('cHead'), lim.headline); counter($('fL1'), $('cL1'), lim.line); counter($('fL2'), $('cL2'), lim.line); counted = true; }
else ['fHead', 'fL1', 'fL2'].forEach(id => $(id).dispatchEvent(new Event('input')));
}
@@ -92,7 +105,7 @@
}
$('adForm').addEventListener('submit', async e => {
e.preventDefault(); $('adSave').disabled = true; VAB.status('Checking your link...');
const r = await VAB.post('/api/my/ad', { headline: $('fHead').value, line1: $('fL1').value, line2: $('fL2').value, link: $('fLink').value });
const r = await VAB.post('/api/my/ad', { headline: $('fHead').value, line1: $('fL1').value, line2: $('fL2').value, link: $('fLink').value, track: $('fTrack').checked });
$('adSave').disabled = false;
if (r.error) return VAB.status(r.error, 'err');
VAB.status(r.created ? 'Posted. Your ad is live on your page and on your team\'s pages.' : 'Saved. Your ad shows the new text everywhere.', 'ok');