Network rate 4:1 (Marty approved 2026-10-27, same as InstantAdPay): views off LinkSpin cost 1/synRateDivisor of the on-site rate, going forward
rates.synRateDivisor (default 4, Admin > Rates; 1 = the old rule). Network Ad Space impressions charge 1 credit per impressionsPerCredit x N views; member campaigns shown in other members' zones on their own sites (zones.js serve, offsite) are counted in the new synImps (not Views here) and charged one batch per N x the on-site batch (2 credits per 40 banner views at N=4) through the same spend path, so burns follow what was charged. Fractions are exact (the cumulative served count / the syn_batch counter carry the remainder). The budget is the limit: bookings, resume, top-up and daily allowances are sized at the network rate, and a live ad booked at the old rate is topped up once. Nothing already charged changes; zone owners keep earning as before. Ads screen + classic Campaigns show network and partner-zone views marked at 1/4; chatbot canned answer + live AI fact; cache tags bumped. QA: qa/run.sh nas (stop 9, ratio 10), loginqueue 13, refill 12, run.sh member passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+12
-2
@@ -76,6 +76,9 @@ const CANNED = [
|
||||
{ id: 'qualification', title: 'Qualification: levels 2 and 3', q: ['How do I unlock level 2?', 'How does qualification work?', 'What is a pass-up?'], tags: ['qualification', 'level 2', 'level 3', 'pass-up'],
|
||||
re: /(qualif|unlock level|open level|level ?2|level ?3|pass.?up|two buyers|five buyers)/i,
|
||||
a: 'Level 1, half of every package your direct referrals buy, pays from their first qualifying purchase once your payouts are on. Level 2 (20 percent) opens after two of your people buy a qualifying package, $25 or larger. Level 3 (10 percent) opens after five. The $10 door package is for trying the ads and does not count toward opening levels. Until a level opens, its share passes up the line to the next qualified member, then to the platform, and it never comes back, so leaders qualify before their teams\' teams buy. Qualification is counted by the contract, never expires and cannot be bought.' },
|
||||
{ id: 'network-rate', title: 'Network and partner-zone views cost a quarter of the rate', q: ['Do network views use my credits?', 'Am I charged for views on other sites?', 'Why are network views cheaper?'], tags: ['network views', 'network ad space', 'syndication', 'zones', 'credits', 'rate'],
|
||||
re: /((network (views?|ad space)|partner (network|sites?|zones?)|syndicat\w*|other (members'?|people'?s?) (zones?|sites?)|other sites?).{0,60}(credits?|charge[ds]?|cost|spend|balance|budget|free|pay|rate|cheap)|(credits?|charge[ds]?|cost|spend|balance|budget|pay|rate).{0,60}(network (views?|ad space)|partner (network|sites?|zones?)|syndicat\w*|other (members'?|people'?s?) (zones?|sites?)|other sites?))/i,
|
||||
a: 'Views here on LinkSpin use credits at the normal rate. Your banner and text ads also show on the partner ad network and in other members\' zones on their own sites, and those views cost a quarter of the rate: 4 of them cost what 1 view here does. So your budget goes further, and every credit still buys real views. The Ads screen shows them under each ad as network and partner zones views, marked at 1/4. Zone owners still earn their usual credits for showing your ad.' },
|
||||
{ id: 'zones', title: 'Ad zones on your own site', q: ['What is an ad zone?', 'How do I put ads on my website?', 'What sizes are the zones?'], tags: ['zones', 'publisher', 'embed', 'website'],
|
||||
re: /(what('s| is) (a |an )?(ad )?zone|zones?\b|embed|script tag|publisher|site owner|my (own )?(web)?site|ad slot|viewable)/i,
|
||||
a: 'A zone is an ad slot on your own site: one script tag, nine standard sizes (728x90, 468x60, 300x250, 336x280, 250x250, 125x125, 160x600, 120x600, 320x50). Each load shows a LinkSpin member campaign first, then a network ad, then our house banner if nothing paid fits. You earn ad credits per viewable impression (half the banner on screen for one second, bots never, 50 credited views per visitor per zone per day): 1 credit per 5 viewable member-ad views and 1 per 10 network-ad views, or 1 per 8 on a Verified zone the admin has reviewed. A new zone earns after its first 100 on-site views with at least 40 percent viewable, and paid ads serve only on the site you declared, so copying the tag elsewhere earns nothing. Everything is explained at ' + SITE_URL + '/publishers and you add zones under Zones in your Control Room.' },
|
||||
@@ -156,6 +159,12 @@ function seeds() {
|
||||
// ---- facts for the AI fallback ----
|
||||
// the refuel fact follows the refuelStreak switch: while it is off the assistant says it is not live yet (2026-10-24)
|
||||
let REFUEL_ON = () => false;
|
||||
// NETWORK RATE (Marty, 2026-10-27, approved 4:1) follows ads rates().synRateDivisor; the canned answer quotes 1/4, so the fast
|
||||
// path rewrites it when the admin picks another N, and the AI fact always states the live N.
|
||||
const SYN_N = () => { try { return Math.max(1, Math.floor(Number(require('./ads').synRateDivisor()) || 1)); } catch (e) { return 4; } };
|
||||
const netRateAnswer = n => n === 1 ? 'Your banner and text ads also show on the partner ad network and in other members\' zones on their own sites, and those views use credits at the same rate as views here.'
|
||||
: 'Views here on LinkSpin use credits at the normal rate. Your banner and text ads also show on the partner ad network and in other members\' zones on their own sites, and those views cost 1/' + n + ' of the rate: ' + n + ' of them cost what 1 view here does. So your budget goes further, and every credit still buys real views. The Ads screen shows them under each ad as network and partner zones views, marked at 1/' + n + '. Zone owners still earn their usual credits for showing your ad.';
|
||||
function synFact() { const n = SYN_N(); return '- NETWORK RATE (live, Marty 2026-10-27): views ON LinkSpin are charged at the normal rate. Banner/text views on the partner ad network (Network Ad Space) and member campaigns shown in OTHER members\' zones on their own sites cost 1/' + n + ' of the on-site rate (' + n + ' of them = the price of 1 view here). The budget is the limit, burns follow what was charged, nothing charged before 2026-10-27 changed. Zone owners still earn their usual zone credits.' + String.fromCharCode(10); }
|
||||
function refuelFact() { return REFUEL_ON() ? "- MONTHLY REFUEL STREAK (built 2026-10-24, switch refuelStreak): ONE streak per member across InstantAdPay and LinkSpin. Counted refuel = a NEW package of $20+ on InstantAdPay or $25+ on LinkSpin by one of the member's own positions. First one sets the member's own refuel day; next due 30 days after the last counted refuel; window opens 5 days before the due day; 5-day grace after it; Central time. Missing the grace resets the streak, except one free miss per 365 days. Bonus (purchased-grade ad credits on the site where bought, credit log 'Refuel streak'): one engine m1 +10%, m2 +15%, m3 +20%, m4+ +25%; both sites in the same cycle m1 +15%, m2 +20%, m3 +30%, m4+ +40% each (first site topped up to the both rate, difference only) plus a 100-credit Featured bonus on InstantAdPay at m4+ (purchased-grade credits, any format). Stacks on Five Dollar Friday / Wired Wednesday. Pit Stop: another $20+/$25+ package on a site already refueled this cycle, before the next window opens (the other site's first package in the cycle is the second engine instead) = half the current streak rate, once per site per cycle, not a counted refuel. Badges: Engine Started (first refuel), Refueled 3 / 6 / 12 months. ENGINE ROOM: unlocked by the first counted refuel (greyed 'Refuel to start your engine' before), IAP tab Engine Room + LinkSpin Ads screen panel, same data both sites: dials Fuel left (credits free + in campaigns on both sites vs this cycle's refuel credits incl. bonus, days left at the recent burn), Clicks this week (vs last week, clicks per 1,000 credits), Goals this month (conversion pixel conversions since the 1st Central vs the member's own goal); streak panel; warning lights (ads at 80%, ads out, refuel day coming, login slot open); six part lights (fuel, banner spin, spin link, page, testing, conversion tracking: green working, amber needs attention, grey not started with a Set it up link); one Next move button from simple rules. REFUEL KIT: each counted refuel unlocks the Central-month's members-only banner set for this site's own program (5 sizes, personalized server-side with @username + QR to the member's link; IAP: Promo tools card with Use in an IAP banner campaign; LinkSpin: Ads screen card with Load into my Banner Spin); kits stay usable after the month; streak month 3+ adds an animated GIF, month 6+ a BannerKitAI custom-banners credit (coming, entitlement saved). Reminders 5 days before, on the day, last call at the end of grace (email + on-site notice). The member's Refuel card (InstantAdPay Overview, LinkSpin Credits/Ads) shows refuel day, streak, next bonus, Pit Stop status. Either site alone keeps the streak (one-engine rates); both sites in one cycle = the bigger bonus; never say both are required. MEMBER GUIDE PAGE (public, 2026-10-24): /refuel on both sites (https://instantadpay.com/refuel and https://linkspin.app/refuel): the flow, the numbers, the member steps, leader coaching and FAQ; point members there for the full picture. Ad credits only, never cash; never promise income. No auto-billing: the member chooses every package. ROUTES (2026-10-25): LinkSpin menu item Refuel = https://linkspin.app/credits#refuel (the Refuel panel, scrolled to and highlighted); packages of $25+ there are marked counts for Refuel; https://linkspin.app/credits#buy = the package picker; https://linkspin.app/ads#engine = LinkSpin Engine Room. InstantAdPay Engine Room = https://instantadpay.com/my#engine; its Set up conversion tracking opens https://instantadpay.com/my#conversions (Campaigns > Conversion tracking card, same goals LinkSpin counts). Engine Room links that cross to LinkSpin (Banner Spin, spin link, page, testing, refuel LinkSpin) open LinkSpin with a note at the top naming the job, Step 1, a guide link and Back to InstantAdPay; same email signs in on both.\n" : '- MONTHLY REFUEL STREAK: built but NOT switched on yet. If asked, say it is coming and nothing counts toward it today; do not quote bonus rates or dates.\n'; }
|
||||
const REFUEL_OFF_ANSWER = 'The Monthly Refuel streak (bonus ad credits for refueling every month, more when you refuel both InstantAdPay and LinkSpin) is built but not switched on yet, so nothing counts toward it today. The bonuses running now are Five Dollar Friday and Wired Wednesday on InstantAdPay. When the streak goes live, your Refuel card will show your refuel day.';
|
||||
function systemPrompt(kbBlock) {
|
||||
@@ -163,7 +172,7 @@ function systemPrompt(kbBlock) {
|
||||
|
||||
FACTS:
|
||||
- LEVEL 4 OVERRIDE (LIVE 2026-10-26, first payout Monday 2026-11-02): company paid, decided off chain, paid on chain. 3% of every LinkSpin package purchase (the POL actually paid) goes to the buyer's 4th upline on the LinkSpin contract sponsor chain if that member's contract buyerCount is 5 or more (qualifying buyer = referral whose first package was $25 or more; same bar as level 3); otherwise it hunts up to the next qualified upline, max 25 hops; company account #1 or nobody qualified = company keeps it; exactly one recipient per purchase. Paid weekly in POL every Monday after 9 AM Central for the previous Monday to Sunday Central week, from a company payer wallet via the contract's award(memberId); shown on the Wallet screen as 'Level 4 override' with a Polygon link. Under 0.01 POL carries to the next week. Purchases from the start date only, no back pay. Funded from the platform's 20%; the contract split is unchanged. Separate from InstantAdPay's override; qualification does not carry between sites. Never promise amounts.
|
||||
${refuelFact()}- PRODUCT, all free with an email account: SPIN LINKS (the rotator: one short link, /r/<code>, rotates between destinations by weight; pause any destination; a fallback for when all are off; one-hop redirect; every click recorded with day, country, source, device and a daily-salted visitor hash; bots filtered on the server; click ids and sub ids such as clickid, subid, s1 to s4 pass through to the destination; split tests by tagging the same link with different sub ids; a demo spin on the home page needs no account; DAYPARTING is live: a 7x24 hours grid per spin and per destination, time zone by name or the local time of the visitor, presets, and 'my best hours' from the clicks of the member after 200 clicks; automatic HEALTH CHECKS are live: every destination is checked every 30 minutes, a dead or parked one is paused after three failing checks and resumed when it passes twice, the owner is told once, and Check now runs it on demand). PAGES (page builder: scan any offer URL, get a bridge, review or squeeze page; designs, palettes, layouts and niche presets with hero images; leads to the member's own list, CSV or webhook; published on the pages domain lookfirst.page; sales, advertorial and press-release layouts are coming). ZONES (an ad slot on the member's own site: one async script tag, nine sizes 728x90, 468x60, 300x250, 336x280, 250x250, 125x125, 160x600, 120x600, 320x50; waterfall = LinkSpin member campaign, then a network ad for 728x90 and 468x60, then the LinkSpin house banner; pays ad credits per VIEWABLE impression, half the banner on screen for one second, bots never, 50 credited views per visitor per zone per day; rates 1 credit per 5 viewable member-ad views and 1 per 10 network-ad views, 1 per 8 on a Verified zone; warm-up: a zone earns after its first 100 on-site views with at least 40 percent viewable and goes on hold below that; origin lock: paid ads serve only on the declared site and its subdomains, elsewhere the house banner shows and nothing is earned; up to 50 zones per account; PUBLISHER PROGRAM at /publishers for site owners, tiers Standard (default) and Verified (admin-reviewed site, better network rate)). AUDIENCES (first-party retargeting: "My visitors" collects everyone who viewed the member's pages and zones for 30 days; a pixel tag /p.js for other sites; campaigns can "show only to" or "never show to" an audience; nothing personal stored). PROMO TOOLS at /tools#promo (social posts, text-a-friend, email swipes, banners, objection bank, hook videos; five hook angles with videos: links, pages, zones, audiences, stack; angle links are the invite link plus ?v=). REPORTS (every link in one view, plus Pages, Zones, and since 2026-10-12 Traffic sources and Placements). BLOG at /blog with RSS at /blog/feed.xml. TRAFFIC SOURCES at /sources (2026-10-12): a source is a record of a network the member buys traffic on, created from a catalog of networks (PropellerAds, Zeropark, Adsterra, ExoClick, HilltopAds, TrafficStars, PopAds and more, with each network's macro tokens and conversion postback URL; account-specific slots such as a goal id are filled in at creation) or defined by hand; a spin link is pointed at one source (Share kit on the Links screen, or the Sources screen), and then the Share kit's first row is the exact campaign URL for that network with its macros already in place; when a click that came through that source converts (join, lead, wallet, purchase, or a partner-reported conversion; the member picks which) LinkSpin fires that network's own postback with the network's click id and the payout, server to server, and only the network that sent the click is told; Reports show clicks, uniques and conversions by source and by placement (the value the network's zone, placement, site, campaign, creative, banner or keyword macro carried); up to 30 sources per account, 20 params each; a source with no postback still builds the campaign URL and shows in Reports; the account-level Postbacks list on the Links screen (for the member's own tracker) still works alongside. Knowledge checked on ${KNOWLEDGE_DATE}.
|
||||
${refuelFact()}${synFact()}- PRODUCT, all free with an email account: SPIN LINKS (the rotator: one short link, /r/<code>, rotates between destinations by weight; pause any destination; a fallback for when all are off; one-hop redirect; every click recorded with day, country, source, device and a daily-salted visitor hash; bots filtered on the server; click ids and sub ids such as clickid, subid, s1 to s4 pass through to the destination; split tests by tagging the same link with different sub ids; a demo spin on the home page needs no account; DAYPARTING is live: a 7x24 hours grid per spin and per destination, time zone by name or the local time of the visitor, presets, and 'my best hours' from the clicks of the member after 200 clicks; automatic HEALTH CHECKS are live: every destination is checked every 30 minutes, a dead or parked one is paused after three failing checks and resumed when it passes twice, the owner is told once, and Check now runs it on demand). PAGES (page builder: scan any offer URL, get a bridge, review or squeeze page; designs, palettes, layouts and niche presets with hero images; leads to the member's own list, CSV or webhook; published on the pages domain lookfirst.page; sales, advertorial and press-release layouts are coming). ZONES (an ad slot on the member's own site: one async script tag, nine sizes 728x90, 468x60, 300x250, 336x280, 250x250, 125x125, 160x600, 120x600, 320x50; waterfall = LinkSpin member campaign, then a network ad for 728x90 and 468x60, then the LinkSpin house banner; pays ad credits per VIEWABLE impression, half the banner on screen for one second, bots never, 50 credited views per visitor per zone per day; rates 1 credit per 5 viewable member-ad views and 1 per 10 network-ad views, 1 per 8 on a Verified zone; warm-up: a zone earns after its first 100 on-site views with at least 40 percent viewable and goes on hold below that; origin lock: paid ads serve only on the declared site and its subdomains, elsewhere the house banner shows and nothing is earned; up to 50 zones per account; PUBLISHER PROGRAM at /publishers for site owners, tiers Standard (default) and Verified (admin-reviewed site, better network rate)). AUDIENCES (first-party retargeting: "My visitors" collects everyone who viewed the member's pages and zones for 30 days; a pixel tag /p.js for other sites; campaigns can "show only to" or "never show to" an audience; nothing personal stored). PROMO TOOLS at /tools#promo (social posts, text-a-friend, email swipes, banners, objection bank, hook videos; five hook angles with videos: links, pages, zones, audiences, stack; angle links are the invite link plus ?v=). REPORTS (every link in one view, plus Pages, Zones, and since 2026-10-12 Traffic sources and Placements). BLOG at /blog with RSS at /blog/feed.xml. TRAFFIC SOURCES at /sources (2026-10-12): a source is a record of a network the member buys traffic on, created from a catalog of networks (PropellerAds, Zeropark, Adsterra, ExoClick, HilltopAds, TrafficStars, PopAds and more, with each network's macro tokens and conversion postback URL; account-specific slots such as a goal id are filled in at creation) or defined by hand; a spin link is pointed at one source (Share kit on the Links screen, or the Sources screen), and then the Share kit's first row is the exact campaign URL for that network with its macros already in place; when a click that came through that source converts (join, lead, wallet, purchase, or a partner-reported conversion; the member picks which) LinkSpin fires that network's own postback with the network's click id and the payout, server to server, and only the network that sent the click is told; Reports show clicks, uniques and conversions by source and by placement (the value the network's zone, placement, site, campaign, creative, banner or keyword macro carried); up to 30 sources per account, 20 params each; a source with no postback still builds the campaign URL and shows in Reports; the account-level Postbacks list on the Links screen (for the member's own tracker) still works alongside. Knowledge checked on ${KNOWLEDGE_DATE}.
|
||||
- CONVERSION PIXEL (LIVE 2026-10-23, Control Room > Conversions at ${SITE_URL}/conversions; InstantAdPay members see the same goals under Campaigns > Conversion tracking, held on their LinkSpin account): a member names GOALS (subscriber, sale, any word, optional default value, up to 20); each goal has a PUBLIC pixel id (px + 10 characters) that can only count clicks the member owns. EVERY CLICK GETS AN ID: LinkSpin ad clicks (banner, text, zones) and InstantAdPay ad clicks add lsclk=<click id> to the target address (other params kept); a spin link reached through an ad passes its own id on and inherits the ad as its source; spin links of a member with a goal add lsclk to the destination too, and so do Banner Spin clicks that go straight to a page (since 2026-10-26; a banner pointed at a spin link gets the spin link's id). SETUP, 3 steps: 1) the LANDING TAG on the landing page, one line <script async src="https://${SITE_HOST}/t.js?px=PIXEL_ID"></script>, keeps the id on the member's own site 30 days (localStorage + a first-party cookie), fills hidden form fields named lsclk, lsid or clickid and adds the id to links that stay on the same site; 2) the GOAL PIXEL on the thank-you page, an image cv.gif?px=PIXEL_ID&goal=NAME (optional &value=19.95) or the script version cv.js that reads what the tag kept; 3) Send a test conversion (recorded apart, never counted). MATCHING ORDER: the click id in the address, then the id the tag kept, then LinkSpin's own cookie, then a 24-hour match on network + browser (a hash, no IP stored); the method is shown per goal so members see how solid each count is. RULES: each goal counts once per click (an ad click and the spin-link click it led to are one click), only within 30 days of a real click, only for the pixel owner's own clicks, rate limited per pixel and per visitor. OWN CLICKS (2026-10-26): the goal owner's own click on ANY click type (ads, spin links, Banner Spins) is kept as a test and never counted: a click made while signed in as the owner, or a click or conversion from a browser (network + browser soft key) the owner has signed in from on LinkSpin or InstantAdPay; the Conversions screen says 'N from your own clicks, kept as tests and left out'. To test, use Send a test conversion and the &test=1 page check, never a sign-up of your own. REPORTS per goal: conversions and cost per goal (the campaign's credits spent / its conversions, in that site's ad credits) by ad campaign (LinkSpin and InstantAdPay), spin link, Banner Spin (banners straight to a page), destination page and traffic source, plus CSV export. POSTBACKS: a postback or traffic source set to the event 'goal' fires for every goal with {event} = the goal name. AUTORESPONDERS: when Aweber, GetResponse or another provider hosts the thank-you page, set its thank-you (success) redirect to the member's own page that carries the pixel; otherwise the pixel still counts through the cookie or the 24-hour match, less surely. The tag and pixel never break the page if LinkSpin cannot be reached and work inside traffic-exchange frames. SETUP GUIDE (public, 2026-10-24): ${SITE_URL}/conversion-tracking (InstantAdPay's copy: https://instantadpay.com/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, the last test time updates, then remove it), what to do without code on the thank-you page (image pixel = cookie or 24-hour match; LinkSpin.goal(pixelId, name) from the page's own code for a pop-up form; postbacks), 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, a Banner Spin banner pointed straight at a page now carries its own click id and counts under By Banner Spin; the member's own clicks on ads, spin links and Banner Spins are all kept as tests). Send members there for any setup question.
|
||||
- TOOL LIMITS BY TIER (2026-10-21): spin links and pages each: Free (no package) 3, Starter (any package of your own) 10, Builder (level 2 open, 2 qualifying buyers) 50, Leader (level 3 open, 5 qualifying buyers) unlimited (fair use). Each spin link rotates up to 25 destinations at every tier; clicks are unlimited. Nothing already made is ever removed when a cap applies; new ones wait for the upgrade. Banner Spin has its own ladder (Starter 2 x 5, Builder 5 x 15, Leader 10 x 25). Other limits, same for everyone: 50 zones, 20 audiences, 20 postbacks, 5 linked positions.
|
||||
- BANNER SPIN (LIVE 2026-10-18, reports and health checks 2026-10-20): one image address (/i/<code>.gif on a link domain) and one click address (/c/<code>) that rotate up to 25 banners, each with its own target (any https page or one of the member's spin links), weights 1 to 100, random by weight on every view or one banner per visitor per day, the dayparting grid per Banner Spin and per banner, pause, a fallback page and an optional fallback banner image, and a traffic source so its conversions fire that network's postback. Built on the Links screen (${SITE_URL}/links#b). WHO GETS IT: a free add-on for members with their own package of $25 or more; tiers: Starter 2 Banner Spins x 5 banners, Builder (level 2 open, 2 qualifying buyers) 5 x 15, Leader (level 3 open, 5 qualifying buyers) 10 x 25; dropping below a tier keeps everything serving, it only stops new ones. One size per Banner Spin (468x60, 728x90, 300x250, 125x125, 160x600, 120x600, 336x280, 250x250, 320x50); JPG, PNG or GIF (animated is fine), 150 KB at most, uploads count toward the 10 files a day. EMBEDS: the image + click pair (traffic exchanges, safelists, downline builders), an HTML snippet (own sites, blogs, HTML email), a script tag (writes the banner and its own link, so every click matches exactly) and forum BBCode; every link domain answers every code. MATCHING: with the pair, the server remembers which banner a visitor saw on which page for 15 minutes and sends the click there; an unmatched click goes to the fallback. LIMITS: paid ad networks (Froggy, PropellerAds and the like) copy the image at upload, so it freezes on one banner there; Gmail and some mail apps fetch images through a caching proxy, so email readers mostly see one banner and clicks fall back: use a single-banner Banner Spin for email. REPORTS: per banner and per placement views, unique viewers (daily sample), clicks, CTR, match rate and conversions, by Central day, country and device, bots and server loads shown separately and never counted; a WINNER badge once two or more live banners have 1,000 views each and one leads on click rate (LinkSpin never changes weights by itself); a CACHED flag on a placement that copies banners to its own server; totals also on the Reports screen. HEALTH: every 30 minutes each live banner's image must load as an image of the right size and its target must pass the spin-link checks (dead, parked, slow); three failures in a row pause that banner, two clean passes resume it, the last live banner is never auto-paused, and the status shows on each banner row.
|
||||
@@ -236,8 +245,9 @@ async function answerRaw(message, historyText) {
|
||||
let hit = null, kbOk = true;
|
||||
try { hit = await kb.fastPath(msg); } catch (e) { kbOk = false; console.error('kb fast path', e.message); }
|
||||
if (hit && hit.id === 'refuel' && !REFUEL_ON()) return { reply: REFUEL_OFF_ANSWER, canned: true, kb: hit.id };
|
||||
if (hit && (hit.id === 'network-rate' || hit.id === 'c-network-rate') && SYN_N() !== 4) return { reply: netRateAnswer(SYN_N()), canned: true, kb: hit.id };
|
||||
if (hit) return Object.assign({ reply: hit.answer, canned: true, kb: hit.id }, hit.handoff ? { handoff: true } : {});
|
||||
if (!kbOk) for (const c of CANNED) if (c.re.test(msg)) return c.id === 'refuel' && !REFUEL_ON() ? { reply: REFUEL_OFF_ANSWER, canned: true } : Object.assign({ reply: c.a, canned: true }, c.handoff ? { handoff: true } : {});
|
||||
if (!kbOk) for (const c of CANNED) if (c.re.test(msg)) return c.id === 'refuel' && !REFUEL_ON() ? { reply: REFUEL_OFF_ANSWER, canned: true } : c.id === 'network-rate' && SYN_N() !== 4 ? { reply: netRateAnswer(SYN_N()), canned: true } : Object.assign({ reply: c.a, canned: true }, c.handoff ? { handoff: true } : {});
|
||||
// retrieval: the closest entries ride along in the system prompt (a short follow-up borrows words from the chat so far)
|
||||
let kbBlock = '', kbIds = [];
|
||||
try {
|
||||
|
||||
@@ -120,6 +120,8 @@ async function bootstrap() {
|
||||
await alterSafe('ALTER TABLE campaigns ADD COLUMN height INT NULL'); // banner size (IAB) → also NAS height
|
||||
await alterSafe('ALTER TABLE campaigns ADD COLUMN nas_ad_id INT NULL'); // syndicated NAS sponsorads.ID
|
||||
await alterSafe('ALTER TABLE campaigns ADD COLUMN nas_served INT NOT NULL DEFAULT 0'); // NAS impressions already reconciled into spend
|
||||
await alterSafe('ALTER TABLE campaigns ADD COLUMN syn_imps INT NOT NULL DEFAULT 0'); // views in other members' zones (charged at 1/synRateDivisor)
|
||||
await alterSafe('ALTER TABLE campaigns ADD COLUMN syn_batch INT NOT NULL DEFAULT 0'); // partner-zone views toward the next 1/N batch
|
||||
await alterSafe('ALTER TABLE campaigns ADD COLUMN expires BIGINT NULL'); // featured rotation end time
|
||||
await alterSafe('ALTER TABLE campaigns ADD COLUMN starts BIGINT NULL'); // featured run start (booked day); any type: scheduled start
|
||||
await q(`CREATE TABLE IF NOT EXISTS camp_hours (
|
||||
|
||||
+1
-1
@@ -535,6 +535,6 @@
|
||||
|
||||
<script src="/assets/common.js?v=20261023ov"></script>
|
||||
<script src="/assets/admin-kb.js?v=20261020kb"></script>
|
||||
<script src="/assets/admin.js?v=20261027th"></script><script src="/assets/admin-sponsorcheck.js?v=20261022sc"></script><script src="/assets/admin-refill.js?v=20261024rf"></script><script src="/assets/admin-kits.js?v=20261024kit"></script>
|
||||
<script src="/assets/admin.js?v=20261027nr"></script><script src="/assets/admin-sponsorcheck.js?v=20261022sc"></script><script src="/assets/admin-refill.js?v=20261024rf"></script><script src="/assets/admin-kits.js?v=20261024kit"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<script src="/assets/cr-shell.js?v=20261025ff"></script>
|
||||
<script src="/assets/ads-screen.js?v=20261023q"></script>
|
||||
<script src="/assets/ads-screen.js?v=20261027nr"></script>
|
||||
<script src="/assets/fuel.js?v=20261025ff"></script>
|
||||
<script src="/assets/engine-room.js?v=20261025ff"></script>
|
||||
</body>
|
||||
|
||||
@@ -1012,6 +1012,7 @@
|
||||
loginCreditsPerDay: ['Login ad: legacy credits per day', 'only for old login ads with no end date (none since slots)'],
|
||||
loginDwellSeconds: ['Login ad: seconds shown', 'full-screen interstitial after sign-in'],
|
||||
burnBatchMin: ['On-chain burn batch (credits)', 'accrued spend is burned once it reaches this'],
|
||||
synRateDivisor: ['Network rate divisor (N)', 'partner-network (NAS) views and member ads in other members zones cost 1/N of the on-site rate; 1 = same rate; whole numbers'],
|
||||
welcomeCredits: ['Welcome credits', 'granted after the welcome tour'],
|
||||
dailyViewTarget: ['Daily view set (ads)', 'ads a member views for the daily claim'],
|
||||
dailyClaimCredits: ['Daily claim (credits)', 'paid when the set is complete'],
|
||||
|
||||
@@ -22,7 +22,10 @@
|
||||
try { [D, EARN] = await Promise.all([CR.get('/api/my/campaigns'), CR.get('/api/my/earn')]); } catch (e) { CR.sub('could not load'); return; }
|
||||
const cs = D.campaigns || []; const live = cs.filter(c => c.status === 'active');
|
||||
{ const sel = $('fAud'); if (sel) { const keep = sel.value; sel.innerHTML = '<option value="">Everyone</option>' + (D.audiences || []).map(a => '<option value="' + a.id + '">' + esc(a.name) + ' (' + fmt(a.size30) + ')</option>').join(''); sel.value = keep; sel.onchange = () => { $('fAudModeRow').hidden = !sel.value; }; } }
|
||||
const views = cs.reduce((n, c) => n + (c.imps || 0) + (c.impsNas || 0), 0);
|
||||
const views = cs.reduce((n, c) => n + (c.imps || 0) + (c.impsNas || 0) + (c.impsSyn || 0), 0);
|
||||
const synN = Math.max(1, Math.floor(Number(D.rates && D.rates.synRateDivisor) || 1)); // network rate (Marty, 2026-10-27, 4:1)
|
||||
const offTxt = c => (c.impsNas ? '<br><span class="muted" style="font-size:11px">+' + fmt(c.impsNas) + ' network' + (synN > 1 ? ' at 1/' + synN : '') + '</span>' : '')
|
||||
+ (c.impsSyn ? '<br><span class="muted" style="font-size:11px">+' + fmt(c.impsSyn) + ' partner zones' + (synN > 1 ? ' at 1/' + synN : '') + '</span>' : '');
|
||||
CR.sub(live.length + ' live · ' + fmt(D.availableCredits) + ' credits available');
|
||||
const hours = new Array(24).fill(0); Object.values(D.hours || {}).forEach(a => (a || []).forEach((n, i) => { hours[i] += Number(n) || 0; })); // last 7 days by UTC hour, all campaigns
|
||||
const week = hours.reduce((a, b) => a + b, 0);
|
||||
@@ -32,7 +35,7 @@
|
||||
CR.tile({ k: 'Views delivered', v: fmt(views), series: week ? hours : null, note: week ? fmt(week) + ' in 7 days, by hour' : '' }),
|
||||
CR.tile({ k: 'Today\'s viewing', v: EARN.views + ' / ' + EARN.target, note: EARN.streakDay > 1 ? 'streak day ' + EARN.streakDay : '' })].join('');
|
||||
const r = D.rates || {};
|
||||
$('rateLine').textContent = 'Rates: ' + r.bannerCreditsPerBatch + ' credits per ' + r.bannerBatch + ' banner views, ' + r.textCreditsPerBatch + ' per ' + r.textBatch + ' text views, ' + fmt(slotInfo().credits) + ' purchased credits for a ' + slotInfo().days + '-day login slot (' + (slotInfo().free ? slotInfo().free + ' of ' + slotInfo().max + ' open' : 'all ' + slotInfo().max + ' taken' + (slotInfo().queued ? ', ' + slotInfo().queued + ' in line' : '') + ', reserve the next one') + '). Viewing pays ' + EARN.claimCredits + ' credits for ' + EARN.target + ' timed views a day.';
|
||||
$('rateLine').textContent = 'Rates: ' + r.bannerCreditsPerBatch + ' credits per ' + r.bannerBatch + ' banner views, ' + r.textCreditsPerBatch + ' per ' + r.textBatch + ' text views' + (synN > 1 ? ' here (views on the partner network and in other members\u2019 zones cost 1/' + synN + ' of that)' : '') + ', ' + fmt(slotInfo().credits) + ' purchased credits for a ' + slotInfo().days + '-day login slot (' + (slotInfo().free ? slotInfo().free + ' of ' + slotInfo().max + ' open' : 'all ' + slotInfo().max + ' taken' + (slotInfo().queued ? ', ' + slotInfo().queued + ' in line' : '') + ', reserve the next one') + '). Viewing pays ' + EARN.claimCredits + ' credits for ' + EARN.target + ' timed views a day.';
|
||||
// traffic-light status (2026-10-20): live green, running low amber (80%+ of the budget spent), out red, paused grey
|
||||
const stKey = c => c.status === 'queued' ? 'queued' : c.status === 'cancelled' ? 'cancelled' : c.scheduled ? 'sched' : c.status === 'active' ? (c.type !== 'login' && c.budget > 0 && c.spent / c.budget >= 0.8 ? 'low' : 'live') : c.status === 'paused' ? 'paused' : c.status === 'out' ? 'out' : c.status === 'done' ? 'ended' : '';
|
||||
const ST_LABEL = { queued: 'In line', cancelled: 'Cancelled, refunded', sched: 'Scheduled', live: 'Live', low: 'Running low', paused: 'Paused', out: 'Out of credits', ended: 'Ended' };
|
||||
@@ -40,14 +43,14 @@
|
||||
const QM = {}; (D.loginQueue || []).forEach(q => { QM[q.id] = q; });
|
||||
const qCell = c => { const q = QM[c.id]; return '<span class="muted">full page<br><span style="font-size:12px"><b>#' + (q ? q.place : '?') + ' in line</b>, paid' + (q && q.estStartCt ? '<br>' + (q.estStartCt === 'any minute now' ? 'starts any minute now' : 'est. start ' + esc(q.estStartCt) + ' CT (an estimate)') : '') + '</span></span>'; };
|
||||
const cr = c => c.status === 'queued' ? qCell(c) : c.status === 'cancelled' ? '<span class="muted">full page<br><span style="font-size:12px">' + fmt(c.refunded || 0) + ' credits refunded</span></span>' : c.type === 'banner' ? (c.imageUrl ? '<img class="thumb" src="' + esc(c.imageUrl) + '" alt="">' : '') + '<span class="mono muted" style="font-size:11px">' + c.width + 'x' + c.height + '</span>' : c.type === 'text' ? '<b>' + esc(c.title) + '</b><br><span class="muted" style="font-size:12px">' + esc(c.body || '') + '</span>' : '<span class="muted">full page' + (c.type === 'login' && c.expires ? '<br><span style="font-size:12px">' + (c.expires > Date.now() ? 'slot ends ' : 'ended ') + new Date(c.expires).toLocaleDateString(undefined, { month: 'short', day: 'numeric' }) + '</span>' : '') + '</span>';
|
||||
$('rows').innerHTML = cs.length ? cs.map(c => '<div class="rw st-row" data-st="' + stKey(c) + '"><div><b>' + esc(c.name) + '</b> <span class="tag t">' + esc(c.type) + '</span>' + (c.audience ? ' <span class="tag plain" title="audience">' + esc((((D && D.audiences) || []).find(a => a.id === c.audience) || {}).name || 'audience') + (c.audienceMode === 'exclude' ? ' · excluded' : '') + '</span>' : '') + '<br><span class="mono muted" style="font-size:11px">#' + c.id + ' · ' + esc(host(c.targetUrl)) + (c.geo ? ' · tiers ' + esc(c.geo) : '') + (c.dailyCap ? ' · cap ' + c.dailyCap + '/day' : '') + '</span></div><div>' + cr(c) + '</div><div><span class="num">' + fmt(c.status === 'cancelled' ? 0 : c.spent) + '</span><span class="muted"> / ' + fmt(c.budget) + (c.status === 'queued' ? ' paid' : '') + '</span><div class="bar st"><i style="width:' + (c.status === 'cancelled' ? 0 : Math.min(100, Math.round(100 * c.spent / Math.max(1, c.budget)))) + '%"></i></div></div><span class="r num">' + fmt(c.imps) + (c.impsNas ? '<br><span class="muted" style="font-size:11px">+' + fmt(c.impsNas) + ' network</span>' : '') + '</span><span class="r num">' + fmt(c.clicks) + '</span><span>' + st(c) + '</span><span style="display:flex;gap:6px;justify-content:flex-end;flex-wrap:wrap">'
|
||||
$('rows').innerHTML = cs.length ? cs.map(c => '<div class="rw st-row" data-st="' + stKey(c) + '"><div><b>' + esc(c.name) + '</b> <span class="tag t">' + esc(c.type) + '</span>' + (c.audience ? ' <span class="tag plain" title="audience">' + esc((((D && D.audiences) || []).find(a => a.id === c.audience) || {}).name || 'audience') + (c.audienceMode === 'exclude' ? ' · excluded' : '') + '</span>' : '') + '<br><span class="mono muted" style="font-size:11px">#' + c.id + ' · ' + esc(host(c.targetUrl)) + (c.geo ? ' · tiers ' + esc(c.geo) : '') + (c.dailyCap ? ' · cap ' + c.dailyCap + '/day' : '') + '</span></div><div>' + cr(c) + '</div><div><span class="num">' + fmt(c.status === 'cancelled' ? 0 : c.spent) + '</span><span class="muted"> / ' + fmt(c.budget) + (c.status === 'queued' ? ' paid' : '') + '</span><div class="bar st"><i style="width:' + (c.status === 'cancelled' ? 0 : Math.min(100, Math.round(100 * c.spent / Math.max(1, c.budget)))) + '%"></i></div></div><span class="r num">' + fmt(c.imps) + offTxt(c) + '</span><span class="r num">' + fmt(c.clicks) + '</span><span>' + st(c) + '</span><span style="display:flex;gap:6px;justify-content:flex-end;flex-wrap:wrap">'
|
||||
+ (c.status === 'active' ? '<button class="btn sm" type="button" data-pause="' + c.id + '">Pause</button>' : c.status === 'paused' ? '<button class="btn sm" type="button" data-resume="' + c.id + '">Resume</button>' : '')
|
||||
+ (['active', 'paused', 'out'].includes(c.status) && c.type !== 'login' ? '<button class="btn sm" type="button" data-top="' + c.id + '">Top up</button>' : '')
|
||||
+ (c.status === 'queued' ? '<button class="btn sm" type="button" data-qcancel="' + c.id + '" title="Leave the line: the ' + fmt(c.budget) + ' credits you paid come back in full">Cancel and refund</button>' : '')
|
||||
+ (!['done', 'cancelled'].includes(c.status) ? '<button class="btn sm" type="button" data-edit="' + c.id + '" title="' + (c.edits ? 'Edit the link, ' + (c.type === 'banner' ? 'image' : c.type === 'text' ? 'text' : 'name') + ' (' + fmt(D.editFee) + ' credits)' : 'Fix the link, ' + (c.type === 'banner' ? 'image' : c.type === 'text' ? 'text' : 'name') + ' (first edit free)') + '">Edit</button>' : '') + '</span></div>').join('')
|
||||
: '<div class="rw"><span class="muted">No ads yet. Launch one: a banner, a text ad or a login-ad slot.</span></div>';
|
||||
if (D.gauntletPending) $('earnNote').insertAdjacentHTML('afterend', '<div class="muted" style="margin-top:8px">Your welcome credits unlock after the short welcome tour on <a href="/tools">the classic dashboard</a>.</div>');
|
||||
$('foot').textContent = 'views = timed views in the ad viewer plus member zones; network = the partner ad network · a paused ad keeps its credits · unspent credits return when an ad ends';
|
||||
$('foot').textContent = 'views = views here on LinkSpin; network = the partner ad network; partner zones = other members\u2019 zones on their own sites' + (synN > 1 ? ' (network and partner-zone views cost 1/' + synN + ' of the rate here, so ' + synN + ' of them cost what 1 view here does)' : '') + ' · a paused ad keeps its credits · unspent credits return when an ad ends';
|
||||
$('rows').querySelectorAll('[data-pause]').forEach(b => b.addEventListener('click', () => act('/api/my/campaigns/' + b.dataset.pause + '/pause')));
|
||||
$('rows').querySelectorAll('[data-resume]').forEach(b => b.addEventListener('click', () => act('/api/my/campaigns/' + b.dataset.resume + '/resume')));
|
||||
$('rows').querySelectorAll('[data-top]').forEach(b => b.addEventListener('click', async () => { const v = await dialog({ title: 'Top up #' + b.dataset.top, text: 'Add credits to this ad. You have ' + fmt(D.availableCredits) + ' available.', fields: [{ k: 'credits', label: 'Credits to add', value: '25', mono: true }], ok: 'Add' }); if (!v) return; try { await api('/api/my/campaigns/' + b.dataset.top + '/topup', { credits: Number(v.credits) }); toast('Topped up.'); load(); } catch (e) { toast(e.message, true); } }));
|
||||
|
||||
+3
-2
@@ -831,12 +831,13 @@
|
||||
if (!r.campaigns.length) { el.innerHTML = '<p class="muted small">No campaigns yet. Launch your first below.</p>'; return; }
|
||||
const tbl = document.createElement('div');
|
||||
tbl.className = 'tablewrap';
|
||||
tbl.innerHTML = '<table class="camp-table"><thead><tr><th>Name</th><th>Type</th><th class="num">Views here</th><th class="num" title="Impressions delivered by Network Ad Space across the wider network (banner and text ads only)">Network views</th><th class="num">Clicks</th>'
|
||||
const synN = Math.max(1, Math.floor(Number(r.rates && r.rates.synRateDivisor) || 1)); // network rate (Marty, 2026-10-27, 4:1)
|
||||
tbl.innerHTML = '<table class="camp-table"><thead><tr><th>Name</th><th>Type</th><th class="num">Views here</th><th class="num" title="Impressions on the partner ad network plus views in other members\u2019 zones on their own sites (banner and text ads)' + (synN > 1 ? ', at 1/' + synN + ' of the rate here' : '') + '">Network views</th><th class="num">Clicks</th>'
|
||||
+ '<th class="num">Spent</th><th class="num">Budget</th><th>Status</th><th></th></tr></thead><tbody>'
|
||||
+ r.campaigns.map(c => '<tr><td data-l="Campaign"><b>' + c.name + '</b>' + hourBars(r.hours && r.hours[c.id]) + geoLine(r.geo && r.geo[c.id]) + '</td>'
|
||||
+ '<td data-l="Type">' + c.type + (c.type === 'banner' && c.width ? ' <span class="muted small">' + c.width + '×' + c.height + '</span>' : '') + (c.dailyCap ? ' <span class="muted small" title="daily cap: ' + c.dailyCap + ' credits, ' + (c.daySpent || 0) + ' spent today">cap ' + c.dailyCap + '/day</span>' : '') + (c.geo ? ' <span class="muted small" title="shown only to viewers in these country tiers">tier ' + esc(c.geo.replace(/,/g, '+')) + '</span>' : '') + schedChips(c) + '</td>'
|
||||
+ '<td class="num" data-l="Views here">' + c.imps.toLocaleString() + '</td>'
|
||||
+ '<td class="num" data-l="Network views">' + (['banner', 'text'].includes(c.type) ? (c.impsNas || 0).toLocaleString() : '<span class="muted small" title="only banner and text ads syndicate to the network">n/a</span>') + '</td>'
|
||||
+ '<td class="num" data-l="Network views">' + (['banner', 'text'].includes(c.type) ? ((c.impsNas || 0) + (c.impsSyn || 0)).toLocaleString() + (synN > 1 && (c.impsNas || c.impsSyn) ? ' <span class="muted small">at 1/' + synN + '</span>' : '') : '<span class="muted small" title="only banner and text ads syndicate to the network">n/a</span>') + '</td>'
|
||||
+ '<td class="num" data-l="Clicks">' + c.clicks + (r.clickSources && r.clickSources[c.id] ? '<div class="muted small clk-src" title="where the clicks happened">' + Object.entries(r.clickSources[c.id]).sort((a, b) => b[1] - a[1]).map(([k, v]) => '<span>' + esc(k) + ' ' + v + '</span>').join('') + (c.impsNas ? ' · network: see Network views' : '') + '</div>' : '') + '</td>'
|
||||
+ '<td class="num" data-l="Spent">' + c.spent + '</td><td class="num" data-l="Budget">' + c.budget + '</td>'
|
||||
+ '<td data-l="Status">' + (c.status === 'out' ? '<span class="badge amber">budget spent</span>' : c.status === 'done' ? '<span class="muted">ended</span>' : c.scheduled ? '<span class="badge">scheduled</span>' : c.status) + '</td>'
|
||||
|
||||
+1
-1
@@ -1012,7 +1012,7 @@
|
||||
<script src="/assets/tools.js?v=20261011a"></script>
|
||||
<script src="/assets/wallet.js?v=20261021a"></script>
|
||||
<script src="/assets/promo.js?v=20261020bs3"></script>
|
||||
<script src="/assets/my.js?v=20261027th"></script>
|
||||
<script src="/assets/my.js?v=20261027nr"></script>
|
||||
<script src="/assets/chat.js?v=20261016a"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
// Network rate on LinkSpin (Marty, 2026-10-27, approved 4:1): views off LinkSpin's own pages cost 1/synRateDivisor of the
|
||||
// on-site rate. JSON store, NAS stubbed, throwaway data dir. node qa/nas-ratio.test.cjs
|
||||
// Covers: N=4 NAS views (1 credit per 20 banner views, fractions exact), partner-zone views (2 credits per 40, counted in
|
||||
// synImps, not in Views here), on-site batches unchanged, budget is the limit, a lowered rate tops NAS up once, N=1 = old rule.
|
||||
'use strict';
|
||||
delete process.env.DATABASE_URL;
|
||||
const fs = require('fs'); const os = require('os'); const path = require('path');
|
||||
const ok = [], bad = [];
|
||||
const t = (n, c, extra) => { (c ? ok : bad).push(n + (c || extra === undefined ? '' : ' -> ' + extra)); };
|
||||
const DATA = fs.mkdtempSync(path.join(os.tmpdir(), 'ls-nas-ratio-'));
|
||||
const nas = require('../nas.js');
|
||||
const rows = {}; const calls = { topUp: [], deactivate: 0 };
|
||||
nas.enabled = () => true;
|
||||
nas.impressionsPerCredit = type => type === 'banner' ? 5 : 10;
|
||||
nas.readServed = async id => { const r = rows[id]; return r ? { assigned: r.assigned, remaining: r.remaining, served: Math.max(0, Math.min(r.assigned, r.assigned - r.remaining)), clicks: 0 } : null; };
|
||||
nas.deactivate = async id => { const r = rows[id]; const served = Math.max(0, r.assigned - r.remaining); r.remaining = 0; calls.deactivate++; return { ok: true, served }; };
|
||||
nas.topUp = async (id, add) => { rows[id].assigned += add; rows[id].remaining += add; calls.topUp.push([id, add]); return { ok: true }; };
|
||||
nas.restart = async (id, base, add) => { rows[id].assigned = base + add; rows[id].remaining = add; return { ok: true }; };
|
||||
nas.updateCreative = async () => ({ ok: true });
|
||||
const ads = require('../ads.js');
|
||||
const zones = require('../zones.js');
|
||||
const ADV = 'ratio@qa.test', PUB = 'pub@qa.test', FILE = path.join(DATA, 'campaigns.json');
|
||||
const banner = (id, x) => Object.assign({ id, owner: ADV, memberId: 0, type: 'banner', name: 'QA ' + id, targetUrl: 'https://example.com/', imageUrl: 'https://example.com/b.png', width: 728, height: 90,
|
||||
budget: 1000, spent: 0, accrued: 0, imps: 0, batchImps: 0, clicks: 0, status: 'active', created: Date.now() }, x || {});
|
||||
const seed = camps => { fs.writeFileSync(FILE, JSON.stringify({ v: 1, nextId: 9100, campaigns: camps, burnsPending: [] })); ads.init({ dataDir: DATA, chain: { creditBalance: async () => 0 } }); };
|
||||
const C = id => JSON.parse(fs.readFileSync(FILE, 'utf8')).campaigns.find(c => c.id === id);
|
||||
const used = c => (c.spent || 0) + (c.accrued || 0);
|
||||
const req = { headers: { referer: 'https://pubsite.org/page', 'user-agent': 'Mozilla/5.0 (QA)', 'x-forwarded-for': '203.0.113.9' }, socket: {} };
|
||||
(async () => {
|
||||
t('default divisor is 4', ads.synRateDivisor() === 4, String(ads.synRateDivisor()));
|
||||
// partner zones
|
||||
seed([banner(9001)]);
|
||||
fs.writeFileSync(path.join(DATA, 'zone-rates.json'), JSON.stringify({ nasOn: 0 }));
|
||||
zones.init({ dataDir: DATA, ads, siteHost: 'linkspin.test' });
|
||||
await ads.addEarned(ADV, 100000);
|
||||
const z = (await zones.create(PUB, { name: 'QA zone', site: 'pubsite.org', size: '728x90' })).zone;
|
||||
for (let i = 0; i < 39; i++) await zones.serve(z.id, req, {});
|
||||
let c = C(9001);
|
||||
t('N=4: 39 partner-zone views charge nothing yet', used(c) === 0, String(used(c)));
|
||||
await zones.serve(z.id, req, {}); c = C(9001);
|
||||
t('the 40th completes one batch: 2 credits (1/4 of 2 per 10)', used(c) === 2, String(used(c)));
|
||||
t('partner-zone views counted in synImps, not in Views here', c.synImps === 40 && c.imps === 0, JSON.stringify({ syn: c.synImps, imps: c.imps }));
|
||||
for (let i = 0; i < 10; i++) await ads.serve('banner', { width: 728, height: 90 });
|
||||
c = C(9001);
|
||||
t('on-site: 10 views still charge 2 credits', used(c) === 4 && c.imps === 10, JSON.stringify({ used: used(c), imps: c.imps }));
|
||||
// NAS
|
||||
rows[9002] = { assigned: 20000, remaining: 20000 };
|
||||
seed([C(9001), banner(9002, { nasAdId: 9002, nasServed: 0 })]);
|
||||
rows[9002].remaining -= 1010; await ads.reconcileNas();
|
||||
t('N=4: 1,010 network views charge 50 credits (1 per 20)', used(C(9002)) === 50, String(used(C(9002))));
|
||||
rows[9002].remaining -= 10; await ads.reconcileNas();
|
||||
t('10 more complete the 51st credit (fraction carried)', used(C(9002)) === 51, String(used(C(9002))));
|
||||
// budget is the limit
|
||||
rows[9003] = { assigned: 200, remaining: 200 };
|
||||
seed([C(9001), C(9002), banner(9003, { budget: 10, nasAdId: 9003, nasServed: 0 })]);
|
||||
rows[9003].remaining -= 200; await ads.reconcileNas();
|
||||
const x = C(9003);
|
||||
t('budget is the limit: 10 credits, ad out, NAS stopped', used(x) === 10 && x.status === 'out' && calls.deactivate >= 1, JSON.stringify({ used: used(x), st: x.status }));
|
||||
// old rule, then the rate lowered
|
||||
ads.setRates({ synRateDivisor: 1 });
|
||||
rows[9004] = { assigned: 1000, remaining: 1000 };
|
||||
seed([C(9001), C(9002), C(9003), banner(9004, { nasAdId: 9004, nasServed: 0 })]);
|
||||
rows[9004].remaining -= 500; await ads.reconcileNas();
|
||||
t('N=1 (old rule): 500 network views charge 100 credits', used(C(9004)) === 100, String(used(C(9004))));
|
||||
ads.setRates({ synRateDivisor: 4 });
|
||||
const b0 = calls.topUp.length; await ads.reconcileNas(); await ads.reconcileNas();
|
||||
const tu = calls.topUp.slice(b0).filter(q => q[0] === 9004);
|
||||
t('rate lowered to 1/4: NAS topped up once to what 900 credits now buy (18,000)', tu.length === 1 && rows[9004].remaining === 18000, JSON.stringify({ tu, row: rows[9004] }));
|
||||
console.log('PASS ' + ok.length);
|
||||
for (const b of bad) console.log('FAIL ' + b);
|
||||
try { fs.rmSync(DATA, { recursive: true, force: true }); } catch (e) {}
|
||||
process.exit(bad.length ? 1 : 0);
|
||||
})().catch(e => { console.error(e); process.exit(1); });
|
||||
+56
-55
@@ -1,55 +1,56 @@
|
||||
// NAS stop trap on LinkSpin (fixed 2026-10-27; the InstantAdPay 2026-09-17 fix was never ported). NAS has no stop flag,
|
||||
// a stop zeroes `remaining`, and served = assigned - remaining then reads the undelivered rest as DELIVERED. Before the fix:
|
||||
// pause/end/exhaustion called nas.deactivate with no snapshot, reconcileNas read EVERY status, so a paused ad was charged
|
||||
// for its zeroed remainder, and a resume/top-up of a stopped ad counted it again. JSON store, NAS stubbed, throwaway data.
|
||||
// node qa/nas-stop.test.cjs
|
||||
'use strict';
|
||||
delete process.env.DATABASE_URL;
|
||||
const fs = require('fs'); const os = require('os'); const path = require('path');
|
||||
const ok = [], bad = [];
|
||||
const t = (n, c, extra) => { (c ? ok : bad).push(n + (c || extra === undefined ? '' : ' -> ' + extra)); };
|
||||
const DATA = fs.mkdtempSync(path.join(os.tmpdir(), 'ls-nas-stop-'));
|
||||
const nas = require('../nas.js');
|
||||
const rows = {}; const calls = { restart: 0, deactivate: 0 };
|
||||
nas.enabled = () => true;
|
||||
nas.impressionsPerCredit = type => type === 'banner' ? 5 : 10;
|
||||
nas.readServed = async id => { const r = rows[id]; return r ? { assigned: r.assigned, remaining: r.remaining, served: Math.max(0, Math.min(r.assigned, r.assigned - r.remaining)), clicks: 0 } : null; };
|
||||
nas.deactivate = async id => { const r = rows[id]; const served = Math.max(0, r.assigned - r.remaining); r.remaining = 0; calls.deactivate++; return { ok: true, served }; };
|
||||
nas.topUp = async (id, add) => { rows[id].assigned += add; rows[id].remaining += add; return { ok: true }; };
|
||||
nas.restart = async (id, base, add) => { rows[id].assigned = base + add; rows[id].remaining = add; calls.restart++; return { ok: true }; };
|
||||
nas.updateCreative = async () => ({ ok: true });
|
||||
const ads = require('../ads.js');
|
||||
const ADV = 'stop@qa.test', FILE = path.join(DATA, 'campaigns.json');
|
||||
const banner = (id, x) => Object.assign({ id, owner: ADV, memberId: 0, type: 'banner', name: 'QA ' + id, targetUrl: 'https://example.com/', imageUrl: 'https://example.com/b.png', width: 728, height: 90,
|
||||
budget: 1000, spent: 0, accrued: 0, imps: 0, batchImps: 0, clicks: 0, status: 'active', nasAdId: id, nasServed: 0, created: Date.now() }, x || {});
|
||||
const seed = camps => { fs.writeFileSync(FILE, JSON.stringify({ v: 1, nextId: 9100, campaigns: camps, burnsPending: [] })); ads.init({ dataDir: DATA, chain: { creditBalance: async () => 0 } }); };
|
||||
const C = id => JSON.parse(fs.readFileSync(FILE, 'utf8')).campaigns.find(c => c.id === id);
|
||||
const used = c => (c.spent || 0) + (c.accrued || 0);
|
||||
(async () => {
|
||||
seed([banner(9001), banner(9002, { budget: 100 })]);
|
||||
await ads.addEarned(ADV, 10000);
|
||||
rows[9001] = { assigned: 5000, remaining: 5000 }; rows[9002] = { assigned: 500, remaining: 500 };
|
||||
rows[9001].remaining -= 1000; await ads.reconcileNas();
|
||||
t('1,000 real NAS views charge 200 credits', used(C(9001)) === 200, String(used(C(9001))));
|
||||
await ads.setStatus(ADV, 9001, 'paused');
|
||||
t('pause records the TRUE 1,000 served, not the 5,000 allocation', C(9001).nasServed === 1000, String(C(9001).nasServed));
|
||||
await ads.reconcileNas();
|
||||
t('a paused ad is not charged for its zeroed remainder', used(C(9001)) === 200, String(used(C(9001))));
|
||||
const r0 = calls.restart; await ads.setStatus(ADV, 9001, 'active'); await ads.reconcileNas();
|
||||
t('resume restarts the stopped ad from the true count', calls.restart === r0 + 1 && rows[9001].assigned === 5000 && rows[9001].remaining === 4000, JSON.stringify(rows[9001]));
|
||||
t('no phantom delivery or charge after the resume', C(9001).nasServed === 1000 && used(C(9001)) === 200, C(9001).nasServed + ' / ' + used(C(9001)));
|
||||
rows[9001].remaining -= 500; await ads.reconcileNas();
|
||||
t('real views after the resume still charge (500 = 100 credits)', used(C(9001)) === 300, String(used(C(9001))));
|
||||
// exhaustion: budget 100 = 500 views; NAS serves 300, a budget top-up of on-site spend exhausts it on the next reconcile
|
||||
const c2 = C(9002); c2.spent = 60; const s = JSON.parse(fs.readFileSync(FILE, 'utf8')); s.campaigns[s.campaigns.findIndex(x => x.id === 9002)] = c2; fs.writeFileSync(FILE, JSON.stringify(s)); ads.init({ dataDir: DATA, chain: { creditBalance: async () => 0 } });
|
||||
rows[9002].remaining -= 300; const d0 = calls.deactivate; await ads.reconcileNas();
|
||||
const x = C(9002);
|
||||
t('exhausted: charge capped at the budget and the NAS ad stopped', used(x) === 100 && x.status === 'out' && calls.deactivate === d0 + 1, JSON.stringify({ used: used(x), st: x.status }));
|
||||
t('exhausted: served kept at the TRUE 300', x.nasServed === 300, String(x.nasServed));
|
||||
await ads.reconcileNas();
|
||||
t('an exhausted (out) ad is never reconciled again', C(9002).nasServed === 300 && used(C(9002)) === 100, String(C(9002).nasServed));
|
||||
console.log('PASS ' + ok.length);
|
||||
for (const b of bad) console.log('FAIL ' + b);
|
||||
try { fs.rmSync(DATA, { recursive: true, force: true }); } catch (e) {}
|
||||
process.exit(bad.length ? 1 : 0);
|
||||
})().catch(e => { console.error(e); process.exit(1); });
|
||||
// NAS stop trap on LinkSpin (fixed 2026-10-27; the InstantAdPay 2026-09-17 fix was never ported). NAS has no stop flag,
|
||||
// a stop zeroes `remaining`, and served = assigned - remaining then reads the undelivered rest as DELIVERED. Before the fix:
|
||||
// pause/end/exhaustion called nas.deactivate with no snapshot, reconcileNas read EVERY status, so a paused ad was charged
|
||||
// for its zeroed remainder, and a resume/top-up of a stopped ad counted it again. JSON store, NAS stubbed, throwaway data.
|
||||
// node qa/nas-stop.test.cjs
|
||||
'use strict';
|
||||
delete process.env.DATABASE_URL;
|
||||
const fs = require('fs'); const os = require('os'); const path = require('path');
|
||||
const ok = [], bad = [];
|
||||
const t = (n, c, extra) => { (c ? ok : bad).push(n + (c || extra === undefined ? '' : ' -> ' + extra)); };
|
||||
const DATA = fs.mkdtempSync(path.join(os.tmpdir(), 'ls-nas-stop-'));
|
||||
const nas = require('../nas.js');
|
||||
const rows = {}; const calls = { restart: 0, deactivate: 0 };
|
||||
nas.enabled = () => true;
|
||||
nas.impressionsPerCredit = type => type === 'banner' ? 5 : 10;
|
||||
nas.readServed = async id => { const r = rows[id]; return r ? { assigned: r.assigned, remaining: r.remaining, served: Math.max(0, Math.min(r.assigned, r.assigned - r.remaining)), clicks: 0 } : null; };
|
||||
nas.deactivate = async id => { const r = rows[id]; const served = Math.max(0, r.assigned - r.remaining); r.remaining = 0; calls.deactivate++; return { ok: true, served }; };
|
||||
nas.topUp = async (id, add) => { rows[id].assigned += add; rows[id].remaining += add; return { ok: true }; };
|
||||
nas.restart = async (id, base, add) => { rows[id].assigned = base + add; rows[id].remaining = add; calls.restart++; return { ok: true }; };
|
||||
nas.updateCreative = async () => ({ ok: true });
|
||||
const ads = require('../ads.js');
|
||||
const ADV = 'stop@qa.test', FILE = path.join(DATA, 'campaigns.json');
|
||||
const banner = (id, x) => Object.assign({ id, owner: ADV, memberId: 0, type: 'banner', name: 'QA ' + id, targetUrl: 'https://example.com/', imageUrl: 'https://example.com/b.png', width: 728, height: 90,
|
||||
budget: 1000, spent: 0, accrued: 0, imps: 0, batchImps: 0, clicks: 0, status: 'active', nasAdId: id, nasServed: 0, created: Date.now() }, x || {});
|
||||
const seed = camps => { fs.writeFileSync(FILE, JSON.stringify({ v: 1, nextId: 9100, campaigns: camps, burnsPending: [] })); ads.init({ dataDir: DATA, chain: { creditBalance: async () => 0 } }); };
|
||||
const C = id => JSON.parse(fs.readFileSync(FILE, 'utf8')).campaigns.find(c => c.id === id);
|
||||
const used = c => (c.spent || 0) + (c.accrued || 0);
|
||||
(async () => {
|
||||
seed([banner(9001), banner(9002, { budget: 100 })]);
|
||||
await ads.addEarned(ADV, 10000);
|
||||
ads.setRates({ synRateDivisor: 1 }); // the stop/restart logic at the on-site rate (qa/nas-ratio.test.cjs covers the network rate)
|
||||
rows[9001] = { assigned: 5000, remaining: 5000 }; rows[9002] = { assigned: 500, remaining: 500 };
|
||||
rows[9001].remaining -= 1000; await ads.reconcileNas();
|
||||
t('1,000 real NAS views charge 200 credits', used(C(9001)) === 200, String(used(C(9001))));
|
||||
await ads.setStatus(ADV, 9001, 'paused');
|
||||
t('pause records the TRUE 1,000 served, not the 5,000 allocation', C(9001).nasServed === 1000, String(C(9001).nasServed));
|
||||
await ads.reconcileNas();
|
||||
t('a paused ad is not charged for its zeroed remainder', used(C(9001)) === 200, String(used(C(9001))));
|
||||
const r0 = calls.restart; await ads.setStatus(ADV, 9001, 'active'); await ads.reconcileNas();
|
||||
t('resume restarts the stopped ad from the true count', calls.restart === r0 + 1 && rows[9001].assigned === 5000 && rows[9001].remaining === 4000, JSON.stringify(rows[9001]));
|
||||
t('no phantom delivery or charge after the resume', C(9001).nasServed === 1000 && used(C(9001)) === 200, C(9001).nasServed + ' / ' + used(C(9001)));
|
||||
rows[9001].remaining -= 500; await ads.reconcileNas();
|
||||
t('real views after the resume still charge (500 = 100 credits)', used(C(9001)) === 300, String(used(C(9001))));
|
||||
// exhaustion: budget 100 = 500 views; NAS serves 300, a budget top-up of on-site spend exhausts it on the next reconcile
|
||||
const c2 = C(9002); c2.spent = 60; const s = JSON.parse(fs.readFileSync(FILE, 'utf8')); s.campaigns[s.campaigns.findIndex(x => x.id === 9002)] = c2; fs.writeFileSync(FILE, JSON.stringify(s)); ads.init({ dataDir: DATA, chain: { creditBalance: async () => 0 } });
|
||||
rows[9002].remaining -= 300; const d0 = calls.deactivate; await ads.reconcileNas();
|
||||
const x = C(9002);
|
||||
t('exhausted: charge capped at the budget and the NAS ad stopped', used(x) === 100 && x.status === 'out' && calls.deactivate === d0 + 1, JSON.stringify({ used: used(x), st: x.status }));
|
||||
t('exhausted: served kept at the TRUE 300', x.nasServed === 300, String(x.nasServed));
|
||||
await ads.reconcileNas();
|
||||
t('an exhausted (out) ad is never reconciled again', C(9002).nasServed === 300 && used(C(9002)) === 100, String(C(9002).nasServed));
|
||||
console.log('PASS ' + ok.length);
|
||||
for (const b of bad) console.log('FAIL ' + b);
|
||||
try { fs.rmSync(DATA, { recursive: true, force: true }); } catch (e) {}
|
||||
process.exit(bad.length ? 1 : 0);
|
||||
})().catch(e => { console.error(e); process.exit(1); });
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
# bash qa/run.sh tankhold # holding tank: network alignment first, plain-activation hold (never a purchase), 24-hour rotation, payouts on at assignment (unit with a mocked clock + fake engine, then a local copy with a mock InstantAdPay)
|
||||
# bash qa/run.sh lsid # page-builder lead -> rotator conversion + postback, audience pixel events and cookieless hits
|
||||
# bash qa/run.sh convpixel # conversion pixel: ad click ids, landing tag + goal pixel (url/stored/cookie/soft), dedupe, window, owner check, cost per goal, IAP partner calls, browser + framed
|
||||
# bash qa/run.sh nas # Network Ad Space billing: stop snapshot, active-only reconcile, restart without phantom delivery, the 1/N network + partner-zone rate (stubbed NAS, throwaway data)
|
||||
# bash qa/run.sh loginqueue # prepaid login-slot queue: ads.js unit test (two app copies promoting at once) + HTTP/Ads-screen e2e on a local copy
|
||||
# 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 fuel # Fuel Your Offers: refill notices, refuel streak, Refuel Kit, Engine Room (unit + two-copy tests, throwaway data)
|
||||
@@ -49,6 +50,9 @@ elif [ "$MODE" = "sponsorfollow" ]; then
|
||||
node qa/carry-activate.test.cjs || status=1
|
||||
elif [ "$MODE" = "tankhold" ]; then
|
||||
node qa/tank-hold.test.mjs || status=1
|
||||
elif [ "$MODE" = "nas" ]; then
|
||||
node qa/nas-stop.test.cjs || status=1
|
||||
node qa/nas-ratio.test.cjs || status=1
|
||||
elif [ "$MODE" = "loginqueue" ]; then
|
||||
node qa/loginqueue.test.cjs || status=1
|
||||
node qa/loginqueue.e2e.mjs || status=1
|
||||
|
||||
@@ -85,7 +85,7 @@ async function serve(zoneId, req, geoOpts) {
|
||||
// retargeting: a real view on the declared site puts the visitor in the zone owner's automatic audience (30 days)
|
||||
if (!off && !vis.bot && geoOpts && (geoOpts.vid || geoOpts.soft)) { try { audiences.hit(audiences.defaultFor(z.owner), geoOpts.vid, geoOpts.soft); } catch (e) {} }
|
||||
// waterfall: 1) a LinkSpin member campaign 2) a Network Ad Space ad (NAS serves 728x90 and 468x60) 3) the LinkSpin house banner
|
||||
let ad = null; if (paidOk) { try { ad = await ads.serve('banner', Object.assign({ width: w, height: h, excludeEmail: z.owner }, geoOpts || {})); } catch (e) { ad = null; } }
|
||||
let ad = null; if (paidOk) { try { ad = await ads.serve('banner', Object.assign({ width: w, height: h, excludeEmail: z.owner, offsite: true }, geoOpts || {})); } catch (e) { ad = null; } }
|
||||
const nas = !ad && paidOk && s.nasOn && NAS_SIZES.has(z.size);
|
||||
const house = !ad && !nas;
|
||||
if (house && !s.houseOn) return null;
|
||||
|
||||
Reference in New Issue
Block a user