Conversion tracking card: goal rows showed 30 (the window length) instead of the goal's conversions
LinkSpin's partnerSummary returns conv = the count and convDays = the window in days; my.js preferred convDays, so every goal read "30" under Conversions (30 days). Now shows g.conv. Also: a goal without a default value (LinkSpin stores 0) no longer adds &value=0 to its snippets or shows 0 as its default. QA mock now matches the real contract (convDays = 30) and asserts the row counts (6, 1). my.js ?v=20261024ct. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+3
-3
@@ -1075,7 +1075,7 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
||||
function convSnips(host, g) {
|
||||
const h = 'https://' + String(host || 'linkspin.app').replace(/^https?:\/\//, '').replace(/\/+$/, '');
|
||||
const px = encodeURIComponent(g.px), goal = encodeURIComponent(g.name);
|
||||
const val = g.value != null && g.value !== '' ? '&value=' + encodeURIComponent(g.value) : '';
|
||||
const val = Number(g.value) > 0 ? '&value=' + encodeURIComponent(g.value) : ''; // a goal with no default value (LinkSpin stores 0) adds nothing
|
||||
return {
|
||||
landing: '<script async src="' + h + '/t.js?px=' + px + '"></' + 'script>',
|
||||
img: '<img src="' + h + '/cv.gif?px=' + px + '&goal=' + goal + val + '" width="1" height="1" alt="" style="display:none">',
|
||||
@@ -1115,9 +1115,9 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
||||
const when = ts => ts ? new Date(ts).toLocaleString([], { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) : 'never';
|
||||
list.innerHTML = '<div class="tablewrap"><table class="camp-table"><thead><tr><th>Goal</th><th class="num">Default value</th><th>Pixel id</th><th class="num">Conversions (30 days)</th><th>Last test</th><th></th></tr></thead><tbody>'
|
||||
+ goals.map(g => '<tr' + (g.px === convSel ? ' style="background:rgba(120,160,255,.08)"' : '') + '><td data-l="Goal"><b>' + esc(g.name) + '</b></td>'
|
||||
+ '<td class="num" data-l="Default value">' + (g.value != null && g.value !== '' ? esc(g.value) : '<span class="muted">none</span>') + '</td>'
|
||||
+ '<td class="num" data-l="Default value">' + (Number(g.value) > 0 ? esc(g.value) : '<span class="muted">none</span>') + '</td>'
|
||||
+ '<td data-l="Pixel id" class="mono small">' + esc(g.px) + '</td>'
|
||||
+ '<td class="num" data-l="Conversions (30 days)">' + Number(g.convDays != null ? g.convDays : g.conv || 0).toLocaleString() + (g.lastAt ? '<div class="muted small">last ' + when(g.lastAt) + '</div>' : '') + '</td>'
|
||||
+ '<td class="num" data-l="Conversions (30 days)">' + Number(g.conv || 0).toLocaleString() + (g.lastAt ? '<div class="muted small">last ' + when(g.lastAt) + '</div>' : '') + '</td>'
|
||||
+ '<td data-l="Last test" class="small">' + when(g.lastTest) + '</td>'
|
||||
+ '<td class="act"><button class="btn small sec" type="button" data-convpick="' + esc(g.px) + '">Snippets</button> <button class="btn small sec" type="button" data-convtest="' + esc(g.px) + '">Send a test conversion</button> <button class="btn small quiet" type="button" data-convdel="' + esc(g.px) + '" data-convname="' + esc(g.name) + '">Remove</button></td></tr>').join('')
|
||||
+ '</tbody></table></div>';
|
||||
|
||||
+1
-1
@@ -1223,7 +1223,7 @@
|
||||
<script src="/assets/wallet.js?v=20260911a"></script>
|
||||
<script src="/assets/promo.js?v=20261016p"></script>
|
||||
<script src="/assets/support.js?v=20261016a"></script>
|
||||
<script src="/assets/my.js?v=20261024b3"></script>
|
||||
<script src="/assets/my.js?v=20261024ct"></script>
|
||||
<script src="/assets/fuel.js?v=20261024rg"></script>
|
||||
<script src="/assets/engine-room.js?v=20261024rg"></script>
|
||||
<script src="/assets/chat.js?v=20261016n"></script>
|
||||
|
||||
@@ -43,7 +43,7 @@ fs.writeFileSync(path.join(DATA, 'campaigns.json'), JSON.stringify({ v: 1, nextI
|
||||
|
||||
// ---- mock LinkSpin ----
|
||||
const PX1 = 'px0123456789', PX2 = 'pxabcdef0123';
|
||||
const mock = { clicks: new Map(), badSig: 0, calls: [], down: false, goals: { [A1]: [{ px: PX1, name: 'subscriber', value: null, created: now - 86400000, conv: 6, convDays: 6, lastAt: now - 3600000, lastTest: null }, { px: PX2, name: 'sale', value: 19.95, created: now - 86400000, conv: 1, convDays: 1, lastAt: now - 7200000, lastTest: null }] } };
|
||||
const mock = { clicks: new Map(), badSig: 0, calls: [], down: false, goals: { [A1]: [{ px: PX1, name: 'subscriber', value: null, created: now - 86400000, conv: 6, convDays: 30, lastAt: now - 3600000, lastTest: null }, { px: PX2, name: 'sale', value: 19.95, created: now - 86400000, conv: 1, convDays: 30, lastAt: now - 7200000, lastTest: null }] } };
|
||||
const verify = (ts, sig, raw) => { if (!ts || !sig || Math.abs(Date.now() - Number(ts)) > 300000) return false; const want = crypto.createHmac('sha256', SECRET).update(ts + '\n' + raw).digest('hex'); return want.length === String(sig).length && crypto.timingSafeEqual(Buffer.from(want), Buffer.from(String(sig))); };
|
||||
const send = (res, code, obj) => { res.writeHead(code, { 'Content-Type': 'application/json' }); res.end(JSON.stringify(obj)); };
|
||||
function mockHandler(req, res) {
|
||||
@@ -57,7 +57,7 @@ function mockHandler(req, res) {
|
||||
mock.calls.push(b); const email = String(b.email || '');
|
||||
const goals = mock.goals[email] || (mock.goals[email] = []);
|
||||
if (b.op === 'summary') return send(res, 200, { ok: true, goals, byCampaign: email === A1 ? { 1: { clicks: 9, conv: { [PX1]: 4, [PX2]: 1 }, value: { [PX2]: 19.95 } }, 2: { clicks: 3, conv: {} } } : {}, methods: { url: 2, stored: 2, cookie: 1, soft: 1 }, host: 'linkspin.app' });
|
||||
if (b.op === 'create') { const g = { px: 'px' + crypto.randomBytes(5).toString('hex'), name: b.name, value: b.value == null ? null : b.value, created: Date.now(), conv: 0, convDays: 0, lastAt: null, lastTest: null }; goals.push(g); return send(res, 200, { ok: true, goal: g }); }
|
||||
if (b.op === 'create') { const g = { px: 'px' + crypto.randomBytes(5).toString('hex'), name: b.name, value: b.value == null ? null : b.value, created: Date.now(), conv: 0, convDays: 30, lastAt: null, lastTest: null }; goals.push(g); return send(res, 200, { ok: true, goal: g }); }
|
||||
if (b.op === 'remove') { const i = goals.findIndex(g => g.px === b.px); if (i < 0) return send(res, 404, { error: 'No such goal.' }); goals.splice(i, 1); return send(res, 200, { ok: true }); }
|
||||
if (b.op === 'test') { const g = goals.find(x => x.px === b.px); if (!g) return send(res, 404, { error: 'No such goal.' }); g.lastTest = Date.now(); return send(res, 200, { ok: true, at: g.lastTest }); }
|
||||
return send(res, 400, { error: 'unknown op' });
|
||||
@@ -164,7 +164,7 @@ try {
|
||||
line1: (document.querySelector('[data-convcamp="1"]') || {}).textContent || '', line1Hidden: !!(document.querySelector('[data-convcamp="1"]') || {}).hidden,
|
||||
line5Hidden: (document.querySelector('[data-convcamp="5"]') || { hidden: true }).hidden,
|
||||
card: !document.getElementById('convCard').hidden, status: document.getElementById('convStatus').textContent,
|
||||
goals: document.querySelectorAll('#convGoals tbody tr').length, landing: (document.getElementById('convLanding') || {}).value || '', img: (document.getElementById('convImg') || {}).value || '',
|
||||
goals: document.querySelectorAll('#convGoals tbody tr').length, convCells: [...document.querySelectorAll('#convGoals td[data-l="Conversions (30 days)"]')].map(td => (td.firstChild && td.firstChild.textContent || '').trim()), landing: (document.getElementById('convLanding') || {}).value || '', img: (document.getElementById('convImg') || {}).value || '',
|
||||
js: (document.getElementById('convJs') || {}).value || '', tip: document.getElementById('convCard').textContent }));
|
||||
await page.screenshot({ path: path.join(OUT, shot), fullPage: true }).catch(() => {});
|
||||
await ctx.close(); return { st, errs };
|
||||
@@ -173,6 +173,7 @@ try {
|
||||
ok(p1.st.rows >= 4 && p1.st.card, 'Campaigns pane loads with the Conversion tracking card', JSON.stringify(p1.st).slice(0, 200));
|
||||
ok(!p1.st.line1Hidden && /subscriber 4 \(75 credits each\)/.test(p1.st.line1) && /sale 1 \(300 credits each\)/.test(p1.st.line1), 'campaign row shows goals + cost per goal (300 / 4 = 75 credits)', p1.st.line1);
|
||||
ok(!/\$/.test(p1.st.line1), 'cost per goal is in credits, never dollars');
|
||||
ok(JSON.stringify(p1.st.convCells) === '["6","1"]', 'goal rows show the conversion count, not the 30-day window (convDays is the window length)', JSON.stringify(p1.st.convCells));
|
||||
ok(p1.st.goals === 2 && p1.st.landing === '<script async src="https://linkspin.app/t.js?px=' + PX1 + '"></script>', 'goal list + landing tag snippet', p1.st.landing);
|
||||
ok(p1.st.img === '<img src="https://linkspin.app/cv.gif?px=' + PX1 + '&goal=subscriber" width="1" height="1" alt="" style="display:none">' && p1.st.js === '<script async src="https://linkspin.app/cv.js?px=' + PX1 + '&goal=subscriber"></script>', 'goal pixel image + JS snippets match the contract', p1.st.img + ' | ' + p1.st.js);
|
||||
ok(/Thank You Page: custom page/.test(p1.st.tip) && /Thank-you page: custom URL/.test(p1.st.tip) && /24-hour match/.test(p1.st.tip), 'autoresponder advice + match legend present');
|
||||
|
||||
Reference in New Issue
Block a user