Skip to content

Commit 772ebd6

Browse files
committed
feat: add my comments
1 parent 7a72bfe commit 772ebd6

6 files changed

Lines changed: 62 additions & 25 deletions

File tree

src/content/docs/flagship/concepts.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 3
66
---
77

8-
Flagship organizes feature flags into apps. You define flags with variations and targeting rules, then evaluate them at the edge with low latency.
8+
Flagship organizes feature flags into apps. You define flags with variations and targeting rules, then evaluate them at the edge.
99

1010
## How it works
1111

@@ -83,7 +83,7 @@ Each rule contains:
8383
- An optional **percentage rollout** that splits traffic across variations.
8484
- A **variation** to serve when the rule matches.
8585

86-
Conditions within a rule can be grouped with `AND`/`OR` operators and nested up to six levels deep.
86+
Conditions within a rule can be grouped with `AND`/`OR` operators.
8787

8888
Refer to [Targeting rules](/flagship/targeting/) and [Operators](/flagship/targeting/operators/) for the full list of operators and configuration options.
8989

@@ -110,4 +110,4 @@ When you change a flag in the dashboard, the change propagates globally within s
110110

111111
During the brief propagation window, some regions may still serve the previous flag value. After propagation completes, all subsequent evaluations return the updated value.
112112

113-
This model is optimized for low-latency evaluation at the edge. You do not need to redeploy your Worker or restart your application to pick up flag changes.
113+
You do not need to redeploy your Worker or restart your application to pick up flag changes.

src/content/docs/flagship/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818

1919
<Description>
2020

21-
Evaluate feature flags at the edge with low latency in Cloudflare Workers.
21+
Evaluate feature flags at the edge in Cloudflare Workers.
2222

2323
</Description>
2424

@@ -78,7 +78,7 @@ Build serverless applications on Cloudflare's global network. Flagship integrate
7878

7979
<RelatedProduct header="KV" href="/kv/" product="kv">
8080

81-
Store key-value data at the edge. Flagship uses Cloudflare's global infrastructure to deliver flag configurations with low latency.
81+
Store key-value data at the edge. Flagship uses Cloudflare's global infrastructure to deliver flag configurations.
8282

8383
</RelatedProduct>
8484

src/content/docs/flagship/reference/limits.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Flagship enforces the following limits.
1313
| ------------------------------- | -------- |
1414
| Apps per account | 10,000 |
1515
| Flags per app | 5,000 |
16-
| Condition nesting depth | 6 levels |
16+
1717
| Flag configuration size per app | 25 MB |
1818

1919
:::note
@@ -22,5 +22,4 @@ The apps-per-account and flags-per-app limits are soft limits. If your use case
2222

2323
## Notes
2424

25-
- Condition nesting depth counts from the top-level condition group. A flat list of conditions (no nesting) has a depth of 1.
2625
- Flag configuration size refers to the total serialized size of all flags within a single app, including their variations and rules.

src/content/docs/flagship/sdk/client-provider.mdx

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,27 @@ sidebar:
55
order: 2
66
---
77

8-
The `FlagshipClientProvider` implements the OpenFeature web provider interface for browser applications. It pre-fetches all flag values on initialization and resolves evaluations synchronously from an in-memory cache.
8+
The `FlagshipClientProvider` implements the OpenFeature web provider interface for browser applications. It pre-fetches a declared set of flag values on initialization and resolves evaluations synchronously from an in-memory cache.
99

1010
This makes the provider suitable for client-side rendering where synchronous access to flag values is required.
1111

1212
:::caution[Important]
1313
The client provider requires an API token to fetch flag values. This token is not scoped to a single app, so anyone with the token can **evaluate flags** across all apps in your account. App-scoped tokens are coming soon. Until then, use the client provider with caution in public-facing applications.
1414
:::
1515

16+
## prefetchFlags
17+
18+
`prefetchFlags` is a required array of flag keys that the provider fetches during initialization and on every context change. Only flags listed in this array are available for synchronous evaluation — any flag key not included returns a `FLAG_NOT_FOUND` error at resolution time.
19+
20+
**Fetch behavior:**
21+
22+
- **On initialization** — all flags in `prefetchFlags` are fetched in parallel and stored in an in-memory cache. The provider transitions to `READY` once all fetches complete (individual failures are non-fatal).
23+
- **On context change** — the cache is invalidated and all flags are re-fetched for the new context. This is required by the [static context paradigm](https://openfeature.dev/specification/glossary/#static-context-paradigm) used by the OpenFeature web SDK, where context is set globally and providers are expected to re-evaluate when it changes.
24+
- **At resolution time** — evaluations are served synchronously from the cache. No network request is made during `getBooleanValue`, `getStringValue`, etc.
25+
1626
## Setup
1727

18-
The following example initializes the provider and evaluates a flag in a browser application.
28+
The following example initializes the provider with a set of pre-fetched flags and evaluates them in a browser application.
1929

2030
```ts
2131
import { OpenFeature } from "@openfeature/web-sdk";
@@ -26,14 +36,18 @@ await OpenFeature.setProviderAndWait(
2636
appId: "your-app-id",
2737
accountId: "your-account-id",
2838
authToken: "your-api-token",
39+
prefetchFlags: ["promo-banner", "dark-mode", "max-uploads"],
2940
}),
3041
);
3142

43+
// Set evaluation context globally. The provider re-fetches all prefetchFlags
44+
// whenever the context changes.
45+
await OpenFeature.setContext({ targetingKey: "user-42", plan: "enterprise" });
46+
3247
const client = OpenFeature.getClient();
3348

34-
const showBanner = client.getBooleanValue("promo-banner", false, {
35-
targetingKey: "user-42",
36-
});
49+
// Synchronous — served from the in-memory cache.
50+
const showBanner = client.getBooleanValue("promo-banner", false);
3751

3852
if (showBanner) {
3953
document.getElementById("banner").style.display = "block";
@@ -46,14 +60,15 @@ if (showBanner) {
4660

4761
## Configuration options
4862

49-
| Option | Type | Required | Description |
50-
| ----------- | -------- | -------- | ----------------------------------------------------------------------------------------------------- |
51-
| `appId` | `string` | Yes | The Flagship app ID from the Cloudflare dashboard. |
52-
| `accountId` | `string` | Yes | Your Cloudflare account ID. |
53-
| `authToken` | `string` | Yes | A Cloudflare [API token](/fundamentals/api/get-started/create-token/) with Flagship read permissions. |
63+
| Option | Type | Required | Description |
64+
| --------------- | ---------- | -------- | ----------------------------------------------------------------------------------------------------- |
65+
| `appId` | `string` | Yes | The Flagship app ID from the Cloudflare dashboard. |
66+
| `accountId` | `string` | Yes | Your Cloudflare account ID. |
67+
| `authToken` | `string` | Yes | A Cloudflare [API token](/fundamentals/api/get-started/create-token/) with Flagship read permissions. |
68+
| `prefetchFlags` | `string[]` | Yes | Flag keys to fetch on initialization and on every context change. Flags not in this list return `FLAG_NOT_FOUND` at evaluation time. |
5469

5570
## When to use the client provider
5671

5772
Use the client provider in browser applications, single-page apps, or any client-side JavaScript environment.
5873

59-
Evaluations are synchronous, so they do not block rendering. Flag values are fetched once during initialization. To refresh flag values, re-initialize the provider.
74+
Evaluations are synchronous, so they do not block rendering. Flag values are fetched once during initialization and re-fetched whenever the evaluation context changes. To force a refresh, update the context via `OpenFeature.setContext(...)`.

src/content/docs/flagship/targeting/index.mdx

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,32 @@ Each condition compares an attribute from the evaluation context against a value
3131

3232
## Logical grouping
3333

34-
Conditions within a rule can be grouped using `AND`/`OR` logical operators. Groups can be nested up to six levels deep for complex targeting logic.
34+
Conditions within a rule are combined with `AND` and `OR` operators. The grouping follows a simple rule: **`OR` starts a new group, `AND` stays in the current group**. Equivalently, `AND` binds tighter than `OR`.
3535

36-
For example, to target enterprise users in the US or Canada:
36+
You can think of the condition list as being split at every `OR` boundary. Each segment between `OR`s forms its own group, and all `AND`s inside that segment belong to the same group. The rule matches when any one group matches entirely.
3737

38-
- `AND`:
39-
- `plan equals "enterprise"`
40-
- `OR`:
41-
- `country equals "US"`
42-
- `country equals "CA"`
38+
For example:
39+
40+
```
41+
IF country IN ["US", "CA"]
42+
AND plan equals "enterprise"
43+
OR email ends_with "cloudflare.com"
44+
OR beta_tester equals true
45+
AND user_age_days > 30
46+
```
47+
48+
This evaluates as:
49+
50+
```
51+
(country IN ["US", "CA"] AND plan equals "enterprise")
52+
OR (email ends_with "cloudflare.com")
53+
OR (beta_tester equals true AND user_age_days > 30)
54+
```
55+
56+
The rule matches users who are either:
57+
- in the US or Canada **and** on the enterprise plan, or
58+
- using a `cloudflare.com` email address, or
59+
- a beta tester **and** have been a user for more than 30 days.
4360

4461
## Learn more
4562

src/content/docs/flagship/targeting/percentage-rollouts.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ Flagship uses consistent hashing on a configurable attribute to assign users to
1717

1818
By default, the bucketing attribute is `targetingKey`. You can configure which attribute to use for bucketing when you set up the rollout in the dashboard.
1919

20+
:::caution[Random assignment without targetingKey]
21+
If `targetingKey` is not present in the evaluation context and no alternative bucketing attribute is configured, Flagship cannot produce a stable hash. In this case the rollout bucket is assigned randomly on each evaluation, meaning the same user may receive different flag values across requests.
22+
23+
Always provide a stable `targetingKey` (or configure a consistent bucketing attribute) to guarantee sticky bucketing.
24+
:::
25+
2026
## Example
2127

2228
Consider a flag `new-checkout` with the following rules:

0 commit comments

Comments
 (0)