Developer guide — traced 2026-06-03 · ahmedbouchefra2
There are 4 pieces that need to talk to each other for a user to subscribe and unlock PDFs.
Each piece runs in a different runtime — browser, Cloudflare edge, Cloudflare KV, and Node.js. They are connected only through HTTP calls and a shared KV namespace. No tool currently traces the full chain automatically.
ELI5: Imagine a vending machine with a "pay here" button, but the payment reader is turned off. You press the button, nothing happens. That's what was happening — the subscribe button called window.PushSubscribe.subscribe(), but PushSubscribe was never loaded because push was disabled.
pushNotify: { enabled: false } in bookpost's AppCoreConfig.
When push is disabled, app-core.js never loads push_subscribe.js, so
window.PushSubscribe is undefined.
handlePdfSubscribeClick() detects this, silently closes the modal, and exits.
app-core.js loads push_subscribe.js → window.PushSubscribe exists →
modal subscribe button calls ps.subscribe() → permission prompt fires → sub sent to worker → localStorage push_subscribed=1 set → PDF unlocks.
onclick="handlePrintClick()"
localStorage for the key push_subscribed=1. If yes → go straight to PDF. If no → show the modal._hasPdfAccess() → checks localStorage.getItem('push_subscribed') === '1'
_onPdfProtected('push-required') → _showPdfPrompt()
window.PushSubscribe.subscribe() — this is the function from push_subscribe.js. If that script isn't loaded (old bug), nothing happens.handlePdfSubscribeClick() → window.PushSubscribe.subscribe()
Notification.requestPermission() → reg.pushManager.subscribe(...)
_sendToBackend(sub) → POST https://push-gate.techiediaries.workers.dev/subscribe
endpoint, keys, country, city, timezone, ua, timestamp
push_subscribed=1 in localStorage (the "VIP pass"). Then handlePrintClick() runs again — this time _hasPdfAccess() returns true and the PDF opens.localStorage.setItem('push_subscribed', '1') → document.dispatchEvent('pushSubscribed') → handlePrintClick() retries
The CLI reads the same KV via the Worker's /stats endpoint. Run:
TODO Per-site tracking — subscribers from ahmedbouchefra.com and techiediaries.com share the same KV with no way to tell them apart. The worker doesn't save which site the subscription came from.
TODO Per-app subpath subscriptions — users can't subscribe to just one app (e.g. /techquiz). It's all-or-nothing.
TODO Cross-runtime chain tracing — no tool currently maps the full browser → worker → KV → CLI chain as a navigable graph. Options: explicit chains.json, extend codeknow with HTTP contract edges, or an architecture doc.