Refill notices: video campaigns report watches, watch length and per-watch price so the relaunch maths is clear
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -37,6 +37,15 @@ const SITE = 'https://instantadpay.com';
|
||||
const n0 = v => (typeof v === 'number' && isFinite(v) ? v : 0);
|
||||
const money = n => Number(n || 0).toLocaleString('en-US');
|
||||
const delivered = c => n0(c.spent) + n0(c.accrued);
|
||||
// video campaigns count watches, not impressions, and the relaunch maths only makes sense with the per-watch price (Marty, 2026-09-30)
|
||||
const unit = c => c.type === 'video' ? 'watches' : 'impressions';
|
||||
function videoNote(c) {
|
||||
if (c.type !== 'video') return '';
|
||||
const secs = Number(c.body) || 0; let cost = 0;
|
||||
try { cost = ((X.ads.rates().videoTiers || []).find(t => t.secs === secs) || {}).cost || 0; } catch (e) {}
|
||||
if (!secs || !cost) return '';
|
||||
return ' (' + secs + '-second video at ' + cost + ' credits a watch: every ' + money(cost * 100) + ' credits buys about 100 more watches)';
|
||||
}
|
||||
const key = (id, state) => id + ':' + state;
|
||||
|
||||
// the five packages and what each dollar buys, so the ladder is never hand-typed
|
||||
@@ -69,9 +78,9 @@ function ladderHtml() {
|
||||
function describe(list) {
|
||||
return list.map(c => {
|
||||
const bits = [money(Math.round(delivered(c))) + ' of ' + money(Math.round(n0(c.budget))) + ' credits delivered'];
|
||||
if (n0(c.imps)) bits.push(money(n0(c.imps)) + ' impressions');
|
||||
if (n0(c.imps)) bits.push(money(n0(c.imps)) + ' ' + unit(c));
|
||||
if (n0(c.clicks)) bits.push(money(n0(c.clicks)) + ' clicks');
|
||||
return ' "' + (c.name || c.title || ('campaign #' + c.id)) + '" (' + (c.type || 'ad') + '): ' + bits.join(', ');
|
||||
return ' "' + (c.name || c.title || ('campaign #' + c.id)) + '" (' + (c.type || 'ad') + '): ' + bits.join(', ') + videoNote(c);
|
||||
}).join('\n');
|
||||
}
|
||||
|
||||
@@ -101,7 +110,7 @@ async function compose(owner, list, state, credits) {
|
||||
+ '<p>' + next.replace(/(https:\/\/[^\s]+)/g, '<a href="$1">$1</a>') + '</p>'
|
||||
+ '<p><b>What each one did:</b></p><ul>' + list.map(c => '<li>' + esc(c.name || ('campaign #' + c.id)) + ' (' + esc(c.type || 'ad') + '): '
|
||||
+ money(Math.round(delivered(c))) + ' of ' + money(Math.round(n0(c.budget))) + ' credits delivered'
|
||||
+ (n0(c.imps) ? ', ' + money(n0(c.imps)) + ' impressions' : '') + (n0(c.clicks) ? ', ' + money(n0(c.clicks)) + ' clicks' : '') + '</li>').join('') + '</ul>'
|
||||
+ (n0(c.imps) ? ', ' + money(n0(c.imps)) + ' ' + unit(c) : '') + (n0(c.clicks) ? ', ' + money(n0(c.clicks)) + ' clicks' : '') + esc(videoNote(c)) + '</li>').join('') + '</ul>'
|
||||
+ ladderHtml()
|
||||
+ '<p style="color:#556">Every package pays your sponsor line in the same on-chain transaction, and every payout is on the public ledger.</p>';
|
||||
return { subject, text, html };
|
||||
|
||||
Reference in New Issue
Block a user