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

@ -1,22 +1,20 @@
<h2>Dashboard</h2>
<div style="display:flex; gap:1rem; margin-bottom:1.5rem; flex-wrap:wrap;">
<div>
<strong>Channel:</strong>
<%= settings.channel || '<em>not set</em>' %>
</div>
<div>
<strong>OBS browser sources</strong> (1920×1080):<br>
<small>Chat only, set its audio to <em>Monitor Only (mute output)</em> so chat sounds stay off stream:</small><br>
<code><%= process.env.APP_BASE_URL %>/overlay/<%= settings.overlay_id %>?parts=chat</code><br>
<small>Everything except chat (alerts, redeems, poll, Hype Train bar, raid send-off):</small><br>
<code><%= process.env.APP_BASE_URL %>/overlay/<%= settings.overlay_id %>?parts=nochat</code><br>
<small>Chat somewhere else, e.g. in the Intermission panel (left,top,width,height in px of the 1920×1080 page; <em>up</em> = newest at the bottom):</small><br>
<code><%= process.env.APP_BASE_URL %>/overlay/<%= settings.overlay_id %>?parts=chat&amp;chat=130,640,700,360&amp;chatflow=up</code><br>
<small title="parts: chat, alerts, poll, hypebar, raid. List them (?parts=chat,raid) or exclude with no… (?parts=nochat,noraid). No ?parts = everything.">
Other combinations: hover for help · everything in one source: <code>/overlay/<%= settings.overlay_id %></code></small>
</div>
<div class="dash-status">
<a href="/settings/connections" title="Settings → Connections">
Twitch <% if (eventsubStatus.connected) { %><span class="badge badge-green">connected</span><% } else if (eventsubStatus.running) { %><span class="badge badge-grey">connecting…</span><% } else { %><span class="badge badge-red">not running</span><% } %>
</a>
<a href="/settings/connections" title="Settings → Connections">
StreamElements <% if (!seStatus.enabled) { %><span class="badge badge-grey">off</span><% } else if (seStatus.subscribed) { %><span class="badge badge-green">connected</span><% } else { %><span class="badge badge-grey">connecting…</span><% } %>
</a>
<a href="/settings/obs" title="Browser source links for OBS">OBS links →</a>
<% if (eventsubStatus.failed.length) { %><a href="/settings/connections" style="color:#f88">Some Twitch permissions are missing: log in again</a><% } %>
</div>
<style>
.dash-status { display:flex; gap:1.4rem; flex-wrap:wrap; align-items:center; margin:0 0 1.4rem; padding:.6rem .9rem;
border:1px solid var(--pico-muted-border-color); border-radius:12px; }
.dash-status a { text-decoration:none; font-size:.92rem; }
</style>
<div style="display:flex; gap:.8rem; align-items:center; margin-bottom:1.5rem;">
<button type="button" id="skip-alert" class="outline" style="width:auto; margin:0;"
@ -32,32 +30,6 @@
});
</script>
<h3>Twitch connection</h3>
<p>
<% if (eventsubStatus.connected) { %>
<span class="badge badge-green">connected</span>
<% } else if (eventsubStatus.running) { %>
<span class="badge badge-grey">connecting…</span>
<% } else { %>
<span class="badge badge-grey">not running</span> (log in again to start)
<% } %>
<% if (eventsubStatus.subscribed.length) { %><br><small>Listening to: <%= eventsubStatus.subscribed.join(', ') %></small><% } %>
<% if (eventsubStatus.failed.length) { %><br><small style="color:#c0392b">Failed: <%= eventsubStatus.failed.join(', ') %> (log out and in again if a permission is missing)</small><% } %>
<% if (eventsubStatus.lastEventAt) { %><br><small>Last event: <%= eventsubStatus.lastEventAt %></small><% } %>
</p>
<h3>StreamElements tips</h3>
<p>
<% if (!seStatus.enabled) { %>
<span class="badge badge-grey">off</span> <small>set <code>SE_JWT</code> in <code>.env</code> (StreamElements dashboard → avatar → your channel → JWT token) and restart</small>
<% } else if (seStatus.subscribed) { %>
<span class="badge badge-green">connected</span><% if (seStatus.lastTipAt) { %> <small>last tip: <%= seStatus.lastTipAt %></small><% } %>
<% } else { %>
<span class="badge badge-grey">connecting…</span>
<% } %>
<% if (seStatus.error) { %><br><small style="color:#c0392b"><%= seStatus.error %></small><% } %>
</p>
<h3>Raid</h3>
<p><small>Start the raid here and the send-off card stays on stream (silent) until the raid happens. Same as Twitch's Raid button.</small></p>
<div style="display:flex; gap:.5rem; align-items:center; flex-wrap:wrap; margin-bottom:.4rem;">
@ -82,7 +54,7 @@
</script>
<h3>Test alerts</h3>
<p><small>Sends a sample alert to the overlay (OBS). Not logged, no actions fired.</small></p>
<p><small>Sends a sample alert to the overlay (OBS). Not logged, no actions fired. Looks and sounds: <a href="/actions/alerts">Actions → Alerts</a>.</small></p>
<div id="test-alerts" style="display:flex; flex-wrap:wrap; gap:.4rem; margin-bottom:.5rem;">
<% for (const key of testKeys) { %>
<button type="button" class="outline" data-key="<%= key %>" style="width:auto; padding:.3rem .8rem; margin:0;"><%= key %></button>