Stats per stream and period, public stats page, dashboard settings, Card alert style

Statistics
- Per day and per stream statistics (src/periodstats.js, one generic stat_day table), backfilled
  once from the older tables; Stream / Week / Month / Year / All time views, Community and Streams tabs.
- Viewer count every 5 minutes and title / category history per stream (EventSub channel.update):
  viewer graph, games played (donut), games in the streams list.
- Twitch sync (src/twitchsync.js): followers with follow dates, current subs, mods, VIPs, all-time
  bits, channel emotes, past streams from VODs. Twitch analytics CSV import (src/twitchcsv.js).
- Public stats page on its own host (Settings -> Stats and data): no message text, no bots,
  !hideme / !showme opt-out. Viewer page: roles, follow age, sub status, bits, a menu for rarely used actions.
- StreamElements watch-time importer removed (already imported minutes stay as a baseline).

Dashboard
- Settings and Actions with a left sidebar; each settings page saves only its own fields.
  Connections (Twitch, StreamElements token now set here, HUDFX), OBS links (hidden behind an eye
  toggle) with a link builder, Chat (sound picked from the media library), TTS, Stats and data,
  Backup (export / import the whole setup), Advanced. Time zone setting for the stats pages.
- Actions -> Alerts: alert style, pictures, sounds, bits tiers and card colours, stored in the
  database (src/theme.js); an old file-based theme is imported once. Alert preview page
  (/actions/alerts/preview, tools/preview/export.js for a static copy).
- Old /actions page removed; Actions = Redeems / Alerts / TTS voices / Media.

Alerts
- New plain Card style for everyone (public/alerts/card.js); Polaroid, Cassette and the TTS letter
  stay as optional looks. Redeem variations can be Card, Cassette, Sound only or Video.

Repo
- No channel data in git: the channel's art, stickers and sounds stay on disk (gitignored) and are
  picked in the dashboard; examples for the server config (apache.example.sh, .env.example).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Bashy 2026-11-23 11:22:49 +02:00
parent 5bf4bffaa0
commit c481ca92cb
57 changed files with 3080 additions and 774 deletions

View file

@ -133,7 +133,6 @@ Chat (`?parts=chat`) is `public/chat/chat.css` + `public/chat/chat.js` (window.H
`room-id` from ROOMSTATE, refreshed every 10 min). 7TV zero-width emotes (data flag 256) stack on the emote before.
Emote-only messages (up to 3 emotes) get bigger emotes.
- Moderation: deleted messages, timeouts, bans and /clear remove the matching slips at once.
- Design preview with other styles: `~/Desktop/Stream/chat/index.html` (not in the repo).
## Overlay updates after a deploy
@ -237,7 +236,7 @@ Page `/redeems` (src/routers/redeems.js, views/redeems.ejs, logic in src/redeems
- Shown as a cassette tape (`public/alerts/cassette.js` + `.css`, called from polaroid.js so it shares the queue):
rarity = shell colour (Ultra Rare: gold, glow, foil, sparkles), reels spin over the sound's length, label =
variation name + reward, paper strip = viewer + caption + typed message, sticker in the corner = the variation's
`art` (URL; '' = headset Streamer). `polaroid` column = "show cassette" (0 = sound only).
`art` (URL; '' = the theme's default sticker). `polaroid` column = "show cassette" (0 = sound only).
- Special styles instead of the cassette (`STYLE` in src/redeems.js, drawn by `public/alerts/fx.js` + `.css`):
Gigantify Power-up → the viewer's emote grows giant; On-Screen Celebration → 14 copies of the emote bounce around
the whole screen for the sound's length; Highlight my message and the Message Effect Power-up → big taped paper note, taller than wide (stays ~2 s + 70 ms/char).
@ -247,7 +246,7 @@ Page `/redeems` (src/routers/redeems.js, views/redeems.ejs, logic in src/redeems
two-pass loudnorm, so volume stays 0.8), `public/alerts/sounds/` (alert sounds + library) and audio uploaded on
the Media page (`/media/<file>`). Stickers: `public/alerts/stickers/` (cut out with rembg / hand masks).
- polaroid off = sound only: it still waits its turn in the overlay queue and holds it for the sound's length.
- First run: `src/redeems-seed.json` (rebuilt from the Twitch alert setup, 2026-11-20) is loaded when the table is
- First run: `src/redeems-seed.json` (Twitch's built-in rewards / Power-ups, silent, Card look) is loaded when the table is
empty. After that the dashboard is the source of truth; the seed file is never re-applied.
- Test buttons: per variation, and "Test random" per trigger (`POST /redeems/variation/:id/test`, `/redeems/trigger/test`).
- Power-up payload field names (`event.type === 'power_up'`, `event.power_up.type`) follow Twitch's docs but were not
@ -298,7 +297,7 @@ To re-enable: undo those three. Description of how it works when enabled:
`data.donation` (`user.username`, `amount`, `currency`, `message`). Only `approved: 'allowed'` + `status: 'success'`
alert; deduped by `data._id`. `reconnect` message → reconnect with `?reconnect_token=` (no re-subscribe). Server
PINGs every 30 s (ws answers). Status on the dashboard.
- Alert: tip polaroid (sound emotional-damage-meme, heart-eyes Streamer, amount via Intl currency format, badge, +1/2/3 hearts at 10/25/50).
- Alert: tip polaroid (art + sound from the theme, amount via Intl currency format, badge, +1/2/3 hearts at 10/25/50).
Turn off StreamElements' own tip alert in its overlay to avoid doubles.
## Polls and Hype Train
@ -308,7 +307,7 @@ To re-enable: undo those three. Description of how it works when enabled:
NOT in the alert queue): bars + votes + countdown; on `completed` the winner gets a heart + WINNER stamp, then it
drops away after 9 s (archived/terminated: away after 1.5 s). Begin/end are logged. Test: dashboard `poll-test`.
- Hype Train (`channel.hype_train.*` v2, scope `channel:read:hype_train`): `alerts.fromHypeTrain()` → queued polaroid
alerts on start, on each NEW level (progress fires per contribution) and at the end (top contributors). HYPE Streamer
alerts on start, on each NEW level (progress fires per contribution) and at the end (top contributors). theme art
art; sounds pro-gamer / toad-ya-hoo / tadaaa (in `describe()` case 'hype'). Golden Kappa / Treasure trains named.
## Polaroid alerts
@ -328,20 +327,20 @@ alerts.send() ─► ws.broadcast({type:'alert', alert}) ─► overlay ─► p
## Production deployment
Runs behind Apache on the VPS as a reverse proxy to Node on port 3000.
Production domain: `https://overlay.example.com`
Runs behind Apache (or any reverse proxy) as a proxy to Node on port 3000. This channel's real hosts, server user and
deploy command are in `CLAUDE.local.md` (not in git; Claude Code loads it automatically).
Apache vhost config is managed by `~/projects/apache.sh` (run on the VPS). Key requirements:
Apache vhost: `apache.example.sh` is a template (copy it outside the repo, fill in your hosts, run it on the server).
Key requirements:
- `RequestHeader set X-Forwarded-Proto "https"` must be in the **443 vhost** — without it Express sees the connection as HTTP, `req.secure` is false, and the session cookie is never sent (OAuth login breaks)
- `app.set('trust proxy', 1)` is set in `app.js` before all middleware
- `/ws/overlay` must be proxied with `ws://` via `mod_proxy_wstunnel` before the catch-all `/`
- Required modules: `proxy`, `proxy_http`, `proxy_wstunnel`, `headers`, `rewrite`
Deploy from Linux Mint:
Deploy by copying the working folder (rsync), not by git: the channel's media library is not in git and must travel too.
```bash
rsync -avzO --exclude='node_modules' --exclude='.env' --exclude='public/media' \
~/projects/heystreamer/ user@your-server:/opt/heystreamer/
rsync -avzO --exclude='node_modules' --exclude='.env' --exclude='public/media' --exclude='*.db*' \
./ user@your-server:/opt/heystreamer/
ssh user@your-server "cd /opt/heystreamer && npm install --production && sudo systemctl restart heystreamer"
```
@ -349,6 +348,29 @@ Twitch requires HTTPS for OAuth redirect URIs in production. Register both in th
- `http://localhost:3000/auth/callback` (dev)
- `https://overlay.example.com/auth/callback` (production)
## Channel setup lives in the database, not in files
Everything a channel customises is set in the dashboard and stored in the database, so the repo holds no channel
data and `git pull` never touches a channel's setup:
| Where in the dashboard | Stored in |
|---|---|
| Actions → Alerts: style (Card / Polaroid), pictures, sounds, bits tiers, card colours (`src/theme.js`) | `settings.alert_theme` (JSON) |
| Actions → Redeems: variations, look (Card / Cassette / Sound only / Video), TTS voice | `reward_variations` |
| Actions → TTS voices, Media (uploads in `public/media/`, not in git) | `tts_voices`, `media_files` |
| Settings → General, Connections (StreamElements token), Chat, TTS, Stats, Advanced | `settings` |
| Settings → Backup: export / import all of the above as one JSON file | — |
Alert styles: **Card** (`public/alerts/card.js`, the plain default) for everyone; **Polaroid**, **Cassette** and the
**Letter** (TTS) are optional looks anyone can pick. The overlay receives the merged theme with its settings
(`S.alert_theme`) and reads it per alert, so saving in the dashboard needs no OBS reload. An old file-based
`public/alerts/theme.js` is imported once at startup (`theme.importLegacyFile()`).
Not in git (`.gitignore`): the database, `.env`, uploads (`public/media`), TTS clips, analytics CSV exports, the
channel's media library under `public/alerts/{art,stickers,sounds,videos}` (picked like uploads on Actions → Alerts /
Redeems), and `CLAUDE.local.md` (this channel's hosts / deploy notes). Never commit viewer names, stats, revenue,
reward ids or the channel's hosts.
## Not yet implemented
- Mod access (streamer-only login for now)