KO
베타 번역

@core / experiments

1.0.2 ▾
인증됨MIT
GitHub

동의 기반 A/B 테스트: 안정적 배정, 전환 목표, 유의성 포함 결과

코드파일 8개컨텍스트약 601토큰검사 통과

설치

$genpm add @core/experiments

포함 내용

  • src/lib/experiments/에 소스 코드, 파일 8개. (21.4kB)
  • src/lib/experiments/AGENTS.md에 AI 규칙, 그리고 IDE 규칙 파일.
  • .env.example에 추가되는 환경 변수: EXPERIMENTS_SECRET.
  • @core/consent, @core/contracts, @core/db, @core/jobs을(를) 자동으로 해결합니다.

README

@core/experiments

genpm license

A/B tests with consent: stable assignment, conversion goals and results with significance, no extra cookies

A GenPM module: source code + AI rules + MCP config, injected into your project instead of hidden in node_modules. The code lands in src/lib/experiments, pinned to a verified commit, and you own it.

Install

genpm add @core/experiments

No genpm yet? curl -fsSL https://genpm.net/install.sh | sh (macOS/Linux), irm https://genpm.net/install.ps1 | iex (Windows), or one-off with npx @genpm-net/cli add @core/experiments.

Or let your AI agent do it: run genpm mcp setup once, then ask "add @core/experiments with genpm" in Claude Code, Cursor, VS Code, Windsurf, Codex or Gemini CLI. It shows you a dry-run plan before writing anything.

What it does

A/B tests that respect consent. Visitors who accepted analytics cookies get a stable variant (deterministic hash of the pseudonymous consent id, no extra cookie); everyone else always sees the control and nothing is stored. Conversions are recorded once per visitor and goal; results show rates, lift, p-value and a 95 % confidence interval (two-proportion z-test) and are frozen when the experiment stops. Tables: experiments, experiment_participants.

Setup

After genpm add, follow these steps (your AI agent finds the same steps in src/lib/experiments/AGENTS.md and can do them for you):

  1. Requires @core/consent (the banner) and its cookie. Env: EXPERIMENTS_SECRET (≥ 32 random chars).
  2. Migrations as in src/lib/db/AGENTS.md. Add experimentsAdminResource to src/genpm/admin.ts (with kit-landing: its "A/B tests (optional)" lines).
  3. Create the experiment in the admin (key, goal, variants: the first is the control), then press "Start".
  4. Render: const { variant } = await getVariant('hero-test', cookieHeader) (cookie header of the request) and show the matching content; or <Experiment name="hero-test" cookieHeader={…} variants={{ a: <A />, b: <B /> }} />.
  5. Conversion: where the goal happens on the server, await recordConversion('lead', req.headers.get('cookie')).
  6. Schedule experiments.prune daily (@core/jobs schedule) to delete participants 30 days after an experiment stops (with kit-cms, its setup-schedules.ts does it).
  7. Verify: with analytics accepted the same browser always sees the same variant; with cookies rejected, always the control.

What's inside

Paths are relative to src/lib/experiments.

  • index.ts — getVariant, recordConversion, upsertExperiment, setExperimentStatus, experimentResults, experimentsAdminResource, pruneExperimentsJob, compare.
  • react.ts — <Experiment name cookieHeader variants={{ a, b }} /> (server component).
  • stats.ts — statistics without dependencies. schema.ts — tables.

At a glance

  • GenPM dependencies (installed with it): @core/db, @core/consent, @core/contracts, @core/jobs
  • npm dependencies (proposed, never installed without asking): zod, react
  • Environment variables (added to .env.example): EXPERIMENTS_SECRET
  • AI rules: AGENTS.md, loaded by your agent only when it works in src/lib/experiments

Security

GenPM installs a 40-character commit SHA (never a branch), verifies an Ed25519-signed manifest, never runs install scripts and scans AI rules for prompt injection. Details: genpm.net/docs/security.

License

MIT — see LICENSE. Browse the full catalog at genpm.net.

@core/experiments 신고

패키지를 신고하려면 GitHub로 로그인하세요.