Plausible analytics reports to Discord (migration 065)
Daily (yesterday) and weekly (Mondays, last 7 days vs the 7 before) summaries: visitors, pageviews, bounce rate, visit length, top pages and sources. Each has its own switch in Site settings > Reports; off until PLAUSIBLE_API_KEY and DISCORD_WEBHOOK_URL are set. Sent at 8:00 REPORT_TZ (default America/Chicago); analytics_reports keeps one a day. node src/analyticsReport.js daily|weekly sends one by hand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b8012c75e9
commit
636388730f
6 changed files with 254 additions and 1 deletions
19
server/src/migrations/065_analytics_reports.sql
Normal file
19
server/src/migrations/065_analytics_reports.sql
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 065 ANALYTICS REPORTS
|
||||
--
|
||||
-- Plausible's numbers posted to Discord (server/src/analyticsReport.js).
|
||||
--
|
||||
-- site_settings.report_daily 'on': yesterday's numbers each morning
|
||||
-- site_settings.report_weekly 'on': last week's each Monday morning
|
||||
-- Blank or 'off': not sent
|
||||
-- analytics_reports the local date each kind was last sent
|
||||
-- for, so a restart doesn't post twice
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
|
||||
ALTER TABLE site_settings ADD COLUMN report_daily TEXT CHECK (report_daily IN ('on', 'off'));
|
||||
ALTER TABLE site_settings ADD COLUMN report_weekly TEXT CHECK (report_weekly IN ('on', 'off'));
|
||||
|
||||
CREATE TABLE analytics_reports (
|
||||
kind TEXT PRIMARY KEY CHECK (kind IN ('daily', 'weekly')),
|
||||
sent_for TEXT NOT NULL
|
||||
) STRICT;
|
||||
Loading…
Add table
Add a link
Reference in a new issue