Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7cadeaa2d9 | |||
| 42a1cce2f1 | |||
| ce977698b9 | |||
| 46bb7dd9dd |
@@ -79,6 +79,10 @@ const CANNED = [
|
|||||||
{ id: 'five-dollar-friday', title: 'Five Dollar Friday bonus', q: ['What is Five Dollar Friday?', 'What happens on Friday?'], tags: ['five dollar friday', 'bonus credits', 'promotion'],
|
{ id: 'five-dollar-friday', title: 'Five Dollar Friday bonus', q: ['What is Five Dollar Friday?', 'What happens on Friday?'], tags: ['five dollar friday', 'bonus credits', 'promotion'],
|
||||||
re: /(five dollar friday|5 dollar friday|\$5 friday|friday (bonus|promo|deal|special)|what happens on friday)/i,
|
re: /(five dollar friday|5 dollar friday|\$5 friday|friday (bonus|promo|deal|special)|what happens on friday)/i,
|
||||||
a: 'Five Dollar Friday: every Friday (Central time), any ad package from $5 up earns +20% bonus credits, added the moment the purchase settles and labelled in your credit log. The page instantadpay.com/friday shows whether it is live right now and the next date; add ?ref=yourusername to that address and anyone who joins from it is your referral. Every pack pays its sponsor line in the same on-chain transaction, so when the whole network buys on the same day every line gets paid at once. Since 2026-10-23 a $5+ Friday package also gives you a free 7-day Game Pass (once per Friday, all nine games); if that package is the one starting a pass you already ordered, it does not add a second week. Five Fridays in a row earn the Five Fridays badge. Buy under My account > Buy packages.' },
|
a: 'Five Dollar Friday: every Friday (Central time), any ad package from $5 up earns +20% bonus credits, added the moment the purchase settles and labelled in your credit log. The page instantadpay.com/friday shows whether it is live right now and the next date; add ?ref=yourusername to that address and anyone who joins from it is your referral. Every pack pays its sponsor line in the same on-chain transaction, so when the whole network buys on the same day every line gets paid at once. Since 2026-10-23 a $5+ Friday package also gives you a free 7-day Game Pass (once per Friday, all nine games); if that package is the one starting a pass you already ordered, it does not add a second week. Five Fridays in a row earn the Five Fridays badge. Buy under My account > Buy packages.' },
|
||||||
|
// 2026-10-23 conversion pixel (LinkSpin counts, IAP shows): Campaigns > Conversion tracking
|
||||||
|
{ id: 'conversion-tracking', title: 'Conversion tracking (goal pixel)', q: ['How do I track conversions?', 'Can I see which ad brought a sign-up or sale?', 'Where do I put the goal pixel?', 'What is the landing tag?'], tags: ['conversion tracking', 'goal pixel', 'landing tag', 'cost per goal', 'aweber', 'getresponse'],
|
||||||
|
re: /(conver(sion|t)s?.{0,20}(track|pixel|goal)|track(ing)?.{0,30}(conversions?|sign.?ups?|sales|subscribers|leads)|goal pixel|landing tag|tracking pixel|cost per (goal|lead|sale|sign.?up|conversion)|thank.?you page|lsclk)/i,
|
||||||
|
a: 'Conversion tracking shows which of your ads bring subscribers and sales, not just clicks. It lives in your dashboard under Campaigns > Conversion tracking (https://instantadpay.com/my#campaigns). Three steps: 1) add a goal, like subscriber or sale (a default value is optional); 2) put the landing tag on the page your ad points to; 3) put the goal pixel on your thank-you page. Every click on your ad carries a click id (lsclk=...), and LinkSpin, our sister site, matches each goal to the click: first by the click id still in the address, then the id the landing tag stored, then LinkSpin\'s cookie, and last a 24-hour match on the same connection and browser (the panel says how sure each kind is). Each goal counts once per click, only within 30 days of a real click on your ad, and each campaign shows its goals and cost per goal in credits. Using Aweber or GetResponse? Set the form\'s thank-you (success) page to a page on YOUR site that carries the goal pixel (Aweber: Thank You Page: custom page; GetResponse: Thank-you page: custom URL). If you cannot change it, the pixel can still count through the cookie or the 24-hour match, just less surely. The Send a test conversion button checks your pixel; tests and clicks on your own ads never count in your numbers.' },
|
||||||
// 2026-10-23 (Marty: "they need to pay for the slot now to get a place in line"): 6 member slots, then a prepaid line
|
// 2026-10-23 (Marty: "they need to pay for the slot now to get a place in line"): 6 member slots, then a prepaid line
|
||||||
{ id: 'login-ads', title: 'Login ads: slots and the paid line', q: ['How do login ads work?', 'All login ad slots are taken, what now?', 'Can I reserve a login ad slot?', 'Can I cancel my login ad reservation?'], tags: ['login ad', 'login slot', 'reserve', 'queue', 'line', 'refund'],
|
{ id: 'login-ads', title: 'Login ads: slots and the paid line', q: ['How do login ads work?', 'All login ad slots are taken, what now?', 'Can I reserve a login ad slot?', 'Can I cancel my login ad reservation?'], tags: ['login ad', 'login slot', 'reserve', 'queue', 'line', 'refund'],
|
||||||
re: /(log ?in.?ads?|sign.?in ads?|log ?in (ad )?(slots?|sponsor)|(reserve|reservation|queue|place in line|waiting list).{0,40}log ?in|log ?in.{0,40}(slots?|reserve|reservation|queue|place in line|waiting list)|reserve (a |the )?(next )?slot)/i,
|
re: /(log ?in.?ads?|sign.?in ads?|log ?in (ad )?(slots?|sponsor)|(reserve|reservation|queue|place in line|waiting list).{0,40}log ?in|log ?in.{0,40}(slots?|reserve|reservation|queue|place in line|waiting list)|reserve (a |the )?(next )?slot)/i,
|
||||||
@@ -212,6 +216,7 @@ ${passTiersFact()}- ROAD AGENT (LIVE 2026-10-15, https://roadagent.app): a night
|
|||||||
- HELP DESK (LIVE 2026-10-16): members open Help in the dashboard (/my#help) to send Marty a support ticket (pick a category, a subject, the message, up to 2 screenshots), see each ticket's status (Open, Waiting on you, Closed) and read and answer his replies; a badge shows when he has replied, and replies also arrive by email. Anyone signed out or locked out uses the public form at https://instantadpay.com/support (name, email, category, subject, message) and gets an email with the ticket number (like IAP-1042) and a private link to view and reply, no sign-in needed. support@instantadpay.com also reaches Marty. Replying to a closed ticket opens it again. In this chat, "Send this to support" turns the conversation into a ticket. Only Marty answers, so replies are not instant; never promise a response time.
|
- HELP DESK (LIVE 2026-10-16): members open Help in the dashboard (/my#help) to send Marty a support ticket (pick a category, a subject, the message, up to 2 screenshots), see each ticket's status (Open, Waiting on you, Closed) and read and answer his replies; a badge shows when he has replied, and replies also arrive by email. Anyone signed out or locked out uses the public form at https://instantadpay.com/support (name, email, category, subject, message) and gets an email with the ticket number (like IAP-1042) and a private link to view and reply, no sign-in needed. support@instantadpay.com also reaches Marty. Replying to a closed ticket opens it again. In this chat, "Send this to support" turns the conversation into a ticket. Only Marty answers, so replies are not instant; never promise a response time.
|
||||||
- PRESENTATION (2026-10-15): instantadpay.com/presentation is a public page (no sign-in) with the narrated InstantAdPay presentation, about six minutes, Marty's voice, captions in 6 languages (English, Italiano, Français, Español, Deutsch, Português) chosen with pills under the player. Sixteen parts: the platform, ad reach, the nine games that pay POL, the $20 split ($10 / $4 / $2 / $4 platform, same transaction), three rules, packages, the 2-then-5 unlock, pass-up, wide versus narrow ($800 vs $36, an illustration), Qualified Start, the Pipeline, LinkSpin (pre-launch Nov 1), one wallet across the network, the first week, and 'the target is five'. Share link: Members > Promo tools > 'Share the presentation' copies instantadpay.com/presentation?ref=<username>; ?ref sets the same 30-day sponsor cookie as the invite link, the page shows 'Shared with you by @name' with avatar and a Join button to /join/<username>. It is in the site menu as 'Presentation'. BUILD WIDE VIDEO: first card in Promo tools > Videos ('Build wide: watch the payments flow'), matched link ?v=wide.
|
- PRESENTATION (2026-10-15): instantadpay.com/presentation is a public page (no sign-in) with the narrated InstantAdPay presentation, about six minutes, Marty's voice, captions in 6 languages (English, Italiano, Français, Español, Deutsch, Português) chosen with pills under the player. Sixteen parts: the platform, ad reach, the nine games that pay POL, the $20 split ($10 / $4 / $2 / $4 platform, same transaction), three rules, packages, the 2-then-5 unlock, pass-up, wide versus narrow ($800 vs $36, an illustration), Qualified Start, the Pipeline, LinkSpin (pre-launch Nov 1), one wallet across the network, the first week, and 'the target is five'. Share link: Members > Promo tools > 'Share the presentation' copies instantadpay.com/presentation?ref=<username>; ?ref sets the same 30-day sponsor cookie as the invite link, the page shows 'Shared with you by @name' with avatar and a Join button to /join/<username>. It is in the site menu as 'Presentation'. BUILD WIDE VIDEO: first card in Promo tools > Videos ('Build wide: watch the payments flow'), matched link ?v=wide.
|
||||||
- WIRED WEDNESDAY: every Wednesday, Central time (midnight to midnight), any ad package of $20 or more (Activation and up; no $10 pack exists) earns +25% bonus credits wired into the buyer's balance the moment the purchase settles, purchased-grade (usable on every format incl. login ads), credit log label "Wired Wednesday". First one: Wednesday 2026-09-30. Page: instantadpay.com/wednesday. Credits buy ad delivery, never money.
|
- WIRED WEDNESDAY: every Wednesday, Central time (midnight to midnight), any ad package of $20 or more (Activation and up; no $10 pack exists) earns +25% bonus credits wired into the buyer's balance the moment the purchase settles, purchased-grade (usable on every format incl. login ads), credit log label "Wired Wednesday". First one: Wednesday 2026-09-30. Page: instantadpay.com/wednesday. Credits buy ad delivery, never money.
|
||||||
|
- CONVERSION TRACKING (LIVE 2026-10-23): Campaigns > Conversion tracking in /my#campaigns. Every click on a member's ad (through /api/ads/click) gets a click id added to the target address as lsclk=<id>; the advertiser adds a goal (name like subscriber or sale, optional default value), puts the LinkSpin landing tag (t.js) on the page the ad points to and the goal pixel (cv.gif image, or the cv.js script) on the thank-you page. LinkSpin (sister site, same email) counts the goals; matching order: click id in the address (url, surest), the id the landing tag stored (stored), LinkSpin's cookie (cookie), a 24-hour match on hashed IP plus browser (soft, least sure). Each goal counts once per click, only within 30 days of a real click, only for the pixel owner's own ads; the advertiser's own clicks and the Send a test conversion button count as tests, never in the numbers. Each campaign row shows goals and cost per goal in credits (campaign credits spent divided by goals; never quote it in dollars). Autoresponder tip: set the Aweber or GetResponse thank-you (success) page to a page on the member's own site carrying the goal pixel (Aweber: Thank You Page: custom page; GetResponse: Thank-you page: custom URL); if they cannot, the cookie or the 24-hour match can still count it, less surely. Privacy: the click id is random and nothing personal is sent.
|
||||||
- FIVE DOLLAR FRIDAY: every Friday, Central time, any ad package of $5 or more earns +20% bonus credits, credited the moment the purchase settles (credit log shows the label). First one: Friday 2026-09-25. Since 2026-10-23 the same $5+ Friday package also gives a FREE 7-day Game Pass automatically (once per member per Friday; not a second week when that package itself fulfils a pass order; the Game Pass badge posts the first time). Five Fridays in a row = the Five Fridays badge. The point: the whole network buys on the same day, every pack pays its sponsor line in the same transaction, so every line gets paid at once. No income promises.
|
- FIVE DOLLAR FRIDAY: every Friday, Central time, any ad package of $5 or more earns +20% bonus credits, credited the moment the purchase settles (credit log shows the label). First one: Friday 2026-09-25. Since 2026-10-23 the same $5+ Friday package also gives a FREE 7-day Game Pass automatically (once per member per Friday; not a second week when that package itself fulfils a pass order; the Game Pass badge posts the first time). Five Fridays in a row = the Five Fridays badge. The point: the whole network buys on the same day, every pack pays its sponsor line in the same transaction, so every line gets paid at once. No income promises.
|
||||||
- SESSIONS LAST 4 HOURS. Sign-ins expire after 4 hours and the member signs in again with a fresh 6-digit code. This is intentional and we say so plainly: it keeps resources optimised, and the login sponsor ad shown on the way back in is part of what pays for the free side. Nothing is lost on expiry - credits, line and account are untouched. Never describe it as a bug, an error, or something to report.
|
- SESSIONS LAST 4 HOURS. Sign-ins expire after 4 hours and the member signs in again with a fresh 6-digit code. This is intentional and we say so plainly: it keeps resources optimised, and the login sponsor ad shown on the way back in is part of what pays for the free side. Nothing is lost on expiry - credits, line and account are untouched. Never describe it as a bug, an error, or something to report.
|
||||||
- Free to join with email only (6-digit code sign-in, no passwords). Wallet appears only at purchase or payout activation. Every new member gets a small welcome batch of ad credits — unlocked by the WELCOME TOUR on first sign-in: they visit their upline's line-banner sites (up to 3, 10 seconds each — the same 3 levels the contract pays), then claim the credits. Members with no upline banners get the credits instantly.
|
- Free to join with email only (6-digit code sign-in, no passwords). Wallet appears only at purchase or payout activation. Every new member gets a small welcome batch of ad credits — unlocked by the WELCOME TOUR on first sign-in: they visit their upline's line-banner sites (up to 3, 10 seconds each — the same 3 levels the contract pays), then claim the credits. Members with no upline banners get the credits instantly.
|
||||||
|
|||||||
+5
-1
@@ -67,6 +67,10 @@ const FAQ = [
|
|||||||
{ id: 'f-recovery-phrase', title: 'Recovery phrase and scam safety', source: 'faq',
|
{ id: 'f-recovery-phrase', title: 'Recovery phrase and scam safety', source: 'faq',
|
||||||
questions: ['Someone asked for my recovery phrase', 'Will support ever ask for my private key?', 'Someone messaged me asking for money'],
|
questions: ['Someone asked for my recovery phrase', 'Will support ever ask for my private key?', 'Someone messaged me asking for money'],
|
||||||
tags: ['recovery phrase', 'private key', 'scam', 'security'],
|
tags: ['recovery phrase', 'private key', 'scam', 'security'],
|
||||||
answer: 'Never share your recovery phrase or private key with anyone. Nobody from InstantAdPay will ever ask for them, and nobody from InstantAdPay will message you first asking for money or wallet access. If someone does, do not reply, and tell support through Help at https://instantadpay.com/my#help.' }
|
answer: 'Never share your recovery phrase or private key with anyone. Nobody from InstantAdPay will ever ask for them, and nobody from InstantAdPay will message you first asking for money or wallet access. If someone does, do not reply, and tell support through Help at https://instantadpay.com/my#help.' },
|
||||||
|
{ id: 'f-conv-thankyou', title: 'Conversion tracking with Aweber or GetResponse', source: 'faq',
|
||||||
|
questions: ['How do I track sign-ups from my ads?', 'Where do I put the goal pixel?', 'How do I use conversion tracking with Aweber?', 'How do I use conversion tracking with GetResponse?', 'My autoresponder thank-you page is not mine, can I still track?'],
|
||||||
|
tags: ['conversion tracking', 'goal pixel', 'landing tag', 'aweber', 'getresponse', 'thank you page', 'autoresponder'],
|
||||||
|
answer: 'Open Campaigns > Conversion tracking, add a goal (like subscriber), then copy its two snippets: the landing tag goes on the page your ad points to, the goal pixel on your thank-you page. Set your autoresponder\'s thank-you (success) page to a page on YOUR site that carries the goal pixel. Aweber: in your sign-up form settings, choose \'Thank You Page: custom page\' and paste your page\'s address. GetResponse: in the form or landing page settings, pick \'Thank-you page: custom URL\' and paste your page\'s address. If you cannot change it, the pixel can still count through the cookie or the 24-hour match, just less surely. Use Send a test conversion to check the pixel; tests never count in your numbers.' },
|
||||||
];
|
];
|
||||||
module.exports = { FAQ };
|
module.exports = { FAQ };
|
||||||
|
|||||||
@@ -0,0 +1,154 @@
|
|||||||
|
// Conversion tracking, InstantAdPay half (Marty approved 2026-10-23). LinkSpin owns goals and conversions;
|
||||||
|
// this module does three things:
|
||||||
|
// record(click) every click through /api/ads/click/:id gets an id ('i' + 11 hex) that rides on the target URL as
|
||||||
|
// ?lsclk=<id>, and the click row is stored here (MySQL ad_clicks, or a capped JSON file locally)
|
||||||
|
// flush loop unpushed rows go to LinkSpin POST /api/partner/clicks every ~3 s, 500 per request, signed exactly
|
||||||
|
// like lssync.js (HMAC-SHA256 of ts + newline + raw body, LS_SYNC_SECRET). A row is marked pushed only
|
||||||
|
// after LinkSpin answers ok, so a failure keeps it for the next try (backoff up to 5 minutes).
|
||||||
|
// LinkSpin upserts by id, so two app copies pushing the same rows during a deploy is harmless.
|
||||||
|
// conv(email,..) the member's goals and summary through POST /api/partner/conv (op summary/create/update/remove/test),
|
||||||
|
// summary cached 60 s per email.
|
||||||
|
// No LS_SYNC_SECRET (or shorter than 32 chars): clicks still get ids and rows, nothing is sent.
|
||||||
|
// The raw IP is never stored: only the soft key 's:' + sha256(ip + '|' + ua) first 20 hex, same on both sites.
|
||||||
|
'use strict';
|
||||||
|
const crypto = require('crypto');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
let R = null, timer = null, flushing = false, fails = 0, nextAt = 0, jstate = null, saveT = null;
|
||||||
|
const stats = { pushed: 0, lastAt: null, lastError: null, errors: 0 };
|
||||||
|
const cache = new Map(); // email -> { at, data }
|
||||||
|
const URL_ = () => String(process.env.LS_URL || 'https://linkspin.app').replace(/\/+$/, '');
|
||||||
|
const SECRET = () => String(process.env.LS_SYNC_SECRET || '').trim();
|
||||||
|
const on = () => SECRET().length >= 32;
|
||||||
|
const useDb = () => !!(R && R.db && R.db.enabled());
|
||||||
|
const JCAP = 5000;
|
||||||
|
const JFILE = () => path.join(R.dataDir, 'adclicks.json');
|
||||||
|
|
||||||
|
function init(deps) {
|
||||||
|
R = deps;
|
||||||
|
if (useDb()) ensureTable().catch(e => console.error('lsconv table', e.message));
|
||||||
|
if (!timer) { timer = setInterval(() => { flush().catch(() => {}); }, 3000); if (timer.unref) timer.unref(); }
|
||||||
|
setInterval(() => prune().catch(() => {}), 6 * 3600 * 1000).unref();
|
||||||
|
}
|
||||||
|
// column names checked against MySQL 8 reserved words (none of id, campaign_id, owner_email, cname, ctype, sk, country,
|
||||||
|
// device, placement, target, spent, is_self, ts, pushed is reserved)
|
||||||
|
async function ensureTable() {
|
||||||
|
await R.db.q(`CREATE TABLE IF NOT EXISTS ad_clicks (
|
||||||
|
id VARCHAR(16) PRIMARY KEY,
|
||||||
|
campaign_id INT NOT NULL,
|
||||||
|
owner_email VARCHAR(190) NOT NULL,
|
||||||
|
cname VARCHAR(80) NULL,
|
||||||
|
ctype VARCHAR(12) NULL,
|
||||||
|
sk VARCHAR(24) NULL,
|
||||||
|
country VARCHAR(4) NULL,
|
||||||
|
device VARCHAR(8) NULL,
|
||||||
|
placement VARCHAR(80) NULL,
|
||||||
|
target VARCHAR(500) NULL,
|
||||||
|
spent INT NOT NULL DEFAULT 0,
|
||||||
|
is_self TINYINT NOT NULL DEFAULT 0,
|
||||||
|
ts BIGINT NOT NULL,
|
||||||
|
pushed TINYINT NOT NULL DEFAULT 0,
|
||||||
|
INDEX (pushed, ts),
|
||||||
|
INDEX (campaign_id)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- helpers (pure) ----
|
||||||
|
const newId = () => 'i' + crypto.randomBytes(6).toString('hex').slice(0, 11);
|
||||||
|
const softKey = (ip, ua) => 's:' + crypto.createHash('sha256').update(String(ip || '') + '|' + String(ua || '')).digest('hex').slice(0, 20);
|
||||||
|
const deviceOf = ua => /Mobi|Android|iPhone|iPad|iPod|Opera Mini|IEMobile/i.test(String(ua || '')) ? 'mobile' : 'desktop';
|
||||||
|
function placementOf(referer) {
|
||||||
|
try { const u = new URL(String(referer || '')); if (!/^https?:$/.test(u.protocol)) return null; return (u.host.replace(/^www\./, '') + u.pathname.replace(/\/+$/, '')).replace(/[^\w.\-\/:]/g, '').slice(0, 80) || null; }
|
||||||
|
catch (e) { return null; }
|
||||||
|
}
|
||||||
|
// append lsclk=<id> without touching anything already in the URL (string insert keeps the original encoding of every
|
||||||
|
// existing param); an existing lsclk is never replaced; a URL that does not parse goes out unchanged
|
||||||
|
function withClickId(target, id) {
|
||||||
|
const t = String(target || '');
|
||||||
|
let u; try { u = new URL(t); } catch (e) { return t; }
|
||||||
|
if (!/^https?:$/.test(u.protocol) || u.searchParams.has('lsclk')) return t;
|
||||||
|
const hashAt = t.indexOf('#'); const base = hashAt >= 0 ? t.slice(0, hashAt) : t; const hash = hashAt >= 0 ? t.slice(hashAt) : '';
|
||||||
|
const sep = base.includes('?') ? (/[?&]$/.test(base) ? '' : '&') : '?';
|
||||||
|
return base + sep + 'lsclk=' + encodeURIComponent(id) + hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- storage ----
|
||||||
|
function jload() { if (jstate) return jstate; try { jstate = JSON.parse(fs.readFileSync(JFILE(), 'utf8')); if (!Array.isArray(jstate.rows)) throw 0; } catch (e) { jstate = { rows: [] }; } return jstate; }
|
||||||
|
function jsave() { if (saveT) return; saveT = setTimeout(() => { saveT = null; try { fs.writeFileSync(JFILE(), JSON.stringify(jload())); } catch (e) {} }, 500); }
|
||||||
|
function jcap() { const st = jload(); if (st.rows.length <= JCAP) return; let drop = st.rows.length - JCAP; st.rows = st.rows.filter(r => !(drop > 0 && r.pushed && drop--)); if (st.rows.length > JCAP) st.rows = st.rows.slice(-JCAP); }
|
||||||
|
|
||||||
|
// c = the campaign (ads.campaignById shape); returns the stored row
|
||||||
|
async function record(c, req, opts) {
|
||||||
|
const o = opts || {};
|
||||||
|
const ip = o.ip || String(req.headers['x-forwarded-for'] || req.socket.remoteAddress || '').split(',')[0].trim();
|
||||||
|
const ua = String(req.headers['user-agent'] || '');
|
||||||
|
const row = { id: newId(), camp: Number(c.id), cname: String(c.name || c.title || '').slice(0, 80) || null, type: String(c.type || '').slice(0, 12) || null,
|
||||||
|
owner: String(c.owner || '').toLowerCase(), ts: Date.now(), sk: softKey(ip, ua), c: o.country ? String(o.country).slice(0, 4) : null, dv: deviceOf(ua),
|
||||||
|
pl: placementOf(req.headers.referer), target: String(o.target || c.targetUrl || '').slice(0, 500), spent: Math.max(0, Math.round(Number(c.spent || 0) + Number(c.accrued || 0))), self: o.self ? 1 : 0 };
|
||||||
|
if (useDb()) {
|
||||||
|
await R.db.q('INSERT INTO ad_clicks (id, campaign_id, owner_email, cname, ctype, sk, country, device, placement, target, spent, is_self, ts, pushed) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,0)',
|
||||||
|
[row.id, row.camp, row.owner, row.cname, row.type, row.sk, row.c, row.dv, row.pl, row.target, row.spent, row.self, row.ts]);
|
||||||
|
} else { const st = jload(); st.rows.push(Object.assign({ pushed: 0 }, row)); jcap(); jsave(); }
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
const fromDb = r => ({ id: r.id, camp: Number(r.campaign_id), cname: r.cname, type: r.ctype, owner: r.owner_email, ts: Number(r.ts), sk: r.sk, c: r.country, dv: r.device, pl: r.placement, target: r.target, spent: Number(r.spent) || 0, self: Number(r.is_self) ? 1 : 0 });
|
||||||
|
async function unpushed(n) {
|
||||||
|
if (useDb()) return (await R.db.q('SELECT * FROM ad_clicks WHERE pushed=0 ORDER BY ts LIMIT ?', [n])).map(fromDb);
|
||||||
|
return jload().rows.filter(r => !r.pushed).slice(0, n).map(r => { const x = Object.assign({}, r); delete x.pushed; return x; });
|
||||||
|
}
|
||||||
|
async function markPushed(ids) {
|
||||||
|
if (!ids.length) return;
|
||||||
|
if (useDb()) { await R.db.q('UPDATE ad_clicks SET pushed=1 WHERE id IN (?)', [ids]); return; }
|
||||||
|
const set = new Set(ids); for (const r of jload().rows) if (set.has(r.id)) r.pushed = 1; jsave();
|
||||||
|
}
|
||||||
|
async function prune() { // click rows only matter for the 30-day window; keep 120 days for questions
|
||||||
|
const cut = Date.now() - 120 * 86400e3;
|
||||||
|
if (useDb()) await R.db.q('DELETE FROM ad_clicks WHERE pushed=1 AND ts<?', [cut]);
|
||||||
|
else { const st = jload(); const n = st.rows.length; st.rows = st.rows.filter(r => !(r.pushed && r.ts < cut)); if (st.rows.length !== n) jsave(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- LinkSpin calls ----
|
||||||
|
async function signedPost(pth, body, timeoutMs) {
|
||||||
|
const raw = JSON.stringify(body || {}); const ts = String(Date.now());
|
||||||
|
const sig = crypto.createHmac('sha256', SECRET()).update(ts + '\n' + raw).digest('hex');
|
||||||
|
const r = await fetch(URL_() + pth, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-LS-Ts': ts, 'X-LS-Sig': sig }, body: raw, signal: AbortSignal.timeout(timeoutMs || 15000) });
|
||||||
|
const txt = await r.text(); let j = null; try { j = JSON.parse(txt); } catch (e) {}
|
||||||
|
if (!r.ok) { const e = new Error((j && j.error) || ('linkspin ' + r.status)); e.status = r.status; e.plain = !!(j && j.error); throw e; }
|
||||||
|
return j || {};
|
||||||
|
}
|
||||||
|
async function flush() {
|
||||||
|
if (!on() || flushing || Date.now() < nextAt) return { skipped: true };
|
||||||
|
flushing = true; let sent = 0;
|
||||||
|
try {
|
||||||
|
for (let round = 0; round < 20; round++) { // drain a backlog, 500 at a time
|
||||||
|
const rows = await unpushed(500); if (!rows.length) break;
|
||||||
|
const res = await signedPost('/api/partner/clicks', { clicks: rows }, 20000);
|
||||||
|
if (!res || res.ok !== true) throw new Error('linkspin answered without ok');
|
||||||
|
await markPushed(rows.map(r => r.id)); sent += rows.length; stats.pushed += rows.length; stats.lastAt = Date.now();
|
||||||
|
if (rows.length < 500) break;
|
||||||
|
}
|
||||||
|
fails = 0; nextAt = 0; return { sent };
|
||||||
|
} catch (e) {
|
||||||
|
fails++; stats.errors++; stats.lastError = e.message; nextAt = Date.now() + Math.min(300000, 3000 * Math.pow(2, Math.min(fails, 7)));
|
||||||
|
if (fails <= 3 || fails % 20 === 0) console.error('lsconv push', e.message);
|
||||||
|
return { error: e.message, sent };
|
||||||
|
} finally { flushing = false; }
|
||||||
|
}
|
||||||
|
// op summary is cached 60 s per email; any write clears that email's cache
|
||||||
|
async function summary(email, fresh) {
|
||||||
|
const e = String(email || '').toLowerCase();
|
||||||
|
const hit = cache.get(e); if (!fresh && hit && Date.now() - hit.at < 60000) return hit.data;
|
||||||
|
const data = await signedPost('/api/partner/conv', { op: 'summary', email: e, days: 30 }, 8000);
|
||||||
|
cache.set(e, { at: Date.now(), data }); if (cache.size > 2000) cache.delete(cache.keys().next().value);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
async function goalOp(email, op, fields) {
|
||||||
|
const e = String(email || '').toLowerCase();
|
||||||
|
if (!['create', 'update', 'remove', 'test'].includes(op)) throw new Error('Unknown action.');
|
||||||
|
const body = Object.assign({ op, email: e }, fields || {});
|
||||||
|
const out = await signedPost('/api/partner/conv', body, 10000);
|
||||||
|
cache.delete(e); return out;
|
||||||
|
}
|
||||||
|
function adminView() { return { on: on(), url: URL_(), pushed: stats.pushed, lastAt: stats.lastAt, errors: stats.errors, lastError: stats.lastError, fails, nextAt: nextAt || null }; }
|
||||||
|
module.exports = { init, record, flush, summary, goalOp, withClickId, softKey, placementOf, deviceOf, newId, adminView, on };
|
||||||
+88
-2
@@ -1063,6 +1063,90 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
|||||||
pageList('credits', box, 'tbody tr');
|
pageList('credits', box, 'tbody tr');
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
// Campaigns > Conversion tracking (2026-10-23). Goals and counts come from LinkSpin through /api/my/conversions. Anything
|
||||||
|
// going wrong here only changes this card's own text: the campaign list never depends on it.
|
||||||
|
let convSel = null, convCamps = [];
|
||||||
|
const convFmt = n => Number(n || 0).toLocaleString(undefined, { maximumFractionDigits: 1 });
|
||||||
|
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) : '';
|
||||||
|
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">',
|
||||||
|
js: '<script async src="' + h + '/cv.js?px=' + px + '&goal=' + goal + val + '"></' + 'script>'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const convBox = (id, label, text) => '<p class="small" style="margin:10px 0 4px"><b>' + label + '</b> <button class="btn small sec" type="button" data-convcopy="' + id + '">Copy</button></p>'
|
||||||
|
+ '<textarea id="' + id + '" readonly rows="2" style="width:100%;font-family:var(--mono);font-size:12px">' + esc(text) + '</textarea>';
|
||||||
|
function convCampLines(d) {
|
||||||
|
document.querySelectorAll('[data-convcamp]').forEach(el => { el.hidden = true; el.innerHTML = ''; });
|
||||||
|
if (!d || !d.ok || !(d.goals || []).length) return;
|
||||||
|
const by = d.byCampaign || {};
|
||||||
|
document.querySelectorAll('[data-convcamp]').forEach(el => {
|
||||||
|
const id = el.dataset.convcamp; const b = by[id]; const c = convCamps.find(x => String(x.id) === String(id)); if (!c) return;
|
||||||
|
const spent = Number(c.spent || 0);
|
||||||
|
const parts = d.goals.map(g => { const n = Number(b && b.conv && b.conv[g.px]) || 0;
|
||||||
|
return '<span>' + esc(g.name) + ' ' + n.toLocaleString() + (n > 0 ? ' (' + convFmt(spent / n) + ' credits each)' : '') + '</span>'; });
|
||||||
|
el.innerHTML = '\u{1F3AF} ' + parts.join(' · ') + (b && b.clicks ? ' <span class="muted">· ' + Number(b.clicks).toLocaleString() + ' tracked clicks</span>' : '');
|
||||||
|
el.title = 'Goals counted for this campaign in the last 30 days. Cost per goal = the credits this campaign has spent, divided by its goals.';
|
||||||
|
el.hidden = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
async function loadConv(fresh) {
|
||||||
|
const card = $('convCard'); if (!card) return;
|
||||||
|
card.hidden = false;
|
||||||
|
let d = null;
|
||||||
|
try { d = await (await fetch('/api/my/conversions' + (fresh ? '?fresh=1' : ''))).json(); } catch (e) { d = { ok: false, error: 'Could not reach InstantAdPay just now. Try again in a minute.' }; }
|
||||||
|
convCampLines(d);
|
||||||
|
const st = $('convStatus'), list = $('convGoals'), snips = $('convSnips'), add = $('convAddRow');
|
||||||
|
if (!d || !d.ok) { st.textContent = (d && d.error) || 'Conversion tracking is not available right now.'; list.innerHTML = ''; snips.innerHTML = ''; add.hidden = !!(d && d.reason === 'off'); return; }
|
||||||
|
add.hidden = false;
|
||||||
|
const goals = d.goals || [];
|
||||||
|
const m = d.methods || {}; const mt = ['url', 'stored', 'cookie', 'soft'].reduce((s, k) => s + (Number(m[k]) || 0), 0);
|
||||||
|
st.textContent = goals.length ? (mt ? 'How your conversions were matched (30 days): ' + ['url', 'stored', 'cookie', 'soft'].map(k => k + ' ' + Number(m[k] || 0).toLocaleString()).join(', ') + '.' : 'No conversions counted yet in the last 30 days.') : 'No goals yet. Add your first one below.';
|
||||||
|
if (!goals.length) { list.innerHTML = ''; snips.innerHTML = ''; return; }
|
||||||
|
if (!convSel || !goals.some(g => g.px === convSel)) convSel = goals[0].px;
|
||||||
|
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 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 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>';
|
||||||
|
const g = goals.find(x => x.px === convSel); const sn = convSnips(d.host, g);
|
||||||
|
snips.innerHTML = '<h4 style="margin:14px 0 0">Snippets for <b>' + esc(g.name) + '</b></h4>'
|
||||||
|
+ convBox('convLanding', '1. Landing tag (the page your ad points to)', sn.landing)
|
||||||
|
+ convBox('convImg', '2. Goal pixel (your thank-you page)', sn.img)
|
||||||
|
+ '<details style="margin-top:8px"><summary class="small">Prefer the JS version of the goal pixel?</summary>'
|
||||||
|
+ '<p class="small muted" style="margin:6px 0 0">Use it where your page allows scripts. It also sends the click id the landing tag stored, which makes the count surer.</p>'
|
||||||
|
+ convBox('convJs', 'Goal pixel, JS version', sn.js) + '</details>';
|
||||||
|
list.querySelectorAll('[data-convpick]').forEach(b => b.addEventListener('click', () => { convSel = b.dataset.convpick; loadConv(); }));
|
||||||
|
list.querySelectorAll('[data-convtest]').forEach(b => b.addEventListener('click', async () => {
|
||||||
|
b.disabled = true;
|
||||||
|
try { await api('/api/my/conversions/test', { px: b.dataset.convtest }); IAP.status('Test conversion sent. It shows under Last test and never counts in your numbers.', 'ok'); await loadConv(true); }
|
||||||
|
catch (e) { IAP.status(e.message, 'bad'); b.disabled = false; }
|
||||||
|
}));
|
||||||
|
list.querySelectorAll('[data-convdel]').forEach(b => b.addEventListener('click', async () => {
|
||||||
|
const yes = await IAP.confirmBox('Remove the goal "' + b.dataset.convname + '"? Its pixel stops counting. Pages that still carry it will simply be ignored.', { title: 'Remove goal', ok: 'Remove', cancel: 'Keep it' });
|
||||||
|
if (!yes) return; b.disabled = true;
|
||||||
|
try { await api('/api/my/conversions/goal', { op: 'remove', px: b.dataset.convdel }); IAP.status('Goal removed.', 'ok'); await loadConv(true); }
|
||||||
|
catch (e) { IAP.status(e.message, 'bad'); b.disabled = false; }
|
||||||
|
}));
|
||||||
|
snips.querySelectorAll('[data-convcopy]').forEach(b => b.addEventListener('click', async () => {
|
||||||
|
const ta = $(b.dataset.convcopy); try { await navigator.clipboard.writeText(ta.value); IAP.status('Copied. Paste it into your page.', 'ok'); } catch (e) { ta.select(); IAP.status('Selected. Press Ctrl+C (or long-press, Copy) to copy it.', 'ok'); }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if ($('convAddBtn')) $('convAddBtn').addEventListener('click', async () => {
|
||||||
|
const b = $('convAddBtn'); const name = $('convName').value.trim(); const value = $('convValue').value.trim();
|
||||||
|
if (!name) { IAP.status('Give the goal a short name, like subscriber or sale.', 'bad'); return; }
|
||||||
|
b.disabled = true;
|
||||||
|
try { const r = await api('/api/my/conversions/goal', { op: 'create', name, value }); if (r.goal && r.goal.px) convSel = r.goal.px; $('convName').value = ''; $('convValue').value = ''; IAP.status('Goal added. Copy its two snippets below.', 'ok'); await loadConv(true); }
|
||||||
|
catch (e) { IAP.status(e.message, 'bad'); }
|
||||||
|
b.disabled = false;
|
||||||
|
});
|
||||||
async function loadCampaigns() {
|
async function loadCampaigns() {
|
||||||
try {
|
try {
|
||||||
const r = await (await fetch('/api/my/campaigns')).json();
|
const r = await (await fetch('/api/my/campaigns')).json();
|
||||||
@@ -1093,12 +1177,13 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
|||||||
+ (r.rates.soloCostPerRecipient || 5) + 'cr/delivery';
|
+ (r.rates.soloCostPerRecipient || 5) + 'cr/delivery';
|
||||||
const el = $('campList');
|
const el = $('campList');
|
||||||
el.innerHTML = '';
|
el.innerHTML = '';
|
||||||
if (!r.campaigns.length) { el.innerHTML = '<p class="muted small">No campaigns yet. Launch your first below.</p>'; loadCreditActivity(el); return; }
|
convCamps = r.campaigns || [];
|
||||||
|
if (!r.campaigns.length) { el.innerHTML = '<p class="muted small">No campaigns yet. Launch your first below.</p>'; loadCreditActivity(el); loadConv(); return; }
|
||||||
const tbl = document.createElement('div');
|
const tbl = document.createElement('div');
|
||||||
tbl.className = 'tablewrap';
|
tbl.className = 'tablewrap';
|
||||||
tbl.innerHTML = '<table class="camp-table"><thead><tr><th>Name</th><th>Type</th><th class="num">Views here</th><th class="num" title="Impressions delivered by Network Ad Space across the wider network (banner and text ads only)">Network views</th><th class="num">Clicks</th>'
|
tbl.innerHTML = '<table class="camp-table"><thead><tr><th>Name</th><th>Type</th><th class="num">Views here</th><th class="num" title="Impressions delivered by Network Ad Space across the wider network (banner and text ads only)">Network views</th><th class="num">Clicks</th>'
|
||||||
+ '<th class="num">Spent</th><th class="num">Budget</th><th>Status</th><th></th></tr></thead><tbody>'
|
+ '<th class="num">Spent</th><th class="num">Budget</th><th>Status</th><th></th></tr></thead><tbody>'
|
||||||
+ r.campaigns.map(c => '<tr><td data-l="Campaign"><b>' + c.name + '</b>' + hourBars(r.hours && r.hours[c.id]) + geoLine(r.geo && r.geo[c.id]) + '</td>'
|
+ r.campaigns.map(c => '<tr><td data-l="Campaign"><b>' + c.name + '</b>' + hourBars(r.hours && r.hours[c.id]) + geoLine(r.geo && r.geo[c.id]) + '<div class="muted small conv-line" data-convcamp="' + c.id + '" hidden></div></td>'
|
||||||
+ '<td data-l="Type">' + c.type + (c.type === 'banner' && c.width ? ' <span class="muted small">' + c.width + '×' + c.height + '</span>' : '') + (c.dailyCap ? ' <span class="muted small" title="daily cap: ' + c.dailyCap + ' credits, ' + (c.daySpent || 0) + ' spent today">cap ' + c.dailyCap + '/day</span>' : '') + (c.geo ? ' <span class="muted small" title="shown only to viewers in these country tiers">tier ' + esc(c.geo.replace(/,/g, '+')) + '</span>' : '') + schedChips(c)
|
+ '<td data-l="Type">' + c.type + (c.type === 'banner' && c.width ? ' <span class="muted small">' + c.width + '×' + c.height + '</span>' : '') + (c.dailyCap ? ' <span class="muted small" title="daily cap: ' + c.dailyCap + ' credits, ' + (c.daySpent || 0) + ' spent today">cap ' + c.dailyCap + '/day</span>' : '') + (c.geo ? ' <span class="muted small" title="shown only to viewers in these country tiers">tier ' + esc(c.geo.replace(/,/g, '+')) + '</span>' : '') + schedChips(c)
|
||||||
+ (c.type === 'visits' && (c.placement === 'golden' || c.placement === 'doors') ? ' <span class="badge' + (c.placement === 'golden' ? ' amber' : '') + '" title="' + (c.doorOnly ? 'runs only in Spooky Doors until the season ends, then any doors left run as normal visits' : 'the Spooky Doors season is over, so any doors left run as normal visits') + '">' + (c.placement === 'golden' ? 'Golden Door' : 'Spooky Doors') + '</span>' : '') + '</td>'
|
+ (c.type === 'visits' && (c.placement === 'golden' || c.placement === 'doors') ? ' <span class="badge' + (c.placement === 'golden' ? ' amber' : '') + '" title="' + (c.doorOnly ? 'runs only in Spooky Doors until the season ends, then any doors left run as normal visits' : 'the Spooky Doors season is over, so any doors left run as normal visits') + '">' + (c.placement === 'golden' ? 'Golden Door' : 'Spooky Doors') + '</span>' : '') + '</td>'
|
||||||
+ '<td class="num" data-l="Views here">' + c.imps.toLocaleString() + '</td>'
|
+ '<td class="num" data-l="Views here">' + c.imps.toLocaleString() + '</td>'
|
||||||
@@ -1120,6 +1205,7 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
|||||||
+ '</td></tr>').join('') + '</tbody></table>';
|
+ '</td></tr>').join('') + '</tbody></table>';
|
||||||
el.appendChild(tbl);
|
el.appendChild(tbl);
|
||||||
pageList('camps', tbl, 'tbody tr');
|
pageList('camps', tbl, 'tbody tr');
|
||||||
|
loadConv();
|
||||||
renderArchived(el, r);
|
renderArchived(el, r);
|
||||||
const note = document.createElement('p'); note.className = 'muted small';
|
const note = document.createElement('p'); note.className = 'muted small';
|
||||||
note.textContent = 'Credits you put into a campaign are set aside the moment you start it, so your Available number drops right away and the campaign spends from its own budget. Featured links and verified-visit packs are paid in full up front; a featured run is sold by the day, so use Extend run to keep it going. Whatever a campaign has not spent comes back to Available when it ends.';
|
note.textContent = 'Credits you put into a campaign are set aside the moment you start it, so your Available number drops right away and the campaign spends from its own budget. Featured links and verified-visit packs are paid in full up front; a featured run is sold by the day, so use Extend run to keep it going. Whatever a campaign has not spent comes back to Available when it ends.';
|
||||||
|
|||||||
@@ -472,6 +472,11 @@
|
|||||||
The 5 dollar package mints 500 credits, and the bigger packages mint bonus credits on top, up to
|
The 5 dollar package mints 500 credits, and the bigger packages mint bonus credits on top, up to
|
||||||
70,000 on the 500 dollar package. That is the product, plain and simple. Your earnings come from
|
70,000 on the 500 dollar package. That is the product, plain and simple. Your earnings come from
|
||||||
referring people who also buy real ad delivery, and the contract splits every purchase automatically.</p></details>
|
referring people who also buy real ad delivery, and the contract splits every purchase automatically.</p></details>
|
||||||
|
<details><summary>Can I see which ads bring me subscribers or sales?</summary>
|
||||||
|
<p>Yes. Campaigns > Conversion tracking in your dashboard gives you two small tags for your own site:
|
||||||
|
a landing tag for the page your ad points to and a goal pixel for your thank-you page. Each subscriber
|
||||||
|
or sale is counted against the ad that sent the visitor, once per click, within 30 days, and every
|
||||||
|
campaign shows its cost per goal in credits.</p></details>
|
||||||
|
|
||||||
<div class="closer">
|
<div class="closer">
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
+28
-1
@@ -618,6 +618,33 @@
|
|||||||
</div>
|
</div>
|
||||||
<button class="btn" id="createCampBtn">Launch campaign</button>
|
<button class="btn" id="createCampBtn">Launch campaign</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="card" id="convCard" hidden>
|
||||||
|
<h3>Conversion tracking</h3>
|
||||||
|
<p class="muted small">See which of your ads bring subscribers and sales, not just clicks. Every click on your ad carries a click id. Put two small tags on your own site and each goal is counted against the ad that sent the visitor, with a cost per goal in credits on each campaign above. The counting is done by LinkSpin, our sister site, under this same email.</p>
|
||||||
|
<ol class="small" style="margin:6px 0 10px 18px;padding:0">
|
||||||
|
<li>Add a goal below, for example <b>subscriber</b> or <b>sale</b>.</li>
|
||||||
|
<li>Put the <b>landing tag</b> on the page your ad sends people to (once per page, just before </body>).</li>
|
||||||
|
<li>Put the <b>goal pixel</b> on your thank-you page, the page people see after they sign up or buy.</li>
|
||||||
|
</ol>
|
||||||
|
<p class="small" id="convStatus"></p>
|
||||||
|
<div id="convGoals"></div>
|
||||||
|
<div id="convAddRow" class="grid c3" style="margin-top:10px">
|
||||||
|
<p><input id="convName" maxlength="32" placeholder="Goal name, like subscriber or sale" style="width:100%"></p>
|
||||||
|
<p><input id="convValue" type="number" min="0" step="0.01" placeholder="Default value (optional), like 19.95" style="width:100%"></p>
|
||||||
|
<p><button class="btn small" id="convAddBtn" type="button">Add goal</button></p>
|
||||||
|
</div>
|
||||||
|
<div id="convSnips"></div>
|
||||||
|
<h4 style="margin:14px 0 4px">Your autoresponder's thank-you page</h4>
|
||||||
|
<p class="small muted" style="margin:0">Set your autoresponder's thank-you (success) page to a page on YOUR site that carries the goal pixel. Aweber: in your sign-up form settings, choose 'Thank You Page: custom page' and paste your page's address. GetResponse: in the form or landing page settings, pick 'Thank-you page: custom URL' and paste your page's address. If you cannot change it, the pixel can still count through the cookie or the 24-hour match, just less surely.</p>
|
||||||
|
<h4 style="margin:14px 0 4px">How sure is each count</h4>
|
||||||
|
<ul class="small muted" id="convLegend" style="margin:0 0 0 18px;padding:0">
|
||||||
|
<li><b>Click id in the address</b> (url): surest. The thank-you page address still carried the click id from your ad.</li>
|
||||||
|
<li><b>Stored by the landing tag</b> (stored): very sure. The landing tag kept the click id on your site and the goal pixel read it back.</li>
|
||||||
|
<li><b>LinkSpin cookie</b> (cookie): fairly sure. Matched through LinkSpin's own cookie in the visitor's browser. Some browsers block it.</li>
|
||||||
|
<li><b>24-hour match</b> (soft): least sure. Same connection and browser within 24 hours of a click. A good guess, not a proof.</li>
|
||||||
|
</ul>
|
||||||
|
<p class="small muted" style="margin:8px 0 0">Each goal counts once per click, only within 30 days of a real click on one of your ads. Your own clicks on your ads and the test button count as tests, never in your numbers.</p>
|
||||||
|
</div>
|
||||||
<div class="card ad-foot" id="adSlotPane-campaigns" hidden></div>
|
<div class="card ad-foot" id="adSlotPane-campaigns" hidden></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -1189,7 +1216,7 @@
|
|||||||
<script src="/assets/wallet.js?v=20260911a"></script>
|
<script src="/assets/wallet.js?v=20260911a"></script>
|
||||||
<script src="/assets/promo.js?v=20261016p"></script>
|
<script src="/assets/promo.js?v=20261016p"></script>
|
||||||
<script src="/assets/support.js?v=20261016a"></script>
|
<script src="/assets/support.js?v=20261016a"></script>
|
||||||
<script src="/assets/my.js?v=20261023ov"></script>
|
<script src="/assets/my.js?v=20261023cv"></script>
|
||||||
<script src="/assets/chat.js?v=20261016n"></script>
|
<script src="/assets/chat.js?v=20261016n"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+3
-1
@@ -10,7 +10,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id="nav"></div>
|
<div id="nav"></div>
|
||||||
<section><div class="wrap" style="max-width:820px">
|
<section><div class="wrap" style="max-width:820px">
|
||||||
<div class="sectionhead" style="text-align:left"><h2>Privacy Policy</h2><p class="muted small">Last updated: September 2026</p></div>
|
<div class="sectionhead" style="text-align:left"><h2>Privacy Policy</h2><p class="muted small">Last updated: October 2026</p></div>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h3>What we collect</h3>
|
<h3>What we collect</h3>
|
||||||
<p class="muted small">A minimal set: the email you sign up with, a username and any profile details you choose to add (avatar, bio, social links), and, only if you link one, your public wallet address. Campaign content you create and reports you submit are stored to run the service. We also read on-chain activity that is already public on the blockchain.</p>
|
<p class="muted small">A minimal set: the email you sign up with, a username and any profile details you choose to add (avatar, bio, social links), and, only if you link one, your public wallet address. Campaign content you create and reports you submit are stored to run the service. We also read on-chain activity that is already public on the blockchain.</p>
|
||||||
@@ -21,6 +21,8 @@
|
|||||||
<h3>Cookies</h3>
|
<h3>Cookies</h3>
|
||||||
<p class="muted small">We use a session cookie to keep you signed in, a referral cookie to credit the sponsor whose link you arrived through, and a browser identifier cookie used only to enforce one account per person. No third-party ad-tracking cookies.</p>
|
<p class="muted small">We use a session cookie to keep you signed in, a referral cookie to credit the sponsor whose link you arrived through, and a browser identifier cookie used only to enforce one account per person. No third-party ad-tracking cookies.</p>
|
||||||
<p class="muted small"><strong>Abuse prevention.</strong> When you create an account and when you sign in we record your IP address, browser type and the browser identifier. We use them to detect duplicate accounts and self-referral, which the Terms prohibit, and for nothing else. They are visible to the site administrator only and are not sold or shared.</p>
|
<p class="muted small"><strong>Abuse prevention.</strong> When you create an account and when you sign in we record your IP address, browser type and the browser identifier. We use them to detect duplicate accounts and self-referral, which the Terms prohibit, and for nothing else. They are visible to the site administrator only and are not sold or shared.</p>
|
||||||
|
<h3>Conversion tracking on ad links</h3>
|
||||||
|
<p class="muted small">When you click an ad here, the link to the advertiser's site gets a random click id added to its address (it looks like <code>lsclk=i3f9a0c1b2d4e</code>). The id says nothing about you. We record which ad it belongs to, the time, your country, phone or computer, and the page the click came from, and pass that to LinkSpin, our sister site, which counts the advertiser's results. If the advertiser has added the LinkSpin landing tag to their own site, that tag keeps the click id on their site (in the browser's local storage and a first-party cookie of their site). If you later sign up or buy there, their goal pixel on the thank-you page tells LinkSpin that one goal happened for that click. Nothing personal is sent: no name, no email, no wallet. Your IP address is never stored; it is only used in hashed form, together with your browser type, for a match within 24 hours of the click when the click id is missing.</p>
|
||||||
<h3>Sharing</h3>
|
<h3>Sharing</h3>
|
||||||
<p class="muted small">Your username, public profile, and public wall are visible to others by design, and on-chain transactions are public by nature. We share data with infrastructure providers (hosting, email delivery) only as needed to operate the service, and when required by law.</p>
|
<p class="muted small">Your username, public profile, and public wall are visible to others by design, and on-chain transactions are public by nature. We share data with infrastructure providers (hosting, email delivery) only as needed to operate the service, and when required by law.</p>
|
||||||
<h3>Your choices</h3>
|
<h3>Your choices</h3>
|
||||||
|
|||||||
@@ -0,0 +1,204 @@
|
|||||||
|
// Conversion pixel, InstantAdPay half (2026-10-23), end to end against a LOCAL copy and a MOCK LinkSpin.
|
||||||
|
// node qa/convpixel.test.mjs (or: bash qa/run.sh convpixel)
|
||||||
|
// Boots server.js on its own port with a throwaway DATA_DIR seeded with two advertisers and a few campaigns (JSON store,
|
||||||
|
// DATABASE_URL blank, no mail key, devCode sign-in, a minimal environment so no live secret can leak in), LS_URL pointing at a
|
||||||
|
// mock LinkSpin on localhost that verifies the HMAC on every call, records the pushed clicks and answers op summary.
|
||||||
|
// Nothing touches production or a real member. Checks: lsclk on the 302 (existing params and #hash kept, a LinkSpin /r/ link
|
||||||
|
// gets it, an existing lsclk is never replaced, an unparsable target goes out unchanged), the click rows pushed with a valid
|
||||||
|
// signature and the contract fields, the owner's own click flagged self=1 and not counted, the proxies, the Campaigns pane
|
||||||
|
// showing goals and cost per goal (300 credits / 4 = 75), LinkSpin down: pane still loads, panel says so, rows kept and
|
||||||
|
// pushed once it is back. Exit code 1 on any failure.
|
||||||
|
import http from 'node:http';
|
||||||
|
import crypto from 'node:crypto';
|
||||||
|
import fs from 'node:fs';
|
||||||
|
import os from 'node:os';
|
||||||
|
import path from 'node:path';
|
||||||
|
import { spawn } from 'node:child_process';
|
||||||
|
import { pathToFileURL, fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
|
const SITE = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||||
|
const PORT = Number(process.env.CONV_PORT || 8831), MPORT = PORT + 1;
|
||||||
|
const B = 'http://127.0.0.1:' + PORT, MOCK = 'http://127.0.0.1:' + MPORT;
|
||||||
|
const SECRET = 'qa-convpixel-' + crypto.randomBytes(24).toString('hex'); // throwaway, 32+ chars
|
||||||
|
const ADMIN = 'localtest';
|
||||||
|
const DATA = fs.mkdtempSync(path.join(os.tmpdir(), 'iap-conv-')); fs.mkdirSync(path.join(DATA, 'uploads'));
|
||||||
|
const OUT = path.join(SITE, 'qa', 'out'); fs.mkdirSync(OUT, { recursive: true });
|
||||||
|
let fails = 0; const ok = (cond, label, extra) => { console.log((cond ? 'PASS ' : 'FAIL ') + label + (!cond && extra ? ' ' + extra : '')); if (!cond) fails++; };
|
||||||
|
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
||||||
|
async function waitFor(fn, ms) { const t0 = Date.now(); while (Date.now() - t0 < (ms || 15000)) { try { const v = await fn(); if (v) return v; } catch (e) {} await sleep(400); } return null; }
|
||||||
|
|
||||||
|
// ---- seed: two advertisers, campaigns with every target shape ----
|
||||||
|
const now = Date.now();
|
||||||
|
const acct = (email, username, code) => ({ email, pass: null, sponsorRef: '', code, username, address: null, created: now - 5 * 86400000, lastSeen: now - 3600000, memberId: 0 });
|
||||||
|
const A1 = 'qa-adv@example.com', A2 = 'qa-adv2@example.com';
|
||||||
|
{ const db = { v: 2, byEmail: {}, byAddress: {}, byCode: {}, joins: 0, positions: {} };
|
||||||
|
for (const a of [acct(A1, 'qaadv', 'cqaadv1'), acct(A2, 'qaadvtwo', 'cqaadv2')]) { db.byEmail[a.email] = a; db.byCode[a.code] = a.email; }
|
||||||
|
fs.writeFileSync(path.join(DATA, 'accounts.json'), JSON.stringify(db)); }
|
||||||
|
const camp = (id, owner, name, targetUrl, spent) => ({ id, owner, memberId: 0, type: 'banner', name, targetUrl, imageUrl: 'https://example.com/b.png', title: null, body: null,
|
||||||
|
budget: 1000, spent, accrued: 0, imps: 50, clicks: 0, batchImps: 0, width: 468, height: 60, status: 'paused', created: now - 86400000 });
|
||||||
|
const T1 = 'https://adv.example/landing?utm_source=iap&x=a%2Cb&q=hello+world#top';
|
||||||
|
const CAMPS = [camp(1, A1, 'QA landing', T1, 300), camp(2, A1, 'QA spin link', 'https://linkspin.app/r/abc12', 120),
|
||||||
|
camp(3, A1, 'QA has lsclk', 'https://adv.example/p?lsclk=keepme', 0), camp(4, A1, 'QA odd target', 'adv.example/no-scheme', 0), camp(5, A2, 'QA other', 'https://other.example/', 50)];
|
||||||
|
fs.writeFileSync(path.join(DATA, 'campaigns.json'), JSON.stringify({ v: 1, nextId: 6, campaigns: CAMPS, burnsPending: [] }));
|
||||||
|
|
||||||
|
// ---- 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 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) {
|
||||||
|
let raw = ''; req.on('data', c => raw += c); req.on('end', () => {
|
||||||
|
if (mock.down) { res.writeHead(503); return res.end('down'); }
|
||||||
|
if (req.method !== 'POST') return send(res, 404, { error: 'not found' });
|
||||||
|
if (!verify(req.headers['x-ls-ts'], req.headers['x-ls-sig'], raw)) { mock.badSig++; return send(res, 401, { error: 'bad signature' }); }
|
||||||
|
const b = JSON.parse(raw || '{}');
|
||||||
|
if (req.url === '/api/partner/clicks') { for (const c of b.clicks || []) mock.clicks.set(c.id, c); return send(res, 200, { ok: true, n: (b.clicks || []).length }); }
|
||||||
|
if (req.url === '/api/partner/conv') {
|
||||||
|
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 === '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' });
|
||||||
|
}
|
||||||
|
return send(res, 404, { error: 'not found' }); // registry sync and anything else: ignored
|
||||||
|
});
|
||||||
|
}
|
||||||
|
let mockSrv = http.createServer(mockHandler); await new Promise(r => mockSrv.listen(MPORT, '127.0.0.1', r));
|
||||||
|
|
||||||
|
// ---- the local copy, minimal environment (no live secrets can ride along) ----
|
||||||
|
const ENV = {};
|
||||||
|
for (const k of ['PATH', 'Path', 'SystemRoot', 'SYSTEMROOT', 'TEMP', 'TMP', 'USERPROFILE', 'HOME', 'APPDATA', 'LOCALAPPDATA', 'COMSPEC', 'windir']) if (process.env[k]) ENV[k] = process.env[k];
|
||||||
|
Object.assign(ENV, { PORT: String(PORT), DATA_DIR: DATA, NODE_ENV: 'development', ADMIN_EMAIL: 'qa-admin@example.com', ADMIN_PASSWORD: ADMIN, DATABASE_URL: '', LS_SYNC_SECRET: SECRET, LS_URL: MOCK });
|
||||||
|
const srv = spawn(process.execPath, ['server.js'], { cwd: SITE, env: ENV, stdio: ['ignore', 'pipe', 'pipe'] });
|
||||||
|
let srvLog = ''; srv.stdout.on('data', d => srvLog += d); srv.stderr.on('data', d => srvLog += d);
|
||||||
|
let browser = null;
|
||||||
|
const cleanup = async () => { try { if (browser) await browser.close(); } catch (e) {} try { srv.kill(); } catch (e) {} try { mockSrv.close(); } catch (e) {} await sleep(300); try { fs.rmSync(DATA, { recursive: true, force: true }); } catch (e) {} };
|
||||||
|
|
||||||
|
try {
|
||||||
|
const up = await waitFor(async () => (await fetch(B + '/api/config')).ok, 30000);
|
||||||
|
if (!up) throw new Error('local server did not come up:\n' + srvLog.slice(-2000));
|
||||||
|
const api = async (p, body, hdr) => { const r = await fetch(B + p, { method: body ? 'POST' : 'GET', headers: Object.assign({ 'Content-Type': 'application/json' }, hdr || {}), body: body ? JSON.stringify(body) : undefined }); let j = null; try { j = await r.json(); } catch (e) {} return { status: r.status, j }; };
|
||||||
|
const click = async (id, hdr) => { const r = await fetch(B + '/api/ads/click/' + id, { redirect: 'manual', headers: Object.assign({ 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0) Mobile/15E148', Referer: 'https://instantadpay.com/ledger?secret=1' }, hdr || {}) }); return { status: r.status, loc: r.headers.get('location') }; };
|
||||||
|
async function signIn(email) {
|
||||||
|
const s = await api('/api/auth/email/start', { email, fts: Date.now() - 5000, fage: 5000 });
|
||||||
|
const v = await fetch(B + '/api/auth/email/verify', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email, code: s.j && s.j.devCode }) });
|
||||||
|
return (v.headers.getSetCookie ? v.headers.getSetCookie() : [v.headers.get('set-cookie')]).map(c => String(c).split(';')[0]).join('; ');
|
||||||
|
}
|
||||||
|
const ID = /lsclk=(i[0-9a-f]{11})(?=$|[&#])/;
|
||||||
|
|
||||||
|
// 1. click ids on the redirect
|
||||||
|
const c1 = await click(1);
|
||||||
|
const id1 = (ID.exec(c1.loc || '') || [])[1];
|
||||||
|
ok(c1.status === 302 && !!id1, 'click -> 302 with lsclk=i+11 hex', c1.status + ' ' + c1.loc);
|
||||||
|
ok(c1.loc === 'https://adv.example/landing?utm_source=iap&x=a%2Cb&q=hello+world&lsclk=' + id1 + '#top', 'existing params kept byte for byte, lsclk before the #hash', c1.loc);
|
||||||
|
const c2 = await click(2); const id2 = (ID.exec(c2.loc || '') || [])[1];
|
||||||
|
ok(!!id2 && c2.loc === 'https://linkspin.app/r/abc12?lsclk=' + id2, 'a LinkSpin /r/ spin link gets lsclk', c2.loc);
|
||||||
|
const c3 = await click(3);
|
||||||
|
ok(c3.loc === 'https://adv.example/p?lsclk=keepme', 'an existing lsclk is never replaced', c3.loc);
|
||||||
|
const c4 = await click(4);
|
||||||
|
ok(c4.status === 302 && c4.loc === 'adv.example/no-scheme', 'an unparsable target redirects unchanged', c4.status + ' ' + c4.loc);
|
||||||
|
const c1b = await click(1); const id1b = (ID.exec(c1b.loc || '') || [])[1];
|
||||||
|
ok(id1b && id1b !== id1, 'every click gets its own id');
|
||||||
|
|
||||||
|
// 2. pushed to the mock, signed, with the contract fields
|
||||||
|
const got = await waitFor(() => mock.clicks.has(id1) && mock.clicks.has(id2) && mock.clicks.has(id1b), 15000);
|
||||||
|
ok(!!got, 'click rows pushed to LinkSpin /api/partner/clicks within ~3 s', [...mock.clicks.keys()].join(','));
|
||||||
|
ok(mock.badSig === 0, 'every push carried a valid HMAC signature', 'bad: ' + mock.badSig);
|
||||||
|
const r1 = mock.clicks.get(id1) || {};
|
||||||
|
ok(r1.camp === 1 && r1.cname === 'QA landing' && r1.type === 'banner' && r1.owner === A1, 'row: camp, cname, type, owner', JSON.stringify(r1));
|
||||||
|
ok(r1.spent === 300 && r1.self === 0 && r1.target === T1, 'row: spent 300, self 0, target', JSON.stringify(r1));
|
||||||
|
ok(/^s:[0-9a-f]{20}$/.test(r1.sk || '') && r1.dv === 'mobile' && r1.pl === 'instantadpay.com/ledger' && Math.abs(r1.ts - Date.now()) < 120000, 'row: soft key, device, placement (query dropped), ts', JSON.stringify(r1));
|
||||||
|
const ip = '127.0.0.1', ua = 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0) Mobile/15E148';
|
||||||
|
const sks = ['s:' + crypto.createHash('sha256').update(ip + '|' + ua).digest('hex').slice(0, 20), 's:' + crypto.createHash('sha256').update('::ffff:127.0.0.1|' + ua).digest('hex').slice(0, 20)];
|
||||||
|
ok(sks.includes(r1.sk), 'soft key = sha256(ip|ua) first 20 hex, no raw IP in the row', r1.sk);
|
||||||
|
ok(!JSON.stringify([...mock.clicks.values()]).includes('127.0.0.1'), 'no raw IP anywhere in the pushed rows');
|
||||||
|
ok(!mock.clicks.has('keepme') && [...mock.clicks.values()].filter(r => r.camp === 3).length === 1, 'the click on the lsclk target is still recorded (its own id), the URL untouched');
|
||||||
|
|
||||||
|
// 3. the owner's own click: still an id, flagged self, not counted as a click
|
||||||
|
const ck1 = await signIn(A1);
|
||||||
|
const before = (await api('/api/my/campaigns', null, { Cookie: ck1 })).j;
|
||||||
|
const clicksBefore = ((before && before.campaigns) || []).find(c => c.id === 1);
|
||||||
|
const own = await click(1, { Cookie: ck1 }); const idOwn = (ID.exec(own.loc || '') || [])[1];
|
||||||
|
ok(!!idOwn, 'own click still gets a click id (so the owner can test)', own.loc);
|
||||||
|
ok(!!(await waitFor(() => mock.clicks.get(idOwn), 10000)) && mock.clicks.get(idOwn).self === 1, 'own click pushed with self=1', JSON.stringify(mock.clicks.get(idOwn)));
|
||||||
|
const after = (await api('/api/my/campaigns', null, { Cookie: ck1 })).j;
|
||||||
|
const clicksAfter = ((after && after.campaigns) || []).find(c => c.id === 1);
|
||||||
|
ok(clicksBefore && clicksAfter && clicksAfter.clicks === clicksBefore.clicks && clicksBefore.clicks === 2, 'own click not counted (clicks stay 2)', JSON.stringify([clicksBefore && clicksBefore.clicks, clicksAfter && clicksAfter.clicks]));
|
||||||
|
|
||||||
|
// 4. proxies
|
||||||
|
const sum = await api('/api/my/conversions', null, { Cookie: ck1 });
|
||||||
|
ok(sum.j && sum.j.ok === true && sum.j.goals.length === 2 && sum.j.byCampaign['1'].conv[PX1] === 4, 'GET /api/my/conversions relays the LinkSpin summary', JSON.stringify(sum.j).slice(0, 200));
|
||||||
|
const lastSum = mock.calls.filter(c => c.op === 'summary').pop();
|
||||||
|
ok(lastSum && lastSum.email === A1 && lastSum.days === 30, 'summary asked for the signed-in email, 30 days', JSON.stringify(lastSum));
|
||||||
|
const nSum = mock.calls.filter(c => c.op === 'summary').length; await api('/api/my/conversions', null, { Cookie: ck1 });
|
||||||
|
ok(mock.calls.filter(c => c.op === 'summary').length === nSum, 'summary cached (second call within 60 s does not hit LinkSpin)');
|
||||||
|
ok((await api('/api/my/conversions')).status === 401, 'signed out: 401');
|
||||||
|
const bad = await api('/api/my/conversions/goal', { op: 'create', name: ' ' }, { Cookie: ck1 });
|
||||||
|
ok(bad.status === 400, 'create without a name refused locally');
|
||||||
|
const cr = await api('/api/my/conversions/goal', { op: 'create', name: 'Free Report', value: '7.5' }, { Cookie: ck1 });
|
||||||
|
ok(cr.j && cr.j.ok && cr.j.goal && /^px[0-9a-f]{10}$/.test(cr.j.goal.px) && cr.j.goal.name === 'free-report' && cr.j.goal.value === 7.5, 'create relays op create (name normalized, value number)', JSON.stringify(cr.j));
|
||||||
|
const ts = await api('/api/my/conversions/test', { px: cr.j && cr.j.goal && cr.j.goal.px }, { Cookie: ck1 });
|
||||||
|
ok(ts.j && ts.j.ok && ts.j.at, 'test relays op test', JSON.stringify(ts.j));
|
||||||
|
const rm = await api('/api/my/conversions/goal', { op: 'remove', px: cr.j && cr.j.goal && cr.j.goal.px }, { Cookie: ck1 });
|
||||||
|
ok(rm.j && rm.j.ok, 'remove relays op remove');
|
||||||
|
const rm2 = await api('/api/my/conversions/goal', { op: 'remove', px: 'px9999999999' }, { Cookie: ck1 });
|
||||||
|
ok(rm2.status === 400 && rm2.j && rm2.j.error === 'No such goal.', 'LinkSpin plain-words error passed through as 400', JSON.stringify(rm2));
|
||||||
|
ok(mock.calls.every(c => c.email === A1), 'every conv call carried only the signed-in email');
|
||||||
|
|
||||||
|
// 5. the Campaigns pane in a real browser
|
||||||
|
const PW = process.env.PW || 'D:/Projects/MarketingAgent/qa-tester/node_modules/playwright';
|
||||||
|
const { chromium } = (await import(pathToFileURL(PW + '/index.js').href)).default;
|
||||||
|
browser = await chromium.launch();
|
||||||
|
async function pane(cookie, shot) {
|
||||||
|
const ctx = await browser.newContext({ viewport: { width: 1280, height: 1000 } });
|
||||||
|
await ctx.addInitScript(() => { try { sessionStorage.setItem('iap.welcome.v1', '1'); } catch (e) {} });
|
||||||
|
const [k, v] = cookie.split(';')[0].split('='); await ctx.addCookies([{ name: k, value: v, url: B }]);
|
||||||
|
const page = await ctx.newPage(); const errs = []; page.on('pageerror', e => errs.push(e.message));
|
||||||
|
await page.goto(B + '/my', { waitUntil: 'domcontentloaded' }); await page.waitForTimeout(2500);
|
||||||
|
await page.evaluate(() => { document.querySelectorAll('.modal-back,.lgate,.iap-welcome').forEach(m => m.hidden = true); });
|
||||||
|
await page.click('.bo-menu [data-pane="campaigns"]'); await page.waitForTimeout(2500);
|
||||||
|
const st = await page.evaluate(() => ({
|
||||||
|
rows: document.querySelectorAll('#campList .camp-table tbody tr').length,
|
||||||
|
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 || '',
|
||||||
|
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 };
|
||||||
|
}
|
||||||
|
const p1 = await pane(ck1, 'convpixel-pane.png');
|
||||||
|
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(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');
|
||||||
|
ok(/url 2, stored 2, cookie 1, soft 1/.test(p1.st.status), 'match methods line', p1.st.status);
|
||||||
|
ok(!p1.errs.length, 'no page errors', p1.errs.join(' | '));
|
||||||
|
|
||||||
|
// 6. LinkSpin down: the pane still loads, the panel says so, campaign rows omit the goal line; clicks are kept and pushed later
|
||||||
|
mock.down = true;
|
||||||
|
const ck2 = await signIn(A2);
|
||||||
|
const down = await api('/api/my/conversions', null, { Cookie: ck2 });
|
||||||
|
ok(down.j && down.j.ok === false && down.j.reason === 'down' && /did not answer/.test(down.j.error), 'proxy says LinkSpin is down in plain words', JSON.stringify(down.j));
|
||||||
|
const p2 = await pane(ck2, 'convpixel-down.png');
|
||||||
|
ok(p2.st.rows >= 1 && p2.st.card && /did not answer/.test(p2.st.status) && p2.st.line5Hidden, 'LinkSpin down: Campaigns pane still loads, no goal line, panel explains', JSON.stringify(p2.st).slice(0, 220));
|
||||||
|
ok(!p2.errs.length, 'no page errors while LinkSpin is down', p2.errs.join(' | '));
|
||||||
|
const cd = await click(5); const idDown = (ID.exec(cd.loc || '') || [])[1];
|
||||||
|
ok(!!idDown, 'clicks still get ids while LinkSpin is down');
|
||||||
|
await sleep(4000);
|
||||||
|
ok(!mock.clicks.has(idDown), 'nothing marked pushed while LinkSpin refuses');
|
||||||
|
mock.down = false;
|
||||||
|
ok(!!(await waitFor(() => mock.clicks.has(idDown), 30000)), 'row kept and pushed once LinkSpin is back (retry with backoff)');
|
||||||
|
const adm = await api('/api/admin/lssync', null, { Authorization: 'Bearer ' + ADMIN });
|
||||||
|
ok(adm.j && adm.j.conv && adm.j.conv.on === true && adm.j.conv.pushed >= 5, 'admin lssync view carries conv push stats', JSON.stringify(adm.j && adm.j.conv));
|
||||||
|
} catch (e) { ok(false, 'run', e.stack); }
|
||||||
|
finally {
|
||||||
|
await cleanup();
|
||||||
|
fs.writeFileSync(path.join(OUT, 'convpixel-server.log'), srvLog);
|
||||||
|
console.log(fails ? fails + ' FAILED' : 'all passed');
|
||||||
|
process.exit(fails ? 1 : 0);
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
# bash qa/run.sh login-queue # prepaid login-ad line: JSON store end to end + the MySQL path's lease/guard logic against a fake SQL layer (no server, throwaway data)
|
# bash qa/run.sh login-queue # prepaid login-ad line: JSON store end to end + the MySQL path's lease/guard logic against a fake SQL layer (no server, throwaway data)
|
||||||
# bash qa/run.sh gamepass-games # the REAL games' polgrant.js + PolHunter's tournament payer against a local copy (needs the sibling game repos)
|
# bash qa/run.sh gamepass-games # the REAL games' polgrant.js + PolHunter's tournament payer against a local copy (needs the sibling game repos)
|
||||||
# bash qa/run.sh override # level-4 override: week math, hunt, house, dust carry, cap, balance, two concurrent payers (fake chain + signer, throwaway data)
|
# bash qa/run.sh override # level-4 override: week math, hunt, house, dust carry, cap, balance, two concurrent payers (fake chain + signer, throwaway data)
|
||||||
|
# bash qa/run.sh convpixel # conversion pixel: lsclk click ids on /api/ads/click, signed push to a MOCK LinkSpin, own-click self flag, Campaigns > Conversion tracking + cost per goal, LinkSpin down (local copy, throwaway data)
|
||||||
# Each local run boots server.js on its own port with a throwaway data dir (JSON store, no DB, no
|
# Each local run boots server.js on its own port with a throwaway data dir (JSON store, no DB, no
|
||||||
# mail key, devCode sign-in), so nothing touches production data. Reports land in qa/out/.
|
# mail key, devCode sign-in), so nothing touches production data. Reports land in qa/out/.
|
||||||
set -u
|
set -u
|
||||||
@@ -54,6 +55,8 @@ elif [ "$MODE" = "sov-passes" ]; then
|
|||||||
elif [ "$MODE" = "login-queue" ]; then
|
elif [ "$MODE" = "login-queue" ]; then
|
||||||
node qa/login-queue.cjs || status=1
|
node qa/login-queue.cjs || status=1
|
||||||
node qa/login-queue-sql.cjs || status=1
|
node qa/login-queue-sql.cjs || status=1
|
||||||
|
elif [ "$MODE" = "convpixel" ]; then
|
||||||
|
node qa/convpixel.test.mjs || status=1
|
||||||
elif [ "$MODE" = "override" ]; then
|
elif [ "$MODE" = "override" ]; then
|
||||||
node qa/override.test.cjs || status=1
|
node qa/override.test.cjs || status=1
|
||||||
elif [ "$MODE" = "gamepass-games" ]; then
|
elif [ "$MODE" = "gamepass-games" ]; then
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ const videosweep = require('./videosweep');
|
|||||||
const sbcheck = require('./sbcheck');
|
const sbcheck = require('./sbcheck');
|
||||||
const reach = require('./reach');
|
const reach = require('./reach');
|
||||||
const lssync = require('./lssync');
|
const lssync = require('./lssync');
|
||||||
|
const lsconv = require('./lsconv'); // conversion tracking: ad click ids pushed to LinkSpin + the member's goals (2026-10-23)
|
||||||
const lsinbound = require('./lsinbound'); // reverse registry sync: LinkSpin-first members arrive as waiting accounts (2026-10-15)
|
const lsinbound = require('./lsinbound'); // reverse registry sync: LinkSpin-first members arrive as waiting accounts (2026-10-15)
|
||||||
const SF = require('./sponsorfollow'); // deliberate sponsor changes follow to LinkSpin until chain-bound + one network tank (2026-10-22)
|
const SF = require('./sponsorfollow'); // deliberate sponsor changes follow to LinkSpin until chain-bound + one network tank (2026-10-22)
|
||||||
let follow = null, followStore = null;
|
let follow = null, followStore = null;
|
||||||
@@ -517,6 +518,7 @@ async function boot() {
|
|||||||
await db.init({ dataDir: DATA_DIR }); // no-op without DATABASE_URL (JSON mode)
|
await db.init({ dataDir: DATA_DIR }); // no-op without DATABASE_URL (JSON mode)
|
||||||
marks.init({ db });
|
marks.init({ db });
|
||||||
marks.ensureTable().catch(e => console.error('marks table', e.message));
|
marks.ensureTable().catch(e => console.error('marks table', e.message));
|
||||||
|
lsconv.init({ db, dataDir: DATA_DIR });
|
||||||
setInterval(() => marks.prune().catch(() => {}), 6 * 3600 * 1000).unref();
|
setInterval(() => marks.prune().catch(() => {}), 6 * 3600 * 1000).unref();
|
||||||
chain.init({ onEvent: ev => {
|
chain.init({ onEvent: ev => {
|
||||||
// the in-memory feed is per instance and always runs
|
// the in-memory feed is per instance and always runs
|
||||||
@@ -3176,7 +3178,7 @@ const server = http.createServer(async (req, res) => {
|
|||||||
if (p === '/api/admin/walletnudge' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, walletnudge.adminView()); }
|
if (p === '/api/admin/walletnudge' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, walletnudge.adminView()); }
|
||||||
if (p === '/api/admin/reach' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, reach.adminView()); }
|
if (p === '/api/admin/reach' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, reach.adminView()); }
|
||||||
if (p === '/api/admin/reach/run' && req.method === 'POST') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); const b = await readBody(req); return json(res, 200, await reach.run({ dry: !!(b && b.dry) })); }
|
if (p === '/api/admin/reach/run' && req.method === 'POST') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); const b = await readBody(req); return json(res, 200, await reach.run({ dry: !!(b && b.dry) })); }
|
||||||
if (p === '/api/admin/lssync' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, Object.assign(lssync.adminView(), { inbound: lsinbound.adminView() })); }
|
if (p === '/api/admin/lssync' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, Object.assign(lssync.adminView(), { inbound: lsinbound.adminView(), conv: lsconv.adminView() })); }
|
||||||
if (p === '/api/admin/lsinbound' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, lsinbound.adminView()); }
|
if (p === '/api/admin/lsinbound' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, lsinbound.adminView()); }
|
||||||
// -- reverse registry sync from LinkSpin (2026-10-15): the same signed rows LinkSpin accepts from us (HMAC LS_SYNC_SECRET
|
// -- reverse registry sync from LinkSpin (2026-10-15): the same signed rows LinkSpin accepts from us (HMAC LS_SYNC_SECRET
|
||||||
// over ts + newline + raw body, 10-minute window). New people become waiting accounts with their LinkSpin line; existing
|
// over ts + newline + raw body, 10-minute window). New people become waiting accounts with their LinkSpin line; existing
|
||||||
@@ -4680,14 +4682,45 @@ const server = http.createServer(async (req, res) => {
|
|||||||
m = /^\/api\/ads\/click\/(\d+)$/.exec(p);
|
m = /^\/api\/ads\/click\/(\d+)$/.exec(p);
|
||||||
if (m && req.method === 'GET') {
|
if (m && req.method === 'GET') {
|
||||||
// an advertiser opening their own ad's link (from Campaigns, a preview, a test) is not a click: relay it uncounted (Marty, 2026-09-30)
|
// an advertiser opening their own ad's link (from Campaigns, a preview, a test) is not a click: relay it uncounted (Marty, 2026-09-30)
|
||||||
let own = false;
|
let own = false, cm = null;
|
||||||
try { const s = await auth.fromRequest(req); if (s && s.email) { const cm = await ads.campaignById(m[1]); own = !!(cm && cm.owner && String(cm.owner).toLowerCase() === String(s.email).toLowerCase()); } } catch (e) {}
|
try { cm = await ads.campaignById(m[1]); } catch (e) {}
|
||||||
|
try { const s = cm && await auth.fromRequest(req); if (s && s.email) own = !!(cm.owner && String(cm.owner).toLowerCase() === String(s.email).toLowerCase()); } catch (e) {}
|
||||||
const target = own ? await ads.targetOf(m[1]) : await ads.click(m[1]);
|
const target = own ? await ads.targetOf(m[1]) : await ads.click(m[1]);
|
||||||
if (!target) { res.writeHead(404, baseHeaders()); return res.end(); }
|
if (!target) { res.writeHead(404, baseHeaders()); return res.end(); }
|
||||||
if (!own) coach.recordClick(m[1], req.headers.referer); // where the click happened
|
if (!own) coach.recordClick(m[1], req.headers.referer); // where the click happened
|
||||||
res.writeHead(302, baseHeaders({ Location: target }));
|
// conversion tracking (2026-10-23): every click, the owner's own too (flagged self, so they can test), gets a click id
|
||||||
|
// on the target URL as lsclk=<id>; the row goes to LinkSpin, which matches the advertiser's goal pixel to it
|
||||||
|
let loc = target;
|
||||||
|
if (cm) { try { const ip = clientIp(req); const row = await lsconv.record(cm, req, { self: own, target, ip, country: geo.countryOf(ip) || null }); loc = lsconv.withClickId(target, row.id); } catch (e) { console.error('lsconv record', e.message); } }
|
||||||
|
res.writeHead(302, baseHeaders({ Location: loc }));
|
||||||
return res.end();
|
return res.end();
|
||||||
}
|
}
|
||||||
|
// Campaigns > Conversion tracking: the member's goals and counts live on LinkSpin; these proxy the signed calls
|
||||||
|
if (p === '/api/my/conversions' && req.method === 'GET') {
|
||||||
|
const s = await auth.fromRequest(req);
|
||||||
|
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||||
|
if (!lsconv.on()) return json(res, 200, { ok: false, reason: 'off', error: 'Conversion tracking is not switched on yet. Your ads and clicks work as usual.' });
|
||||||
|
try { return json(res, 200, Object.assign({}, await lsconv.summary(s.email, u.searchParams.get('fresh') === '1'), { ok: true })); }
|
||||||
|
catch (e) { return json(res, 200, { ok: false, reason: 'down', error: 'LinkSpin, the service that counts your conversions, did not answer just now. Your ads and clicks are fine. Try again in a minute.' }); }
|
||||||
|
}
|
||||||
|
if ((p === '/api/my/conversions/goal' || p === '/api/my/conversions/test') && req.method === 'POST') {
|
||||||
|
const s = await auth.fromRequest(req);
|
||||||
|
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||||
|
if (!lsconv.on()) return json(res, 503, { error: 'Conversion tracking is not switched on yet.' });
|
||||||
|
const b = await readBody(req) || {};
|
||||||
|
const op = p.endsWith('/test') ? 'test' : String(b.op || '');
|
||||||
|
if (!['create', 'update', 'remove', 'test'].includes(op)) return json(res, 400, { error: 'Unknown action.' });
|
||||||
|
const f = {};
|
||||||
|
if (op !== 'create') { const px = String(b.px || '').trim().toLowerCase(); if (!/^px[0-9a-f]{10}$/.test(px)) return json(res, 400, { error: 'That pixel id does not look right.' }); f.px = px; }
|
||||||
|
if (op === 'create' || op === 'update') {
|
||||||
|
if (b.name != null) { const nm = String(b.name).trim().toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9_-]/g, '').slice(0, 32); if (!nm) return json(res, 400, { error: 'Give the goal a short name, like subscriber or sale (letters, numbers, dashes).' }); f.name = nm; }
|
||||||
|
else if (op === 'create') return json(res, 400, { error: 'Give the goal a short name, like subscriber or sale.' });
|
||||||
|
if (b.value != null && String(b.value).trim() !== '') { const v = Number(b.value); if (!isFinite(v) || v < 0 || v > 1e6) return json(res, 400, { error: 'The value should be a number, like 19.95, or left empty.' }); f.value = Math.round(v * 100) / 100; }
|
||||||
|
else if (op === 'update' && b.value != null) f.value = null;
|
||||||
|
}
|
||||||
|
try { return json(res, 200, Object.assign({ ok: true }, await lsconv.goalOp(s.email, op, f))); }
|
||||||
|
catch (e) { return json(res, e.plain && e.status && e.status < 500 ? 400 : 502, { error: e.plain ? e.message : 'LinkSpin did not answer just now. Nothing was changed. Try again in a minute.' }); }
|
||||||
|
}
|
||||||
if (p === '/api/my/trace' && req.method === 'GET') { // payment trace for yourself or anyone within 3 levels of you, either direction
|
if (p === '/api/my/trace' && req.method === 'GET') { // payment trace for yourself or anyone within 3 levels of you, either direction
|
||||||
const s = await auth.fromRequest(req);
|
const s = await auth.fromRequest(req);
|
||||||
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
|
||||||
|
|||||||
Reference in New Issue
Block a user