fix(stats): add CACHE_KV binding to fix login redirect loop#1010
Open
lane711 wants to merge 7 commits into
Open
fix(stats): add CACHE_KV binding to fix login redirect loop#1010lane711 wants to merge 7 commits into
lane711 wants to merge 7 commits into
Conversation
Without CACHE_KV, withCloudflare had kv=undefined — session writes silently failed, causing a login-success → redirect → "please login" loop on stats.sonicjs.com. Reuses the shared KV namespace (a16f8246fc294d809c90b0fb2df6d363) for both default and production envs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…anges Removes the path filter so stats.sonicjs.com always runs the latest version of @sonicjs-cms/core after any merge to main. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
wrangler >=4 requires Node >=22. Lock file was also out of sync with current esbuild/emnapi versions; npm install resolves fresh rather than failing on the stale lock file. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…oard - Removes LIMIT 20 / slice(15) so all collections appear in the table - Sorts by installations desc (most-adopted first) — chart still capped at top 20 - Adds "Custom Collections" side-by-side card: filters to installations = 1 (user-defined collections unique to one install), sorted by doc count - Both tables are scrollable (max-h-96) so the page doesn't balloon Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ding bootstrap.ts read c.env.KV but the binding is named CACHE_KV in wrangler.toml. KV was always undefined → installationId defaulted to 'unknown' on every project_snapshot event, making per-installation analytics useless. Falls back to c.env.KV for any deployment that uses the legacy name. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
SQL bug: HAVING created_at = MAX(created_at) picked collection_counts arbitrarily (SQLite GROUP BY semantics) — most snapshot rows were silently dropped. Now reads collection_names from every snapshot row directly. Logic bug: "installations = 1" as the custom filter was wrong since all existing snapshots carry installation_id='unknown', collapsing them all into one fake installation. Replaced with a SYSTEM_COLLECTIONS exclusion set (menu_item, plugin, plugin_activity, rbac_role, rbac_verb, rbac_user_roles, content, media) — everything else is user-defined. System collections shown dimmed with [sys] label in the All Collections table so they're still visible but visually deprioritized. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Captures the scheme+host of the first cold-start request so the stats dashboard can show which domains are running SonicJS. No path, query string, or user data is collected — only the origin (e.g. "https://example.com"). Dashboard adds a "Deployed Sites" table showing all unique origins + snapshot counts. Hidden when no deploy_url data exists yet. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
stats.sonicjs.comlogin succeeded but immediately redirected back to "Please login to access the admin area"packages/stats/wrangler.tomlhad noCACHE_KVbinding — Better Auth'swithCloudflarereceivedkv: undefined, session writes silently failed, soc.get('user')was alwaysundefinedon the next requestCACHE_KVKV namespace binding (reusinga16f8246fc294d809c90b0fb2df6d363) to both default and[env.production]sectionsTest plan
BETTER_AUTH_SECRETwrangler secret is set onsonicjs-statsworker (runwrangler secret list --name sonicjs-stats)🤖 Generated with Claude Code