fix(insights-edge): weekly report cron fired every Sunday, not Monday

Cloudflare Cron Triggers number weekdays 1=Sunday..7=Saturday (Quartz-style),
not the POSIX 0=Sunday..6=Saturday most cron syntax assumes. The configured
trigger "0 7 * * 1" was written assuming POSIX semantics (1=Monday) but
Cloudflare resolved it as Sunday — confirmed against three real delivered
digest emails (2026-10-11/18/25, all Sunday 07:00-07:01 UTC). Switched to the
unambiguous "0 7 * * MON" literal per Cloudflare's own docs recommendation.
Verified live: redeployed, confirmed the new schedule via the Workers API,
and triggered a real POST /api/report to confirm the send path still works
end to end (real email landed in the inbox within seconds).
This commit is contained in:
caelum0x 2026-10-26 16:55:38 +03:00
parent 47188beb0c
commit be8072ce88
2 changed files with 10 additions and 2 deletions

View File

@ -1,6 +1,8 @@
// Weekly funnel report: every site in the SITES KV, last 7 full UTC days
// against the 7 before, emailed through Scribase Mail (Rally Send protocol).
// Runs from the Worker cron (Mondays 07:00 UTC) and from POST /api/report.
// Runs from the Worker cron (Mondays 07:00 UTC -- wrangler.jsonc's "triggers.crons",
// fixed 2026-10-26 to "0 7 * * MON" after it silently fired every Sunday for weeks;
// see the comment there) and from POST /api/report.
import { siteStats } from "./store.mjs";

View File

@ -21,7 +21,13 @@
// `<siteKey>/<sessionId>/<seq>.json`. Create once with `wrangler r2 bucket create railyard-insights-replay`.
"r2_buckets": [{ "binding": "REPLAY", "bucket_name": "railyard-insights-replay" }],
// Weekly funnel report, Mondays 07:00 UTC, through Scribase Mail.
"triggers": { "crons": ["0 7 * * 1"] },
// NB (found 2026-10-26): Cloudflare Cron Triggers number weekdays 1=Sunday..7=Saturday
// (Quartz-style), NOT the POSIX 0=Sunday..6=Saturday most cron docs assume. "0 7 * * 1"
// therefore actually fired every SUNDAY 07:00 UTC in production for weeks (confirmed via
// the real delivered digest emails: 2026-10-11, -18, -25 all landed Sunday 07:00-07:01
// UTC, not Monday). Using the three-letter abbreviation instead, as Cloudflare's own docs
// recommend, to avoid this ambiguity ever recurring.
"triggers": { "crons": ["0 7 * * MON"] },
// Namespace RAILYARD_SITES, created 2026-09-30 (`wrangler kv namespace create RAILYARD_SITES`).
"kv_namespaces": [{ "binding": "SITES", "id": "323121abfdc64ff6ab90927620d3dbb2" }],
"vars": {