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

38
views/settings/stats.ejs Normal file
View file

@ -0,0 +1,38 @@
<h2 class="set-h">Stats and data</h2>
<p class="set-intro">The public stats page, and data copied from Twitch.</p>
<%- include('_flash') %>
<form method="POST" action="/settings/stats" class="set-card">
<h3>Public stats page</h3>
<div class="set-row">
<div class="lbl">Public page on<small>Off: it answers “not found” for everyone except you (preview below). Never shows message text, bots, or viewers who typed !hideme.</small></div>
<label><input type="checkbox" name="public_stats_enabled" role="switch" <%= settings.public_stats_enabled ? 'checked' : '' %>></label>
</div>
<div class="set-row">
<div class="lbl">Host name<small>Its own address. Needs a DNS record to this server, a certificate, and the web server sending it to HeyStreamer. On that host only the public page answers.</small></div>
<input type="text" name="public_stats_host" value="<%= settings.public_stats_host || '' %>" placeholder="stats.example.com">
</div>
<div class="set-row">
<div class="lbl"></div>
<div class="set-inline"><button type="submit" class="btn-auto">Save</button><a href="/public" target="_blank" rel="noopener">Preview ↗</a></div>
</div>
</form>
<div class="set-card">
<h3>Twitch</h3>
<% const bad = Object.entries(sync.parts || {}).filter(([, v]) => !String(v).startsWith('ok')); %>
<div class="set-row">
<div class="lbl">Sync with Twitch<small>Followers with follow dates, current subs, mods, VIPs, all-time bits, your emotes, past streams (VODs). Runs every 6 hours and after each stream.</small></div>
<div>
<form method="POST" action="/stats/sync?back=settings" class="set-inline"><button type="submit" class="outline btn-auto">Sync now</button>
<small><%= sync.at ? `last ${sync.at.slice(0, 16).replace('T', ' ')} UTC` : 'never' %></small></form>
<% if (sync.at) { %><small><% for (const [k, v] of Object.entries(sync.parts || {})) { %><%= k %>: <span style="<%= String(v).startsWith('ok') ? '' : 'color:#f88' %>"><%= v %></span> · <% } %></small><% } %>
</div>
</div>
<div class="set-row">
<div class="lbl">Twitch analytics (CSV)<small>Creator Dashboard → Analytics → export “Analytics and Revenue by day”. Fills in your history before HeyStreamer, and numbers only Twitch has. Importing again only updates days. Revenue is never public.</small></div>
<form method="POST" action="/stats/import-twitch?back=settings" enctype="multipart/form-data" class="set-inline">
<label role="button" class="outline btn-auto">Choose CSV files…<input type="file" name="files" accept=".csv,text/csv" multiple hidden onchange="this.form.requestSubmit()"></label>
<small><%= csv.days ? `${csv.days} days imported (${csv.from_day} – ${csv.to_day})` : 'none imported yet' %></small>
</form>
</div>
</div>