Skip to content

Commit

Permalink
Version Packages (#3)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and github-actions[bot] authored Jan 16, 2025
1 parent 2e520b5 commit 10f85c4
Show file tree
Hide file tree
Showing 18 changed files with 114 additions and 84 deletions.
10 changes: 0 additions & 10 deletions .changeset/fifty-points-sin.md

This file was deleted.

46 changes: 0 additions & 46 deletions .changeset/olive-chairs-grab.md

This file was deleted.

16 changes: 0 additions & 16 deletions .changeset/poor-rules-film.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/ten-eagles-build.md

This file was deleted.

7 changes: 7 additions & 0 deletions packages/adapter-happykit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @flags-sdk/happykit

## 0.1.0

### Minor Changes

- 3c66284: initialize
2 changes: 1 addition & 1 deletion packages/adapter-happykit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@flags-sdk/happykit",
"version": "0.0.0",
"version": "0.1.0",
"description": "",
"keywords": [],
"license": "MIT",
Expand Down
7 changes: 7 additions & 0 deletions packages/adapter-hypertune/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @flags-sdk/hypertune

## 0.1.0

### Minor Changes

- 3c66284: initialize
2 changes: 1 addition & 1 deletion packages/adapter-hypertune/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@flags-sdk/hypertune",
"version": "0.0.0",
"version": "0.1.0",
"description": "",
"keywords": [],
"license": "MIT",
Expand Down
7 changes: 7 additions & 0 deletions packages/adapter-launchdarkly/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @flags-sdk/launchdarkly

## 0.1.0

### Minor Changes

- 3c66284: initialize
2 changes: 1 addition & 1 deletion packages/adapter-launchdarkly/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@flags-sdk/launchdarkly",
"version": "0.0.0",
"version": "0.1.0",
"description": "",
"keywords": [],
"license": "MIT",
Expand Down
7 changes: 7 additions & 0 deletions packages/adapter-optimizely/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @flags-sdk/optimizely

## 0.1.0

### Minor Changes

- 3c66284: initialize
2 changes: 1 addition & 1 deletion packages/adapter-optimizely/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@flags-sdk/optimizely",
"version": "0.0.0",
"version": "0.1.0",
"description": "",
"keywords": [],
"license": "MIT",
Expand Down
7 changes: 7 additions & 0 deletions packages/adapter-split/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @flags-sdk/split

## 0.1.0

### Minor Changes

- 3c66284: initialize
2 changes: 1 addition & 1 deletion packages/adapter-split/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@flags-sdk/split",
"version": "0.0.0",
"version": "0.1.0",
"description": "",
"keywords": [],
"license": "MIT",
Expand Down
7 changes: 7 additions & 0 deletions packages/adapter-statsig/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @flags-sdk/statsig

## 0.1.0

### Minor Changes

- 3c66284: initialize
2 changes: 1 addition & 1 deletion packages/adapter-statsig/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@flags-sdk/statsig",
"version": "0.0.0",
"version": "0.1.0",
"description": "",
"keywords": [],
"license": "MIT",
Expand Down
65 changes: 65 additions & 0 deletions packages/flags/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,70 @@
# @vercel/flags

## 3.0.0

### Major Changes

- db89f0d: - **BREAKING CHANGE** removed all `unstable_` prefixes, e.g. `unstable_flag` is now `flag`

- **BREAKING CHANGE** removed `getPrecomputationContext`, use `dedupe` instead (see below)
- **BREAKING CHANGE** moved all provider functions to dedicated packages
- `@vercel/flags/providers/launchdarkly``@flags-sdk/launchdarkly`
- `@vercel/flags/providers/statsig``@flags-sdk/statsig`
- `@vercel/flags/providers/split``@flags-sdk/split`
- `@vercel/flags/providers/hypertune``@flags-sdk/hypertune`
- `@vercel/flags/providers/optimizely``@flags-sdk/optimizely`
- `@vercel/flags/providers/happykit``@flags-sdk/happykit`
- **BREAKING CHANGE** changed `.run({})` behavior

See [flags-sdk.com](https://flags-sdk.com/) for the latest APIs.

- db89f0d: remove unstable\_ prefixes

### Minor Changes

- db89f0d: **@vercel/flags/next: Added a `dedupe` function**

`dedupe` is a middleware-friendly version of `React.cache`. It allows ensuring a function only ever runs once per request.

```ts
import { dedupe } from '@vercel/flags/next';

let i = 0;
const runOnce = dedupe(async () => {
return i++;
});

await runOnce(); // returns 0
await runOnce(); // still returns 0
```

This function is useful when you want to deduplicate work within each feature flag's `decide` function. For example if multiple flags need to check auth you can dedupe the auth function so it only runs once per request.

`dedupe` is also useful to optimistically generate a random visitor id to be set in a cookie, while also allowing each feature flag to access the id. You can call a dedupe'd function to generate the random id within your Edge Middleware and also within your feature flag's `decide` functions. The function will return a consistent id.

```ts
import { nanoid } from 'nanoid';
import { cookies, headers } from 'next/headers';
import { dedupe } from '@vercel/flags/next';

/**
* Reads the visitor id from a cookie or returns a new visitor id
*/
export const getOrGenerateVisitorId = dedupe(
async (): Promise<{ value: string; fresh: boolean }> => {
const visitorIdCookie = (await cookies()).get('visitor-id')?.value;

return visitorIdCookie
? { value: visitorIdCookie, fresh: false }
: { value: nanoid(), fresh: true };
},
);
```

> Note: "once per request" is an imprecise description. A `dedupe`d function actually runs once per request, per compute instance. If a dedupe'd function is used in Edge Middleware and in a React Server Component it will run twice, as there are two separate compute instances handling this request.
> Note: This function acts as a sort of polyfill until similar functionality lands in Next.js directly.
## 2.7.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/flags/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vercel/flags",
"version": "2.7.0",
"version": "3.0.0",
"description": "Make the Vercel Toolbar aware of your feature flags and read overrides set by it",
"keywords": [
"feature flags",
Expand Down

0 comments on commit 10f85c4

Please sign in to comment.