diff --git a/public/app.js b/public/app.js index 906de5a..2a3abb9 100644 --- a/public/app.js +++ b/public/app.js @@ -75,6 +75,7 @@ const AD_COPY = [ ]; const fmt = s => `${Math.floor(s/60)}:${String(Math.floor(s%60)).padStart(2,"0")}`; +const track = (event, props) => { try { window.plausible(event, { props }); } catch(e) {} }; // Cha-ching sound effect via Tone.js const playChaChing = async () => { @@ -279,6 +280,7 @@ function PayPlay() { }, [flash]); const tryAct = (k, fn) => { + track("feature_click", { feature: k, subscribed: !!has(k) }); if (has(k)) { fn(); return; } setModal({ key: k, action: fn }); setModalPhase("choose"); @@ -291,6 +293,7 @@ function PayPlay() { if (bal < p) { setModalPhase("broke"); return; } charge(p, s.name); setSubs_(prev => ({ ...prev, [modal.key]: true })); + track("subscribe", { feature: modal.key, price: p }); setSuccessText(`${s.name} is yours. Was it worth it? (It wasn't.)`); setModalPhase("success"); setTimeout(() => { modal.action(); setModal(null); setModalPhase("choose"); }, 1800); @@ -304,6 +307,7 @@ function PayPlay() { const s = SUBS[modal.key]; if (bal < s.micro) { setModalPhase("broke"); return; } charge(s.micro, `${s.name} (1x)`); + track("microtransaction", { feature: modal.key, price: s.micro }); setSuccessText(`One-time access. That's $${s.micro.toFixed(2)} you'll never see again.`); setModalPhase("success"); setTimeout(() => { modal.action(); setModal(null); setModalPhase("choose"); }, 1500); @@ -317,6 +321,7 @@ function PayPlay() { setBalKey(k => k + 1); flash("+$9.50 ($0.50 processing fee)", "#f39c12"); playChaChing(); + track("topup", { source: "modal" }); setModalPhase("choose"); }; @@ -436,7 +441,7 @@ function PayPlay() { "", `Try it: ${window.location.href}` ]; if (navigator.clipboard) { - navigator.clipboard.writeText(lines.join("\n")).then(() => flash("Receipt copied! Share your shame.", accent)); + navigator.clipboard.writeText(lines.join("\n")).then(() => { flash("Receipt copied! Share your shame.", accent); track("share_receipt", { spent: spent.toFixed(2) }); }); } }; @@ -487,7 +492,7 @@ function PayPlay() {