feat: dynamic environment filter from observed data#278
Merged
Conversation
The Release Health page hardcoded only two environment options
(production, development). SDKs sending other environments like
'staging' had no way to be filtered — the data was stored but
inaccessible from the UI.
Replace the hardcoded list with a dynamic filter backed by a new
endpoint that queries distinct environment values actually observed
for the project (union of release_health + transactions tables).
Backend:
- trapfall-db: list_environments() trait method + sqlite/postgres impls
(SELECT DISTINCT environment UNION across release_health + transactions)
- trapfall-core: expose list_environments on Store wrapper
- trapfalld: GET /api/0/projects/{slug}/environments endpoint
- openapi.yaml: document the new endpoint
- test: list_environments unions release_health + transactions
Frontend:
- api.ts: listEnvironments() client method
- release-health page: dynamic envOptions derived from observed
environments; active filter always rendered (handles URL-restore
race before fetch resolves)
Any environment an SDK reports (staging, qa, preview, ...) now appears
automatically.
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.
Problem
The Release Health page hardcoded only two environment options —
productionanddevelopment. SDKs sending other environments (e.g.stagingfrom a Flutter app) had their data stored correctly, but there was no way to filter for it in the UI. Adding a new env required a code change every time.Solution
Replace the hardcoded dropdown with a dynamic filter backed by a new endpoint that returns the distinct
environmentvalues actually observed for the project.Changes
New endpoint:
GET /api/0/projects/{slug}/environments→["development", "production", "staging"]trapfall-db/src/lib.rslist_environments()methodtrapfall-db/src/sqlite.rsSELECT DISTINCT environmentUNION ofrelease_health+transactionstrapfall-db/src/postgres.rs$Nplaceholderstrapfall-core/src/store.rslist_environmentstrapfalld/src/server.rsopenapi.yamlweb/src/lib/api.tslistEnvironments()release-health/+page.svelteenvOptionsderived from observed dataDesign decisions
release_health+transactions— both have a properenvironmentcolumn on sqlite + postgres.eventsstores environment inside a JSON blob, so excluded. (Also, transactions aren't persisted yet per 1c: Add transactions + transaction_spans DB tables and queries #237, but the column exists and the query is forward-compatible.)filterEnvis restored from a URL param before the fetch resolves (or points to an env no longer in the DB), it still appears as a selected button rather than silently vanishing.Verification
cargo fmt --all -- --check→ cleancargo test -p trapfall_db --lib→ 23 passed (incl. newtest_list_environments_unions_release_health_and_transactions)cargo build -p trapfalld→ oknpm run check→ 0 errors (1 pre-existing warning in transactions page, unrelated)npm run build+npm run test→ 5 passedResult
Any environment an SDK reports —
staging,qa,preview, anything — now appears in the filter automatically, no code changes needed.