@vllnt/convex-experiments 0.1.0-canary.f2cd1ba → 0.1.1-canary.b4e25b0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +150 -36
  2. package/dist/client/index.d.ts +54 -3
  3. package/dist/client/index.d.ts.map +1 -1
  4. package/dist/client/index.js +53 -4
  5. package/dist/client/index.js.map +1 -1
  6. package/dist/client/types.d.ts +8 -3
  7. package/dist/client/types.d.ts.map +1 -1
  8. package/dist/component/_generated/component.d.ts +35 -0
  9. package/dist/component/_generated/component.d.ts.map +1 -1
  10. package/dist/component/_generated/server.d.ts +12 -0
  11. package/dist/component/_generated/server.d.ts.map +1 -1
  12. package/dist/component/_generated/server.js +2 -0
  13. package/dist/component/_generated/server.js.map +1 -1
  14. package/dist/component/convex.config.d.ts.map +1 -1
  15. package/dist/component/mutations.d.ts +47 -20
  16. package/dist/component/mutations.d.ts.map +1 -1
  17. package/dist/component/mutations.js +220 -26
  18. package/dist/component/mutations.js.map +1 -1
  19. package/dist/component/queries.d.ts +41 -8
  20. package/dist/component/queries.d.ts.map +1 -1
  21. package/dist/component/queries.js +82 -20
  22. package/dist/component/queries.js.map +1 -1
  23. package/dist/component/schema.d.ts +39 -17
  24. package/dist/component/schema.d.ts.map +1 -1
  25. package/dist/component/schema.js +20 -5
  26. package/dist/component/schema.js.map +1 -1
  27. package/dist/component/validators.d.ts +31 -18
  28. package/dist/component/validators.d.ts.map +1 -1
  29. package/dist/component/validators.js +14 -3
  30. package/dist/component/validators.js.map +1 -1
  31. package/dist/react/index.d.ts +57 -0
  32. package/dist/react/index.d.ts.map +1 -0
  33. package/dist/react/index.js +39 -0
  34. package/dist/react/index.js.map +1 -0
  35. package/dist/shared.d.ts +5 -3
  36. package/dist/shared.d.ts.map +1 -1
  37. package/dist/shared.js +5 -3
  38. package/dist/shared.js.map +1 -1
  39. package/package.json +50 -20
  40. package/src/client/index.ts +98 -4
  41. package/src/client/types.ts +8 -3
  42. package/src/component/_generated/component.ts +42 -1
  43. package/src/component/_generated/server.ts +13 -0
  44. package/src/component/mutations.ts +250 -28
  45. package/src/component/queries.ts +97 -20
  46. package/src/component/schema.ts +21 -5
  47. package/src/component/validators.ts +14 -3
  48. package/src/react/index.tsx +68 -0
  49. package/src/shared.ts +6 -3
  50. package/src/test.ts +2 -1
  51. package/src/unit.test.ts +0 -84
package/dist/shared.js CHANGED
@@ -4,6 +4,8 @@ export const COMPONENT_NAME = "experiments";
4
4
  export const DEFAULT_SCOPE = "global";
5
5
  /** Lifecycle status the client applies to `define` when the caller omits one. */
6
6
  export const DEFAULT_STATUS = "running";
7
+ /** Default page size for a `deleteExperiment` cascade pass before it self-reschedules. */
8
+ export const DEFAULT_DELETE_BATCH = 200;
7
9
  /**
8
10
  * FNV-1a 32-bit hash of `input`, returned as an unsigned integer. Deterministic,
9
11
  * synchronous, and dependency-free — the component runs in a V8 isolate, so a
@@ -22,9 +24,9 @@ export function fnv1a(input) {
22
24
  * Deterministically pick a variant for `subjectRef` from `variants`, weighted by
23
25
  * each variant's `weight`. The same `(salt, subjectRef)` always maps to the same
24
26
  * variant — sticky assignment with no storage — and the distribution matches the
25
- * weights. `salt` lets a host re-randomize an experiment (a fresh re-run) without
26
- * changing subject ids. Assumes a non-empty `variants` with positive weights; the
27
- * caller validates that upstream.
27
+ * weights. The component folds `scope` into the salt so the same subject buckets
28
+ * independently per scope. Assumes a non-empty `variants` with positive weights;
29
+ * the caller validates that upstream.
28
30
  */
29
31
  export function pickVariant(variants, salt, subjectRef) {
30
32
  const lastVariant = variants[variants.length - 1];
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAEhG,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC;AAE5C,oEAAoE;AACpE,MAAM,CAAC,MAAM,aAAa,GAAG,QAAQ,CAAC;AAEtC,iFAAiF;AAC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I,IAAI,UAAU,EAAE,CAAC,GAAG,WAAW,CAAC,GAAG,KAAK,CAAC;IACpE,iEAAiE;IACjE,KAAK,MAAM,OAAO,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;QACzB,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;YACf,OAAO,OAAO,CAAC,GAAG,CAAC;QACrB,CAAC;IACH,CAAC;IACD,+EAA+E;IAC/E,OAAO,WAAW,CAAC,GAAG,CAAC;AACzB,CAAC"}
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@vllnt/convex-experiments",
3
- "version": "0.1.0-canary.f2cd1ba",
3
+ "version": "0.1.1-canary.b4e25b0",
4
4
  "description": "Deterministic A/B experimentation — sticky variant assignment and deduped exposure tracking, as a Convex component",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "packageManager": "pnpm@9.15.4",
7
+ "packageManager": "pnpm@10.34.8",
8
8
  "files": [
9
9
  "dist",
10
- "src"
10
+ "src",
11
+ "!src/**/*.test.*"
11
12
  ],
12
13
  "exports": {
13
14
  "./package.json": "./package.json",
@@ -15,6 +16,10 @@
15
16
  "types": "./dist/client/index.d.ts",
16
17
  "default": "./dist/client/index.js"
17
18
  },
19
+ "./react": {
20
+ "types": "./dist/react/index.d.ts",
21
+ "default": "./dist/react/index.js"
22
+ },
18
23
  "./test": "./src/test.ts",
19
24
  "./_generated/component.js": {
20
25
  "types": "./dist/component/_generated/component.d.ts"
@@ -35,35 +40,47 @@
35
40
  "module": "./dist/client/index.js",
36
41
  "scripts": {
37
42
  "build": "tsc --project ./tsconfig.build.json",
38
- "build:codegen": "pnpm convex codegen --component-dir ./src/component && pnpm build",
43
+ "build:codegen": "pnpm codegen && pnpm build",
39
44
  "build:clean": "rm -rf dist *.tsbuildinfo && pnpm build:codegen",
40
45
  "typecheck": "tsc --noEmit",
41
46
  "typecheck:ci": "tsc --noEmit --project tsconfig.ci.json",
42
- "lint": "eslint .",
47
+ "lint": "pnpm check:agents && eslint .",
43
48
  "test": "vitest run --passWithNoTests",
44
49
  "test:watch": "vitest --typecheck --clearScreen false",
45
50
  "test:coverage": "vitest run --coverage --coverage.reporter=text",
46
51
  "generate:llms": "node scripts/generate-llms.mjs",
47
52
  "preversion": "pnpm install --frozen-lockfile && pnpm build && pnpm test:coverage && pnpm typecheck && pnpm generate:llms",
48
- "prepublishOnly": "npm whoami || npm login",
49
- "alpha": "npm version prerelease --preid alpha && npm publish --tag alpha && git push --follow-tags",
50
- "release": "npm version patch && npm publish && git push --follow-tags"
53
+ "check:agents": "node -e \"const f=require('node:fs');if(!f.existsSync('AGENTS.md')||f.existsSync('CLAUDE.md')||f.existsSync('.claude'))process.exit(1)\"",
54
+ "codegen": "pnpm convex codegen --component-dir ./src/component"
51
55
  },
52
- "dependencies": {},
53
56
  "peerDependencies": {
54
- "convex": "^1.41.0"
57
+ "convex": "^1.45.0",
58
+ "react": ">=18"
59
+ },
60
+ "peerDependenciesMeta": {
61
+ "react": {
62
+ "optional": true
63
+ }
55
64
  },
56
65
  "devDependencies": {
57
66
  "@edge-runtime/vm": "^5.0.0",
58
- "@vitest/coverage-v8": "^4.1.8",
59
- "@vllnt/eslint-config": "^1.0.0",
60
- "@vllnt/typescript": "^1.0.0",
61
- "convex": "^1.41.0",
62
- "convex-test": "^0.0.53",
63
- "eslint": "^9.0.0",
64
- "prettier": "^3.4.0",
65
- "typescript": "^5.7.0",
66
- "vitest": "^4.1.8"
67
+ "@testing-library/react": "^16.3.3",
68
+ "@types/react": "^19.3.0",
69
+ "@types/react-dom": "^19.3.0",
70
+ "@typescript/native": "npm:typescript@7.0.2",
71
+ "@vitest/coverage-v8": "^5.0.5",
72
+ "@vllnt/eslint-config": "2.0.0",
73
+ "@vllnt/typescript": "2.0.0",
74
+ "convex": "^1.48.0",
75
+ "convex-test": "^0.0.65",
76
+ "eslint": "^9.39.5",
77
+ "jsdom": "^30.1.3",
78
+ "prettier": "^3.9.10",
79
+ "react": "^19.3.1",
80
+ "react-dom": "^19.3.1",
81
+ "typescript": "npm:@typescript/typescript6@^6.0.2",
82
+ "vite": "^8.3.5",
83
+ "vitest": "^5.0.5"
67
84
  },
68
85
  "homepage": "https://github.com/vllnt/convex-experiments#readme",
69
86
  "bugs": {
@@ -95,5 +112,18 @@
95
112
  "ab-testing",
96
113
  "split-testing",
97
114
  "feature-experimentation"
98
- ]
115
+ ],
116
+ "pnpm": {
117
+ "minimumReleaseAge": 10080,
118
+ "minimumReleaseAgeExclude": [
119
+ "@vllnt/*"
120
+ ],
121
+ "ignoredBuiltDependencies": [
122
+ "esbuild"
123
+ ],
124
+ "overrides": {
125
+ "handlebars@<4.7.10": "^4.7.10",
126
+ "deepmerge-ts@<8.0.0": "^8.0.2"
127
+ }
128
+ }
99
129
  }
@@ -14,7 +14,7 @@ import type {
14
14
  Variant,
15
15
  VariantResult,
16
16
  } from "./types.js";
17
- import { DEFAULT_SCOPE, DEFAULT_STATUS } from "../shared.js";
17
+ import { DEFAULT_DELETE_BATCH, DEFAULT_SCOPE, DEFAULT_STATUS } from "../shared.js";
18
18
 
19
19
  /**
20
20
  * The experiments component's function references, as exposed on the host via
@@ -53,6 +53,18 @@ export interface ExperimentsComponent {
53
53
  { scope: string; key: string; subjectRef: string },
54
54
  ExposureOutcome
55
55
  >;
56
+ forgetSubject: FunctionReference<
57
+ "mutation",
58
+ "internal",
59
+ { scope: string; key: string; subjectRef: string },
60
+ boolean
61
+ >;
62
+ deleteExperiment: FunctionReference<
63
+ "mutation",
64
+ "internal",
65
+ { scope: string; key: string; batch: number },
66
+ number
67
+ >;
56
68
  };
57
69
  queries: {
58
70
  getExperiment: FunctionReference<
@@ -61,12 +73,24 @@ export interface ExperimentsComponent {
61
73
  { scope: string; key: string },
62
74
  ExperimentDefinition | null
63
75
  >;
76
+ listExperiments: FunctionReference<
77
+ "query",
78
+ "internal",
79
+ { scope: string; status?: ExperimentStatus },
80
+ ExperimentDefinition[]
81
+ >;
64
82
  getAssignment: FunctionReference<
65
83
  "query",
66
84
  "internal",
67
85
  { scope: string; key: string; subjectRef: string },
68
86
  Assignment | null
69
87
  >;
88
+ peek: FunctionReference<
89
+ "query",
90
+ "internal",
91
+ { scope: string; key: string; subjectRef: string },
92
+ ExposureOutcome
93
+ >;
70
94
  results: FunctionReference<
71
95
  "query",
72
96
  "internal",
@@ -130,8 +154,9 @@ export class Experiments {
130
154
  /**
131
155
  * Create or update an experiment. `variants` are weighted (equal weights split
132
156
  * evenly). `salt` defaults to `key`; `status` to the client default (`running`).
133
- * Returns `{ created }` — `false` when an existing definition was updated.
134
- * Updating never disturbs existing sticky assignments.
157
+ * Returns `{ created }` — `false` when an existing definition was updated. Status
158
+ * transitions are always allowed; `variants`/`salt` are immutable once a subject
159
+ * is assigned (throws `EXPERIMENT_LOCKED`).
135
160
  */
136
161
  define(
137
162
  ctx: RunMutationCtx,
@@ -223,7 +248,41 @@ export class Experiments {
223
248
  });
224
249
  }
225
250
 
226
- /** Per-variant exposure tallies (distinct subjects + total exposures). */
251
+ /**
252
+ * Read-only deterministic variant for a subject — the sticky variant **without
253
+ * persisting**. Returns the stored assignment if present, else the deterministic
254
+ * pick; `null` when not enrolled. Use for SSR / a flicker-free first paint, then
255
+ * call `logExposure` to enroll + tally.
256
+ */
257
+ peek(
258
+ ctx: RunQueryCtx,
259
+ key: string,
260
+ subjectRef: string,
261
+ scope?: string,
262
+ ): Promise<ExposureOutcome> {
263
+ return ctx.runQuery(this.component.queries.peek, {
264
+ scope: this.scopeOf(scope),
265
+ key,
266
+ subjectRef,
267
+ });
268
+ }
269
+
270
+ /** Every experiment in a scope, optionally filtered by `status`. */
271
+ listExperiments(
272
+ ctx: RunQueryCtx,
273
+ opts: { scope?: string; status?: ExperimentStatus } = {},
274
+ ): Promise<ExperimentDefinition[]> {
275
+ return ctx.runQuery(this.component.queries.listExperiments, {
276
+ scope: this.scopeOf(opts.scope),
277
+ status: opts.status,
278
+ });
279
+ }
280
+
281
+ /**
282
+ * Per-variant tallies — `assigned`, distinct `subjects` exposed, total
283
+ * `exposures`, and the configured `weight` (for sample-ratio-mismatch). Reads
284
+ * O(variants), not the exposure table.
285
+ */
227
286
  results(
228
287
  ctx: RunQueryCtx,
229
288
  key: string,
@@ -234,6 +293,41 @@ export class Experiments {
234
293
  key,
235
294
  });
236
295
  }
296
+
297
+ /**
298
+ * Erase a subject's assignment + exposure in one experiment (GDPR right-to-
299
+ * erasure), decrementing tallies. Returns `true` if anything was deleted. Loop
300
+ * over `listExperiments` to erase a subject across a whole scope.
301
+ */
302
+ forgetSubject(
303
+ ctx: RunMutationCtx,
304
+ key: string,
305
+ subjectRef: string,
306
+ scope?: string,
307
+ ): Promise<boolean> {
308
+ return ctx.runMutation(this.component.mutations.forgetSubject, {
309
+ scope: this.scopeOf(scope),
310
+ key,
311
+ subjectRef,
312
+ });
313
+ }
314
+
315
+ /**
316
+ * Delete an experiment and all of its data (definition, assignments, exposures,
317
+ * tallies). Bounded + self-rescheduling; returns the rows removed this pass.
318
+ * Idempotent and safe on an absent experiment.
319
+ */
320
+ deleteExperiment(
321
+ ctx: RunMutationCtx,
322
+ key: string,
323
+ opts: { scope?: string; batch?: number } = {},
324
+ ): Promise<number> {
325
+ return ctx.runMutation(this.component.mutations.deleteExperiment, {
326
+ scope: this.scopeOf(opts.scope),
327
+ key,
328
+ batch: opts.batch ?? DEFAULT_DELETE_BATCH,
329
+ });
330
+ }
237
331
  }
238
332
 
239
333
  export type {
@@ -24,8 +24,9 @@ export interface DefineOptions {
24
24
  /** Namespace for this experiment. Defaults to the client `defaultScope`. */
25
25
  scope?: string;
26
26
  /**
27
- * Hash salt for deterministic assignment. Defaults to the experiment `key`;
28
- * change it to re-randomize buckets without changing subject ids.
27
+ * Hash salt for deterministic assignment. Defaults to the experiment `key`.
28
+ * Fixed once any subject is assigned (changing it after enrollment throws
29
+ * `EXPERIMENT_LOCKED`); to re-randomize, define a new experiment key.
29
30
  */
30
31
  salt?: string;
31
32
  /** Initial lifecycle status. Defaults to the client `defaultStatus`. */
@@ -62,12 +63,16 @@ export type AssignOutcome =
62
63
  /** Outcome of {@link Experiments.logExposure}: the variant, or `null` if not enrolled. */
63
64
  export type ExposureOutcome = { variant: string | null };
64
65
 
65
- /** A per-variant exposure tally, as returned by {@link Experiments.results}. */
66
+ /** A per-variant tally, as returned by {@link Experiments.results}. */
66
67
  export interface VariantResult {
67
68
  /** The variant key. */
68
69
  variant: string;
70
+ /** Subjects assigned to this variant (the realized split, for SRM). */
71
+ assigned: number;
69
72
  /** Distinct subjects exposed to this variant (the funnel denominator). */
70
73
  subjects: number;
71
74
  /** Total exposure events recorded for this variant. */
72
75
  exposures: number;
76
+ /** The configured weight from the current definition (0 if the variant is gone). */
77
+ weight: number;
73
78
  }
@@ -44,6 +44,20 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
44
44
  { created: boolean },
45
45
  Name
46
46
  >;
47
+ deleteExperiment: FunctionReference<
48
+ "mutation",
49
+ "internal",
50
+ { batch: number; key: string; scope: string },
51
+ number,
52
+ Name
53
+ >;
54
+ forgetSubject: FunctionReference<
55
+ "mutation",
56
+ "internal",
57
+ { key: string; scope: string; subjectRef: string },
58
+ boolean,
59
+ Name
60
+ >;
47
61
  logExposure: FunctionReference<
48
62
  "mutation",
49
63
  "internal",
@@ -81,11 +95,38 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
81
95
  },
82
96
  Name
83
97
  >;
98
+ listExperiments: FunctionReference<
99
+ "query",
100
+ "internal",
101
+ { scope: string; status?: "draft" | "running" | "stopped" },
102
+ Array<{
103
+ createdAt: number;
104
+ key: string;
105
+ salt: string;
106
+ scope: string;
107
+ status: "draft" | "running" | "stopped";
108
+ variants: Array<{ key: string; weight: number }>;
109
+ }>,
110
+ Name
111
+ >;
112
+ peek: FunctionReference<
113
+ "query",
114
+ "internal",
115
+ { key: string; scope: string; subjectRef: string },
116
+ { variant: null } | { variant: string },
117
+ Name
118
+ >;
84
119
  results: FunctionReference<
85
120
  "query",
86
121
  "internal",
87
122
  { key: string; scope: string },
88
- Array<{ exposures: number; subjects: number; variant: string }>,
123
+ Array<{
124
+ assigned: number;
125
+ exposures: number;
126
+ subjects: number;
127
+ variant: string;
128
+ weight: number;
129
+ }>,
89
130
  Name
90
131
  >;
91
132
  };
@@ -30,6 +30,17 @@ import {
30
30
  } from "convex/server";
31
31
  import type { DataModel } from "./dataModel.js";
32
32
 
33
+ /**
34
+ * Typesafe environment variables.
35
+ *
36
+ * This includes platform-provided env vars and any variables declared in
37
+ * `convex.config.ts`.
38
+ */
39
+ type Env = {
40
+ readonly CONVEX_CLOUD_URL: string;
41
+ readonly CONVEX_SITE_URL: string;
42
+ };
43
+
33
44
  /**
34
45
  * Define a query in this Convex app's public API.
35
46
  *
@@ -106,6 +117,8 @@ export const internalAction: ActionBuilder<DataModel, "internal"> =
106
117
  * @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
107
118
  */
108
119
  export const httpAction: HttpActionBuilder = httpActionGeneric;
120
+ export const env: Env = (globalThis as unknown as { process: { env: Env } })
121
+ .process.env;
109
122
 
110
123
  /**
111
124
  * A set of services for use within Convex query functions.