Conversion linkage, InstantAdPay side (Marty 2026-11-07, "Yes ship these"): a LinkSpin click stays with the account, and its sign-up, wallet link and each package purchase are reported to LinkSpin. Reporting only: no sponsor, payout, credit or chain path changes; accounts.js only gains a notification after a wallet is linked.
lsreport.js. A click id (lsclk or lsid) arriving on any page is kept in a first-party cookie iap.lsclk, 30 days, last click wins, like the sponsor cookie. The join page also sends its own copy with the code request and verify (the cookie is refused in traffic-exchange frames and never crosses browsers, the 2026-09-29 lesson) and it is remembered per email. It is stored in its own table ls_account_clicks when the account is created or a waiting LinkSpin shell is claimed, on /api/signup, email sign-in and in-game sign-in (a game may pass lsclk; none does yet). Reports queue in ls_events, whose primary key is the idempotency key (join:<hash>, wallet:<hash>, purchase:<tx>:<log index>), so two app copies in a deploy cannot double a row, and LinkSpin dedupes on the same key. A background loop sends them signed, retrying up to every 5 minutes; a sign-up or a purchase never waits on LinkSpin. The purchase hook runs after the existing ev: claim and its value is the USD price on the chain event. A first purchase finds its buyer through the contract's wallet for that member id, since member_id may not be stored yet. Linked positions count as the account's purchases. Past 30 days from the sign-up nothing is queued (LinkSpin's window is from the click). Campaigns > Conversion tracking lists everything the member's clicks led to, and joins, wallets and purchases on each campaign row. Guide, privacy page and chatbot (CANNED + FACTS) updated; common.js, join.js and my.js tags bumped. QA: bash qa/run.sh netconv (54 checks: local InstantAdPay + local LinkSpin + a mock Polygon RPC, a real Purchase log through the real event fan-out, LinkSpin down, two copies racing). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+3
-2
@@ -411,6 +411,7 @@ async function signup(email, password, sponsorRef) {
|
||||
async function login(email, password) { return impl().login(normEmail(email), String(password || '')); }
|
||||
// change listener (2026-10-08): LinkSpin's registry sync hears about created / named / wallet-linked / re-sponsored accounts
|
||||
let changeFn = null; function onChange(fn) { changeFn = fn; } const changed = e => { try { if (changeFn) changeFn(e); } catch (err) {} };
|
||||
let walletFn = null; function onWalletLinked(fn) { walletFn = fn; } // reporting only (lsreport.js, 2026-11-07): told after a main wallet is linked, never in the way of it
|
||||
async function ensure(email, sponsorRef, via, joinedRef) {
|
||||
const e = normEmail(email);
|
||||
if (!EMAIL_RE.test(e)) return { error: 'That email address does not look right.' };
|
||||
@@ -474,7 +475,7 @@ async function downline(email, depth = 3) {
|
||||
async function linkWallet(email, address) {
|
||||
const a = normAddr(address);
|
||||
if (!/^0x[0-9a-f]{40}$/.test(a)) return { error: 'Bad wallet address.' };
|
||||
const r = await impl().linkWallet(normEmail(email), a); if (r && !r.error) changed(normEmail(email)); return r;
|
||||
const r = await impl().linkWallet(normEmail(email), a); if (r && !r.error) { changed(normEmail(email)); try { if (walletFn) walletFn(normEmail(email)); } catch (err) {} } return r;
|
||||
}
|
||||
async function count() { return impl().count(); }
|
||||
// admin: newest-first account list, and re-pointing a member's sponsor (a
|
||||
@@ -509,7 +510,7 @@ async function getChatSettings(email) {
|
||||
return { available: a ? a.chatAvailable !== false : true, mutes: await impl().getMutes(String(email || '').toLowerCase()) };
|
||||
}
|
||||
|
||||
module.exports = { init, signup, login, ensure, onChange, isUnclaimedShell, byEmail, byAddress, byCode, byUsername, byMemberId: id => impl().byMemberId(Number(id) || 0), listAll, identities, setSponsorRef,
|
||||
module.exports = { init, signup, login, ensure, onChange, onWalletLinked, isUnclaimedShell, byEmail, byAddress, byCode, byUsername, byMemberId: id => impl().byMemberId(Number(id) || 0), listAll, identities, setSponsorRef,
|
||||
setUsername, reservedUsername, setMemberId, namesForMembers, listByReferrer, downline, linkWallet, count,
|
||||
setLineBanner: (e, b, t) => impl().setLineBanner(String(e || '').toLowerCase(), b, t),
|
||||
setWallOffers: (e, j) => impl().setWallOffers(String(e || '').toLowerCase(), j),
|
||||
|
||||
@@ -125,6 +125,10 @@ const CANNED = [
|
||||
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 the 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
|
||||
// 2026-11-07 conversion linkage (reporting only)
|
||||
{ id: 'network-conversions', title: 'Sign-ups and purchases on your click', q: ['I sent someone and they joined, why do I not see a conversion?', 'Do sign-ups on InstantAdPay show in my LinkSpin reports?', 'Does the landing tag track InstantAdPay purchases?'], tags: ['conversion tracking', 'lsclk', 'landing tag', 'reports', 'join', 'purchase'],
|
||||
re: /((sign.?ups?|joins?|purchases?|sales?|conversions?).{0,40}(show|count|track|see|report).{0,30}(linkspin|reports?|landing tag|bridge|on my click)|(bridge|landing) page.{0,40}(click id|lsclk|track|count)|landing tag.{0,40}(instantadpay|purchases?|sign.?ups?|joins?))/i,
|
||||
a: 'People you send to InstantAdPay or LinkSpin count with no goal and no pixel, as long as the click reaches the join page. With the LinkSpin landing tag on your page, your links to either site carry the click id, also inside a redirect link of your own. A spin link or Banner Spin pointed straight at either site carries it too. We keep the click 30 days and store it on the account at sign-up, then their sign-up, wallet link and each package they buy within 30 days of the click count on your click: a sign-up and a wallet once per click, each package on its own with its USD price. See them on Campaigns > Conversion tracking and in LinkSpin under Reports, Conversions, next to your goals. Your own account is never counted, a button that only runs a script cannot carry the click, and people who joined before 2026-11-07 cannot be matched afterwards. This is reporting only: it never changes who a sponsor is or what anyone is paid.' },
|
||||
{ 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?', 'How do I set up conversion tracking on WordPress?'], tags: ['conversion tracking', 'goal pixel', 'landing tag', 'cost per goal', 'aweber', 'getresponse', 'wordpress', 'setup guide'],
|
||||
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 its cost per goal (30 days) in credits: the credits that campaign spent in the same 30 days, divided by its goals. 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 fires your real pixel in test mode (Last test updates); to check your real thank-you page, add &test=1 to its pixel and open it once. Tests and your own clicks (on your ads, and on your LinkSpin spin links and Banner Spins) never count in your numbers; the card says how many of your own clicks were kept as tests. The step-by-step guide, with copy-paste examples for plain HTML, WordPress, page builders and autoresponder thank-you pages, how to read the report and a troubleshooting checklist: https://instantadpay.com/conversion-tracking' },
|
||||
@@ -333,6 +337,7 @@ ${passTiersFact()}${heroesFact()}${refuelFact()}${synFact()}${polminerFact()}${w
|
||||
- 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.
|
||||
- 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 LINKAGE (LIVE 2026-11-07, reporting only: it never changes sponsors, payouts, credits or anything on chain): a LinkSpin click id (lsclk or lsid in the address) arriving on any InstantAdPay page is kept 30 days in a first-party cookie (last click wins) and travels with the code request, and is stored with the account at sign-up, in-game sign-in included when the game passes it on. InstantAdPay then reports sign-up, wallet link and each package purchase (value = the USD price on the chain event, linked positions included) to LinkSpin, which counts join and wallet once per click and each purchase on its own, for the click's owner. The landing tag adds the click id to links to instantadpay.com, linkspin.app and the share domains, also inside a member's own redirect link; a spin link or Banner Spin pointed straight at those sites carries it with no goal needed. 30 days from the click to the event, same as goals. The first account on a click owns it. The click owner's own account and own clicks are never counted. People who joined before 2026-11-07 cannot be matched afterwards. Shown on the Conversion tracking card (with goals, 30 days) and in LinkSpin under Reports, Conversions.
|
||||
- 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 (signed in, or from a browser they sign in from; their linked positions share their email so count as them too) and the Send a test conversion button count as tests, never in the numbers; the card shows 'N from your own clicks, kept as tests'. SEND A TEST CONVERSION (2026-10-26) loads the member's real LinkSpin pixel in test mode from their browser (falls back to the signed partner call if the browser blocks it), so Last test updates. Each campaign row shows goals and COST PER GOAL (30 DAYS) in credits (2026-10-26: the credits the campaign spent in the last 30 days, from the credit activity log, divided by its goals in the same 30 days; a campaign started inside the window uses its spend since start; 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. SETUP GUIDE (public, 2026-10-24): https://instantadpay.com/conversion-tracking (LinkSpin's copy: https://linkspin.app/conversion-tracking): why track, the flow, the 4 steps (goal, landing tag, goal pixel, test), copy-paste examples (plain HTML, WordPress footer plugin + Custom HTML block, page builders, Aweber/GetResponse custom thank-you page), the page check (add &test=1 to the pixel address, open the thank-you page, Last test updates, then remove it), what to do without code on the thank-you page, how to read the report and a troubleshooting checklist (same domain for landing and thank-you page, goal pixel only on the thank-you page, the script version is surest). Send members there for any setup question.
|
||||
- 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.
|
||||
|
||||
@@ -173,4 +173,4 @@ async function goalOp(email, op, fields) {
|
||||
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, noteSession, isOwnerSk };
|
||||
module.exports = { signedPost, init, record, flush, summary, goalOp, withClickId, softKey, placementOf, deviceOf, newId, adminView, on, noteSession, isOwnerSk };
|
||||
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
// Conversion linkage, InstantAdPay half (Marty 2026-11-07, "Yes ship these"). REPORTING ONLY: this module never reads or changes a
|
||||
// sponsor, a payout, credits or anything on chain. LinkSpin owns the counting; this keeps the click and tells it what happened.
|
||||
// the click arrives as ?lsclk= or ?lsid= on any page: a first-party cookie iap.lsclk, 30 days, last click wins (the same life
|
||||
// and last-touch rule as the sponsor cookie), plus the page's own copy sent with the code request, because the
|
||||
// cookie is refused inside a traffic-exchange frame and never crosses browsers (the 2026-09-29 sponsor lesson)
|
||||
// the account kept in its own table, ls_account_clicks, keyed by email: remembered when the code is requested, bound when the
|
||||
// account is created (or a waiting LinkSpin shell is claimed). Its own table on purpose: accounts is not touched
|
||||
// the events sign-up, wallet link, each package Purchase on the chain, by an account with a bound click. One row each in
|
||||
// ls_events; its primary key is the idempotency key (join:<hash>, wallet:<hash>, purchase:<tx>:<log index>), so two
|
||||
// app copies during a deploy can both try and only one row exists
|
||||
// the delivery a loop in the background posts unsent rows to LinkSpin (POST /api/partner/conv op events, signed like lsconv), 100
|
||||
// at a time, every ~5 s with backoff to 5 minutes. A row is marked sent only after LinkSpin answers, and LinkSpin
|
||||
// dedupes by the same key, so a row sent by both copies, or twice, counts once
|
||||
// Nothing here runs in the chain event handler's path or in a sign-up's path beyond one local write: LinkSpin down, slow or
|
||||
// blocked changes nothing except that rows wait. No LS_SYNC_SECRET: rows wait too.
|
||||
'use strict';
|
||||
const crypto = require('crypto');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const lsconv = require('./lsconv');
|
||||
|
||||
let R = null, timer = null, flushing = false, fails = 0, nextAt = 0, jstate = null, saveT = null;
|
||||
const stats = { sent: 0, lastAt: null, lastError: null, errors: 0 };
|
||||
const DAY = 86400000, WINDOW = 30 * DAY;
|
||||
const useDb = () => !!(R && R.db && R.db.enabled());
|
||||
const JFILE = () => path.join(R.dataDir, 'lsreport.json');
|
||||
const norm = e => String(e || '').trim().toLowerCase();
|
||||
const isId = v => /^(?:[a-f0-9]{10}|[aik][a-f0-9]{11})$/.test(String(v || ''));
|
||||
const hash = email => crypto.createHash('sha256').update(norm(email)).digest('hex').slice(0, 24);
|
||||
// the id in a page address, or '' (lsclk first: it is the id the landing tag and ad clicks carry)
|
||||
const fromUrl = u => { const v = u.searchParams.get('lsclk') || u.searchParams.get('lsid') || ''; return isId(v) ? v : ''; };
|
||||
const pick = (...vals) => { for (const v of vals) if (isId(v)) return String(v); return ''; };
|
||||
const COOKIE = 'iap.lsclk';
|
||||
const cookieHeader = (id, isProd) => COOKIE + '=' + id + '; Path=/; Max-Age=' + (30 * 86400) + '; ' + (isProd ? 'SameSite=None; Secure' : 'SameSite=Lax');
|
||||
|
||||
function init(deps) {
|
||||
R = deps;
|
||||
if (useDb()) ensureTables().catch(e => console.error('lsreport tables', e.message));
|
||||
if (!deps.noTimers) {
|
||||
if (!timer) { timer = setInterval(() => { flush().catch(() => {}); }, 5000); if (timer.unref) timer.unref(); }
|
||||
setInterval(() => prune().catch(() => {}), 6 * 3600 * 1000).unref();
|
||||
}
|
||||
}
|
||||
// column names checked against MySQL 8 reserved words (none of email, click_id, ts, bound, k, ev, cents, ev_ts, tx, sk, pushed, outcome is reserved)
|
||||
async function ensureTables() {
|
||||
await R.db.q(`CREATE TABLE IF NOT EXISTS ls_account_clicks (
|
||||
email VARCHAR(190) PRIMARY KEY,
|
||||
click_id VARCHAR(16) NOT NULL,
|
||||
ts BIGINT NOT NULL,
|
||||
bound TINYINT NOT NULL DEFAULT 0
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4`);
|
||||
await R.db.q(`CREATE TABLE IF NOT EXISTS ls_events (
|
||||
k VARCHAR(120) PRIMARY KEY,
|
||||
ev VARCHAR(10) NOT NULL,
|
||||
email VARCHAR(190) NOT NULL,
|
||||
click_id VARCHAR(16) NOT NULL,
|
||||
cents INT NOT NULL DEFAULT 0,
|
||||
ev_ts BIGINT NOT NULL,
|
||||
tx VARCHAR(80) NULL,
|
||||
sk VARCHAR(24) NULL,
|
||||
pushed TINYINT NOT NULL DEFAULT 0,
|
||||
outcome VARCHAR(12) NULL,
|
||||
INDEX (pushed, ev_ts)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4`);
|
||||
}
|
||||
|
||||
// ---- JSON store (local runs) ----
|
||||
function jload() { if (jstate) return jstate; try { jstate = JSON.parse(fs.readFileSync(JFILE(), 'utf8')); if (!jstate.clicks || !Array.isArray(jstate.events)) throw 0; } catch (e) { jstate = { clicks: {}, events: [] }; } return jstate; }
|
||||
function jsave() { if (saveT) return; saveT = setTimeout(() => { saveT = null; try { fs.writeFileSync(JFILE(), JSON.stringify(jload())); } catch (e) {} }, 300); if (saveT.unref) saveT.unref(); }
|
||||
|
||||
// ---- the click on the account ----
|
||||
async function clickOf(email) {
|
||||
const e = norm(email);
|
||||
if (useDb()) { const r = (await R.db.q('SELECT click_id, ts, bound FROM ls_account_clicks WHERE email=?', [e]))[0]; return r ? { click: r.click_id, ts: Number(r.ts), bound: Number(r.bound) ? 1 : 0 } : null; }
|
||||
return jload().clicks[e] || null;
|
||||
}
|
||||
// at the code request: the click travels with the email, so verifying in another browser still finds it. Last click wins until bound.
|
||||
async function remember(email, click) {
|
||||
const e = norm(email); if (!e || e.length > 190 || !isId(click)) return false;
|
||||
const now = Date.now();
|
||||
if (useDb()) { await R.db.q('INSERT INTO ls_account_clicks (email, click_id, ts, bound) VALUES (?,?,?,0) ON DUPLICATE KEY UPDATE click_id=IF(bound=0,VALUES(click_id),click_id), ts=IF(bound=0,VALUES(ts),ts)', [e, click, now]); return true; }
|
||||
const st = jload(); if (st.clicks[e] && st.clicks[e].bound) return false; st.clicks[e] = { click, ts: now, bound: 0 }; jsave(); return true;
|
||||
}
|
||||
// the account now exists: bind the click (this request's, else the remembered one), once, and queue the join
|
||||
async function signup(email, click, sk) {
|
||||
const e = norm(email); if (!e || e.length > 190) return false;
|
||||
const row = await clickOf(e); if (row && row.bound) return false;
|
||||
const c = isId(click) ? click : (row && Date.now() - row.ts <= WINDOW ? row.click : ''); if (!c) return false;
|
||||
const now = Date.now();
|
||||
if (useDb()) {
|
||||
await R.db.q('INSERT IGNORE INTO ls_account_clicks (email, click_id, ts, bound) VALUES (?,?,?,0)', [e, c, now]);
|
||||
const u = await R.db.q('UPDATE ls_account_clicks SET click_id=?, ts=?, bound=1 WHERE email=? AND bound=0', [c, now, e]);
|
||||
if (!(u && u.affectedRows === 1)) return false;
|
||||
} else { const st = jload(); st.clicks[e] = { click: c, ts: now, bound: 1 }; jsave(); }
|
||||
await enqueue({ k: 'join:' + hash(e), ev: 'join', email: e, click: c, cents: 0, ts: now, sk: /^s:[a-f0-9]{20}$/.test(String(sk || '')) ? sk : null });
|
||||
return true;
|
||||
}
|
||||
async function wallet(email) {
|
||||
const e = norm(email); const row = await clickOf(e); if (!row || !row.bound) return false;
|
||||
return enqueue({ k: 'wallet:' + hash(e), ev: 'wallet', email: e, click: row.click, cents: 0, ts: Date.now() });
|
||||
}
|
||||
// a Purchase chain event, already resolved to its account. Value = the USD price on the event. Linked positions sit on the same
|
||||
// account, so they count as that account's purchases. Past the click window nothing is queued: LinkSpin would refuse it anyway
|
||||
// (the bind is never earlier than the click, so more than 30 days after the bind is more than 30 days after the click).
|
||||
async function purchase(ev, email) {
|
||||
const e = norm(email); const cents = Number(ev && ev.priceCents) || 0; if (!e || cents <= 0 || !ev.tx) return false;
|
||||
const row = await clickOf(e); if (!row || !row.bound) return false;
|
||||
const ts = Number(ev.ts) || Date.now();
|
||||
if (ts < row.ts - 60000 || ts - row.ts > WINDOW) return false; // before the sign-up, or past the window
|
||||
return enqueue({ k: ('purchase:' + ev.tx + ':' + ev.li).slice(0, 120), ev: 'purchase', email: e, click: row.click, cents, ts, tx: String(ev.tx).slice(0, 80) });
|
||||
}
|
||||
async function enqueue(x) {
|
||||
if (useDb()) { const r = await R.db.q('INSERT IGNORE INTO ls_events (k, ev, email, click_id, cents, ev_ts, tx, sk, pushed) VALUES (?,?,?,?,?,?,?,?,0)', [x.k, x.ev, x.email, x.click, x.cents, x.ts, x.tx || null, x.sk || null]); return !!(r && r.affectedRows === 1); }
|
||||
const st = jload(); if (st.events.some(r => r.k === x.k)) return false; st.events.push(Object.assign({ pushed: 0 }, x)); if (st.events.length > 5000) st.events = st.events.slice(-4000); jsave(); return true;
|
||||
}
|
||||
|
||||
// ---- delivery ----
|
||||
async function unsent(n) {
|
||||
if (useDb()) return (await R.db.q('SELECT k, ev, email, click_id, cents, ev_ts, tx, sk FROM ls_events WHERE pushed=0 ORDER BY ev_ts LIMIT ?', [n])).map(r => ({ k: r.k, ev: r.ev, email: r.email, click: r.click_id, cents: Number(r.cents) || 0, ts: Number(r.ev_ts), tx: r.tx, sk: r.sk }));
|
||||
return jload().events.filter(r => !r.pushed).slice(0, n);
|
||||
}
|
||||
async function markSent(k, outcome) {
|
||||
if (useDb()) { await R.db.q('UPDATE ls_events SET pushed=1, outcome=? WHERE k=?', [String(outcome || '').slice(0, 12) || null, k]); return; }
|
||||
const r = jload().events.find(x => x.k === k); if (r) { r.pushed = 1; r.outcome = outcome; jsave(); }
|
||||
}
|
||||
async function flush() {
|
||||
if (!lsconv.on() || flushing || Date.now() < nextAt) return { skipped: true };
|
||||
flushing = true; let sent = 0;
|
||||
try {
|
||||
for (let round = 0; round < 10; round++) {
|
||||
const rows = await unsent(100); if (!rows.length) break;
|
||||
const res = await lsconv.signedPost('/api/partner/conv', { op: 'events', events: rows.map(r => ({ k: r.k, ev: r.ev, email: r.email, click: r.click, value: r.cents / 100, ts: r.ts, tx: r.tx || undefined, sk: r.sk || undefined })) }, 15000);
|
||||
if (!res || res.ok !== true || !Array.isArray(res.results)) throw new Error('linkspin answered without results');
|
||||
for (const a of res.results) { await markSent(a.k, a.result); sent++; stats.sent++; }
|
||||
stats.lastAt = Date.now();
|
||||
if (rows.length < 100) break;
|
||||
}
|
||||
fails = 0; nextAt = 0; return { sent };
|
||||
} catch (e) {
|
||||
fails++; stats.errors++; stats.lastError = e.message; nextAt = Date.now() + Math.min(300000, 5000 * Math.pow(2, Math.min(fails, 6)));
|
||||
if (fails <= 3 || fails % 20 === 0) console.error('lsreport push', e.message);
|
||||
return { error: e.message, sent };
|
||||
} finally { flushing = false; }
|
||||
}
|
||||
async function prune() {
|
||||
const now = Date.now(); const old = now - 60 * DAY, stale = now - 31 * DAY;
|
||||
if (useDb()) { await R.db.q('DELETE FROM ls_events WHERE ev_ts<?', [old]); await R.db.q('DELETE FROM ls_account_clicks WHERE (bound=0 AND ts<?) OR ts<?', [stale, old]); return; }
|
||||
const st = jload(); st.events = st.events.filter(r => r.ts >= old); for (const k of Object.keys(st.clicks)) { const c = st.clicks[k]; if (c.ts < old || (!c.bound && c.ts < stale)) delete st.clicks[k]; } jsave();
|
||||
}
|
||||
function adminView() { return { on: lsconv.on(), sent: stats.sent, lastAt: stats.lastAt, errors: stats.errors, lastError: stats.lastError, fails, nextAt: nextAt || null }; }
|
||||
module.exports = { init, ensureTables, fromUrl, pick, cookieHeader, COOKIE, isId, remember, signup, wallet, purchase, clickOf, flush, prune, adminView };
|
||||
+1
-1
@@ -651,7 +651,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/common.js?v=20261107nc"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/admin-kb.js?v=20261020kb"></script>
|
||||
<script src="/assets/admin.js?v=20261107tg"></script><script src="/assets/admin-sponsorcheck.js?v=20261107tg"></script><script src="/assets/admin-kits.js?v=20261101th"></script>
|
||||
</body>
|
||||
|
||||
@@ -191,7 +191,7 @@ window.IAP = (function () {
|
||||
await formSettled();
|
||||
for (let i = 0; i < 4; i++) {
|
||||
const r = await (await fetch('/api/auth/email/start', { method: 'POST', headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ email, fts: FORM_TS, fage: Date.now() - FORM_TS, hp_field_x9: hpValue(o.honeypot), pick, ref: o.ref || null, angle: o.angle || null }) })).json(); // ref = the join page's own link token, so the sponsor survives a lost cookie
|
||||
body: JSON.stringify({ email, fts: FORM_TS, fage: Date.now() - FORM_TS, hp_field_x9: hpValue(o.honeypot), pick, ref: o.ref || null, angle: o.angle || null, lsclk: o.lsclk || null }) })).json(); // ref = the join page's own link token, so the sponsor survives a lost cookie
|
||||
if (r.challenge && o.host) { pick = await iconCheck(o.host, r.challenge, r.error); continue; }
|
||||
if (r.error) throw new Error(r.error);
|
||||
return r;
|
||||
|
||||
@@ -84,7 +84,8 @@
|
||||
function busy(btn, fn) {
|
||||
return async () => { if (btn.disabled) return; btn.disabled = true; err(''); try { await fn(); } catch (e) { err(e.message || 'Something went wrong.'); } finally { btn.disabled = false; } };
|
||||
}
|
||||
const codeOpts = () => ({ honeypot: $('jnWebsite'), host: $('jnCheck'), ref: linkTok, angle: v || '' }); // the page's own token rides with the code request (cookie may be blocked in a frame)
|
||||
const pageClick = (() => { const q = new URLSearchParams(location.search); return q.get('lsclk') || q.get('lsid') || ''; })(); // the LinkSpin click in this page's address: travels with the requests, the cookie may be refused in a frame (reporting only)
|
||||
const codeOpts = () => ({ honeypot: $('jnWebsite'), host: $('jnCheck'), ref: linkTok, angle: v || '', lsclk: pageClick }); // the page's own token rides with the code request (cookie may be blocked in a frame)
|
||||
const send = busy($('jnSend'), async () => {
|
||||
const r = await IAP.requestCode($('jnEmail').value, codeOpts());
|
||||
$('jnCodeRow').hidden = false; $('jnVerify').hidden = false; $('jnSend').hidden = true; $('jnResend').hidden = false;
|
||||
@@ -105,7 +106,7 @@
|
||||
IAP.status('Fresh code sent.', 'ok');
|
||||
}));
|
||||
$('jnVerify').addEventListener('click', busy($('jnVerify'), async () => {
|
||||
await api('/api/auth/email/verify', { email: $('jnEmail').value, code: $('jnCode').value, newsletter: !!$('jnNews').checked, followups: !!$('jnNews').checked, ref: linkTok });
|
||||
await api('/api/auth/email/verify', { email: $('jnEmail').value, code: $('jnCode').value, newsletter: !!$('jnNews').checked, followups: !!$('jnNews').checked, ref: linkTok, lsclk: pageClick });
|
||||
IAP.status('You are in. Taking you to your dashboard…', 'ok');
|
||||
location.href = '/my?welcome=1'; // dashboard runs the username step + welcome tour on arrival
|
||||
}));
|
||||
|
||||
+5
-1
@@ -1201,7 +1201,7 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
||||
else if (Number(c.created) >= since) { spent = Number(c.spent || 0); basis = 'the credits it spent since it started on ' + new Date(Number(c.created)).toLocaleDateString([], { month: 'short', day: 'numeric' }) + ', inside the 30 days'; }
|
||||
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 && spent != null ? ' (' + convFmt(spent / n) + ' credits each)' : '') + '</span>'; });
|
||||
el.innerHTML = '\u{1F3AF} <span class="muted">Goals and cost per goal (30 days):</span> ' + parts.join(' · ') + (spent == null ? ' <span class="muted">· no spend on record for these 30 days, so no cost per goal</span>' : '') + (b && b.clicks ? ' <span class="muted">· ' + Number(b.clicks).toLocaleString() + ' tracked clicks</span>' : '');
|
||||
el.innerHTML = '\u{1F3AF} <span class="muted">Goals and cost per goal (30 days):</span> ' + parts.join(' · ') + (spent == null ? ' <span class="muted">· no spend on record for these 30 days, so no cost per goal</span>' : '') + (b && b.clicks ? ' <span class="muted">· ' + Number(b.clicks).toLocaleString() + ' tracked clicks</span>' : '') + (() => { const nb = ((d.network || {}).byCampaign || {})[id]; if (!nb) return ''; const bits = [['join', 'joins'], ['wallet', 'wallets'], ['purchase', 'purchases']].filter(([k]) => nb[k]).map(([k, l]) => nb[k].toLocaleString() + ' ' + l); return bits.length ? ' <span>· ' + bits.join(' · ') + (nb.value ? ' ($' + Number(nb.value).toFixed(2) + ')' : '') + '</span>' : ''; })();
|
||||
el.title = 'Goals counted for this campaign in the last 30 days. Cost per goal (30 days) = ' + (spent != null ? basis : 'the credits it spent in the same 30 days') + ', divided by those goals.';
|
||||
el.hidden = false;
|
||||
});
|
||||
@@ -1215,6 +1215,10 @@ function shareLink(ref) { return SHARE_DOMAIN && /^[A-Za-z0-9_]{1,40}$/.test(Str
|
||||
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;
|
||||
// network events (2026-11-07): sign-ups, wallets and purchases on the member's clicks, plus goals, each once (LinkSpin's one list)
|
||||
{ const nt = $('convNet'), rows = (d.network && d.network.rows) || []; const NAME = { join: 'joins', lead: 'leads', wallet: 'wallets', purchase: 'purchases', external: 'partner postbacks' };
|
||||
nt.hidden = !rows.length;
|
||||
if (rows.length) nt.innerHTML = '<b>Everything your clicks led to (30 days):</b> ' + rows.map(x => esc(Number(x.n).toLocaleString() + ' ' + (NAME[x.k] || String(x.k).replace(/^goal:\s*/, '') + ' (goal)')) + (x.value ? ' ($' + Number(x.value).toFixed(2) + ')' : '')).join(' \u00b7 ') + '.'; }
|
||||
const goals = d.goals || [];
|
||||
const m = d.methods || {}; const mt = ['url', 'stored', 'cookie', 'soft'].reduce((s, k) => s + (Number(m[k]) || 0), 0);
|
||||
const selfN = Number(d.selfTests) || 0; // own clicks (ads here, spin links and Banner Spins on LinkSpin), kept as tests
|
||||
|
||||
+1
-1
@@ -165,7 +165,7 @@
|
||||
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/common.js?v=20261101th"></script>
|
||||
<script src="/assets/common.js?v=20261107nc"></script>
|
||||
<script src="/assets/bixpay-guide.js?v=20261029bz"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -143,7 +143,7 @@
|
||||
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees. Crypto transactions are irreversible. Never spend what you cannot afford.</div>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/common.js?v=20261107nc"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/contract.js?v=20260908p"></script>
|
||||
<script src="/assets/chat.js?v=20261016n"></script>
|
||||
</body>
|
||||
|
||||
@@ -119,6 +119,7 @@
|
||||
<li class="f-win"><span class="k">5</span><b>Counted on your campaign</b>The goal shows on the ad that sent them, with its cost per goal in credits.</li>
|
||||
</ol>
|
||||
<p class="rg-note">The id is random. It identifies the click, not the person. Nothing personal is read from your page or sent anywhere.</p>
|
||||
<p class="rg-note"><b>Sending people to InstantAdPay or LinkSpin?</b> Those two count by themselves, with no goal and no pixel. The landing tag adds the click id to your links to either site, also when the address sits inside a redirect link of your own. A LinkSpin spin link or Banner Spin pointed straight at either site carries it too. Their sign-up, wallet link and each package they buy within 30 days of the click then show on your Conversion tracking card and in LinkSpin under Reports, Conversions, purchases with their USD price. This is reporting only. It never changes who a sponsor is or what anyone is paid.</p>
|
||||
|
||||
<p class="rg-eye">Set it up</p>
|
||||
<h2>Four steps, one time</h2>
|
||||
@@ -252,7 +253,8 @@
|
||||
<div><dt>Will the tags slow down or break my page?</dt><dd>No. Both load in the background, never stop your page from showing, and do nothing visible. If LinkSpin cannot be reached, your page works exactly as before.</dd></div>
|
||||
<div><dt>Do I need a separate goal for each ad?</dt><dd>No. One goal covers all your ads. Each conversion is counted against whichever ad sent that visitor.</dd></div>
|
||||
<div><dt>Do my ads get the click id automatically?</dt><dd>Yes. Every click through your InstantAdPay ads carries one. Your page address keeps all its own parameters; the click id is added to the end.</dd></div>
|
||||
<div><dt>Is any personal data sent?</dt><dd>No. The click id is random. No name or email from your page is read or sent.</dd></div>
|
||||
<div><dt>Is any personal data sent?</dt><dd>No. The click id is random. No name or email from your page is read or sent. When someone joins here on your click, the two sites match the event to your click server to server, and your reports show counts and values, never who the person is.</dd></div>
|
||||
<div><dt>Why does a sign-up I sent not show?</dt><dd>The click has to reach the join page. Check that your landing tag is on the page and the link is a real link (a button that only runs a script cannot carry it), and that the visitor opened it from your click within the last 30 days. A sign-up and a wallet count once per click, each package counts on its own, and your own account is left out. People who joined before this was switched on on 2026-11-07 cannot be matched afterwards.</dd></div>
|
||||
</dl>
|
||||
|
||||
<div class="rg-rule"><b>What a credit is.</b> One credit is one cent of ad delivery across the network. Credits are not money and cannot be withdrawn. Cost per goal is shown in credits for that reason.</div>
|
||||
@@ -263,7 +265,7 @@
|
||||
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/common.js?v=20261101th"></script>
|
||||
<script src="/assets/common.js?v=20261107nc"></script>
|
||||
<script src="/assets/conversion-guide.js?v=20261024ct"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<p class="muted small">You decide whether, and how much, to spend. Never spend more than you can afford to lose.</p>
|
||||
</div>
|
||||
</div></section>
|
||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/common.js?v=20261107nc"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/legal.js?v=20260908a"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+1
-1
@@ -97,6 +97,6 @@
|
||||
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/common.js?v=20261107nc"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+1
-1
@@ -127,7 +127,7 @@
|
||||
</ul>
|
||||
</div>
|
||||
</div></section>
|
||||
<script src="/assets/common.js?v=20261101th"></script>
|
||||
<script src="/assets/common.js?v=20261107nc"></script>
|
||||
<script src="/assets/legal.js?v=20260908a"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+1
-1
@@ -72,6 +72,6 @@
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/friday.js?v=20260925a"></script>
|
||||
<script src="/assets/common.js?v=20261101th"></script>
|
||||
<script src="/assets/common.js?v=20261107nc"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+1
-1
@@ -79,6 +79,6 @@
|
||||
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/games-page.js?v=20261012b"></script>
|
||||
<script src="/assets/common.js?v=20261107nc"></script><script src="/assets/games-page.js?v=20261012b"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+1
-1
@@ -506,7 +506,7 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/common.js?v=20261107nc"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/wallet.js?v=20260909c"></script>
|
||||
<script src="/assets/home.js?v=20261027tb"></script>
|
||||
<script src="/assets/chat.js?v=20261016n"></script>
|
||||
|
||||
+2
-2
@@ -158,7 +158,7 @@
|
||||
InstantAdPay · <a href="/contract">Contract</a> · <a href="/terms">Terms</a> · <a href="/privacy">Privacy</a> · <a href="/disclaimer">Disclaimer</a>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/join.js?v=20261016p"></script>
|
||||
<script src="/assets/common.js?v=20261107nc"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/join.js?v=20261107nc"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@
|
||||
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/common.js?v=20261107nc"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/launch.js?v=20260915b"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@
|
||||
<div class="small">InstantAdPay is the Polygon hub of the <a href="https://cryptoteambuild.com" target="_blank" rel="noopener">Crypto Team Build Network</a>.</div>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/common.js?v=20261107nc"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/ledger.js?v=20260906m"></script>
|
||||
<script src="https://polhunter.com/embed.js" data-slots="1" async></script>
|
||||
<script src="/assets/chat.js?v=20261016n"></script>
|
||||
|
||||
+4
-3
@@ -638,13 +638,14 @@
|
||||
<div class="card" id="convCard" hidden>
|
||||
<h3>Conversion tracking</h3>
|
||||
<p class="small" style="margin:0 0 6px"><a href="/conversion-tracking" target="_blank" rel="noopener">How to set it up: the step-by-step guide with copy-paste examples</a></p>
|
||||
<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>
|
||||
<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. People you send to InstantAdPay or LinkSpin count without any goal: with the landing tag on your page, or a spin link pointed straight at the join page, their sign-up, wallet link and package purchases within 30 days of the click show below, with values. This is reporting only: it never changes who a sponsor is or what anyone is paid. The full list is in LinkSpin under Reports, Conversions.</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>
|
||||
<p class="small" id="convNet" hidden></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>
|
||||
@@ -1270,11 +1271,11 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/common.js?v=20261107nc"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/wallet.js?v=20260911a"></script>
|
||||
<script src="/assets/promo.js?v=20261103gp"></script>
|
||||
<script src="/assets/support.js?v=20261101th"></script>
|
||||
<script src="/assets/my.js?v=20261107tg"></script>
|
||||
<script src="/assets/my.js?v=20261107nc"></script>
|
||||
<script src="/assets/fuel.js?v=20261025ff"></script>
|
||||
<script src="/assets/engine-room.js?v=20261101th"></script>
|
||||
<script src="/assets/chat.js?v=20261016n"></script>
|
||||
|
||||
@@ -131,7 +131,7 @@
|
||||
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees. Crypto transactions are irreversible. Never spend what you cannot afford to lose.</div>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/common.js?v=20261107nc"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/partners.js?v=20260914a"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+1
-1
@@ -194,7 +194,7 @@
|
||||
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees. Crypto transactions are irreversible. Never spend what you cannot afford.</div>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/common.js?v=20261107nc"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/plays.js?v=20260910b"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -87,6 +87,6 @@
|
||||
<div class="small">InstantAdPay is the Polygon hub of the <a href="https://cryptoteambuild.com" target="_blank" rel="noopener">Crypto Team Build Network</a>.</div>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/presentation.js?v=20261015b"></script>
|
||||
<script src="/assets/common.js?v=20261107nc"></script><script src="/assets/presentation.js?v=20261015b"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@
|
||||
<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>
|
||||
<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>
|
||||
<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. If you arrive here from a LinkSpin click (the address carries lsclk or lsid), we keep that click id in a cookie for 30 days and with your account when you join, and tell LinkSpin about your sign-up, wallet link and package purchases on that click. The owner of the click sees counts and values in their reports, never who you are.</p>
|
||||
<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>
|
||||
<h3>Your choices</h3>
|
||||
@@ -32,7 +32,7 @@
|
||||
<p class="muted small">We use reasonable safeguards, but no system is perfectly secure. Protect your email and your wallet.</p>
|
||||
</div>
|
||||
</div></section>
|
||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/common.js?v=20261107nc"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/legal.js?v=20260908a"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -261,6 +261,6 @@
|
||||
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees.</div>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/common.js?v=20261101th"></script>
|
||||
<script src="/assets/common.js?v=20261107nc"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
<div id="supMain"><div class="card"><p class="muted small">Loading…</p></div></div>
|
||||
<p class="small muted">We will never ask for your recovery phrase or private key, and nobody from InstantAdPay will message you first asking for money or wallet access.</p>
|
||||
</div></section>
|
||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/common.js?v=20261107nc"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/legal.js?v=20260908a"></script>
|
||||
<script src="/assets/support.js?v=20261101th"></script>
|
||||
<script src="/assets/chat.js?v=20261016n"></script>
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@
|
||||
<p class="muted small" style="margin-top:18px">See also the <a href="/disclaimer">Disclaimer</a> and <a href="/privacy">Privacy Policy</a>. Questions: the <a href="/support">support page</a> or <a href="mailto:support@instantadpay.com">support@instantadpay.com</a>.</p>
|
||||
</div>
|
||||
</div></section>
|
||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/common.js?v=20261107nc"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/legal.js?v=20260908a"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@
|
||||
<p><a href="/ledger">← Back to the live ledger</a> · <a href="/contract">Read the contract review</a></p>
|
||||
</div>
|
||||
</section>
|
||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/common.js?v=20261107nc"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/tx.js?v=20260906m"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/common.js?v=20261107nc"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/wall.js?v=20261030pp"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+1
-1
@@ -123,7 +123,7 @@
|
||||
<div class="small">Advertising services with a performance referral program. Not an investment product; no income guarantees. Crypto transactions are irreversible. Never share your recovery phrase.</div>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/common.js?v=20261101th"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/common.js?v=20261107nc"></script><script src="/assets/welcome.js?v=20261101th"></script>
|
||||
<script src="/assets/wallets.js?v=20260911b"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -65,6 +65,6 @@
|
||||
</footer>
|
||||
</div>
|
||||
<script src="/assets/wednesday.js?v=20260929c"></script>
|
||||
<script src="/assets/common.js?v=20261101th"></script>
|
||||
<script src="/assets/common.js?v=20261107nc"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// QA only, loaded with node --require by qa/netconv.test.mjs: chain.js talks https to its RPC; a local mock RPC speaks plain http.
|
||||
const https = require('https'), http = require('http');
|
||||
const PORT = Number(process.env.QA_RPC_PORT);
|
||||
const real = https.request;
|
||||
https.request = function (opts, cb) {
|
||||
if (opts && opts.hostname === '127.0.0.1') return http.request(Object.assign({}, opts, { port: PORT }), cb);
|
||||
return real.apply(https, arguments);
|
||||
};
|
||||
@@ -0,0 +1,245 @@
|
||||
// Conversion linkage end to end (2026-11-07, reporting only). Boots a local InstantAdPay AND a local LinkSpin on throwaway data dirs
|
||||
// (JSON stores, no DATABASE_URL, no mail key), pointed only at each other with a throwaway secret, and a mock Polygon RPC, so a real
|
||||
// Purchase log goes through the real chain.js and the real event fan-out. Nothing touches production or a real member.
|
||||
// node qa/netconv.test.mjs (or bash qa/run.sh netconv). Needs the LinkSpin repo beside this one (LS_SITE to override).
|
||||
// The funnel: spin link -> /join?lsclk -> cookie -> sign-up -> join counted on LinkSpin; wallet link signed with a throwaway key ->
|
||||
// wallet counted; Purchase on the mock chain, before member_id is stored -> purchase counted with its USD value, once, even when the
|
||||
// mock serves the log to a second scan; Reports and the Campaigns card show them. Sponsor stays exactly what the join link set.
|
||||
// Also: the page's own copy of the click (no cookie), own account not counted, LinkSpin down blocks nothing and the rows arrive later,
|
||||
// duplicate delivery. Part 2: lsreport.js against a fake SQL layer, two app copies racing the same events.
|
||||
import { spawn } from 'node:child_process';
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import http from 'node:http';
|
||||
import crypto from 'node:crypto';
|
||||
import { createRequire } from 'node:module';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
const require = createRequire(import.meta.url);
|
||||
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
||||
const IAP_SITE = path.join(HERE, '..');
|
||||
const LS_SITE = process.env.LS_SITE || path.join(IAP_SITE, '..', '..', 'linkspin', 'site');
|
||||
const SECRET = 'qa-netconv-' + crypto.randomBytes(24).toString('hex');
|
||||
const P = Number(process.env.NC_PORT || 8861), IAP = 'http://127.0.0.1:' + P, LS = 'http://127.0.0.1:' + (P + 1), RPC_PORT = P + 2;
|
||||
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
||||
let pass = 0, fail = 0;
|
||||
const ok = (c, name, extra) => { if (c) pass++; else fail++; console.log((c ? 'PASS ' : 'FAIL ') + name + (!c && extra !== undefined ? ' :: ' + (typeof extra === 'string' ? extra : JSON.stringify(extra)) : '')); };
|
||||
async function waitFor(fn, ms) { const t0 = Date.now(); while (Date.now() - t0 < (ms || 20000)) { try { const v = await fn(); if (v) return v; } catch (e) {} await sleep(500); } return null; }
|
||||
const hex = n => '0x' + BigInt(n).toString(16);
|
||||
const w = n => BigInt(n).toString(16).padStart(64, '0');
|
||||
|
||||
// ---- mock RPC ----
|
||||
const rpc = { block: 1000, logs: [], memberAcct: {} };
|
||||
const PUR = '0x11dc109cafd0f24c81621f745383ec82be7f2947c650355791e27b56ac83bc8c';
|
||||
const purchaseLog = (block, buyerId, cents, tx, li) => ({ address: '0x07786E664AAfc0641eEB5297766935763dbA2288', topics: [PUR, '0x' + w(buyerId), '0x' + w(1)], data: '0x' + w(1000000000000000000n) + w(cents) + w(0) + w(500), blockNumber: hex(block), transactionHash: tx, logIndex: hex(li) });
|
||||
const rpcSrv = http.createServer((q, s) => { let d = ''; q.on('data', c => d += c); q.on('end', () => {
|
||||
const b = JSON.parse(d || '{}'); let result = null;
|
||||
if (b.method === 'eth_blockNumber') result = hex(rpc.block);
|
||||
else if (b.method === 'eth_getLogs') { const f = parseInt(b.params[0].fromBlock, 16), t = parseInt(b.params[0].toBlock, 16); result = rpc.logs.filter(l => { const n = parseInt(l.blockNumber, 16); return n >= f && n <= t; }); }
|
||||
else if (b.method === 'eth_call') { const data = b.params[0].data; if (data.startsWith('0x5f59bb40')) { const id = Number(BigInt('0x' + data.slice(10))); const a = rpc.memberAcct[id]; result = '0x' + w(a ? BigInt(a) : 0) + w(0) + w(0) + w(a ? 1 : 0) + w(0); } else result = '0x' + w(0).repeat(10); }
|
||||
else result = '0x0';
|
||||
s.writeHead(200, { 'Content-Type': 'application/json' }); s.end(JSON.stringify({ jsonrpc: '2.0', id: b.id, result }));
|
||||
}); }).listen(RPC_PORT, '127.0.0.1');
|
||||
|
||||
// ---- two sites ----
|
||||
const now = Date.now();
|
||||
const acct = (email, username, o) => Object.assign({ email, pass: null, sponsorRef: '', code: ('c' + username).slice(0, 7), username, address: null, created: now - 20 * 86400000, lastSeen: now - 3600000, memberId: 0 }, o || {});
|
||||
function seed(dir, list) { fs.mkdirSync(path.join(dir, 'uploads'), { recursive: true }); const db = { v: 2, byEmail: {}, byAddress: {}, byCode: {}, joins: 0, positions: {} }; for (const a of list) { db.byEmail[a.email] = a; db.byCode[a.code] = a.email; } fs.writeFileSync(path.join(dir, 'accounts.json'), JSON.stringify(db)); }
|
||||
const iapDir = fs.mkdtempSync(path.join(os.tmpdir(), 'nc-iap-')), lsDir = fs.mkdtempSync(path.join(os.tmpdir(), 'nc-ls-'));
|
||||
const OWNER = 'orlando@qa.test';
|
||||
seed(iapDir, [acct(OWNER, 'qaorlando', { memberId: 2 })]); seed(lsDir, [acct(OWNER, 'qaorlando', { memberId: 2 })]);
|
||||
fs.writeFileSync(path.join(iapDir, 'config.json'), JSON.stringify({ rpcs: ['https://127.0.0.1'], deployBlock: 990, telegramBotToken: '', adminEmail: 'admin@qa.test' }));
|
||||
const env = (port, dir, extra) => { const e = {}; for (const k of ['PATH', 'Path', 'SystemRoot', 'SYSTEMROOT', 'TEMP', 'TMP', 'USERPROFILE', 'HOME', 'APPDATA', 'LOCALAPPDATA', 'COMSPEC', 'windir']) if (process.env[k]) e[k] = process.env[k]; return Object.assign(e, { PORT: String(port), DATA_DIR: dir, ADMIN_EMAIL: 'admin@qa.test', ADMIN_PASSWORD: 'localtest', LS_SYNC_SECRET: SECRET }, extra); };
|
||||
const OUT = path.join(IAP_SITE, 'qa', 'out'); fs.mkdirSync(OUT, { recursive: true });
|
||||
const procs = [];
|
||||
function boot(site, port, dir, extra, log, args) { const fd = fs.openSync(log, 'a'); const p = spawn(process.execPath, (args || []).concat(['server.js']), { cwd: site, env: env(port, dir, extra), stdio: ['ignore', fd, fd] }); procs.push(p); return p; }
|
||||
const bootLs = () => boot(LS_SITE, P + 1, lsDir, { IAP_URL: IAP, SITE_HOST: '127.0.0.1:' + (P + 1) }, path.join(OUT, 'netconv-ls.log'));
|
||||
async function up(url) { for (let i = 0; i < 50; i++) { try { const r = await fetch(url + '/api/config', { signal: AbortSignal.timeout(2000) }); if (r.status < 500) return true; } catch (e) {} await sleep(500); } return false; }
|
||||
|
||||
// a client with its own cookie jar and its own address, so the sign-up guards see separate people
|
||||
let ipN = 10;
|
||||
function client() {
|
||||
const jar = new Map(), ip = '198.51.100.' + (ipN++);
|
||||
const call = async (url, o) => {
|
||||
o = o || {}; const headers = Object.assign({ 'X-Forwarded-For': ip, 'User-Agent': 'Mozilla/5.0 NetconvQA ' + ip }, o.body ? { 'Content-Type': 'application/json' } : {}, jar.size ? { Cookie: [...jar].map(([k, v]) => k + '=' + v).join('; ') } : {});
|
||||
const r = await fetch(url, { method: o.body ? 'POST' : 'GET', headers, body: o.body ? JSON.stringify(o.body) : undefined, redirect: 'manual' });
|
||||
for (const c of r.headers.getSetCookie()) { const m = /^([^=]+)=([^;]*)/.exec(c); if (m) { if (/Max-Age=0/i.test(c) || m[2] === '') jar.delete(m[1]); else jar.set(m[1], m[2]); } }
|
||||
const txt = await r.text(); let j = null; try { j = JSON.parse(txt); } catch (e) {} return { status: r.status, j, txt, headers: r.headers };
|
||||
};
|
||||
return { call, jar, ip };
|
||||
}
|
||||
async function signUp(c, base, email, extra) {
|
||||
const st = await c.call(base + '/api/auth/email/start', { body: Object.assign({ email, fts: Date.now() - 8000, fage: 8000 }, extra || {}) });
|
||||
if (!st.j || !st.j.devCode) throw new Error('no devCode: ' + st.txt.slice(0, 200));
|
||||
return c.call(base + '/api/auth/email/verify', { body: Object.assign({ email, code: st.j.devCode }, extra || {}) });
|
||||
}
|
||||
const accountRow = async email => { const r = await fetch(IAP + '/api/admin/member?email=' + encodeURIComponent(email), { headers: { Authorization: 'Bearer localtest' } }); return r.json().catch(() => null); };
|
||||
const ledger = () => { try { return fs.readFileSync(path.join(lsDir, 'netconv.jsonl'), 'utf8').trim().split('\n').filter(Boolean).map(l => JSON.parse(l)); } catch (e) { return []; } };
|
||||
const iapState = () => { try { return JSON.parse(fs.readFileSync(path.join(iapDir, 'lsreport.json'), 'utf8')); } catch (e) { return { clicks: {}, events: [] }; } };
|
||||
async function signed(pth, body) { 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(LS + pth, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-LS-Ts': ts, 'X-LS-Sig': sig }, body: raw }); return r.json(); }
|
||||
|
||||
let lsProc = null;
|
||||
try {
|
||||
boot(IAP_SITE, P, iapDir, { LS_URL: LS, QA_RPC_PORT: String(RPC_PORT) }, path.join(OUT, 'netconv-iap.log'), ['--require', path.join(HERE, 'netconv-rpc-preload.cjs')]);
|
||||
lsProc = bootLs();
|
||||
ok(await up(IAP), 'local InstantAdPay up'); ok(await up(LS), 'local LinkSpin up');
|
||||
|
||||
// the owner's spin link, pointed straight at the join page, no goal set up
|
||||
const own = client(); const so = await signUp(own, LS, OWNER); ok(so.status === 200, 'owner signed in on LinkSpin', so.txt.slice(0, 160));
|
||||
const rot = (await own.call(LS + '/api/my/rotations', { body: { name: 'Bridge spin' } })).j.rotation;
|
||||
await own.call(LS + '/api/my/rotations/' + rot.id + '/dest', { body: { url: 'https://instantadpay.com/join/qaorlando', weight: 1 } });
|
||||
const clickFor = async c => { const r = await c.call(LS + '/r/' + rot.code); const loc = r.headers.get('location'); return new URL(loc).searchParams.get('lsclk'); };
|
||||
|
||||
// 1 sign-up with the cookie
|
||||
const v1 = client(); const id1 = await clickFor(v1);
|
||||
ok(/^[a-f0-9]{10}$/.test(id1 || ''), 'the spin link hands the visitor a click id', id1);
|
||||
const land = await v1.call(IAP + '/join/qaorlando?lsclk=' + id1);
|
||||
ok(land.status === 200 && v1.jar.get('iap.lsclk') === id1, 'arrival keeps the click in a first-party cookie', [...v1.jar.keys()]);
|
||||
ok(v1.jar.get('iap.sponsor') === 'qaorlando', 'the sponsor cookie still lands beside it');
|
||||
const r1 = await signUp(v1, IAP, 'lead1@qa.test');
|
||||
ok(r1.status === 200 && r1.j.created, 'sign-up works', r1.txt.slice(0, 160));
|
||||
ok(r1.j.account.sponsorRef === 'qaorlando', "the sponsor is the join link's, exactly", r1.j.account.sponsorRef);
|
||||
ok(iapState().clicks['lead1@qa.test'] && iapState().clicks['lead1@qa.test'].click === id1 || await waitFor(() => (iapState().clicks['lead1@qa.test'] || {}).click === id1, 3000), 'the click is on the account');
|
||||
ok(await waitFor(() => ledger().find(r => r.ev === 'join' && r.owner === OWNER && r.click === id1), 15000), 'LinkSpin counted the join for the click owner');
|
||||
|
||||
// 2 the control: no click, same sponsor path, nothing reported
|
||||
const v0 = client(); await v0.call(IAP + '/join/qaorlando'); const r0 = await signUp(v0, IAP, 'plain@qa.test');
|
||||
ok(r0.j.account.sponsorRef === 'qaorlando', 'a sign-up with no click gets the same sponsor');
|
||||
await sleep(1000); ok(!iapState().clicks['plain@qa.test'], 'and nothing is kept or reported for it');
|
||||
|
||||
// 3 wallet link, signed with a throwaway key
|
||||
const { Wallet } = require(path.join(IAP_SITE, 'node_modules', 'ethers'));
|
||||
const wlt = Wallet.createRandom(); const addr = wlt.address;
|
||||
const ch = await v1.call(IAP + '/api/auth/challenge', { body: { address: addr } });
|
||||
const vf = await v1.call(IAP + '/api/auth/verify', { body: { address: addr, signature: await wlt.signMessage(ch.j.message) } });
|
||||
ok(vf.status === 200 && vf.j.linked, 'wallet linked', vf.txt.slice(0, 200));
|
||||
ok(await waitFor(() => ledger().find(r => r.ev === 'wallet' && r.click === id1), 15000), 'LinkSpin counted the wallet');
|
||||
|
||||
// 4 a Purchase log on the mock chain, member_id not stored yet: the buyer is found through the contract's wallet for that id
|
||||
rpc.memberAcct[900] = addr; const TX = '0x' + 'ab'.repeat(32);
|
||||
rpc.logs.push(purchaseLog(1001, 900, 2000, TX, 3)); rpc.block = 1002;
|
||||
ok(await waitFor(() => ledger().find(r => r.ev === 'purchase' && r.tx === TX), 45000), 'a real Purchase event reached LinkSpin');
|
||||
const pr = ledger().find(r => r.ev === 'purchase' && r.tx === TX);
|
||||
ok(pr && pr.value === 20, 'value = the USD price on the chain event ($20.00)', pr && pr.value);
|
||||
ok(pr && pr.owner === OWNER && pr.rot === rot.id, 'counted on the link and its owner');
|
||||
// the same event a second time on its way to LinkSpin, plus a second package
|
||||
const k = pr.k; const dupd = await signed('/api/partner/conv', { op: 'events', events: [{ k, ev: 'purchase', click: id1, email: 'lead1@qa.test', value: 20, ts: Date.now() }] });
|
||||
ok(dupd.results[0].result === 'dup', 'the same purchase delivered again is a dup', dupd);
|
||||
const TX2 = '0x' + 'cd'.repeat(32); rpc.logs.push(purchaseLog(1003, 900, 500, TX2, 1)); rpc.block = 1004;
|
||||
ok(await waitFor(() => ledger().find(r => r.tx === TX2), 45000), 'a second package counts on its own');
|
||||
ok(await waitFor(() => (iapState().events || []).filter(r => r.ev === 'purchase').length === 2, 4000), 'two purchase rows on InstantAdPay', iapState().events);
|
||||
// a purchase by someone with no click reports nothing
|
||||
const v9 = client(); await signUp(v9, IAP, 'other@qa.test');
|
||||
const w9 = Wallet.createRandom(); const c9 = await v9.call(IAP + '/api/auth/challenge', { body: { address: w9.address } });
|
||||
await v9.call(IAP + '/api/auth/verify', { body: { address: w9.address, signature: await w9.signMessage(c9.j.message) } });
|
||||
rpc.memberAcct[901] = w9.address; rpc.logs.push(purchaseLog(1005, 901, 5000, '0x' + 'ef'.repeat(32), 1)); rpc.block = 1006;
|
||||
await waitFor(() => JSON.parse(fs.readFileSync(path.join(iapDir, 'chain-index.json'), 'utf8')).lastBlock >= 1006, 45000); await sleep(1500);
|
||||
ok(!ledger().some(r => r.value === 50), 'a buyer with no click reports nothing');
|
||||
|
||||
// 5 the page's own copy of the click: no cookie reached the server
|
||||
const v2 = client(); const id2 = await clickFor(v2);
|
||||
const r2 = await signUp(v2, IAP, 'lead2@qa.test', { ref: 'qaorlando', lsclk: id2 });
|
||||
ok(r2.j.created && v2.jar.get('iap.lsclk') === undefined, 'sign-up with no cookie, the page sent its own copy');
|
||||
ok(await waitFor(() => ledger().find(r => r.ev === 'join' && r.click === id2), 15000), 'the join still counts');
|
||||
// code requested in one browser, finished in another
|
||||
const v3a = client(), v3b = client(); const id3 = await clickFor(v3a);
|
||||
const s3 = await v3a.call(IAP + '/api/auth/email/start', { body: { email: 'lead3@qa.test', fts: Date.now() - 8000, ref: 'qaorlando', lsclk: id3 } });
|
||||
await sleep(400); const f3 = await v3b.call(IAP + '/api/auth/email/verify', { body: { email: 'lead3@qa.test', code: s3.j.devCode } });
|
||||
ok(f3.j.created, 'code finished in a second browser');
|
||||
ok(await waitFor(() => ledger().find(r => r.ev === 'join' && r.click === id3), 15000), 'the click travelled with the email');
|
||||
// a bad click id is ignored everywhere
|
||||
const v4 = client(); await v4.call(IAP + '/join/qaorlando?lsclk=../evil'); ok(!v4.jar.has('iap.lsclk'), 'a malformed click id sets nothing');
|
||||
// lsid and non-join pages
|
||||
const v5 = client(); await v5.call(IAP + '/?lsid=abcdef0123'); ok(v5.jar.get('iap.lsclk') === 'abcdef0123', 'lsid on any page is kept too');
|
||||
|
||||
// 6 the owner's own account
|
||||
const v6 = client(); const id6 = await clickFor(v6); await v6.call(IAP + '/join/qaorlando?lsclk=' + id6);
|
||||
const claim = await signUp(v6, IAP, 'orlando2@qa.test'); ok(claim.j.created, 'control account'); // (the seeded owner already has an account: an existing sign-in binds nothing)
|
||||
const v7 = client(); const id7 = await clickFor(v7); await v7.call(IAP + '/join/qaorlando?lsclk=' + id7);
|
||||
await signUp(v7, IAP, OWNER); await sleep(800);
|
||||
ok(!iapState().clicks[OWNER] || !iapState().clicks[OWNER].bound, 'an existing account signing in binds no click');
|
||||
const self = await signed('/api/partner/conv', { op: 'events', events: [{ k: 'join:selfcheck', ev: 'join', click: id7, email: OWNER, ts: Date.now() }] });
|
||||
ok(self.results[0].result === 'self', "LinkSpin keeps the owner's own account as a test", self);
|
||||
|
||||
// 7 Reports and the Campaigns card
|
||||
await waitFor(() => ledger().filter(r => r.ev === 'join').length >= 5, 8000);
|
||||
const rep = (await own.call(LS + '/api/my/reports?days=30')).j;
|
||||
const row = k2 => (rep.conversions || []).find(x => x.k === k2) || { n: 0, value: 0 };
|
||||
const joins = ledger().filter(r => r.ev === 'join' && !r.self && r.owner === OWNER).length;
|
||||
ok(row('join').n === joins && row('purchase').n === 2 && row('purchase').value === 25 && row('wallet').n === 1, 'Reports > Conversions: every join, 1 wallet, 2 purchases $25.00', rep.conversions);
|
||||
ok(rep.totals.joins === joins && rep.totals.purchases === 1 && rep.totals.purchaseCount === 2, 'the tiles follow (1 buyer, 2 purchases)', rep.totals);
|
||||
ok(rep.top[0].conv === joins + 3, 'Top links Conv. counts the same events', rep.top[0]);
|
||||
const card = (await signUp(client(), IAP, OWNER)); const ownerIap = client(); await signUp(ownerIap, IAP, OWNER);
|
||||
const cv = (await ownerIap.call(IAP + '/api/my/conversions?fresh=1')).j;
|
||||
ok(cv && cv.ok && cv.network && (cv.network.rows.find(x => x.k === 'purchase') || {}).value === 25, 'InstantAdPay Campaigns card gets the same rows', cv && cv.network);
|
||||
|
||||
// the two screens themselves, in a browser
|
||||
const PW = process.env.PW || 'D:/Projects/MarketingAgent/qa-tester/node_modules/playwright';
|
||||
if (fs.existsSync(PW)) {
|
||||
const pw = require(PW); const br = await pw.chromium.launch();
|
||||
const open = async (jar, base, url) => { const ctx = await br.newContext({ viewport: { width: 1280, height: 900 } }); await ctx.addCookies([...jar].map(([name, value]) => ({ name, value, url: base }))); const p = await ctx.newPage(); const errs = []; p.on('pageerror', e => errs.push(e.message)); await p.goto(base + url, { waitUntil: 'domcontentloaded' }); return { p, errs }; };
|
||||
const a = await open(own.jar, LS, '/reports');
|
||||
await a.p.waitForFunction(() => /Purchases/.test((document.getElementById('convRows') || {}).textContent || ''), null, { timeout: 15000 }).catch(() => {});
|
||||
const txt = await a.p.$eval('#convRows', e => e.textContent).catch(() => '');
|
||||
ok(/Joins/.test(txt) && /Wallets/.test(txt) && /Purchases \u00b7 \$25\.00/.test(txt), 'LinkSpin Reports shows Joins, Wallets and Purchases with the value', txt);
|
||||
ok(a.errs.length === 0, 'no script errors on Reports', a.errs);
|
||||
await a.p.screenshot({ path: path.join(OUT, 'netconv-reports.png'), fullPage: false });
|
||||
const b = await open(ownerIap.jar, IAP, '/my#campaigns');
|
||||
await b.p.waitForFunction(() => { const e = document.getElementById('convNet'); return e && !e.hidden; }, null, { timeout: 20000 }).catch(() => {});
|
||||
const nt = await b.p.$eval('#convNet', e => e.textContent).catch(() => '');
|
||||
ok(/purchases \(\$25\.00\)/.test(nt), 'InstantAdPay Conversion tracking card shows the events', nt);
|
||||
ok(b.errs.length === 0, 'no script errors on Campaigns', b.errs);
|
||||
await br.close();
|
||||
} else console.log('SKIP the two screens (no Playwright at ' + PW + ')');
|
||||
|
||||
// 8 LinkSpin down blocks nothing, rows arrive later
|
||||
lsProc.kill(); await sleep(600);
|
||||
const v8 = client(); await v8.call(IAP + "/join/qaorlando?lsclk=" + id1);
|
||||
const t0 = Date.now(); const r8 = await signUp(v8, IAP, 'whiledown@qa.test'); const ms = Date.now() - t0;
|
||||
ok(r8.status === 200 && r8.j.created, 'sign-up works with LinkSpin down'); ok(ms < 4000, 'and is not slowed by it', ms + ' ms');
|
||||
ok(await waitFor(() => (iapState().events || []).find(r => r.email === 'whiledown@qa.test' && !r.pushed), 4000), 'the join waits in the queue');
|
||||
const before = ledger().length;
|
||||
lsProc = bootLs(); ok(await up(LS), 'LinkSpin back');
|
||||
ok(await waitFor(() => (iapState().events || []).find(r => r.email === 'whiledown@qa.test' && r.pushed), 60000), 'the queue delivers it once LinkSpin is back', iapState().events.filter(r => r.email === 'whiledown@qa.test'));
|
||||
const last = (iapState().events || []).find(r => r.email === 'whiledown@qa.test');
|
||||
ok(last && last.outcome === 'other', "and id1's click already belongs to the first account, so it is refused, not counted", last);
|
||||
ok(ledger().length === before, 'nothing added to the ledger for it');
|
||||
} catch (e) { ok(false, 'crashed: ' + e.message, e.stack); } finally { for (const p of procs) { try { p.kill(); } catch (e) {} } rpcSrv.close(); }
|
||||
|
||||
// ---- part 2: two app copies against one SQL layer ----
|
||||
{
|
||||
const fake = () => { const clicks = new Map(), events = new Map();
|
||||
const q = async (sql, a) => { await sleep(1 + Math.random() * 3);
|
||||
if (/^SELECT click_id/.test(sql)) { const r = clicks.get(a[0]); return r ? [{ click_id: r.click, ts: r.ts, bound: r.bound }] : []; }
|
||||
if (/^INSERT IGNORE INTO ls_account_clicks/.test(sql)) { if (clicks.has(a[0])) return { affectedRows: 0 }; clicks.set(a[0], { click: a[1], ts: a[2], bound: 0 }); return { affectedRows: 1 }; }
|
||||
if (/^INSERT INTO ls_account_clicks/.test(sql)) { const r = clicks.get(a[0]); if (r && r.bound) return { affectedRows: 0 }; clicks.set(a[0], { click: a[1], ts: a[2], bound: 0 }); return { affectedRows: 1 }; }
|
||||
if (/^UPDATE ls_account_clicks/.test(sql)) { const r = clicks.get(a[2]); if (!r || r.bound) return { affectedRows: 0 }; Object.assign(r, { click: a[0], ts: a[1], bound: 1 }); return { affectedRows: 1 }; }
|
||||
if (/^INSERT IGNORE INTO ls_events/.test(sql)) { if (events.has(a[0])) return { affectedRows: 0 }; events.set(a[0], { k: a[0], ev: a[1], email: a[2], click_id: a[3], cents: a[4], ev_ts: a[5], tx: a[6], sk: a[7], pushed: 0 }); return { affectedRows: 1 }; }
|
||||
if (/^SELECT k, ev/.test(sql)) return [...events.values()].filter(r => !r.pushed).slice(0, a[0]);
|
||||
if (/^UPDATE ls_events/.test(sql)) { const r = events.get(a[1]); if (r) { r.pushed = 1; r.outcome = a[0]; } return { affectedRows: 1 }; }
|
||||
return []; };
|
||||
return { enabled: () => true, q, events, clicks }; };
|
||||
process.env.LS_SYNC_SECRET = SECRET; process.env.LS_URL = 'http://127.0.0.1:' + (P + 5);
|
||||
const load = db => { for (const k of Object.keys(require.cache)) if (/[\\/](lsreport|lsconv)\.js$/.test(k)) delete require.cache[k]; const m = require(path.join(IAP_SITE, 'lsreport.js')); m.init({ db, dataDir: os.tmpdir(), noTimers: true }); return m; };
|
||||
const db = fake(); const A = load(db), B = load(db);
|
||||
ok(A !== B, 'two copies of the module');
|
||||
const bound = await Promise.all([A.signup('x@qa.test', 'abcdef0123'), B.signup('x@qa.test', 'abcdef0123')]);
|
||||
ok(bound.filter(Boolean).length === 1, 'two copies binding the same sign-up: one wins', bound);
|
||||
const ev = { type: 'Purchase', tx: '0x1', li: 4, priceCents: 500, ts: Date.now() };
|
||||
const pu = await Promise.all([A.purchase(ev, 'x@qa.test'), B.purchase(ev, 'x@qa.test')]);
|
||||
ok(pu.filter(Boolean).length === 1, 'two copies queueing the same purchase: one row', pu);
|
||||
await Promise.all([A.wallet('x@qa.test'), B.wallet('x@qa.test')]);
|
||||
ok([...db.events.keys()].sort().join() === [...new Set([...db.events.keys()])].sort().join() && db.events.size === 3, 'three rows: join, purchase, wallet', [...db.events.keys()]);
|
||||
const got = []; const srv = http.createServer((q, s) => { let d = ''; q.on('data', c => d += c); q.on('end', () => { const b = JSON.parse(d); for (const e of b.events) got.push(e); s.writeHead(200, { 'Content-Type': 'application/json' }); s.end(JSON.stringify({ ok: true, results: b.events.map(e => ({ k: e.k, result: 'counted' })) })); }); }).listen(P + 5, '127.0.0.1');
|
||||
await Promise.all([A.flush(), B.flush()]);
|
||||
ok(got.length >= 3 && new Set(got.map(e => e.k)).size === 3, 'both copies may send a row; every row has one key, LinkSpin dedupes on it', got.length);
|
||||
ok([...db.events.values()].every(r => r.pushed), 'all marked sent');
|
||||
ok(got.find(e => e.ev === 'purchase').value === 5, 'the purchase value goes as dollars ($5.00)');
|
||||
const late = { type: 'Purchase', tx: '0x2', li: 1, priceCents: 500, ts: Date.now() + 32 * 86400000 };
|
||||
ok(!(await A.purchase(late, 'x@qa.test')), 'a purchase past the click window is not even queued');
|
||||
ok(!(await A.purchase({ type: 'Purchase', tx: '0x3', li: 1, priceCents: 500, ts: Date.now() }, 'noclick@qa.test')), 'an account with no click queues nothing');
|
||||
srv.close();
|
||||
}
|
||||
|
||||
console.log('\n' + pass + ' passed, ' + fail + ' failed');
|
||||
process.exit(fail ? 1 : 0);
|
||||
@@ -17,6 +17,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 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 netconv # conversion linkage end to end: spin link -> join -> wallet -> a Purchase on a mock chain, local InstantAdPay + local LinkSpin, LinkSpin down, own account, two copies racing
|
||||
# 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)
|
||||
# bash qa/run.sh fuel # Fuel Your Offers: refill notices, refuel streak, Refuel Kit, Engine Room (unit + two-copy tests, throwaway data)
|
||||
# bash qa/run.sh policy # profile policy + link-farm scan: prohibited list, bio links, quarantine, 06:30 claim, walls of free/paying members, 404 walls (unit + local copy; also runs in member)
|
||||
@@ -100,6 +101,8 @@ elif [ "$MODE" = "nas" ]; then
|
||||
elif [ "$MODE" = "login-queue" ]; then
|
||||
node qa/login-queue.cjs || status=1
|
||||
node qa/login-queue-sql.cjs || status=1
|
||||
elif [ "$MODE" = "netconv" ]; then
|
||||
node qa/netconv.test.mjs || status=1
|
||||
elif [ "$MODE" = "convpixel" ]; then
|
||||
node qa/convpixel.test.mjs || status=1
|
||||
elif [ "$MODE" = "fuel" ]; then
|
||||
|
||||
@@ -51,6 +51,7 @@ const sbcheck = require('./sbcheck');
|
||||
const reach = require('./reach');
|
||||
const lssync = require('./lssync');
|
||||
const lsconv = require('./lsconv'); // conversion tracking: ad click ids pushed to LinkSpin + the member's goals (2026-10-23)
|
||||
const lsreport = require('./lsreport'); // conversion linkage: the LinkSpin click on the account, sign-up / wallet / purchase reported, reporting only (2026-11-07)
|
||||
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 bixpay = require('./bixpay'); // BixPay Visa card: partner-link field, sponsor-follows resolver, tracked clicks (2026-10-29, gated by site config bixpayLive)
|
||||
@@ -535,6 +536,8 @@ async function boot() {
|
||||
marks.init({ db });
|
||||
marks.ensureTable().catch(e => console.error('marks table', e.message));
|
||||
lsconv.init({ db, dataDir: DATA_DIR });
|
||||
lsreport.init({ db, dataDir: DATA_DIR });
|
||||
accounts.onWalletLinked(e => { lsreport.wallet(e).catch(err => console.error('lsreport wallet', err.message)); });
|
||||
auth.onSeen((email, req) => lsconv.noteSession(email, clientIp(req), req.headers['user-agent'])); // own-click tests on LinkSpin (2026-10-26)
|
||||
setInterval(() => marks.prune().catch(() => {}), 6 * 3600 * 1000).unref();
|
||||
chain.init({ onEvent: ev => {
|
||||
@@ -555,6 +558,7 @@ async function boot() {
|
||||
wednesday.onEvent(ev).catch(e => console.error('wednesday bonus', e.message));
|
||||
refuel.onIapPurchase(ev).catch(e => console.error('refuel streak', e.message)); // its own bonus, stacked on Friday/Wednesday; no-op while refuelStreak is off
|
||||
sponsorSyncOnEvent(ev).catch(e => console.error('sponsor sync', e.message));
|
||||
lsReportPurchase(ev).catch(e => console.error('lsreport purchase', e.message)); // reporting only: one local row, delivered in the background
|
||||
}).catch(e => console.error('marks claim', e.message));
|
||||
} });
|
||||
auth.init({ dataDir: DATA_DIR, chain, isProd: IS_PROD, site: 'instantadpay.com' });
|
||||
@@ -1056,6 +1060,15 @@ async function postWalkUp(buyerId, oldRef, toId, pur) {
|
||||
// The referral follows the money (Marty, 2026-09-16): when a position is created on-chain under a
|
||||
// different sponsor than the account's stored referrer (walk-up past an unactivated sponsor, or the
|
||||
// catch-position fallback), move the account to the sponsor that actually got paid, #1 included.
|
||||
// a package Purchase, for the click on the buyer's account (lsreport.js, reporting only). The buyer's account: main member id, a linked
|
||||
// position, or on a first purchase, when member_id is not stored yet, through the wallet the contract holds for that id.
|
||||
async function lsReportPurchase(ev) {
|
||||
if (!ev || ev.type !== 'Purchase' || !ev.buyerId) return;
|
||||
let a = await accounts.byMemberId(ev.buyerId);
|
||||
if (!a) { const pos = await accounts.positionByMember(ev.buyerId); if (pos && pos.email) a = { email: pos.email }; }
|
||||
if (!a) { const m = await chain.member(ev.buyerId); if (m && m.account) { a = await accounts.byAddress(m.account); if (!a) { const pos = await accounts.positionOwner(m.account); if (pos && pos.email) a = { email: pos.email }; } } }
|
||||
if (a && a.email) await lsreport.purchase(ev, a.email);
|
||||
}
|
||||
async function sponsorSyncOnEvent(ev) {
|
||||
if (!ev || ev.type !== 'MemberActivated' || !ev.account) return;
|
||||
const acct = await accounts.byAddress(ev.account); if (!acct) return;
|
||||
@@ -2264,6 +2277,15 @@ const server = http.createServer(async (req, res) => {
|
||||
res.writeHead(302, { Location: to, 'Cache-Control': 'no-store', 'X-Robots-Tag': 'noindex' }); return res.end();
|
||||
} }
|
||||
|
||||
// a LinkSpin click arriving on any page (?lsclk= or ?lsid=): the first-party cookie, 30 days, last click wins (reporting only, lsreport.js).
|
||||
// Added to whatever the page sends, like the viral-link cookies below.
|
||||
if (req.method === 'GET' && !p.startsWith('/api/') && !p.startsWith('/admin') && !/\.[a-z0-9]{2,5}$/i.test(p)) {
|
||||
const lsc = lsreport.fromUrl(u);
|
||||
if (lsc) {
|
||||
const ck = lsreport.cookieHeader(lsc, IS_PROD); const wh = res.writeHead.bind(res);
|
||||
res.writeHead = function (code, h) { if (typeof h === 'string') return wh.apply(res, arguments); h = Object.assign({}, h || {}); h['Set-Cookie'] = [].concat(res.getHeader('Set-Cookie') || [], h['Set-Cookie'] || [], ck); return wh(code, h); };
|
||||
}
|
||||
}
|
||||
// -- traffic log: public page views by referring domain (admin > Traffic)
|
||||
if (req.method === 'GET' && ((TRAFFIC_PAGES.has(p) && !(p === '/refuel' && u.searchParams.has('t'))) || /^\/(join|from|wall|blog)\/[^/]+$/.test(p))) traffic.hit(p.startsWith('/blog/') ? '/blog/*' : p, req.headers.referer, req.headers['user-agent']);
|
||||
// -- viral links (Marty, 2026-09-21): ANY public page + ?ref=<username|code|id> is that member's
|
||||
@@ -2628,6 +2650,7 @@ const server = http.createServer(async (req, res) => {
|
||||
const r = await accounts.signup(b.email, b.password, ref);
|
||||
if (r.error) return json(res, 400, r);
|
||||
pendingSponsor.del(String(b.email || '').trim().toLowerCase());
|
||||
await lsreport.signup(r.account.email, lsreport.pick(b.lsclk, parseCookies(req)[lsreport.COOKIE]), lsconv.softKey(clientIp(req), req.headers['user-agent'])).catch(e => console.error('lsreport signup', e.message));
|
||||
// sponsor is notified once the new member picks a username (onboarding),
|
||||
// so the email can name them — see /api/my/profile
|
||||
if (b.newsletter) sendy.subscribe(r.account.email, r.account.username || '').catch(() => {}); // pre-checked opt-in, silent
|
||||
@@ -2659,7 +2682,8 @@ const server = http.createServer(async (req, res) => {
|
||||
const code = String(Math.floor(100000 + Math.random() * 900000));
|
||||
emailCodes.set(e, { code, exp: Date.now() + 15 * 60 * 1000, tries: 0, nextAt: Date.now() + 60 * 1000 });
|
||||
{ const ck = parseCookies(req); const bound = pageTok(b.ref) || ck['iap.sponsor'] || '';
|
||||
if (bound && !(await accounts.byEmail(e))) pendingSponsor.set(e, { ref: bound, via: pageTok(b.ref) ? (String(b.angle || '').toLowerCase().slice(0, 20) || ck['iap.angle'] || 'page') : (ck['iap.angle'] || ''), joinedRef: decodeURIComponent(ck['iap.ref'] || '') || null }); }
|
||||
if (bound && !(await accounts.byEmail(e))) pendingSponsor.set(e, { ref: bound, via: pageTok(b.ref) ? (String(b.angle || '').toLowerCase().slice(0, 20) || ck['iap.angle'] || 'page') : (ck['iap.angle'] || ''), joinedRef: decodeURIComponent(ck['iap.ref'] || '') || null });
|
||||
const lsc = lsreport.pick(b.lsclk, ck[lsreport.COOKIE]); if (lsc) { const ex = await accounts.byEmail(e); if (!ex || accounts.isUnclaimedShell(ex)) lsreport.remember(e, lsc).catch(err => console.error('lsreport remember', err.message)); } } // the click travels with the email, like the sponsor
|
||||
if (mailer.hasKey()) {
|
||||
try { await mailer.sendCode(e, code); } catch (err) {
|
||||
console.error('sendCode failed', err.message);
|
||||
@@ -2701,6 +2725,7 @@ const server = http.createServer(async (req, res) => {
|
||||
if (r.error) return json(res, 400, r);
|
||||
if (r.created) pendingSponsor.del(e);
|
||||
if (claim) await claimShell(e, existing, ref);
|
||||
if (r.created || claim) await lsreport.signup(e, lsreport.pick(b.lsclk, parseCookies(req)[lsreport.COOKIE]), lsconv.softKey(clientIp(req), req.headers['user-agent'])).catch(err => console.error('lsreport signup', err.message));
|
||||
if (r.created || claim) { fraud.recordSignup(e, req, fraudFlags).catch(() => {}); if (fraudFlags.length) fraudAlert(e, { flags: fraudFlags, ip: fraud.ipOf(req) }, null, false); }
|
||||
else fraud.recordSeen(e, req).catch(() => {});
|
||||
// the lead is in the door: queue the getting-started sequence (opt-in box is pre-checked on both forms)
|
||||
@@ -2767,6 +2792,7 @@ const server = http.createServer(async (req, res) => {
|
||||
const ref = pageTok(b.ref);
|
||||
const srcTag = String(b.src || '').toLowerCase().replace(/[^a-z0-9_.-]/g, '').slice(0, 30); // paid-traffic source the game saw (2026-10-03)
|
||||
if (!(await accounts.byEmail(e))) pendingSponsor.set(e, { ref: ref || '', via: String(b.game), joinedRef: g.host() + (srcTag ? '/' + srcTag : '') });
|
||||
{ const lsc = lsreport.pick(b.lsclk, parseCookies(req)[lsreport.COOKIE]); if (lsc) { const ex = await accounts.byEmail(e); if (!ex || accounts.isUnclaimedShell(ex)) lsreport.remember(e, lsc).catch(err => console.error('lsreport remember', err.message)); } } // a game sends its own lsclk when it has one; no cookie crosses here
|
||||
console.log('game-signin code', b.game, e.replace(/^(.).*(@.*)$/, '$1***$2'), ref ? 'ref ' + ref : '');
|
||||
if (mailer.hasKey()) {
|
||||
try { await mailer.sendCode(e, code); } catch (err) { console.error('sendCode failed', err.message); return json(res, 502, { error: 'Could not send the email. Try again in a minute.' }, cors); }
|
||||
@@ -2803,6 +2829,7 @@ const server = http.createServer(async (req, res) => {
|
||||
}
|
||||
const r = await accounts.ensure(e, ref, via, joinedRef); // first touch wins; existing accounts unchanged
|
||||
if (r.error) return json(res, 400, r, cors);
|
||||
if (r.created || claim) await lsreport.signup(e, lsreport.pick(b.lsclk, parseCookies(req)[lsreport.COOKIE]), lsconv.softKey(clientIp(req), req.headers['user-agent'])).catch(err => console.error('lsreport signup', err.message));
|
||||
if (claim) { await claimShell(e, existing, ref); fraud.recordSignup(e, req, fraudFlags).catch(() => {}); if (fraudFlags.length) fraudAlert(e, { flags: fraudFlags, ip: fraud.ipOf(req) }, null, false); }
|
||||
if (r.created) {
|
||||
pendingSponsor.del(e);
|
||||
@@ -3508,7 +3535,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/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/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/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(), report: lsreport.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
|
||||
// over ts + newline + raw body, 10-minute window). New people become waiting accounts with their LinkSpin line; existing
|
||||
|
||||
Reference in New Issue
Block a user