Skip to content

Split any YouTube song into stems

TypeScript

add anonymous usage heartbeat with self-hosted stats worker

Daniel Ravina681cbc81d2b9
diff --git a/README.md b/README.md
index 7d2afc4..10d8b73 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@ Split any YouTube song into isolated stems — **vocals, drums, bass, guitar, pi
Search YouTube or paste a link, pick the instruments you want, and play the result like a mini DAW: the video on one side, every stem on its own fader, all perfectly in sync. Karaoke, acapellas and instrumentals are one click away.
-Everything runs locally — no accounts, no cloud, no API keys.
+Everything runs locally — no accounts, no API keys. Your songs, searches and audio never leave your machine. The app sends one tiny anonymous ping per day (a random install id + version/OS) so I can count how many people use it — see [Privacy](#privacy) for details.
![platform](https://img.shields.io/badge/platform-macOS%20%7C%20Windows%20%7C%20Linux-black) ![local](https://img.shields.io/badge/100%25-local-emerald)
@@ -105,6 +105,13 @@ video iframe (muted) + Web Audio stem playback · master clock = the audio itsel
- Downloading audio from YouTube violates their ToS for public products — keep this personal.
- yt-dlp breaks occasionally when YouTube changes things; the error dialog offers a one-click update (updates `yt-dlp` + the challenge solver together).
+## Privacy
+
+- **Never leaves your machine:** the videos you download, the songs you split, your library, your searches and your audio — none of it is uploaded anywhere. All separation runs locally.
+- **Anonymous usage count:** on each launch the app sends one small POST to a Cloudflare Worker (`stemkit-stats.danielravina.workers.dev`) — at most once per day. It contains a **random install id** (generated locally, stored in the app's settings folder), the app version, OS and architecture. No IP-address-based profiles are built, no cookies, no identifiers tied to you, no analytics SDKs.
+- **What it's for:** counting installs and active usage (the same stats you'd get from GitHub release downloads, minus auto-update noise). The counter code is in [`telemetry-worker/`](telemetry-worker) — inspectable like the rest of the app.
+- **Fully offline builds:** if you'd rather send nothing, build from source and remove `src/main/telemetry.ts` (or block the worker domain in your firewall) — everything else works identically offline.
+
## Layout
```
diff --git a/src/main/index.ts b/src/main/index.ts
index ccec0d6..129d720 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -25,6 +25,7 @@ import { startJob, cancelJob, searchYouTube } from './pipeline'
import { initUpdater } from './updater'
import { runSmoke } from './smoke'
import { getThumb, clearThumbMemo } from './thumbs'
+import { maybePing } from './telemetry'
let mainWindow: BrowserWindow | null = null
let staticServer: Server | null = null
@@ -235,6 +236,8 @@ app.whenReady().then(async () => {
else void ensureGpuEngine()
})
initUpdater()
+ // anonymous usage heartbeat: one POST per install per day
+ maybePing()
ipcMain.handle('open-external', (_e, url: string) => {
if (/^https:\/\/(www\.)?(youtube\.com|youtu\.be)\//.test(url)) {
shell.openExternal(url)
diff --git a/src/main/telemetry.ts b/src/main/telemetry.ts
new file mode 100644
index 0000000..7b759fa
--- /dev/null
+++ b/src/main/telemetry.ts
@@ -0,0 +1,72 @@
+import { randomUUID } from 'crypto'
+import { readFileSync, writeFileSync, mkdirSync } from 'fs'
+import { join } from 'path'
+import { app, net } from 'electron'
+import { userDataDir } from './env'
+
+/* anonymous usage heartbeat: one small POST per install per day (first launch,
+ then once every 24h). Payload is a random install id plus version/os/arch —
+ nothing that identifies the machine or user. The endpoint is a Cloudflare
+ Worker (telemetry-worker/ in this repo); STEMKIT_TELEMETRY_URL overrides it
+ for testing without a rebuild. */
+const TELEMETRY_URL =
+ (process.env.STEMKIT_TELEMETRY_URL || 'https://stemkit-stats.danielravina.workers.dev') + '/ping'
+
+const DAY_MS = 24 * 60 * 60 * 1000
+
+interface TelemetryState {
+ installId: string
+ lastPing: number
+}
+
+function stateFile(): string {
+ return join(userDataDir(), 'telemetry.json')
+}
+
+function loadState(): TelemetryState {
+ try {
+ const data = JSON.parse(readFileSync(stateFile(), 'utf8'))
+ if (typeof data.installId === 'string' && data.installId) {
+ return { installId: data.installId, lastPing: Number(data.lastPing) || 0 }
+ }
+ } catch {}
+ return { installId: randomUUID(), lastPing: 0 }
+}
+
+function saveState(state: TelemetryState): void {
+ try {
+ mkdirSync(userDataDir(), { recursive: true })
+ writeFileSync(stateFile(), JSON.stringify(state, null, 2))
+ } catch {}
+}
+
+/* fire-and-forget: never let a ping slow startup or log errors */
+export function maybePing(): void {
+ if (!app.isPackaged) return
+ const state = loadState()
+ if (Date.now() - state.lastPing < DAY_MS) return
+
+ const payload = JSON.stringify({
+ id: state.installId,
+ version: app.getVersion(),
+ platform: process.platform,
+ arch: process.arch,
+ ts: Date.now()
+ })
+
+ const req = net.request({
+ url: TELEMETRY_URL,
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' }
+ })
+ // remember the ping only once the server confirmed it, so offline launches
+ // retry on the next open instead of silently dropping
+ req.on('response', (res) => {
+ if (res.statusCode >= 200 && res.statusCode < 300) {
+ saveState({ ...state, lastPing: Date.now() })
+ }
+ })
+ req.on('error', () => {})
+ req.write(payload)
+ req.end()
+}
\ No newline at end of file
diff --git a/telemetry-worker/.gitignore b/telemetry-worker/.gitignore
new file mode 100644
index 0000000..488516e
--- /dev/null
+++ b/telemetry-worker/.gitignore
@@ -0,0 +1,3 @@
+.wrangler/
+node_modules/
+.stats-token
diff --git a/telemetry-worker/README.md b/telemetry-worker/README.md
new file mode 100644
index 0000000..25fa2f5
--- /dev/null
+++ b/telemetry-worker/README.md
@@ -0,0 +1,41 @@
+# StemKit telemetry worker
+
+Anonymous usage counter for StemKit. The app POSTs one tiny heartbeat per
+install per day (random install id + version/os/arch, no PII) to `/ping`;
+`/stats` returns aggregated counts.
+
+## Deploy
+
+Requires [Wrangler](https://developers.cloudflare.com/workers/wrangler/) and a
+Cloudflare account (free).
+
+```sh
+cd telemetry-worker
+
+# create the KV namespace and copy its id into wrangler.toml
+wrangler kv namespace create DB
+
+# pick a random token for the /stats endpoint
+# (or use: wrangler secret put STATS_TOKEN)
+# edit wrangler.toml [vars] STATS_TOKEN, then:
+
+wrangler deploy
+```
+
+## Point the app at it
+
+The app defaults to `https://stemkit-stats.danielravina.workers.dev/ping` in
+`src/main/telemetry.ts`. After deploying, replace that host with your worker's
+URL (wrangler prints it, or check the Cloudflare dashboard). The subdomain is
+`stemkit-stats.<your-account-subdomain>.workers.dev`.
+
+## View stats
+
+```sh
+curl -H "Authorization: Bearer <token>" \
+ https://stemkit-stats.<account>.workers.dev/stats
+```
+
+Returns total unique installs, installs per platform/version, and a 30-day
+daily breakdown (active = unique installs that pinged that day, new = first
+pings).
\ No newline at end of file
diff --git a/telemetry-worker/src/worker.js b/telemetry-worker/src/worker.js
new file mode 100644
index 0000000..ed2c6df
--- /dev/null
+++ b/telemetry-worker/src/worker.js
@@ -0,0 +1,132 @@
+/* Anonymous usage heartbeat collector for StemKit.
+
+ POST /ping — the app pings once per install per day with a random install
+ id + version/os/arch. No PII, nothing linkable to a person.
+ GET /stats — aggregated counts, guarded by a Bearer token (STATS_TOKEN).
+
+ KV layout (read-modify-write counters; races are acceptable at this scale):
+ i:<id> install record {firstSeen,lastSeen,version,platform,arch}
+ d:<date>:<id> dedupes the daily-active counter (48h TTL)
+ c:total unique installs ever
+ c:os:<platform> installs per platform
+ c:ver:<version> installs per app version
+ c:new:<date> new installs per day
+ c:dau:<date> daily active unique installs
+*/
+
+const DAY = 24 * 60 * 60 * 1000
+const DAILY_TTL = 45 * 24 * 60 * 60
+const DEDUPE_TTL = 48 * 60 * 60
+
+const json = (data, status = 200) =>
+ new Response(JSON.stringify(data, null, 2), {
+ status,
+ headers: { 'Content-Type': 'application/json', 'Cache-Control': 'no-store' }
+ })
+
+function today(offset = 0) {
+ return new Date(Date.now() - offset * DAY).toISOString().slice(0, 10)
+}
+
+export default {
+ async fetch(request, env) {
+ const { DB } = env
+ const incr = async (key, ttl) => {
+ const raw = await DB.get(key)
+ const next = (parseInt(raw || '0', 10) || 0) + 1
+ await DB.put(key, String(next), ttl ? { expirationTtl: ttl } : undefined)
+ return next
+ }
+
+ const url = new URL(request.url)
+ const { pathname } = url
+
+ if (pathname === '/ping' && request.method === 'POST') {
+ let body
+ try {
+ body = await request.json()
+ } catch {
+ return json({ error: 'bad json' }, 400)
+ }
+ const id = typeof body.id === 'string' ? body.id : null
+ if (!id || id.length > 64) return json({ error: 'bad id' }, 400)
+
+ const version = typeof body.version === 'string' ? body.version.slice(0, 32) : 'unknown'
+ const platform = typeof body.platform === 'string' ? body.platform.slice(0, 16) : 'unknown'
+ const arch = typeof body.arch === 'string' ? body.arch.slice(0, 16) : 'unknown'
+ const now = Date.now()
+ const date = today()
+
+ const recKey = `i:${id}`
+ const existing = await DB.get(recKey)
+
+ if (!existing) {
+ await DB.put(
+ recKey,
+ JSON.stringify({ firstSeen: now, lastSeen: now, version, platform, arch })
+ )
+ await incr('c:total')
+ await incr(`c:os:${platform}`)
+ await incr(`c:ver:${version}`)
+ await incr(`c:new:${date}`, DAILY_TTL)
+ } else {
+ try {
+ const rec = JSON.parse(existing)
+ rec.lastSeen = now
+ rec.version = version
+ rec.platform = platform
+ rec.arch = arch
+ await DB.put(recKey, JSON.stringify(rec))
+ } catch {
+ await DB.put(
+ recKey,
+ JSON.stringify({ firstSeen: now, lastSeen: now, version, platform, arch })
+ )
+ }
+ }
+
+ // one daily-active credit per install per day
+ const dedupeKey = `d:${date}:${id}`
+ if (!(await DB.get(dedupeKey))) {
+ await DB.put(dedupeKey, '1', { expirationTtl: DEDUPE_TTL })
+ await incr(`c:dau:${date}`, DAILY_TTL)
+ }
+
+ return new Response(null, { status: 204 })
+ }
+
+ if (pathname === '/stats' && request.method === 'GET') {
+ const auth = request.headers.get('Authorization') || ''
+ if (auth !== `Bearer ${env.STATS_TOKEN}`) return json({ error: 'forbidden' }, 401)
+
+ const total = parseInt((await DB.get('c:total')) || '0', 10)
+
+ const os = {}
+ const versions = {}
+ for (const key of (await DB.list({ prefix: 'c:os:' })).keys) {
+ os[key.name.slice(5)] = parseInt(await DB.get(key.name), 10)
+ }
+ for (const key of (await DB.list({ prefix: 'c:ver:' })).keys) {
+ versions[key.name.slice(6)] = parseInt(await DB.get(key.name), 10)
+ }
+
+ const daily = []
+ for (let i = 29; i >= 0; i--) {
+ const date = today(i)
+ const dau = parseInt((await DB.get(`c:dau:${date}`)) || '0', 10)
+ const fresh = parseInt((await DB.get(`c:new:${date}`)) || '0', 10)
+ daily.push({ date, active: dau, new: fresh })
+ }
+
+ return json({
+ totalInstalls: total,
+ os,
+ versions,
+ daily,
+ updatedAt: new Date().toISOString()
+ })
+ }
+
+ return json({ error: 'not found' }, 404)
+ }
+}
\ No newline at end of file
diff --git a/telemetry-worker/stats.sh b/telemetry-worker/stats.sh
new file mode 100755
index 0000000..8100e75
--- /dev/null
+++ b/telemetry-worker/stats.sh
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+# Live install stats from the telemetry worker.
+# Token is read from STEMKIT_STATS_TOKEN, or from .stats-token next to this script.
+set -euo pipefail
+
+URL="${STEMKIT_STATS_URL:-https://stemkit-stats.danielravina.workers.dev/stats}"
+HERE="$(cd "$(dirname "$0")" && pwd)"
+TOKEN="${STEMKIT_STATS_TOKEN:-}"
+
+if [ -z "$TOKEN" ] && [ -f "$HERE/.stats-token" ]; then
+ TOKEN="$(tr -d '[:space:]' < "$HERE/.stats-token")"
+fi
+
+if [ -z "$TOKEN" ]; then
+ echo "No token. Set STEMKIT_STATS_TOKEN or create telemetry-worker/.stats-token" >&2
+ exit 1
+fi
+
+curl -sf -H "Authorization: Bearer $TOKEN" "${URL%/stats}/stats" |
+ python3 -c '
+import json, sys
+
+d = json.load(sys.stdin)
+daily = d.get("daily", [])
+total = d["totalInstalls"]
+dau = sum(x["active"] for x in daily[-1:])
+wau = max(x["active"] for x in daily[-7:]) if daily else 0
+
+print(f"total installs : {total}")
+print(f"active today : {dau}")
+print(f"active (7d max): {wau}")
+print("per OS :", ", ".join(f"{k} {v}" for k, v in d.get("os", {}).items()) or "-")
+print("per version :", ", ".join(f"{k} {v}" for k, v in sorted(d.get("versions", {}).items())) or "-")
+print()
+print("last 14 days (date active new)")
+for x in daily[-14:]:
+ date, active, new = x["date"], x["active"], x["new"]
+ print(f" {date} {active:>6} {new:>5}")
+'
diff --git a/telemetry-worker/wrangler.toml b/telemetry-worker/wrangler.toml
new file mode 100644
index 0000000..badff14
--- /dev/null
+++ b/telemetry-worker/wrangler.toml
@@ -0,0 +1,7 @@
+name = "stemkit-stats"
+main = "src/worker.js"
+compatibility_date = "2026-01-01"
+
+[[kv_namespaces]]
+binding = "DB"
+id = "f2d9e609846d4bdbb9d3afc725bd5639"
\ No newline at end of file
diff --git a/website/index.html b/website/index.html
index 9219c9b..0eff1f5 100644
--- a/website/index.html
+++ b/website/index.html
@@ -363,6 +363,7 @@
<div class="req"><b>First launch</b><span>StemKit sets up its own engine, about 2GB, one time. Nothing to install by hand.</span></div>
<div class="req"><b>Disk space</b><span>About 2GB, downloaded once during setup.</span></div>
<div class="req"><b>Internet</b><span>Needed to fetch songs from YouTube and for the one-time setup.</span></div>
+ <div class="req"><b>Privacy</b><span>Your songs and audio never leave your machine. The app sends one anonymous ping per day (random id + version/OS) to count installs — nothing else.</span></div>
</div>
</section>
@@ -375,7 +376,7 @@
</a>
<a class="btn-ghost" href="https://github.com/danvelope/stemkit" target="_blank" rel="noopener" data-ga="github">Star on GitHub</a>
</div>
- <p class="caption-note">no account needed · fully local processing</p>
+ <p class="caption-note">no account needed · fully local processing · your audio never leaves your machine</p>
</div>
<footer>
@@ -384,6 +385,7 @@
<a href="https://github.com/danvelope/stemkit" target="_blank" rel="noopener" data-ga="github">GitHub</a>
<a href="https://github.com/danvelope/stemkit/releases" target="_blank" rel="noopener" data-ga="releases">Releases</a>
<a href="https://github.com/danvelope/stemkit/issues" target="_blank" rel="noopener" data-ga="github">Issues</a>
+ <a href="https://github.com/danvelope/stemkit#privacy" target="_blank" rel="noopener" data-ga="privacy">Privacy</a>
</div>
</footer>
</div>