Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .changeset/rename-global-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
'@flags-sdk/global-config': minor
'@flags-sdk/growthbook': major
'@flags-sdk/hypertune': patch
'@flags-sdk/launchdarkly': major
'@flags-sdk/posthog': patch
'@flags-sdk/reflag': patch
'@flags-sdk/statsig': major
'flags': major
---

Replace `@vercel/edge-config` with `@vercel/global-config`.

Rename the Edge Config adapter package to `@flags-sdk/global-config` and rename repository-owned Edge Config files, exports, types, options, variables, and environment variables to Global Config.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
env:
NPM_CONFIG_PROVENANCE: "true"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
EDGE_CONFIG: ${{ secrets.EDGE_CONFIG }}
GLOBAL_CONFIG: ${{ secrets.GLOBAL_CONFIG }}
FLAGS_SECRET: ${{ secrets.FLAGS_SECRET }}
FLAGS: ${{ secrets.FLAGS }}
HAPPYKIT_API_TOKEN: ${{ secrets.HAPPYKIT_API_TOKEN }}
Expand Down Expand Up @@ -123,7 +123,7 @@ jobs:
- name: Build
run: pnpm turbo build --filter='./packages/*'
env:
EDGE_CONFIG: ${{ secrets.EDGE_CONFIG }}
GLOBAL_CONFIG: ${{ secrets.GLOBAL_CONFIG }}
FLAGS_SECRET: ${{ secrets.FLAGS_SECRET }}
FLAGS: ${{ secrets.FLAGS }}
HAPPYKIT_API_TOKEN: ${{ secrets.HAPPYKIT_API_TOKEN }}
Expand Down
12 changes: 6 additions & 6 deletions apps/docs/components/custom/provider-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const providers: Provider[] = [
name: 'Vercel',
href: '/providers/vercel',
logo: VercelLogo,
badges: ['Adapter', 'Edge Config', 'Flags Explorer'],
badges: ['Adapter', 'Global Config', 'Flags Explorer'],
glowColor: '#000000',
skipInvert: true,
},
Expand All @@ -53,31 +53,31 @@ const providers: Provider[] = [
name: 'Statsig',
href: '/providers/statsig',
logo: StatsigLogo,
badges: ['Adapter', 'Edge Config', 'Flags Explorer', 'Marketplace'],
badges: ['Adapter', 'Global Config', 'Flags Explorer', 'Marketplace'],
glowColor: '#1b63d2',
},
{
key: 'hypertune',
name: 'Hypertune',
href: '/providers/hypertune',
logo: HypertuneLogo,
badges: ['Adapter', 'Edge Config', 'Flags Explorer', 'Marketplace'],
badges: ['Adapter', 'Global Config', 'Flags Explorer', 'Marketplace'],
glowColor: '#000000',
},
{
key: 'launchdarkly',
name: 'LaunchDarkly',
href: '/providers/launchdarkly',
logo: LaunchDarklyLogo,
badges: ['Adapter', 'Edge Config', 'Flags Explorer'],
badges: ['Adapter', 'Global Config', 'Flags Explorer'],
glowColor: '#7084ff',
},
{
key: 'growthbook',
name: 'GrowthBook',
href: '/providers/growthbook',
logo: GrowthbookLogo,
badges: ['Adapter', 'Edge Config', 'Flags Explorer', 'Marketplace'],
badges: ['Adapter', 'Global Config', 'Flags Explorer', 'Marketplace'],
glowColor: '#7B51FB',
},
{
Expand Down Expand Up @@ -127,7 +127,7 @@ const providers: Provider[] = [
// name: 'Split',
// href: '/providers/split',
// logo: SplitLogo,
// badges: ['Edge Config', 'Flags Explorer'],
// badges: ['Global Config', 'Flags Explorer'],
// glowColor: '#ff00d2',
// },
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const dashboardFlag = flag<boolean, Entities>({
identify,
decide({ entities }) {
if (!entities?.user) return false;
// Allowed users could be loaded from Edge Config or elsewhere
// Allowed users could be loaded from Global Config or elsewhere
const allowedUsers = ['user1'];

return allowedUsers.includes(entities.user.id);
Expand Down
10 changes: 5 additions & 5 deletions apps/docs/content/docs/principles/data-locality.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ applications need to pay the latency cost of bootstrapping feature flags
more frequently. Having multiple websocket connections to the same flag
provider also increases load on the provider.

## Vercel Edge Config
## Vercel Global Config

Vercel offers a solution called Edge Config to this problem. It is
specifically designed for storing feature flag definitions. Edge Config
Vercel offers a solution called Global Config to this problem. It is
specifically designed for storing feature flag definitions. Global Config
can be read in under 1ms at p90 and under 15ms at p95, including the
network latency from your Serverless Function or Routing Middleware.

To put this into perspective, [according to this benchmark](https://github.com/dvassallo/s3-benchmark), an AWS S3 bucket does not even send the first byte by the time an Edge
Config is fully read.

Using Edge Config is optional, but highly recommended, when using the
Using Global Config is optional, but highly recommended, when using the
Flags SDK.

## Evaluating on the server
Expand All @@ -79,7 +79,7 @@ request to establish the evaluation context.
To evaluate feature flags at the edge, you need the definition and the
evaluation context available at the edge.

Using Edge Config allows storing definitions at the Edge as shown in the
Using Global Config allows storing definitions at the Edge as shown in the
previous section. This means you can use feature flags in Routing
Functions at ultra low latency.

Expand Down
22 changes: 11 additions & 11 deletions apps/docs/content/docs/providers/custom-adapters.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Creating custom adapters is possible by creating an adapter factory:

```ts title="example-adapter.ts"
import type { Adapter } from "flags";
import { createClient, EdgeConfigClient } from "@vercel/edge-config";
import { createClient, GlobalConfigClient } from "@vercel/global-config";

/**
* A factory function for your adapter
Expand Down Expand Up @@ -108,7 +108,7 @@ return {

## Example

Below is an example of an Flags SDK adapter reading Edge Config.
Below is an example of an Flags SDK adapter reading Global Config.

<IframeBrowser
src="snippets:/concepts/adapters"
Expand Down Expand Up @@ -141,27 +141,27 @@ initialize itself based on known environment variables.

```ts title="example-adapter.ts"
// extend the adapter definition to expose a default adapter
let defaultEdgeConfigAdapter:
| ReturnType<typeof createEdgeConfigAdapter>
let defaultGlobalConfigAdapter:
| ReturnType<typeof createGlobalConfigAdapter>
| undefined;

/**
* A default Vercel adapter for Edge Config
* A default Vercel adapter for Global Config
*
*/
export function edgeConfigAdapter<ValueType, EntitiesType>(): Adapter<
export function globalConfigAdapter<ValueType, EntitiesType>(): Adapter<
ValueType,
EntitiesType
> {
// Initialized lazily to avoid warning when it is not actually used and env vars are missing.
if (!defaultEdgeConfigAdapter) {
if (!process.env.EDGE_CONFIG) {
throw new Error("Edge Config Adapter: Missing EDGE_CONFIG env var");
if (!defaultGlobalConfigAdapter) {
if (!process.env.GLOBAL_CONFIG) {
throw new Error("Global Config Adapter: Missing GLOBAL_CONFIG env var");
}

defaultEdgeConfigAdapter = createEdgeConfigAdapter(process.env.EDGE_CONFIG);
defaultGlobalConfigAdapter = createGlobalConfigAdapter(process.env.GLOBAL_CONFIG);
}

return defaultEdgeConfigAdapter<ValueType, EntitiesType>();
return defaultGlobalConfigAdapter<ValueType, EntitiesType>();
}
```
108 changes: 0 additions & 108 deletions apps/docs/content/docs/providers/edge-config.mdx

This file was deleted.

108 changes: 108 additions & 0 deletions apps/docs/content/docs/providers/global-config.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
title: 'Global Config'
---

The `@flags-sdk/global-config` package provides a basic adapter for defining feature flags powered by [Vercel Global Config](https://vercel.com/docs/storage/global-config)

<LearnMore
icon="arrow"
href="/providers"
>
Learn more about Adapters
</LearnMore>

## Installation

Follow the [Quickstart](/docs/getting-started/next), then add the [Global Config adapter](https://github.com/vercel/flags/tree/main/packages/adapter-global-config).

Install desired dependencies

```sh
pnpm i @flags-sdk/global-config
```

Set relevant variables

```sh title=".env.local"
GLOBAL_CONFIG="global-config-connection-string"
```

## Usage

```ts title="flags.ts#next"
import { flag } from 'flags/next';
import { globalConfigAdapter } from '@flags-sdk/global-config';

export const exampleFlag = flag({
// Will load the `flags` key from Global Config
adapter: globalConfigAdapter,
// Will get the `example-flag` key from the `flags` object
key: 'example-flag',
});
```

Your Global Config should be [managed on the dashboard](https://vercel.com/docs/storage/global-config/global-config-dashboard) as follows:

```json
{
// `flags` is the default used by the Global Config adapter
"flags": {
// Flags using the adapter should have their `key` defined here
"example-flag": true,
"another-example-flag": false,
}
}
```

## API reference

### globalConfigAdapter

The adapter assumes that there is an `GLOBAL_CONFIG` environment variable set with a connection string,
and that it contains a `flags` object with each key corresponding to a flag you define in code.

```ts title="flags.ts#next"
import { globalConfigAdapter } from '@flags-sdk/global-config';

export const exampleFlag = flag({
adapter: globalConfigAdapter,
key: 'example-flag',
});
```

### createGlobalConfigAdapter

To customize these options you can import and call `createGlobalConfigAdapter` manually.

| Option key | Type | Description |
| ----------- | -------- | ----------------------- |
| `connectionString` | `string | GlobalConfigClient` | A [connection string](https://vercel.com/docs/storage/global-config/using-global-config#using-a-connection-string) or a [client instance](https://vercel.com/docs/storage/global-config/global-config-sdk#use-connection-strings) |
| `options.globalConfigItemKey` | `string` | Defaults to `flags` |
| `options.teamSlug` | `string` | The team slug used for your team in the Vercel dashboard, used to create links to your Global Config |

```ts title="flags.ts#next"
import { createGlobalConfigAdapter } from '@flags-sdk/global-config';

const myGlobalConfigAdapter = createGlobalConfigAdapter({
connectionString: process.env.OTHER_GLOBAL_CONFIG_CONNECTION_STRING,
options: {
globalConfigItemKey: 'other-flags-key',
teamSlug: 'my-vercel-team-slug',
},
});

export const exampleFlag = flag({
adapter: myGlobalConfigAdapter,
key: 'example-flag',
});
```

## Read more

Read more about Global Config, Flags SDK, and the Global Config adapter.

- [Concepts: Precompute](/principles/precompute)
- [Global Config Docs](https://vercel.com/docs/storage/global-config)
- [Global Config SDK Reference](https://vercel.com/docs/storage/global-config/global-config-sdk)
- [Global Config Examples](https://vercel.com/templates/global-config)
- [Global Config Limits and Pricing](https://vercel.com/docs/storage/global-config/global-config-limits)
Loading
Loading