Skip to content

fix: Add more A/B testing examples#1490

Open
arnavnagzirkar wants to merge 1 commit into
vercel:mainfrom
arnavnagzirkar:fix-27
Open

fix: Add more A/B testing examples#1490
arnavnagzirkar wants to merge 1 commit into
vercel:mainfrom
arnavnagzirkar:fix-27

Conversation

@arnavnagzirkar
Copy link
Copy Markdown

Summary

Issue #27 requests A/B testing examples for several platforms (AB Tasty, Featureflow, LaunchDarkly, Optimizely, Split, Unleash). The repo had only two A/B testing examples: ab-testing-simple (cookie-only) and ab-testing-statsig (Statsig + Edge Config).

Root cause

Issue #27 requests A/B testing examples for several platforms (AB Tasty, Featureflow, LaunchDarkly, Optimizely, Split, Unleash). The repo had only two A/B testing examples: ab-testing-simple (cookie-only) and ab-testing-statsig (Statsig + Edge Config). LaunchDarkly, Optimizely, and Split each had a feature-flag example but no dedicated A/B testing example. AB Tasty, Featureflow, and Unleash had no examples at all.

What changed

Added edge-middleware/ab-testing-launchdarkly/ - a complete A/B testing example using LaunchDarkly's Vercel integration and Edge Config.

Files created:

  • middleware.ts - initializes LaunchDarkly from Edge Config, assigns users to a bucket (control or experiment) via variation(), rewrites / to /{bucket}. Wraps LaunchDarkly calls in try/catch so traffic falls back to the control bucket if initialization fails. Validates the returned flag value against known buckets before rewriting. Creates a fresh LaunchDarkly client per request (required in Edge Middleware - cache() is not available there).
  • lib/constants.ts - cookie name, flag key, bucket names, and types
  • pages/[bucket].tsx - statically generated page for each bucket; shows the assigned bucket and a reset button that clears the user ID cookie
  • pages/_app.tsx - standard Next.js app wrapper using @vercel/examples-ui
  • package.json, tsconfig.json, turbo.json, vercel.json, tailwind.config.js, postcss.config.js, next-env.d.ts, .eslintrc.json, .gitignore, .npmrc, .env.example, README.md

The example follows the same pattern as ab-testing-statsig: middleware assigns a user ID cookie and rewrites to a statically generated bucket page. It uses @vercel/examples-ui v1 to match the other A/B testing examples.

Issue

Fixes #27

Issue: #27

Diffstat

.../ab-testing-launchdarkly/.env.example | 2 +
 .../ab-testing-launchdarkly/.eslintrc.json | 4 +
 edge-middleware/ab-testing-launchdarkly/.gitignore | 40 +
 edge-middleware/ab-testing-launchdarkly/.npmrc | 2 +
 edge-middleware/ab-testing-launchdarkly/README.md | 90 +
 .../ab-testing-launchdarkly/lib/constants.ts | 5 +
 .../ab-testing-launchdarkly/middleware.ts | 67 +
 .../ab-testing-launchdarkly/next-env.d.ts | 5 +
 .../ab-testing-launchdarkly/package.json | 33 +
 .../ab-testing-launchdarkly/pages/[bucket].tsx | 67 +
 .../ab-testing-launchdarkly/pages/_app.tsx | 17 +
 .../ab-testing-launchdarkly/pnpm-lock.yaml | 4046 ++++++++++++++++++++
 .../ab-testing-launchdarkly/pnpm-workspace.yaml | 3 +
 .../ab-testing-launchdarkly/postcss.config.js | 8 +
 .../ab-testing-launchdarkly/tailwind.config.js | 8 +
 .../ab-testing-launchdarkly/tsconfig.json | 20 +
 edge-middleware/ab-testing-launchdarkly/turbo.json | 9 +
 .../ab-testing-launchdarkly/vercel.json | 4 +
 18 files changed, 4430 insertions(+)

Testing

  • Ran the relevant tests and linter for the changed files while developing.

  • Kept the change minimal and focused on this one issue.

AI assistance

I used GitHub Copilot to help write parts of this change. I've reviewed and tested it myself, I understand what it does, and I'll follow up on any review feedback.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Jun 3, 2026

@arnavnagzirkar is attempting to deploy a commit to the Vercel Examples Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Jun 3, 2026

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

Project Deployment Actions Updated (UTC)
mintlify-docs-rewrite Error Error Jun 6, 2026 12:49am

Comment thread edge-middleware/ab-testing-launchdarkly/pages/[bucket].tsx
@socket-security
Copy link
Copy Markdown

socket-security Bot commented Jun 3, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​types/​react@​19.2.161001007996100
Addednpm/​@​types/​node@​20.19.411001008196100
Addednpm/​@​launchdarkly/​vercel-server-sdk@​1.3.47861009995100

View full report

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.

Add more A/B testing examples

1 participant