|
1 | 1 | # @vercel/flags
|
2 | 2 |
|
| 3 | +## 3.1.0 |
| 4 | + |
| 5 | +### Minor Changes |
| 6 | + |
| 7 | +- 76feb16: Add `mergeProviderData` function to `@vercel/flags`. |
| 8 | + |
| 9 | + This function allows merging ProviderData from multiple sources. |
| 10 | + |
| 11 | + This is handy when you declare feature flags in code, and want to extend those definitions with data loaded from your feature flag provider. |
| 12 | + |
| 13 | + ```ts |
| 14 | + import { verifyAccess, mergeProviderData, type ApiData } from '@vercel/flags'; |
| 15 | + import { getProviderData } from '@vercel/flags/next'; |
| 16 | + import { NextResponse, type NextRequest } from 'next/server'; |
| 17 | + import { getProviderData as getStatsigProviderData } from '@flags-sdk/statsig'; |
| 18 | + import * as flagsA from '../../../../flags-a'; // your feature flags file(s) |
| 19 | + import * as flagsB from '../../../../flags-b'; // your feature flags file(s) |
| 20 | + |
| 21 | + export async function GET(request: NextRequest) { |
| 22 | + const access = await verifyAccess(request.headers.get('Authorization')); |
| 23 | + if (!access) return NextResponse.json(null, { status: 401 }); |
| 24 | + |
| 25 | + const providerData = await mergeProviderData([ |
| 26 | + // expose flags declared in code first |
| 27 | + getProviderData({ ...flagsA, ...flagsB }), |
| 28 | + // then enhance them with metadata from your flag provider |
| 29 | + getStatsigProviderData({ consoleApiKey: '', projectId: '' }), |
| 30 | + ]); |
| 31 | + |
| 32 | + return NextResponse.json<ApiData>(providerData); |
| 33 | + } |
| 34 | + ``` |
| 35 | + |
| 36 | +### Patch Changes |
| 37 | + |
| 38 | +- 2713ea7: Handle `undefined` values |
| 39 | + |
| 40 | + - fix: Fall back to `defaultValue` when a feature flag returns `undefined` |
| 41 | + - fix: Throw error when a flag resolves to `undefined` and no `defaultValue` is present |
| 42 | + |
| 43 | + The value `undefined` can not be serialized so feature flags should never resolve to `undefined`. Use `null` instead. |
| 44 | + |
| 45 | + Fix exports |
| 46 | + |
| 47 | + - fix: Export `Identify` and `Decide` types |
| 48 | + |
3 | 49 | ## 3.0.2
|
4 | 50 |
|
5 | 51 | ### Patch Changes
|
|
0 commit comments