From 017017ad63730b950af29de7315bde78e6c381c1 Mon Sep 17 00:00:00 2001 From: martbost Date: Sun, 18 Oct 2026 06:17:41 -0500 Subject: [PATCH] Login ad in the games: the sponsor interstitial after a fresh in-game sign-in, counted per surface - Game sign-in kit (game-signin.js): after a fresh email sign-in (never a remembered pass) the kit shows the login ad before the hand-off to /auth?t=, same as the dashboard: sponsor card, Open Ad (a counted click through /api/ads/click), sponsor framed in a full-screen overlay when frameable else a new tab, 10 s countdown (loginDwellSeconds), then Continue to the game. No ad, an error, a non-200 or a 7 s stall all go straight to the game. A game page whose CSP blocks the frame gets a new-tab link instead. mount option loginAd: false switches it off. - GET /api/game/ads/login?game=: CORS only for that game's GAME_AUTH origins (dev: localhost); the dashboard /api/ads/slot route keeps no CORS. Both share loginAdFor() (ads.serve: impression + lastShownDay as before). Drip Runner and PolyBreak are marked frames: false (their CSP is default-src 'self'), so their ad opens in a new tab; frame checks for games ignore an instantadpay.com-only frame-ancestors allowance. - loginshows.js: every login-ad request tallied per Central day, surface (dashboard or game slug) and kind (member slot, house, none); MySQL table login_shows (created on first use) or DATA_DIR/login-shows.json. GET /api/admin/login-shows + a Login-ad showings card on the admin Traffic pane (dashboard vs games, house, no-ad, by game). - The kit is served no-cache so games pick it up without a tag bump; admin.js tag bumped. - Chatbot fact updated (slot rules + games), KNOWLEDGE_DATE 2026-10-18. Co-Authored-By: Claude Opus 5.5 --- chatbot.js | 4 +- loginshows.js | 61 +++++++++++++++++++++++++ public/admin.html | 3 +- public/assets/admin.js | 14 ++++++ public/assets/game-signin.js | 87 ++++++++++++++++++++++++++++++++++-- server.js | 66 +++++++++++++++++++-------- 6 files changed, 211 insertions(+), 24 deletions(-) create mode 100644 loginshows.js diff --git a/chatbot.js b/chatbot.js index 1e38e3d..59e494b 100644 --- a/chatbot.js +++ b/chatbot.js @@ -20,7 +20,7 @@ function key() { function enabled() { return !!key(); } // ---- canned answers: instant, free, always in voice ---- -const KNOWLEDGE_DATE = '2026-10-16'; // bump whenever the canned answers / prompt are brought up to date +const KNOWLEDGE_DATE = '2026-10-18'; // bump whenever the canned answers / prompt are brought up to date const SUPPORT_RE = /(contact|reach|email|e-mail|message|talk to|speak (to|with)|get hold of) (the )?(support|admin|administrator|owner|marty|staff|team at instantadpay|someone|a (human|person|real person))|support (email|address|ticket|team|desk)|help ?desk|(open|send|file|submit|raise) (a )?(support )?ticket|\b(human|real person|live (agent|person|chat|support))\b|customer (service|support)|support@|how (do|can) i get (help|support)/i; const CANNED = [ { re: SUPPORT_RE, handoff: true, @@ -172,7 +172,7 @@ FACTS: - CREDIT ACTIVITY LEDGER (2026-09-16): Members > Campaigns has a 'Credit activity' list (last 40 lines, newest first; also linked from the Earn credits pane) showing every real credit movement with a reason: welcome credits, sign-in bonus with streak, daily claim, inbox reads, video watches, verified visits, milestone and leaderboard bonuses, partner codes, admin/team grants, AI Copy Engine charges and refunds, flat buys (featured runs, extensions, visit packs, more visits), login-ad days, and metered delivery rolled up as one line per campaign per day ('Ad views: NAME', 'Inbox deliveries: NAME', 'Video views: NAME'); lines marked '(purchased credits)' spent on-chain purchased credits rather than the earned pool. Reservations (credits set aside for a live campaign) are NOT ledger lines; they show as 'in live campaigns'. Earned credits are spent before purchased ones, so an earn followed by a buy appears as two lines. The ledger starts 2026-09-16; nothing earlier is listed. - PAYMENT + MISSED-PAYMENT NOTICES (2026-09-15): every payout that lands (who bought, level, share in POL and dollars, transaction link) and every missed payout is delivered BOTH by email and as an on-site inbox message from the company account, shown in the login pop-up and the Messages card, so it is waiting when the member signs in. MISSED-PAYOUT detail: when a level-2 or level-3 share passes a member by because that level is not open on their account, the member gets an email the same minute: who bought, the POL and dollar amount they missed, how many qualifying buyers they have versus the 2 or 5 needed, and the two ways to close the gap (bring buyers, or Qualified Start). Qualified members whose wallet rejected a transfer get a different email telling them to link a regular wallet. MISSED PAYOUTS ARE ALSO PUBLIC (2026-09-16): the team's Telegram payments feed posts, by username, who was passed over on a purchase, why (not qualified yet with N of 2 buyers, or payouts not switched on), the amount, and who received it instead; the same for a sale that routed past an unactivated sponsor. Nothing about the contract changed; it is visibility. - LAUNCH WEEK SWIPES (2026-09-15): the founding-week checklist page (/launch) ends with four promoter emails members send to their OWN lists, one a day toward Monday's opening, with the member's invite link and the FOUNDER code (500 credits for anyone who joins before Mon 2026-09-21 9 AM Central) filled in, each with a Copy button. These are swipes for members, not emails the site sends. -- LOGIN ADS ARE A SLOT (2026-09-19): 1,000 purchased credits buys 30 days on the sign-in screen, paid up front, never metered. At most 3 member slots run at once because every slot shares the same sign-ins; when all 3 are taken the buy is refused until one ends. House login ads only show when no member slot is running. Featured links count views (one per viewer per hour) as well as clicks. +- LOGIN ADS ARE A SLOT (2026-09-19, updated 2026-10-18): 1,000 purchased credits buys 30 days on the sign-in screen, paid up front, never metered. Purchased credits only: credited purchased credits first, the rest from the position's on-chain package credits; earned (viewing) credits never pay for a login slot. At most 3 member slots run at once because every slot shares the same sign-ins; when all 3 are taken the buy is refused until one ends, and a paused slot can only be resumed while a slot is open. A slot cannot be topped up (it is a flat 30-day buy with unlimited sign-in impressions). Since 2026-10-18 the login ad shows after a fresh sign-in on the dashboard AND after a fresh email sign-in inside the connected games (Drip Runner, Gem Kingdom, ClutterHunt, PolyBreak, SpellWheel, PolyWarriors), before the player continues to the game; a remembered game session does not show it. House login ads only show when no member slot is running. Featured links count views (one per viewer per hour) as well as clicks. - AD VIEWER OPEN-IN-TAB (2026-09-19): the earn viewer shows the advertiser's page inside a frame; a link in its bar opens the same site in a new tab for sites that refuse to load framed or where signing up is easier in a full tab. The view still credits from the frame's countdown and check. - (2026-09-14 hold rule REPLACED on 2026-09-16 by the walk-up rule above: a purchase is never held for an unactivated sponsor; only a transient chain read error pauses a buy.) - NO-PAYOUT POSITIONS (2026-09-14): admin can list member ids (Settings > No-payout positions) whose wallets must never be paid again (e.g. a compromised key). Those positions stay linked for history and counting only: the buy-from picker disables them, a purchase from them is refused, and invite links that would place a new member under them (or under their upline chain) route to the fallback sponsor instead. The contract itself cannot change a member's wallet. diff --git a/loginshows.js b/loginshows.js new file mode 100644 index 0000000..2d9fb00 --- /dev/null +++ b/loginshows.js @@ -0,0 +1,61 @@ +// Login-ad showings per day per surface (Marty, 2026-10-18). The sign-in interstitial now runs on +// the dashboard AND inside the games' sign-in kit; before raising the 3-slot cap he wants a week of +// combined numbers. One row per Central day, surface ('dashboard' or a game slug) and kind: +// 'member' (a member's slot was shown), 'house' (the house login ad), 'none' (a sign-in with no +// login ad to show). MySQL table login_shows when the DB is on, else DATA_DIR/login-shows.json. +'use strict'; +const fs = require('fs'); +const path = require('path'); +const db = require('./db'); +let DATA_DIR = null, J = null, ready = null; +const ctDay = t => new Date(t === undefined ? Date.now() : t).toLocaleDateString('en-CA', { timeZone: 'America/Chicago' }); +const FILE = () => path.join(DATA_DIR, 'login-shows.json'); + +function init(opts) { DATA_DIR = opts.dataDir; } +function ensure() { + if (!ready) ready = db.q(`CREATE TABLE IF NOT EXISTS login_shows ( + day VARCHAR(10) NOT NULL, surface VARCHAR(40) NOT NULL, kind VARCHAR(10) NOT NULL, n INT NOT NULL DEFAULT 0, + PRIMARY KEY (day, surface, kind) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4`).catch(e => { ready = null; throw e; }); + return ready; +} +function load() { if (J) return J; try { J = JSON.parse(fs.readFileSync(FILE(), 'utf8')); } catch (e) { J = {}; } return J; } + +// surface: 'dashboard' | game slug; ad: what ads.serve returned (null = nothing to show) +async function record(surface, ad) { + const s = String(surface || 'dashboard').toLowerCase().replace(/[^a-z0-9_-]/g, '').slice(0, 40) || 'dashboard'; + const kind = !ad ? 'none' : ad.house ? 'house' : 'member'; + const d = ctDay(); + try { + if (db.enabled()) { + await ensure(); + await db.q('INSERT INTO login_shows (day,surface,kind,n) VALUES (?,?,?,1) ON DUPLICATE KEY UPDATE n=n+1', [d, s, kind]); + } else { + const k = d + '|' + s + '|' + kind, st = load(); + st[k] = (st[k] || 0) + 1; + fs.writeFileSync(FILE(), JSON.stringify(st)); + } + } catch (e) { console.error('login shows', e.message); } +} +// last `days` Central days, newest first: { day, dashboard: {member,house,none}, games: {member,house,none}, byGame: {slug: shown} } +async function report(days) { + days = Math.max(1, Math.min(90, Number(days) || 14)); + const since = ctDay(Date.now() - (days - 1) * 86400000); + let rows = []; + if (db.enabled()) { + await ensure(); + rows = (await db.q('SELECT day, surface, kind, n FROM login_shows WHERE day>=?', [since])).map(r => ({ day: String(r.day), surface: r.surface, kind: r.kind, n: Number(r.n) })); + } else { + for (const [k, n] of Object.entries(load())) { const [day, surface, kind] = k.split('|'); if (day >= since) rows.push({ day, surface, kind, n }); } + } + const out = {}; + const blank = () => ({ member: 0, house: 0, none: 0 }); + for (let i = 0; i < days; i++) { const d = ctDay(Date.now() - i * 86400000); out[d] = { day: d, dashboard: blank(), games: blank(), byGame: {} }; } + for (const r of rows) { + const o = out[r.day]; if (!o || !['member', 'house', 'none'].includes(r.kind)) continue; + if (r.surface === 'dashboard') o.dashboard[r.kind] += r.n; + else { o.games[r.kind] += r.n; if (r.kind !== 'none') o.byGame[r.surface] = (o.byGame[r.surface] || 0) + r.n; } + } + return Object.values(out).sort((a, b) => (a.day < b.day ? 1 : -1)); +} +module.exports = { init, record, report }; diff --git a/public/admin.html b/public/admin.html index 4bcf3b1..9d51782 100644 --- a/public/admin.html +++ b/public/admin.html @@ -314,6 +314,7 @@