Conversion pixel engine (Marty approved 2026-10-23): goals with public pixel ids, click ids on every ad click (lsclk, 'a'+11 hex), spin links pass the ad click on, landing tag /t.js + goal pixel /cv.gif /cv.js matching url > stored > cookie > 24 h soft key, once per click, 30-day window, owner check, rate limits, goal postbacks (event 'goal'), member + signed partner APIs for InstantAdPay
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+4
-3
@@ -17,7 +17,7 @@ const J = { db: null, FILE: () => path.join(DATA_DIR, 'postbacks.json'),
|
||||
save() { try { fs.writeFileSync(this.FILE(), JSON.stringify(this.db)); } catch (e) {} } };
|
||||
function init(opts) { DATA_DIR = opts.dataDir; ownHosts = opts.ownHosts || (() => []); rotator = opts.rotator; SOURCES = opts.sources || null; J.load(); }
|
||||
const norm = e => String(e || '').trim().toLowerCase();
|
||||
const EVENTS = ['join', 'lead', 'wallet', 'purchase', 'external'];
|
||||
const EVENTS = ['join', 'lead', 'wallet', 'purchase', 'external', 'goal']; // 'goal' = any conversion-pixel goal (2026-10-23); {event} carries the goal's name
|
||||
const MACRO = /\{([a-z0-9_]{1,24})\}/gi;
|
||||
|
||||
function isPrivateIp(ip) {
|
||||
@@ -102,7 +102,8 @@ async function fire(owner, event, ctx) {
|
||||
const q = (ctx.q || {});
|
||||
const vals = { clickid: q.clickid || q.cid || q.click_id || q.external_id || q.visitor_id || '', subid: q.subid || q.sub_id || q.s1 || '', s1: q.s1 || q.sub1 || '', s2: q.s2 || q.sub2 || '', s3: q.s3 || q.sub3 || '', s4: q.s4 || q.sub4 || '', s5: q.s5 || q.sub5 || '', source: ctx.source || '', event, payout: ctx.payout != null ? ctx.payout : '', currency: ctx.currency || 'USD', txid: ctx.txid || '', lsid: ctx.lsid || '', code: ctx.code || '', country: ctx.country || '', device: ctx.device || '' };
|
||||
for (const [k, v] of Object.entries(q)) if (/^(utm_[a-z]+|sub\d|s\d|aff_sub\d?|t\d|cost|zone|placement|site|campaign|creative|banner|keyword|geo|os|browser|carrier|format)$/.test(k) && vals[k] == null) vals[k] = v;
|
||||
for (const p of J.db.items.filter(x => x.owner === o && x.enabled && x.events.includes(event))) {
|
||||
const listens = evs => (evs || []).includes(event) || (!!ctx.goal && (evs || []).includes('goal'));
|
||||
for (const p of J.db.items.filter(x => x.owner === o && x.enabled && listens(x.events))) {
|
||||
if (!rateOk(o)) break;
|
||||
const url = fill(p.url, vals);
|
||||
let r = await deliver(p, url, Object.assign({}, ctx, { event }));
|
||||
@@ -112,7 +113,7 @@ async function fire(owner, event, ctx) {
|
||||
// the traffic source that sent this click (and only that one) hears about it through its own postback
|
||||
if (ctx.sourceId && SOURCES) {
|
||||
const s = SOURCES.forFire(o, ctx.sourceId);
|
||||
if (s && (s.events || []).includes(event) && rateOk(o)) {
|
||||
if (s && listens(s.events) && rateOk(o)) {
|
||||
const url = fill(s.postbackUrl, vals);
|
||||
let r = await deliver(s, url, Object.assign({}, ctx, { event, viaSource: s.id }));
|
||||
if (!r.ok && !ctx.test) { await new Promise(res => setTimeout(res, 4000)); r = await deliver(s, url, Object.assign({}, ctx, { event, viaSource: s.id })); }
|
||||
|
||||
Reference in New Issue
Block a user