Skip to content

Conversation

@renovate
Copy link
Contributor

@renovate renovate bot commented Jan 16, 2025

This PR contains the following updates:

Package Change Age Confidence
@vercel/flags (source) ^2.6.3^3.0.0 age confidence

Release Notes

vercel/flags (@​vercel/flags)

v3.1.1

Compare Source

Patch Changes
  • 6955b68: emit reduced console info when falling back to defaultValue during development
  • cf532da: Update package.json and tsup.config.js for flags package

v3.1.0

Compare Source

Minor Changes
  • 76feb16: Add mergeProviderData function to @vercel/flags.

    This function allows merging ProviderData from multiple sources.

    This is handy when you declare feature flags in code, and want to extend those definitions with data loaded from your feature flag provider.

    import { verifyAccess, mergeProviderData, type ApiData } from '@​vercel/flags';
    import { getProviderData } from '@​vercel/flags/next';
    import { NextResponse, type NextRequest } from 'next/server';
    import { getProviderData as getStatsigProviderData } from '@​flags-sdk/statsig';
    import * as flagsA from '../../../../flags-a'; // your feature flags file(s)
    import * as flagsB from '../../../../flags-b'; // your feature flags file(s)
    
    export async function GET(request: NextRequest) {
      const access = await verifyAccess(request.headers.get('Authorization'));
      if (!access) return NextResponse.json(null, { status: 401 });
    
      const providerData = await mergeProviderData([
        // expose flags declared in code first
        getProviderData({ ...flagsA, ...flagsB }),
        // then enhance them with metadata from your flag provider
        getStatsigProviderData({ consoleApiKey: '', projectId: '' }),
      ]);
    
      return NextResponse.json<ApiData>(providerData);
    }
Patch Changes
  • 2713ea7: Handle undefined values

    • fix: Fall back to defaultValue when a feature flag returns undefined
    • fix: Throw error when a flag resolves to undefined and no defaultValue is present

    The value undefined can not be serialized so feature flags should never resolve to undefined. Use null instead.

    Fix exports

    • fix: Export Identify and Decide types

v3.0.2

Compare Source

Patch Changes
  • 708d5e2: generatePermutations: infer options of boolean flags

v3.0.1

Compare Source

Patch Changes
  • 7e21d4f: add metadata to package.json

v3.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 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.

    import { dedupe } from '@&#8203;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.

    import { nanoid } from 'nanoid';
    import { cookies, headers } from 'next/headers';
    import { dedupe } from '@&#8203;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 deduped 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.


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@vercel
Copy link

vercel bot commented Jan 16, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
website Error Error Jan 19, 2026 4:49pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants