diff --git a/nas.js b/nas.js index 8d8188b..207879e 100644 --- a/nas.js +++ b/nas.js @@ -75,7 +75,8 @@ async function pushCampaign(c, opts = {}) { (Username, Subject, Body, WebsiteURL, assigned, remaining, hits, approved, Date, adtype, Name, Email, PaymentDetails, EDate, sp, width, height, BannerURL, pid, ref_by, catid) VALUES (?,?,?,?,?,?,0,1,?,?,?,?,?,?,'',?,?,?,?,0,?)`, - [token, c.title || null, c.type === 'text' ? (c.body || null) : null, c.targetUrl, + // clicks route through our redirect so they count and carry the network site as the referrer + [token, c.title || null, c.type === 'text' ? (c.body || null) : null, 'https://instantadpay.com/api/ads/click/' + c.id, assigned, assigned, now, kind.adtype, opts.name || 'InstantAdPay member', opts.email || 'ads@instantadpay.com', 'InstantAdPay campaign #' + c.id, edate, @@ -107,6 +108,12 @@ async function deactivate(nasAdId) { } // top up a syndicated ad with more impressions (buy-more-views / reactivate). +// point an existing NAS ad at our click redirect (migration for rows pushed before 2026-09-10) +async function setClickUrl(nasAdId, campaignId) { + if (!enabled()) return { skipped: 'flag-off' }; + await q('UPDATE sponsorads SET WebsiteURL=? WHERE ID=?', ['https://instantadpay.com/api/ads/click/' + Number(campaignId), Number(nasAdId)]); + return { ok: true }; +} async function topUp(nasAdId, addImpressions, days) { if (!enabled()) return { skipped: 'flag-off' }; await q(`UPDATE sponsorads SET assigned=assigned+?, remaining=remaining+?, approved=1, @@ -115,4 +122,4 @@ async function topUp(nasAdId, addImpressions, days) { return { ok: true }; } -module.exports = { enabled, pushCampaign, readServed, deactivate, topUp, impressionsPerCredit, nasKind }; +module.exports = { setClickUrl, enabled, pushCampaign, readServed, deactivate, topUp, impressionsPerCredit, nasKind };