// LinkSpin Reports: one view across every link the member owns (rotator.summary via /api/my/reports). (function () { const $ = id => document.getElementById(id); const esc = CR.esc, fmt = CR.fmt; let RANGE = 30; CR.mount({ active: 'reports', title: 'Reports', sub: 'loading', actions: '
' }); $('range').querySelectorAll('button').forEach(b => b.addEventListener('click', () => { RANGE = Number(b.dataset.d); $('range').querySelectorAll('button').forEach(x => x.classList.toggle('on', x === b)); load(); })); const kv = (rows, total) => rows && rows.length ? rows.map(x => '' + esc(x.k) + '' + fmt(x.n) + (total ? ' ' + Math.round(x.n / total * 100) + '%' : '') + '').join('') : 'nothing yet'; async function load() { let s; try { s = await CR.get('/api/my/reports?days=' + RANGE); } catch (e) { CR.sub('could not load'); return; } const t = s.totals || {}; CR.sub(RANGE + ' days · ' + fmt(s.links || 0) + ' link' + (s.links === 1 ? '' : 's') + ' · Central time days'); $('tiles').innerHTML = [['Served', fmt(t.served), ''], ['Unique', fmt(t.unique), ''], ['Bots dropped', fmt(t.bots), t.served ? Math.round(t.bots / (t.served + t.bots) * 100) + '% of hits' : ''], ['Joins', fmt(t.joins), t.unique ? (t.joins / t.unique * 100).toFixed(1) + '% of unique' : ''], ['Buyers', fmt(t.purchases), t.joins ? Math.round(t.purchases / t.joins * 100) + '% of joins' : ''], ['Partner conversions', fmt(t.external), '']] .map(([k, v, n], i) => '