Member welcome offer from the games: starter.js (+100 purchased-grade credits on a first $5+ package after a game visit within 14 days, once per account; setting starterBonusCredits), /api/starter + /api/starter/public, /my?from=<game>#buy banner with the way back to the game perk, Members get <perk> on game cards, admin Traffic 'Games to members' table

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-10-05 06:26:03 -05:00
parent f09ff71c56
commit c99896c131
6 changed files with 4370 additions and 4257 deletions
+3 -2
View File
@@ -289,7 +289,8 @@
</div>
<div class="pane" id="pane-traffic" hidden>
<div class="card">
<div class="card"><div class="card-head"><h3>Games to members</h3><span class="sub" id="stSub">the $5 welcome offer after a game win</span></div><div class="tablewrap"><table class="adm-table" id="trfStarter"></table></div></div>
<div class="card">
<div class="card-head"><h3>Where visitors come from</h3><span class="sub" id="trfSub"></span></div>
<div class="chips" id="trfRange" style="margin:0 0 10px"><button type="button" class="chip-t" data-days="7">7 days</button><button type="button" class="chip-t on" data-days="30">30 days</button><button type="button" class="chip-t" data-days="90">90 days</button><button type="button" class="chip-t" data-days="365">Year</button></div>
<p class="muted small" style="margin:0 0 10px">Page views are public-page loads by referring domain (crawlers skipped; our own pages and no referrer count as direct). Join-page views are invite-link opens. Signups, registered and $20+ buyers are accounts whose first-touch source was that domain; legacy arrivals show as legacy:brand:domain.</p>
@@ -520,6 +521,6 @@
</div>
<script src="/assets/common.js?v=20261003fr2"></script><script src="/assets/welcome.js?v=20260923b"></script>
<script src="/assets/admin.js?v=20261004tax"></script>
<script src="/assets/admin.js?v=20261005st"></script>
</body>
</html>
+4
View File
@@ -607,6 +607,10 @@
const pct = (num, den) => den ? (100 * num / den).toFixed(num && 100 * num / den < 10 ? 1 : 0) + '%' : '<span class="muted">-</span>';
$('trfSources').innerHTML = '<tr><th>Source</th><th>Page<br>views</th><th>Join-page<br>views</th><th>Signups</th><th>Visit &rarr;<br>signup</th><th>Registered</th><th>Signup &rarr;<br>registered</th><th>$20+<br>buyers</th><th>Signup &rarr;<br>buyer</th></tr>'
+ (d.sources.length ? d.sources.map(s => '<tr><td>' + esc(s.source) + '</td><td>' + n(s.hits) + '</td><td>' + n(s.joinViews) + '</td><td>' + n(s.signups) + '</td><td>' + pct(s.signups, s.hits + s.joinViews) + '</td><td>' + n(s.registered) + '</td><td>' + pct(s.registered, s.signups) + '</td><td>' + n(s.buyers) + '</td><td>' + pct(s.buyers, s.signups) + '</td></tr>').join('') : '<tr><td colspan="9" class="muted">Nothing recorded in this range yet.</td></tr>');
// games to members (2026-10-05): card taps that reached InstantAdPay, first packages bought, dollars, per game (all time)
if (d.starter) { const st = d.starter, rows = Object.values(st.games);
$('stSub').textContent = (st.settings.on ? 'on' : 'off') + ' · welcome bonus ' + st.settings.bonus + ' credits · ' + st.granted + ' granted';
$('trfStarter').innerHTML = '<tr><th>Game</th><th>Offer taps</th><th>First packages</th><th>Package $</th><th>Tap &rarr; buy</th></tr>' + rows.map(g => '<tr><td>' + esc(g.name) + '</td><td>' + n(g.visits) + '</td><td>' + n(g.buyers) + '</td><td>$' + g.usd.toFixed(2) + '</td><td>' + pct(g.buyers, g.visits) + '</td></tr>').join(''); }
$('trfPaths').innerHTML = '<tr><th>Page</th><th>Views</th></tr>' + (d.paths.length ? d.paths.map(p => '<tr><td>' + esc(p.path) + '</td><td>' + n(p.hits) + '</td></tr>').join('') : '<tr><td colspan="2" class="muted">No page views yet.</td></tr>');
$('trfAngles').innerHTML = '<tr><th>Angle</th><th>Join-page<br>views</th><th>Signups</th><th>View &rarr;<br>signup</th></tr>' + (d.angles.length ? d.angles.map(a => '<tr><td>' + esc(a.angle) + '</td><td>' + n(a.views) + '</td><td>' + n(a.signups) + '</td><td>' + pct(a.signups, a.views) + '</td></tr>').join('') : '<tr><td colspan="4" class="muted">No angle data yet.</td></tr>');
$('trfDaily').innerHTML = '<tr><th>Day</th><th>Page views</th><th>Signups</th></tr>' + (d.daily.length ? d.daily.slice().reverse().map(x => '<tr><td>' + esc(x.day) + '</td><td>' + n(x.hits) + '</td><td>' + n(x.signups) + '</td></tr>').join('') : '<tr><td colspan="3" class="muted">Nothing yet.</td></tr>');
+20 -1
View File
@@ -633,6 +633,24 @@
$('gsGo').addEventListener('click', copy[3]);
card.hidden = false;
}
// member welcome offer from the games (2026-10-05): a game's after-win card sends players to /my?from=<game>#buy.
// We remember the game (through sign-in), tell the server once, and show the offer + the way back to the perk.
try { const fm = /[?&]from=([a-z]{3,20})/.exec(location.search); if (fm) { sessionStorage.setItem('iap.starterFrom', fm[1]); history.replaceState(null, '', '/my' + (location.hash || '')); } } catch (e) {}
async function starterBanner(me) {
let from = null; try { from = sessionStorage.getItem('iap.starterFrom'); } catch (e) {}
let v = null;
if (from) { try { sessionStorage.removeItem('iap.starterFrom'); } catch (e) {} v = await (await fetch('/api/starter', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ game: from }) })).json(); }
else v = await (await fetch('/api/starter')).json();
if (!v || !v.on || !v.game) return;
const pane = document.querySelector('#pane-buy .card'); if (!pane) return;
let box = document.getElementById('starterBox'); if (!box) { box = document.createElement('div'); box.id = 'starterBox'; pane.insertBefore(box, pane.children[1] || null); }
const esc = t => String(t).replace(/[&<>"]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
box.style.cssText = 'border:1px solid var(--gold, #e2b04a);border-radius:12px;padding:12px 14px;margin:0 0 14px;background:rgba(226,176,74,.08)';
box.innerHTML = v.eligible
? '<b>Welcome from ' + esc(v.game) + '!</b><br><span class="small">Your first package, $5 or more, comes with <b>+' + v.bonus + ' bonus ad credits</b>, and ' + esc(v.perk) + ' waiting for you in ' + esc(v.game) + '.</span>'
: '<b>You are a member.</b> <span class="small">' + (v.granted ? 'Your +' + v.bonus + ' welcome credits are in your balance. ' : '') + 'Your ' + esc(v.perk) + ' is waiting in ' + esc(v.game) + '.</span><br><a class="btn small" style="margin-top:8px;display:inline-block" href="' + esc(v.back) + '">Back to ' + esc(v.game) + ' to collect it</a>';
if (from) setPane('buy');
}
function jumpTo(pane, id) {
setPane(pane);
setTimeout(() => { const el = id && $(id); if (!el) return; el.scrollIntoView({ behavior: 'smooth', block: 'center' }); el.classList.remove('pulse'); void el.offsetWidth; el.classList.add('pulse'); try { el.focus({ preventScroll: true }); } catch (e) {} }, 250);
@@ -839,6 +857,7 @@
await render();
})();
}
starterBanner(me).catch(() => {});
setPane(location.hash.slice(1) || 'overview');
$('campGate').hidden = !!me.memberId;
$('earnGate').hidden = !!me.memberId;
@@ -1682,7 +1701,7 @@
const list = (g && g.games) || [];
if (!list.length) { el.innerHTML = '<p class="muted small">No games are open yet. Check back soon.</p>'; return; }
// a seasonal card (x.season, 2026-10-02) wears the pink limited-time ribbon from the Spooky Doors UI kit
el.innerHTML = list.map(x => '<div class="game-card"><img src="' + esc(x.art) + '" alt="" loading="lazy"' + (x.artPos ? ' style="object-position:' + esc(x.artPos) + ' center"' : '') + '>' + (x.soon ? '' : x.season && x.season.ends ? '<span class="gc-ribbon"><i></i>Limited time \u00b7 ends ' + esc(x.season.ends) + '</span>' : '') + '<div class="gc-body"><span class="gc-tag">' + esc(x.tag || '') + '</span><h4>' + esc(x.name) + (x.preview ? '<span class="gc-pre">' + esc(x.previewNote || 'preview, not live') + '</span>' : '') + '</h4><p class="muted small" style="margin:0">' + esc(x.blurb) + '</p>' + (x.progress && x.progress.line ? '<div class="gc-prog">' + esc(x.progress.line) + '</div>' : '') + '<p class="muted small" style="margin:0">Pays: ' + esc(x.pays || 'POL') + '</p>' + (x.soon ? '<span class="btn gc-soonbtn" aria-disabled="true">' + esc(x.soon) + '</span>' : '<a class="btn" href="' + esc(x.play) + '">' + esc(x.cta || 'Play') + '</a>') + '</div></div>').join('');
el.innerHTML = list.map(x => '<div class="game-card"><img src="' + esc(x.art) + '" alt="" loading="lazy"' + (x.artPos ? ' style="object-position:' + esc(x.artPos) + ' center"' : '') + '>' + (x.soon ? '' : x.season && x.season.ends ? '<span class="gc-ribbon"><i></i>Limited time \u00b7 ends ' + esc(x.season.ends) + '</span>' : '') + '<div class="gc-body"><span class="gc-tag">' + esc(x.tag || '') + '</span><h4>' + esc(x.name) + (x.preview ? '<span class="gc-pre">' + esc(x.previewNote || 'preview, not live') + '</span>' : '') + '</h4><p class="muted small" style="margin:0">' + esc(x.blurb) + '</p>' + (x.progress && x.progress.line ? '<div class="gc-prog">' + esc(x.progress.line) + '</div>' : '') + '<p class="muted small" style="margin:0">Pays: ' + esc(x.pays || 'POL') + '</p>' + (x.perk ? '<p class="small" style="margin:0;color:var(--gold, #e2b04a)">Members get ' + esc(x.perk) + '</p>' : '') + (x.soon ? '<span class="btn gc-soonbtn" aria-disabled="true">' + esc(x.soon) + '</span>' : '<a class="btn" href="' + esc(x.play) + '">' + esc(x.cta || 'Play') + '</a>') + '</div></div>').join('');
}
async function loadReturnCard() {
const card = $('phReturn'); if (!card) return;
+1 -1
View File
@@ -1131,7 +1131,7 @@
<script src="/assets/common.js?v=20261003fr2"></script><script src="/assets/welcome.js?v=20260923b"></script>
<script src="/assets/wallet.js?v=20260911a"></script>
<script src="/assets/promo.js?v=20261002ref"></script>
<script src="/assets/my.js?v=20261004soon2"></script>
<script src="/assets/my.js?v=20261005st"></script>
<script src="/assets/chat.js?v=20260907l"></script>
</body>
</html>
+16 -3
View File
@@ -45,6 +45,7 @@ const leaderboard = require('./leaderboard');
const toolkit = require('./toolkit');
const badge = require('./badge'); // achievement badge image drawn on the server with ffmpeg (2026-09-16)
const friday = require('./friday');
const starter = require('./starter'); // member welcome offer from the games (2026-10-05)
const wednesday = require('./wednesday'); // Wired Wednesday: +25% on $10+ packs, wired into a visits campaign (2026-09-29)
const fridaybank = require('./fridaybank'); // Friday Bonus Hunts: days banked Sat-Thu by solo + video (2026-09-26)
const refill = require('./refill');
@@ -477,6 +478,7 @@ async function boot() {
emailOnEvent(ev).catch(() => {});
telegramOnEvent(ev).catch(() => {});
friday.onEvent(ev).catch(e => console.error('friday bonus', e.message));
starter.onEvent(ev).catch(e => console.error('starter bonus', e.message));
wednesday.onEvent(ev).catch(e => console.error('wednesday bonus', e.message));
sponsorSyncOnEvent(ev).catch(e => console.error('sponsor sync', e.message));
}).catch(e => console.error('marks claim', e.message));
@@ -500,6 +502,7 @@ async function boot() {
send: async (c, t, th) => { await telegramSend(c, t, th); return true; },
sendPhoto: (c, jpeg, cap, th) => telegramSendPhoto(c, jpeg, cap, th) });
fridaybank.init({ db });
starter.init({ dataDir: DATA_DIR, siteConfig, chain, ads, accounts });
friday.init({ dataDir: DATA_DIR, siteConfig, chain, ads, accounts, mailer, drip, marks,
telegram: async text => { const sc = siteConfig(); if (!sc.telegramBotToken || !sc.telegramEchoChatId) return false; return telegramSend(sc.telegramEchoChatId, '\u{1F7E0} <b>InstantAdPay</b> \u00b7 ' + text, sc.telegramEchoTopicId); },
notify: async (memberId, subject, text, kind) => { const a = await accounts.byMemberId(memberId); if (!a || !a.email) return; const html = '<p>' + String(text).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/(https:\/\/[^\s]+)/g, '<a href="$1" target="_blank" rel="noopener">$1</a>').split('\n\n').join('</p><p>').replace(/\n/g, '<br>') + '</p>'; await messages.deliver(1, ADMIN_EMAIL || 'house@instantadpay.com', [a.email], subject, html, kind || 'notice'); } });
@@ -1419,7 +1422,7 @@ function seasonState(season, day, admin) {
}
// -- the games registry (2026-10-01). Add a game here; launch it by adding its slug to site config gamesLive.
function GAMES() {
return [
return withPerks([
{ slug: 'spookydoors', name: 'Spooky Doors', tag: 'Halloween \u00b7 Oct 4 to 31', blurb: 'Trick or treat! Walk the street, knock on doors and fill your candy bucket. Every door is a short visit to a member\u2019s page or ad, and candy climbs a ladder with POL at set levels. Gone after Halloween night.',
art: SD_URL() + '/og-spookydoors.jpg', play: '/api/my/spookydoors', pays: 'POL at set candy levels', season: { start: SD_SEASON.start, end: SD_SEASON.end }, progress: sdProgress },
{ slug: 'driprunner', name: 'Drip Runner', tag: 'Arcade runner', blurb: 'Hop the network, dodge the bots, clear chapters. Each first clear drips POL into your game balance, and a refuel on a member\u2019s page keeps your run alive.',
@@ -1434,8 +1437,10 @@ function GAMES() {
// the card with its date and no Play button until `soon.opens` (Central); from then it is an ordinary card, live via gamesLive
{ slug: 'spellwheel', name: 'SpellWheel', tag: 'Word game', blurb: 'Swipe the letter wheel to fill the crossword, travel through six cozy places, and solve a new daily puzzle with everyone. Clear levels and chapters to earn POL.',
art: '/assets/games/spellwheel-soon.jpg?v=1', play: '/api/my/spellwheel', pays: 'POL for levels, chapters and daily puzzles', soon: { opens: '2026-10-10', label: 'Opens Saturday, Oct 10' } },
];
]);
}
// each game's member perk (the $5 welcome offer, 2026-10-05) shown on its card
const withPerks = list => { const st = starter.cfg(); return list.map(g => starter.GAMES[g.slug] && st.on ? Object.assign({}, g, { perk: starter.GAMES[g.slug].perk }) : g); };
// -- cross-promo strip (2026-10-03): one short line per game and where a signed-out player lands (the game's own page)
const STRIP = () => ({
spookydoors: { line: 'Halloween only. Run the graveyard, knock on doors, climb the candy ladder to POL.', open: SD_URL() + '/play', host: SD_URL().replace(/^https?:\/\//, '') },
@@ -1650,6 +1655,14 @@ const server = http.createServer(async (req, res) => {
// -- public API
if (p === '/api/friday' && req.method === 'GET') return json(res, 200, friday.view(), { 'Cache-Control': 'public, max-age=60' });
// member welcome offer from the games: public numbers for the game cards, the member's own view, and the 'came from' mark
if (p === '/api/starter/public' && req.method === 'GET') return json(res, 200, starter.publicView(), { 'Cache-Control': 'public, max-age=300', 'Access-Control-Allow-Origin': '*' });
if (p === '/api/starter' && (req.method === 'GET' || req.method === 'POST')) {
const s = await auth.fromRequest(req); if (!s || !s.email) return json(res, 401, { error: 'Sign in first.' });
if (req.method === 'POST') { const b = await readBody(req); starter.setFrom(s.email, String(b.game || '')); }
const acct = await accounts.byEmail(s.email);
return json(res, 200, await starter.view(s.email, Number((acct && acct.memberId) || s.memberId || 0)));
}
if (p === '/api/wednesday' && req.method === 'GET') return json(res, 200, wednesday.view(), { 'Cache-Control': 'public, max-age=60' });
if (p === '/api/admin/pdsync' && req.method === 'GET') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, pdsync.status()); }
if (p === '/api/admin/pdsync/run' && req.method === 'POST') { if (!isAdmin(req)) return json(res, 401, { error: 'auth' }); return json(res, 200, await pdsync.sync()); }
@@ -2628,7 +2641,7 @@ const server = http.createServer(async (req, res) => {
const k = a.joinedVia || 'plain'; angles[k] = angles[k] || { angle: k, views: 0, signups: 0 }; angles[k].signups += 1;
}
const sources = Object.values(hosts).sort((x, y) => (y.hits + y.joinViews + y.signups * 10) - (x.hits + x.joinViews + x.signups * 10));
return json(res, 200, { days, sources, paths: Object.entries(paths).map(([path, hits]) => ({ path, hits })).sort((x, y) => y.hits - x.hits),
return json(res, 200, { starter: starter.adminView(), days, sources, paths: Object.entries(paths).map(([path, hits]) => ({ path, hits })).sort((x, y) => y.hits - x.hits),
angles: Object.values(angles).sort((x, y) => y.views - x.views), daily: Object.values(daily).sort((x, y) => x.day < y.day ? -1 : 1),
totals: { hits: sources.reduce((n, s) => n + s.hits, 0), joinViews: sources.reduce((n, s) => n + s.joinViews, 0), signups: sources.reduce((n, s) => n + s.signups, 0), buyers: sources.reduce((n, s) => n + s.buyers, 0) } });
}
+76
View File
@@ -0,0 +1,76 @@
// Member welcome offer from the games (Marty, 2026-10-05). After a win in a network game, a signed-in player who is not a
// member yet sees one card a day: "Become an InstantAdPay member for $5". The card links to /my?from=<game>#buy; this module
// remembers which game sent them, and when that account's FIRST package ($5 or more) lands on chain it grants the welcome
// bonus credits (purchased-grade, once per account) and counts the conversion for that game. The game perk itself is handed
// out by each game the next time the player signs in there as a member (the sign-in token carries memberId).
//
// Settings (siteConfig): starterOffer '1'|'0' (on), starterBonusCredits (100), starterWindowDays (14: the game visit must be
// this recent). Every number comes from the chain index, never a marketing counter. Games are a marketing cost
// (Marty 2026-10-05); this is how we see what each one converts.
'use strict';
const fs = require('fs');
const path = require('path');
let X = {}, FILE = null, S = null;
const GAMES = {
driprunner: { name: 'Drip Runner', perk: 'a free hangar upgrade', back: '/api/my/driprunner' },
clutterhunt: { name: 'ClutterHunt', perk: '5 bonus hints', back: '/api/my/clutterhunt' },
spellwheel: { name: 'SpellWheel', perk: '5 bonus hints', back: '/api/my/spellwheel' },
gemkingdom: { name: 'Gem Kingdom', perk: '50 Crowns', back: '/api/my/gemkingdom' },
spookydoors: { name: 'Spooky Doors', perk: 'a lucky caramel apple', back: '/api/my/spookydoors' },
polywarriors: { name: 'PolyWarriors', perk: 'a free warrior recruit', back: '/api/my/polywarriors' },
};
function init(opts) { X = opts; FILE = path.join(opts.dataDir, 'starter.json'); S = load(); }
function load() { try { return Object.assign({ from: {}, granted: {}, conv: {}, visits: {} }, JSON.parse(fs.readFileSync(FILE, 'utf8'))); } catch (e) { return { from: {}, granted: {}, conv: {}, visits: {} }; } }
function save() { try { fs.writeFileSync(FILE + '.tmp', JSON.stringify(S)); fs.renameSync(FILE + '.tmp', FILE); } catch (e) {} }
function cfg() {
const c = (X.siteConfig && X.siteConfig()) || {};
return { on: String(c.starterOffer == null ? '1' : c.starterOffer) === '1', bonus: Math.max(0, Math.round(Number(c.starterBonusCredits == null ? 100 : c.starterBonusCredits) || 0)), windowDays: Math.max(1, Number(c.starterWindowDays) || 14) };
}
const known = g => Object.prototype.hasOwnProperty.call(GAMES, String(g || ''));
// a member who has bought before cannot get the welcome bonus; the chain index decides
function hasPurchased(memberId) { if (!memberId) return false; try { return X.chain.recentEvents(1e9).some(e => e.type === 'Purchase' && e.buyerId === memberId); } catch (e) { return false; } }
// the card in a game was tapped and the player reached InstantAdPay (signed in): remember the game
function setFrom(email, game) {
if (!email || !known(game)) return null; const e = String(email).toLowerCase();
S.from[e] = { game, at: Date.now() }; const day = new Date().toLocaleDateString('en-CA', { timeZone: 'America/Chicago' });
S.visits[game] = S.visits[game] || {}; S.visits[game][day] = (S.visits[game][day] || 0) + 1; save();
return S.from[e];
}
// what the Buy page shows this member
async function view(email, memberId) {
const c = cfg(), e = String(email || '').toLowerCase(), f = S.from[e];
const fresh = f && Date.now() - f.at < c.windowDays * 86400000 ? f : null, bought = hasPurchased(memberId);
const g = fresh ? GAMES[fresh.game] : null;
return { on: c.on, bonus: c.bonus, from: fresh ? fresh.game : null, game: g ? g.name : null, perk: g ? g.perk : null, back: g ? g.back : null,
eligible: c.on && !!fresh && !bought, granted: !!Object.values(S.granted).find(x => x.email === e) };
}
// public numbers for the game cards (no account needed)
function publicView() { const c = cfg(); return { on: c.on, bonus: c.bonus, games: Object.fromEntries(Object.entries(GAMES).map(([k, v]) => [k, { name: v.name, perk: v.perk }])) }; }
// a Purchase on chain: the buyer's first package, $5 or more, with a recent game visit -> welcome bonus, once per account
async function onEvent(ev) {
if (!ev || ev.type !== 'Purchase' || (ev.priceCents || 0) < 500) return null;
const c = cfg(); if (!c.on || S.granted[ev.tx]) return null;
let earlier = false; try { earlier = X.chain.recentEvents(1e9).some(e => e.type === 'Purchase' && e.buyerId === ev.buyerId && e.tx !== ev.tx && (e.block < ev.block || (e.block === ev.block && e.li < ev.li))); } catch (e) {}
if (earlier) return null;
const a = await X.accounts.byMemberId(ev.buyerId); if (!a || !a.email) return null;
const e = String(a.email).toLowerCase(), f = S.from[e];
if (!f || ev.ts - f.at > c.windowDays * 86400000 || ev.ts < f.at - 60000) return null; // the game visit came first, recently
if (Object.values(S.granted).some(x => x.email === e)) return null; // once per account
const g = GAMES[f.game] || { name: f.game };
S.granted[ev.tx] = { email: e, memberId: ev.buyerId, game: f.game, bonus: c.bonus, cents: ev.priceCents, at: Date.now() };
S.conv[f.game] = S.conv[f.game] || { buyers: 0, cents: 0 }; S.conv[f.game].buyers++; S.conv[f.game].cents += ev.priceCents; save();
if (c.bonus > 0) await X.ads.addEarned(e, c.bonus, { purchased: true, log: { kind: 'bonus', note: 'Member welcome bonus: +' + c.bonus + ' credits (you came from ' + g.name + ')', ref: 'starter:' + String(ev.tx).slice(0, 30) } });
return S.granted[ev.tx];
}
// admin: what each game converted (card taps that reached InstantAdPay, first packages, dollars)
function adminView() {
const out = {}; for (const k of Object.keys(GAMES)) { const v = S.visits[k] || {}; out[k] = { name: GAMES[k].name, visits: Object.values(v).reduce((n, x) => n + x, 0), buyers: (S.conv[k] || {}).buyers || 0, usd: ((S.conv[k] || {}).cents || 0) / 100 }; }
return { settings: cfg(), games: out, granted: Object.values(S.granted).length };
}
module.exports = { init, GAMES, setFrom, view, publicView, onEvent, adminView, cfg };