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:
+15
-2
@@ -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');
|
||||
|
||||
@@ -261,6 +261,8 @@ table.facts td{padding:12px 8px;border-bottom:1px solid var(--line2);overflow-wr
|
||||
label.f{display:flex;flex-direction:column;gap:6px;font:600 13px var(--body);color:var(--ink2)}
|
||||
.f input,.f textarea{background:#fff;border:2px solid var(--line);color:var(--ink);font:16px var(--body);padding:11px 12px;width:100%;border-radius:0}
|
||||
.f input:focus,.f textarea:focus{outline:none;border-color:var(--blue)}
|
||||
.chk{display:flex;gap:10px;align-items:flex-start;cursor:pointer}.chk input{width:20px;height:20px;margin:3px 0 0;flex:none;accent-color:var(--blue)}
|
||||
.lsline{margin:12px 0 0;padding:10px 12px;border:2px dashed var(--line);font-size:14px;overflow-wrap:anywhere}.lsline b{font-family:var(--mono,monospace)}
|
||||
.f .cnt{align-self:flex-end;font:12px var(--mono);color:var(--sub)}
|
||||
.form{display:flex;flex-direction:column;gap:14px;max-width:720px}
|
||||
.note{border-left:4px solid var(--blue);background:var(--card);padding:12px 16px;color:var(--ink2);overflow-wrap:anywhere}
|
||||
|
||||
Reference in New Issue
Block a user