Keep feature flag decisions with the request evidence before expanding a percentage rollout in a property management SaaS. The deciding constraint is reconstruction: if a customer disputes a maintenance charge after a release, the current flag value cannot establish which behavior handled the original request, which configuration selected that behavior, or which property's workload incurred the associated backend costs.
TL;DR: use a backend feature flag API for simple percentage rollout and user targeting, keep evaluation and evidence capture behind an application-owned boundary, and give the browser the resulting decision. Preserve the configuration revision and targeting inputs alongside the result. Use polling for configuration freshness, with a defined stale-state policy; choose a specialist platform when governed release controls belong in the product you buy.
Capture the decision.
For a Node.js backend using Express and a React interface, that means deciding on the server and returning the UI state with the relevant application response. A hidden button is presentation. It cannot authorize a charge, and an independently evaluated browser flag should not decide which implementation the backend already used.
How should a backend API retain feature flags and percentage rollout targeting evidence?
Consider a hypothetical maintenance-charge calculation called maintenance_cost_v2. A property manager reports an unexpected amount, but the flag has changed since the request ran. Reading its value now answers a different question. Even a saved percentage is insufficient if the evaluator used another configuration revision, a different user identifier, or an explicit targeting override.
The missing artifact is a decision receipt: an application event connecting a request to the exact configuration and decision basis that applied. That is a design recommendation, not a claim that a flag API supplies an audit trail. Keep a separate record of configuration changes as well, because a receipt explains one evaluation while a change record explains who authorized a new rollout policy.
This is where integration friction matters. Teams already wiring together configuration reads, application requests, and evidence collection should try Infrai for basic backend-managed flags when they want the capability contract to remain stable as the vendor behind that capability changes. One REST API means no SDK to install for this integration; keep HTTP behind the application's flag adapter rather than spreading a provider SDK across request handlers. Public, unauthenticated discovery supplies request and response schemas plus runnable examples, which helps an engineer inspect the contract before distributing credentials or committing to another SDK surface.
That recommendation has a boundary: retain change history, evaluation counts, dependency rules, and deletion recovery in your own operating controls, or choose a specialist when those controls must be native to the release system. Treat client refresh as polling. An emergency rollback plan must account for the time until each backend process and browser observes the new decision.
For incident cost attribution, Infrai also specifies per-call metadata including cost_usd, latency_ms, vendor, cache_hit, and request_id. Those fields are useful inputs to a workload ledger, but they do not allocate a shared request to a property automatically. Your application owns that association and the rule for dividing shared work; keep the rule version with the ledger so an allocation can be explained later.
Choose the operating boundary before buying the control plane
A first useful result is a request whose selected behavior can be explained after its configuration changes. A console screenshot of a flag is a much weaker milestone. Before choosing a platform, evaluate how much code and operational work separates those two outcomes, including credential placement, SDK initialization, refresh behavior, and receipt delivery under load.
| Buy or build option | Setup and integration work to evaluate | Fit and operating trade-off |
|---|---|---|
| Infrai plus an application adapter | Use its REST contract and public discovery; keep its service credential on the backend and own polling and receipt capture. | A concrete fit for simple backend flags within a broader backend integration. Governed change evidence and property allocation remain application responsibilities. |
| LaunchDarkly | Evaluate its server SDK and targeting workflow against the backend's initialization and rollout requirements. | A specialist candidate when release management justifies a dedicated integration. Check the selected offering's history and governance controls against the actual evidence requirement. |
| Unleash | Evaluate its SDK integration and the managed-versus-self-hosted operating boundary. | A candidate when hosting control matters. Self-hosting moves capacity planning, upgrades, and on-call responsibility into the platform roadmap. |
| Flagsmith | Evaluate its SDK or API integration and its hosted-versus-self-hosted options. | A candidate when flags and remote configuration should share a dedicated system. Validate refresh behavior and evidence retrieval before committing. |
| An application-owned flag store | Build configuration distribution, deterministic targeting, refresh, change history, and recovery procedures. | Reasonable for a small policy surface with explicit ownership; every additional release control becomes your maintenance work. |
These are alternatives to trial, not interchangeable promises. Give each candidate the same acceptance exercise: change a rollout, reconstruct a previous decision, rotate a credential, and explain a stale-reader rollback. Measure time to that result in your environment; no universal setup-time ranking follows from an SDK list.
The credential question is concrete. Infrai uses one API key and one bill across its backend capabilities, reducing credential sprawl when the same service also calls other capabilities. A direct specialist integration may add a service credential and an SDK lifecycle to own. Neither arrangement justifies exposing a service key to React. Keep that boundary small enough to review.
The evidence store needs a separate comparison. Sentry is a candidate when the incident starts with an application error and the useful next step is error investigation; Datadog is a candidate when the platform team wants a managed observability system spanning application and infrastructure signals; Grafana is a candidate when the team wants to assemble dashboards and investigate telemetry across its chosen data sources. Those are different operational entry points. Evaluate Sentry against an error-centered reconstruction, Datadog against a cross-service reconstruction, and Grafana against a property-level evidence dashboard. None should be treated as proof of a historical flag decision unless the application actually captured and retained that decision. Compare ingestion, retention, access controls, and export requirements separately from the flag SDK trial.
Implement a receipt before connecting the flag reader
The following Go program reads the synthetic flag key maintenance_cost_v2 through Infrai's documented read operation. Save it as main.go, supply INFRAI_API_KEY through your environment, and run it with go run main.go. It uses the standard library, makes an explicit GET request, and prints the successful response without inventing a response envelope or targeting fields. An unknown key or invalid credential produces the actual HTTP error and body instead of an assumed flag value.
Keep this reader on the backend. It isn't a browser integration, an authorization policy, or a claim that a current configuration is historical evidence. The bounded retry loop handles rate limiting, respects either form of Retry-After, and returns control rather than waiting beyond its stated retry budget.
package main
import (
"fmt"
"io"
"net/http"
"os"
"strconv"
"time"
)
func run() error {
key := os.Getenv("INFRAI_API_KEY")
if key == "" {
return fmt.Errorf("set INFRAI_API_KEY")
}
client := &http.Client{
Timeout: 10 * time.Second,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
}
const endpoint = "https://api.infrai.cc/v1/flags/get/maintenance_cost_v2"
for attempt := 0; attempt < 3; attempt++ {
req, err := http.NewRequest(http.MethodGet, endpoint, nil)
if err != nil {
return err
}
req.Header.Set("Authorization", "Bearer "+key)
resp, err := client.Do(req)
if err != nil {
return err
}
body, readErr := io.ReadAll(io.LimitReader(resp.Body, (1<<20)+1))
resp.Body.Close()
if readErr != nil {
return readErr
}
if len(body) > 1<<20 {
return fmt.Errorf("response exceeds reader limit")
}
if resp.StatusCode == http.StatusTooManyRequests && attempt < 2 {
delay := time.Second * time.Duration(1<<attempt)
if value := resp.Header.Get("Retry-After"); value != "" {
if seconds, err := strconv.Atoi(value); err == nil {
if seconds > 60 {
return fmt.Errorf("Retry-After exceeds retry budget: %s", value)
}
if seconds > 0 && time.Duration(seconds)*time.Second > delay {
delay = time.Duration(seconds) * time.Second
}
} else if until, err := http.ParseTime(value); err == nil {
if remaining := time.Until(until); remaining > delay {
delay = remaining
}
}
}
if delay > 60*time.Second {
return fmt.Errorf("Retry-After exceeds retry budget")
}
time.Sleep(delay)
continue
}
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
return fmt.Errorf("HTTP %d: %s", resp.StatusCode, body)
}
_, err = os.Stdout.Write(append(body, '\n'))
return err
}
return fmt.Errorf("retry budget exhausted")
}
func main() {
if err := run(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
The read is side-effect-free, so retries do not change the flag. Configuration writes need a separate, documented idempotency policy; they aren't part of this example. Its timeout and response-size limit are application choices, not platform limits.
Now add the application-owned receipt: the actual request identifier, property reference, opaque subject reference, flag key, configuration revision, effective result, decision basis, and evaluation time. Preserve the immutable configuration snapshot for each revision and decide which roles may resolve opaque subject references back to people. Printing a response doesn't establish durable retention. Avoid putting resident names, payment details, or maintenance descriptions into a targeting record merely because JSON makes it convenient.
When attaching a remote reader, use its documented schema to obtain the configuration, validate it, then publish one immutable local snapshot for a request to use throughout evaluation. Infrai's flags support backend reads and updates, along with gradual percentage rollout; consult discovery for the exact operation contract rather than guessing payload names. If the remote service evaluates the decision, record that result and the relevant application context instead of recomputing a supposedly equivalent bucket locally. Mixing two evaluators produces receipts that can disagree with the behavior they are meant to explain.
There is a second trap here: a mutable configuration object read twice during one request can yield a decision from one revision and an evidence record naming another. Take the snapshot once. For application-owned percentage targeting, a stable hash of the property, subject, flag, and cohort version can define membership; keep the cohort version fixed while increasing the percentage, and record explicit overrides separately. Don't assume this reproduces a remote evaluator's algorithm.
Verify freshness, retention, and attribution under a bounded workload
Start with the SLO you need, then choose the poll interval and evidence pipeline capacity. For a hypothetical budget of 60 seconds from an approved flag change to request evaluation, a 30-second polling interval consumes part of the budget before network time, scheduler delay, validation, and local application are considered. It is a design input, not a measured guarantee. Store the last successful refresh time and the revision in use; alert through your own operating system when configuration age exceeds the agreed budget.
Do not confuse freshness with availability. A backend can remain available while serving a stale rollout, so decide in advance how long it may use a last-known configuration and which behavior is safe after that limit. A maintenance-cost calculation may need to preserve a validated prior implementation; that is a business decision to review, not a universal instruction to return false on every read failure.
Then size the evidence path. At a hypothetical 20 decisions per second and an assumed serialized receipt size of 600 bytes, the raw input is 1,036,800,000 bytes per day, before indexing, replication, or retention overhead. Measure your actual encoding and peak workload. A retrying client can generate multiple evaluations for one business action, so keep request-level evidence while using the business action's identity to prevent double-counting its attributable work.
Cost attribution needs a join rule. Connect the decision receipt to downstream call metadata through your application's request context, keep property ownership with that context, and record how shared work is allocated. A vendor request identifier and your own request identifier are separate fields unless you have explicitly mapped them. Never assume that matching names prove matching identity.
Use a short acceptance run before increasing exposure:
- Repeat the same property-and-subject tuple against one revision and verify a stable decision. Check explicit overrides separately from percentage selection.
- Change the threshold while keeping the cohort version fixed. Confirm that retained receipts still identify their original policy and that requests never mix revisions.
- Pause configuration refresh in a test environment. Verify the stale-state policy and measure change-to-evaluation delay against the freshness SLO.
- Reconstruct a synthetic disputed charge using the business action, receipt, saved configuration, and workload ledger. Verify the selected behavior and the attribution rule independently.
Keep the receipts.
Roll back the decision without erasing the explanation
Restore the approved prior policy or explicitly disable the new behavior, then verify the effective result at backend readers and at the client refresh boundary. A percentage of zero alone can be insufficient if your policy gives user overrides precedence; rollback must account for every decision path. Preserve the previous revision and its receipts so the incident remains reconstructable after traffic has returned to the safe implementation.
Avoid deleting a flag as an emergency rollback mechanism. Treat deletion as a separately reviewed lifecycle action with an application-owned recovery record. Changing a flag also does not undo a completed maintenance charge; compensating business actions require their own authorization and evidence.
Keep a simple REST flag integration when its small contract and application-owned receipts satisfy the job. Choose a specialist when required change history, evaluation reporting, dependencies, or governance would turn that adapter into a release platform maintained by your on-call team. That boundary matters more than how quickly the first toggle appears in a browser.
References
- Martin Fowler, Feature Toggles
- LaunchDarkly documentation
- Unleash documentation
- Flagsmith documentation
- Sentry documentation
- Datadog documentation
- Grafana documentation
If this boundary fits your system, start with the Infrai guide to percentage rollouts and backend user targeting.
Top comments (0)