@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.
- package/README.md +150 -36
- package/dist/client/index.d.ts +54 -3
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +53 -4
- package/dist/client/index.js.map +1 -1
- package/dist/client/types.d.ts +8 -3
- package/dist/client/types.d.ts.map +1 -1
- package/dist/component/_generated/component.d.ts +35 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/_generated/server.d.ts +12 -0
- package/dist/component/_generated/server.d.ts.map +1 -1
- package/dist/component/_generated/server.js +2 -0
- package/dist/component/_generated/server.js.map +1 -1
- package/dist/component/convex.config.d.ts.map +1 -1
- package/dist/component/mutations.d.ts +47 -20
- package/dist/component/mutations.d.ts.map +1 -1
- package/dist/component/mutations.js +220 -26
- package/dist/component/mutations.js.map +1 -1
- package/dist/component/queries.d.ts +41 -8
- package/dist/component/queries.d.ts.map +1 -1
- package/dist/component/queries.js +82 -20
- package/dist/component/queries.js.map +1 -1
- package/dist/component/schema.d.ts +39 -17
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/schema.js +20 -5
- package/dist/component/schema.js.map +1 -1
- package/dist/component/validators.d.ts +31 -18
- package/dist/component/validators.d.ts.map +1 -1
- package/dist/component/validators.js +14 -3
- package/dist/component/validators.js.map +1 -1
- package/dist/react/index.d.ts +57 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +39 -0
- package/dist/react/index.js.map +1 -0
- package/dist/shared.d.ts +5 -3
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +5 -3
- package/dist/shared.js.map +1 -1
- package/package.json +50 -20
- package/src/client/index.ts +98 -4
- package/src/client/types.ts +8 -3
- package/src/component/_generated/component.ts +42 -1
- package/src/component/_generated/server.ts +13 -0
- package/src/component/mutations.ts +250 -28
- package/src/component/queries.ts +97 -20
- package/src/component/schema.ts +21 -5
- package/src/component/validators.ts +14 -3
- package/src/react/index.tsx +68 -0
- package/src/shared.ts +6 -3
- package/src/test.ts +2 -1
- package/src/unit.test.ts +0 -84
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Create or update an experiment definition, keyed by `(scope, key)`. Returns
|
|
3
|
-
* `{ created: true }` on insert, `{ created: false }` on update.
|
|
4
|
-
*
|
|
5
|
-
* status) changes. Time is server-sourced.
|
|
3
|
+
* `{ created: true }` on insert, `{ created: false }` on update. Time is
|
|
4
|
+
* server-sourced.
|
|
6
5
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* **Immutability once assigned:** `variants` and `salt` are fixed once any subject
|
|
7
|
+
* is assigned — changing them would split the population across two randomizations
|
|
8
|
+
* (some subjects bucketed under the old definition, some the new) and orphan
|
|
9
|
+
* tallies. Status transitions (start/stop) are always allowed. To re-randomize or
|
|
10
|
+
* reweight after enrollment, define a new experiment key.
|
|
11
|
+
*
|
|
12
|
+
* @throws `ConvexError({ code: "INVALID_ARGUMENT" })` when `scope` or `key` is empty.
|
|
13
|
+
* @throws `ConvexError({ code: "INVALID_VARIANTS", reason })` for a bad variant set.
|
|
14
|
+
* @throws `ConvexError({ code: "EXPERIMENT_LOCKED" })` when `variants`/`salt` change
|
|
15
|
+
* after a subject has been assigned.
|
|
9
16
|
*/
|
|
10
17
|
export declare const define: import("convex/server").RegisteredMutation<"public", {
|
|
11
|
-
scope: string;
|
|
12
18
|
key: string;
|
|
19
|
+
salt: string;
|
|
20
|
+
scope: string;
|
|
21
|
+
status: "draft" | "running" | "stopped";
|
|
13
22
|
variants: {
|
|
14
23
|
key: string;
|
|
15
24
|
weight: number;
|
|
16
25
|
}[];
|
|
17
|
-
salt: string;
|
|
18
|
-
status: "running" | "draft" | "stopped";
|
|
19
26
|
}, Promise<{
|
|
20
27
|
created: boolean;
|
|
21
28
|
}>>;
|
|
@@ -26,21 +33,19 @@ export declare const define: import("convex/server").RegisteredMutation<"public"
|
|
|
26
33
|
* leaving recorded assignments and exposures intact.
|
|
27
34
|
*/
|
|
28
35
|
export declare const setStatus: import("convex/server").RegisteredMutation<"public", {
|
|
29
|
-
scope: string;
|
|
30
36
|
key: string;
|
|
31
|
-
|
|
37
|
+
scope: string;
|
|
38
|
+
status: "draft" | "running" | "stopped";
|
|
32
39
|
}, Promise<boolean>>;
|
|
33
40
|
/**
|
|
34
41
|
* Enroll `subjectRef` and return the sticky variant. `{ variant: null }` when the
|
|
35
42
|
* experiment is absent or not `running` (the host treats it as control). When
|
|
36
43
|
* `running`, the first call deterministically picks and persists a variant
|
|
37
|
-
* (`isNew: true`); later calls replay it (`isNew: false`).
|
|
38
|
-
* function of `(salt, subjectRef)` — see {@link pickVariant} — so it is sticky
|
|
39
|
-
* even before persistence. Time is server-sourced.
|
|
44
|
+
* (`isNew: true`); later calls replay it (`isNew: false`). Time is server-sourced.
|
|
40
45
|
*/
|
|
41
46
|
export declare const assign: import("convex/server").RegisteredMutation<"public", {
|
|
42
|
-
scope: string;
|
|
43
47
|
key: string;
|
|
48
|
+
scope: string;
|
|
44
49
|
subjectRef: string;
|
|
45
50
|
}, Promise<{
|
|
46
51
|
variant: string;
|
|
@@ -49,19 +54,41 @@ export declare const assign: import("convex/server").RegisteredMutation<"public"
|
|
|
49
54
|
variant: null;
|
|
50
55
|
}>>;
|
|
51
56
|
/**
|
|
52
|
-
* Record that `subjectRef` was exposed
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* unique subjects. `{ variant: null }` when not enrolled. Time is server-sourced.
|
|
57
|
+
* Record that `subjectRef` was exposed and return their variant, enrolling if
|
|
58
|
+
* needed. First exposure inserts a tally row and bumps `subjects` + `exposures`;
|
|
59
|
+
* later exposures bump `exposures` only (deduped per subject). `{ variant: null }`
|
|
60
|
+
* when not enrolled. Time is server-sourced.
|
|
57
61
|
*/
|
|
58
62
|
export declare const logExposure: import("convex/server").RegisteredMutation<"public", {
|
|
59
|
-
scope: string;
|
|
60
63
|
key: string;
|
|
64
|
+
scope: string;
|
|
61
65
|
subjectRef: string;
|
|
62
66
|
}, Promise<{
|
|
63
67
|
variant: null;
|
|
64
68
|
} | {
|
|
65
69
|
variant: string;
|
|
66
70
|
}>>;
|
|
71
|
+
/**
|
|
72
|
+
* Erase a subject's footprint in one experiment — their assignment and exposure
|
|
73
|
+
* rows — decrementing the variant tallies accordingly. The GDPR right-to-erasure
|
|
74
|
+
* primitive for a `subjectRef` that maps to a person. Returns `true` if anything
|
|
75
|
+
* was deleted. Loop over `listExperiments` to erase a subject across a scope.
|
|
76
|
+
*/
|
|
77
|
+
export declare const forgetSubject: import("convex/server").RegisteredMutation<"public", {
|
|
78
|
+
key: string;
|
|
79
|
+
scope: string;
|
|
80
|
+
subjectRef: string;
|
|
81
|
+
}, Promise<boolean>>;
|
|
82
|
+
/**
|
|
83
|
+
* Delete an experiment and all of its data — the definition, every assignment,
|
|
84
|
+
* exposure, and tally row. Bounded: removes up to `batch` rows per table per pass
|
|
85
|
+
* and self-reschedules until the children are drained, then deletes the definition.
|
|
86
|
+
* Idempotent and safe to call on an absent experiment. Returns the rows removed
|
|
87
|
+
* this pass.
|
|
88
|
+
*/
|
|
89
|
+
export declare const deleteExperiment: import("convex/server").RegisteredMutation<"public", {
|
|
90
|
+
batch: number;
|
|
91
|
+
key: string;
|
|
92
|
+
scope: string;
|
|
93
|
+
}, Promise<number>>;
|
|
67
94
|
//# sourceMappingURL=mutations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../src/component/mutations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../src/component/mutations.ts"],"names":[],"mappings":"AAqJA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;GAmDjB,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,SAAS;;;;oBAiBpB,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,MAAM;;;;;aAlIG,MAAM;WAAS,OAAO;;;GAkJ1C,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,WAAW;;;;;;;;GAqDtB,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;;oBAyCxB,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB;;;;mBA6D3B,CAAC"}
|
|
@@ -1,43 +1,102 @@
|
|
|
1
1
|
import { ConvexError, v } from "convex/values";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { api } from "./_generated/api.js";
|
|
3
|
+
import { mutation } from "./_generated/server.js";
|
|
4
|
+
import { pickVariant } from "../shared.js";
|
|
5
|
+
import { assignResult, experimentStatus, exposureResult, variant } from "./validators.js";
|
|
6
|
+
/** Reject empty identifiers: an empty scope/key/subjectRef would store a meaningless row. */
|
|
7
|
+
function assertNonEmpty(fields) {
|
|
8
|
+
for (const [name, value] of Object.entries(fields)) {
|
|
9
|
+
if (value === "") {
|
|
10
|
+
throw new ConvexError({
|
|
11
|
+
code: "INVALID_ARGUMENT",
|
|
12
|
+
message: `${name} must be non-empty`,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
5
17
|
/**
|
|
6
18
|
* Reject a malformed variant set before any write: at least one variant, every
|
|
7
|
-
* weight a positive finite number, and no duplicate variant keys.
|
|
8
|
-
*
|
|
9
|
-
* assignment ambiguous.
|
|
19
|
+
* weight a positive finite number, and no duplicate variant keys. The thrown
|
|
20
|
+
* `ConvexError` carries a `reason` so the host can branch on the specific failure.
|
|
10
21
|
*
|
|
11
|
-
* @throws `ConvexError({ code: "INVALID_VARIANTS" })`
|
|
22
|
+
* @throws `ConvexError({ code: "INVALID_VARIANTS", reason })`
|
|
12
23
|
*/
|
|
13
24
|
function validateVariants(variants) {
|
|
14
25
|
if (variants.length === 0) {
|
|
15
26
|
throw new ConvexError({
|
|
16
27
|
code: "INVALID_VARIANTS",
|
|
28
|
+
reason: "empty",
|
|
17
29
|
message: "an experiment needs at least one variant",
|
|
18
30
|
});
|
|
19
31
|
}
|
|
20
32
|
const seen = new Set();
|
|
21
33
|
for (const candidate of variants) {
|
|
34
|
+
if (candidate.key === "") {
|
|
35
|
+
throw new ConvexError({
|
|
36
|
+
code: "INVALID_VARIANTS",
|
|
37
|
+
reason: "empty_key",
|
|
38
|
+
message: "variant keys must be non-empty",
|
|
39
|
+
});
|
|
40
|
+
}
|
|
22
41
|
if (!(candidate.weight > 0 && isFinite(candidate.weight))) {
|
|
23
42
|
throw new ConvexError({
|
|
24
43
|
code: "INVALID_VARIANTS",
|
|
44
|
+
reason: "non_positive_weight",
|
|
45
|
+
key: candidate.key,
|
|
25
46
|
message: `variant "${candidate.key}" weight must be a positive finite number`,
|
|
26
47
|
});
|
|
27
48
|
}
|
|
28
49
|
if (seen.has(candidate.key)) {
|
|
29
50
|
throw new ConvexError({
|
|
30
51
|
code: "INVALID_VARIANTS",
|
|
52
|
+
reason: "duplicate_key",
|
|
53
|
+
key: candidate.key,
|
|
31
54
|
message: `duplicate variant key "${candidate.key}"`,
|
|
32
55
|
});
|
|
33
56
|
}
|
|
34
57
|
seen.add(candidate.key);
|
|
35
58
|
}
|
|
36
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* The hash salt for an experiment folds in `scope` so the same `subjectRef` lands
|
|
62
|
+
* in an independent bucket per scope (a tenant-correlation bug otherwise) and the
|
|
63
|
+
* host's `salt` re-keys within the scope.
|
|
64
|
+
*/
|
|
65
|
+
function hashSalt(experiment) {
|
|
66
|
+
return `${experiment.scope}:${experiment.salt}`;
|
|
67
|
+
}
|
|
68
|
+
/** Incrementally maintain the per-`(scope, experiment, variant)` tally row. */
|
|
69
|
+
async function bumpTally(ctx, scope, experimentKey, variantKey, delta) {
|
|
70
|
+
const assigned = delta.assigned ?? 0;
|
|
71
|
+
const subjects = delta.subjects ?? 0;
|
|
72
|
+
const exposures = delta.exposures ?? 0;
|
|
73
|
+
const row = await ctx.db
|
|
74
|
+
.query("variantTallies")
|
|
75
|
+
.withIndex("by_scope_experiment_variant", (q) => q.eq("scope", scope).eq("experimentKey", experimentKey).eq("variant", variantKey))
|
|
76
|
+
.unique();
|
|
77
|
+
if (row === null) {
|
|
78
|
+
await ctx.db.insert("variantTallies", {
|
|
79
|
+
scope,
|
|
80
|
+
experimentKey,
|
|
81
|
+
variant: variantKey,
|
|
82
|
+
assigned,
|
|
83
|
+
subjects,
|
|
84
|
+
exposures,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
await ctx.db.patch("variantTallies", row._id, {
|
|
89
|
+
assigned: row.assigned + assigned,
|
|
90
|
+
subjects: row.subjects + subjects,
|
|
91
|
+
exposures: row.exposures + exposures,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
37
95
|
/**
|
|
38
96
|
* Return the subject's sticky assignment, persisting a fresh deterministic pick on
|
|
39
|
-
* first sight
|
|
40
|
-
* share one enrollment path. Time is
|
|
97
|
+
* first sight (and bumping the variant's `assigned` tally). Plain helper (not a
|
|
98
|
+
* Convex function) so `assign` and `logExposure` share one enrollment path. Time is
|
|
99
|
+
* server-sourced by the caller.
|
|
41
100
|
*/
|
|
42
101
|
async function ensureAssignment(ctx, experiment, subjectRef, now) {
|
|
43
102
|
const existing = await ctx.db
|
|
@@ -50,7 +109,7 @@ async function ensureAssignment(ctx, experiment, subjectRef, now) {
|
|
|
50
109
|
if (existing !== null) {
|
|
51
110
|
return { variant: existing.variant, isNew: false };
|
|
52
111
|
}
|
|
53
|
-
const variantKey = pickVariant(experiment.variants, experiment
|
|
112
|
+
const variantKey = pickVariant(experiment.variants, hashSalt(experiment), subjectRef);
|
|
54
113
|
await ctx.db.insert("assignments", {
|
|
55
114
|
scope: experiment.scope,
|
|
56
115
|
experimentKey: experiment.key,
|
|
@@ -58,16 +117,28 @@ async function ensureAssignment(ctx, experiment, subjectRef, now) {
|
|
|
58
117
|
variant: variantKey,
|
|
59
118
|
assignedAt: now,
|
|
60
119
|
});
|
|
120
|
+
await bumpTally(ctx, experiment.scope, experiment.key, variantKey, { assigned: 1 });
|
|
61
121
|
return { variant: variantKey, isNew: true };
|
|
62
122
|
}
|
|
123
|
+
/** True when two variant sets differ in key, weight, or order. */
|
|
124
|
+
function variantsChanged(a, b) {
|
|
125
|
+
return JSON.stringify(a) !== JSON.stringify(b);
|
|
126
|
+
}
|
|
63
127
|
/**
|
|
64
128
|
* Create or update an experiment definition, keyed by `(scope, key)`. Returns
|
|
65
|
-
* `{ created: true }` on insert, `{ created: false }` on update.
|
|
66
|
-
*
|
|
67
|
-
*
|
|
129
|
+
* `{ created: true }` on insert, `{ created: false }` on update. Time is
|
|
130
|
+
* server-sourced.
|
|
131
|
+
*
|
|
132
|
+
* **Immutability once assigned:** `variants` and `salt` are fixed once any subject
|
|
133
|
+
* is assigned — changing them would split the population across two randomizations
|
|
134
|
+
* (some subjects bucketed under the old definition, some the new) and orphan
|
|
135
|
+
* tallies. Status transitions (start/stop) are always allowed. To re-randomize or
|
|
136
|
+
* reweight after enrollment, define a new experiment key.
|
|
68
137
|
*
|
|
69
|
-
* @throws `ConvexError({ code: "
|
|
70
|
-
*
|
|
138
|
+
* @throws `ConvexError({ code: "INVALID_ARGUMENT" })` when `scope` or `key` is empty.
|
|
139
|
+
* @throws `ConvexError({ code: "INVALID_VARIANTS", reason })` for a bad variant set.
|
|
140
|
+
* @throws `ConvexError({ code: "EXPERIMENT_LOCKED" })` when `variants`/`salt` change
|
|
141
|
+
* after a subject has been assigned.
|
|
71
142
|
*/
|
|
72
143
|
export const define = mutation({
|
|
73
144
|
args: {
|
|
@@ -79,6 +150,7 @@ export const define = mutation({
|
|
|
79
150
|
},
|
|
80
151
|
returns: v.object({ created: v.boolean() }),
|
|
81
152
|
handler: async (ctx, args) => {
|
|
153
|
+
assertNonEmpty({ scope: args.scope, key: args.key });
|
|
82
154
|
validateVariants(args.variants);
|
|
83
155
|
const existing = await ctx.db
|
|
84
156
|
.query("experiments")
|
|
@@ -95,7 +167,19 @@ export const define = mutation({
|
|
|
95
167
|
});
|
|
96
168
|
return { created: true };
|
|
97
169
|
}
|
|
98
|
-
|
|
170
|
+
if (variantsChanged(existing.variants, args.variants) || existing.salt !== args.salt) {
|
|
171
|
+
const firstAssignment = await ctx.db
|
|
172
|
+
.query("assignments")
|
|
173
|
+
.withIndex("by_scope_experiment_subject", (q) => q.eq("scope", args.scope).eq("experimentKey", args.key))
|
|
174
|
+
.first();
|
|
175
|
+
if (firstAssignment !== null) {
|
|
176
|
+
throw new ConvexError({
|
|
177
|
+
code: "EXPERIMENT_LOCKED",
|
|
178
|
+
message: "variants and salt are immutable once subjects are assigned; define a new experiment key to re-randomize",
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
await ctx.db.patch("experiments", existing._id, {
|
|
99
183
|
status: args.status,
|
|
100
184
|
variants: args.variants,
|
|
101
185
|
salt: args.salt,
|
|
@@ -113,6 +197,7 @@ export const setStatus = mutation({
|
|
|
113
197
|
args: { scope: v.string(), key: v.string(), status: experimentStatus },
|
|
114
198
|
returns: v.boolean(),
|
|
115
199
|
handler: async (ctx, args) => {
|
|
200
|
+
assertNonEmpty({ scope: args.scope, key: args.key });
|
|
116
201
|
const existing = await ctx.db
|
|
117
202
|
.query("experiments")
|
|
118
203
|
.withIndex("by_scope_key", (q) => q.eq("scope", args.scope).eq("key", args.key))
|
|
@@ -120,7 +205,7 @@ export const setStatus = mutation({
|
|
|
120
205
|
if (existing === null) {
|
|
121
206
|
return false;
|
|
122
207
|
}
|
|
123
|
-
await ctx.db.patch(existing._id, { status: args.status });
|
|
208
|
+
await ctx.db.patch("experiments", existing._id, { status: args.status });
|
|
124
209
|
return true;
|
|
125
210
|
},
|
|
126
211
|
});
|
|
@@ -128,14 +213,13 @@ export const setStatus = mutation({
|
|
|
128
213
|
* Enroll `subjectRef` and return the sticky variant. `{ variant: null }` when the
|
|
129
214
|
* experiment is absent or not `running` (the host treats it as control). When
|
|
130
215
|
* `running`, the first call deterministically picks and persists a variant
|
|
131
|
-
* (`isNew: true`); later calls replay it (`isNew: false`).
|
|
132
|
-
* function of `(salt, subjectRef)` — see {@link pickVariant} — so it is sticky
|
|
133
|
-
* even before persistence. Time is server-sourced.
|
|
216
|
+
* (`isNew: true`); later calls replay it (`isNew: false`). Time is server-sourced.
|
|
134
217
|
*/
|
|
135
218
|
export const assign = mutation({
|
|
136
219
|
args: { scope: v.string(), key: v.string(), subjectRef: v.string() },
|
|
137
220
|
returns: assignResult,
|
|
138
221
|
handler: async (ctx, args) => {
|
|
222
|
+
assertNonEmpty({ scope: args.scope, key: args.key, subjectRef: args.subjectRef });
|
|
139
223
|
const experiment = await ctx.db
|
|
140
224
|
.query("experiments")
|
|
141
225
|
.withIndex("by_scope_key", (q) => q.eq("scope", args.scope).eq("key", args.key))
|
|
@@ -147,16 +231,16 @@ export const assign = mutation({
|
|
|
147
231
|
},
|
|
148
232
|
});
|
|
149
233
|
/**
|
|
150
|
-
* Record that `subjectRef` was exposed
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
* unique subjects. `{ variant: null }` when not enrolled. Time is server-sourced.
|
|
234
|
+
* Record that `subjectRef` was exposed and return their variant, enrolling if
|
|
235
|
+
* needed. First exposure inserts a tally row and bumps `subjects` + `exposures`;
|
|
236
|
+
* later exposures bump `exposures` only (deduped per subject). `{ variant: null }`
|
|
237
|
+
* when not enrolled. Time is server-sourced.
|
|
155
238
|
*/
|
|
156
239
|
export const logExposure = mutation({
|
|
157
240
|
args: { scope: v.string(), key: v.string(), subjectRef: v.string() },
|
|
158
241
|
returns: exposureResult,
|
|
159
242
|
handler: async (ctx, args) => {
|
|
243
|
+
assertNonEmpty({ scope: args.scope, key: args.key, subjectRef: args.subjectRef });
|
|
160
244
|
const experiment = await ctx.db
|
|
161
245
|
.query("experiments")
|
|
162
246
|
.withIndex("by_scope_key", (q) => q.eq("scope", args.scope).eq("key", args.key))
|
|
@@ -183,14 +267,124 @@ export const logExposure = mutation({
|
|
|
183
267
|
lastExposedAt: now,
|
|
184
268
|
count: 1,
|
|
185
269
|
});
|
|
270
|
+
await bumpTally(ctx, args.scope, args.key, variantKey, {
|
|
271
|
+
subjects: 1,
|
|
272
|
+
exposures: 1,
|
|
273
|
+
});
|
|
186
274
|
}
|
|
187
275
|
else {
|
|
188
|
-
await ctx.db.patch(existing._id, {
|
|
276
|
+
await ctx.db.patch("exposures", existing._id, {
|
|
189
277
|
lastExposedAt: now,
|
|
190
278
|
count: existing.count + 1,
|
|
191
279
|
});
|
|
280
|
+
await bumpTally(ctx, args.scope, args.key, variantKey, { exposures: 1 });
|
|
192
281
|
}
|
|
193
282
|
return { variant: variantKey };
|
|
194
283
|
},
|
|
195
284
|
});
|
|
285
|
+
/**
|
|
286
|
+
* Erase a subject's footprint in one experiment — their assignment and exposure
|
|
287
|
+
* rows — decrementing the variant tallies accordingly. The GDPR right-to-erasure
|
|
288
|
+
* primitive for a `subjectRef` that maps to a person. Returns `true` if anything
|
|
289
|
+
* was deleted. Loop over `listExperiments` to erase a subject across a scope.
|
|
290
|
+
*/
|
|
291
|
+
export const forgetSubject = mutation({
|
|
292
|
+
args: { scope: v.string(), key: v.string(), subjectRef: v.string() },
|
|
293
|
+
returns: v.boolean(),
|
|
294
|
+
handler: async (ctx, args) => {
|
|
295
|
+
assertNonEmpty({ scope: args.scope, key: args.key, subjectRef: args.subjectRef });
|
|
296
|
+
let deleted = false;
|
|
297
|
+
const assignment = await ctx.db
|
|
298
|
+
.query("assignments")
|
|
299
|
+
.withIndex("by_scope_experiment_subject", (q) => q
|
|
300
|
+
.eq("scope", args.scope)
|
|
301
|
+
.eq("experimentKey", args.key)
|
|
302
|
+
.eq("subjectRef", args.subjectRef))
|
|
303
|
+
.unique();
|
|
304
|
+
if (assignment !== null) {
|
|
305
|
+
await bumpTally(ctx, args.scope, args.key, assignment.variant, {
|
|
306
|
+
assigned: -1,
|
|
307
|
+
});
|
|
308
|
+
await ctx.db.delete("assignments", assignment._id);
|
|
309
|
+
deleted = true;
|
|
310
|
+
}
|
|
311
|
+
const exposure = await ctx.db
|
|
312
|
+
.query("exposures")
|
|
313
|
+
.withIndex("by_scope_experiment_subject", (q) => q
|
|
314
|
+
.eq("scope", args.scope)
|
|
315
|
+
.eq("experimentKey", args.key)
|
|
316
|
+
.eq("subjectRef", args.subjectRef))
|
|
317
|
+
.unique();
|
|
318
|
+
if (exposure !== null) {
|
|
319
|
+
await bumpTally(ctx, args.scope, args.key, exposure.variant, {
|
|
320
|
+
subjects: -1,
|
|
321
|
+
exposures: -exposure.count,
|
|
322
|
+
});
|
|
323
|
+
await ctx.db.delete("exposures", exposure._id);
|
|
324
|
+
deleted = true;
|
|
325
|
+
}
|
|
326
|
+
return deleted;
|
|
327
|
+
},
|
|
328
|
+
});
|
|
329
|
+
/**
|
|
330
|
+
* Delete an experiment and all of its data — the definition, every assignment,
|
|
331
|
+
* exposure, and tally row. Bounded: removes up to `batch` rows per table per pass
|
|
332
|
+
* and self-reschedules until the children are drained, then deletes the definition.
|
|
333
|
+
* Idempotent and safe to call on an absent experiment. Returns the rows removed
|
|
334
|
+
* this pass.
|
|
335
|
+
*/
|
|
336
|
+
export const deleteExperiment = mutation({
|
|
337
|
+
args: { scope: v.string(), key: v.string(), batch: v.number() },
|
|
338
|
+
returns: v.number(),
|
|
339
|
+
handler: async (ctx, args) => {
|
|
340
|
+
assertNonEmpty({ scope: args.scope, key: args.key });
|
|
341
|
+
if (!Number.isFinite(args.batch) || !Number.isInteger(args.batch) || args.batch < 1 || args.batch > 500) {
|
|
342
|
+
throw new ConvexError({
|
|
343
|
+
code: "INVALID_BATCH",
|
|
344
|
+
message: "batch must be an integer between 1 and 500",
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
let removed = 0;
|
|
348
|
+
const assignments = await ctx.db
|
|
349
|
+
.query("assignments")
|
|
350
|
+
.withIndex("by_scope_experiment_subject", (q) => q.eq("scope", args.scope).eq("experimentKey", args.key))
|
|
351
|
+
.take(args.batch);
|
|
352
|
+
for (const row of assignments) {
|
|
353
|
+
await ctx.db.delete("assignments", row._id);
|
|
354
|
+
removed++;
|
|
355
|
+
}
|
|
356
|
+
const exposures = await ctx.db
|
|
357
|
+
.query("exposures")
|
|
358
|
+
.withIndex("by_scope_experiment", (q) => q.eq("scope", args.scope).eq("experimentKey", args.key))
|
|
359
|
+
.take(args.batch);
|
|
360
|
+
for (const row of exposures) {
|
|
361
|
+
await ctx.db.delete("exposures", row._id);
|
|
362
|
+
removed++;
|
|
363
|
+
}
|
|
364
|
+
const tallies = await ctx.db
|
|
365
|
+
.query("variantTallies")
|
|
366
|
+
.withIndex("by_scope_experiment", (q) => q.eq("scope", args.scope).eq("experimentKey", args.key))
|
|
367
|
+
.take(args.batch);
|
|
368
|
+
for (const row of tallies) {
|
|
369
|
+
await ctx.db.delete("variantTallies", row._id);
|
|
370
|
+
removed++;
|
|
371
|
+
}
|
|
372
|
+
if (removed > 0) {
|
|
373
|
+
await ctx.scheduler.runAfter(0, api.mutations.deleteExperiment, {
|
|
374
|
+
scope: args.scope,
|
|
375
|
+
key: args.key,
|
|
376
|
+
batch: args.batch,
|
|
377
|
+
});
|
|
378
|
+
return removed;
|
|
379
|
+
}
|
|
380
|
+
const def = await ctx.db
|
|
381
|
+
.query("experiments")
|
|
382
|
+
.withIndex("by_scope_key", (q) => q.eq("scope", args.scope).eq("key", args.key))
|
|
383
|
+
.unique();
|
|
384
|
+
if (def !== null) {
|
|
385
|
+
await ctx.db.delete("experiments", def._id);
|
|
386
|
+
}
|
|
387
|
+
return removed;
|
|
388
|
+
},
|
|
389
|
+
});
|
|
196
390
|
//# sourceMappingURL=mutations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutations.js","sourceRo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AAG,IAAI,OAAO,EAAE,CAAC;YAC1B,MAAM,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,gBAAgB,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;YAC/C,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;YAChB,MAAM,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,SAAS,CAAC,gBAAgB,EAAE;gBAC9D,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,KAAK,EAAE,IAAI,CAAC,KAAK;aAClB,CAAC,CAAC;YACH,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,EAAE;aACrB,KAAK,CAAC,aAAa,CAAC;aACpB,SAAS,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,EAAE,CAC/B,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAC9C;aACA,MAAM,EAAE,CAAC;QACZ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACjB,MAAM,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,aAAa,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/** The experiment definition for `(scope, key)`, or `null` if none exists. */
|
|
2
2
|
export declare const getExperiment: import("convex/server").RegisteredQuery<"public", {
|
|
3
|
-
scope: string;
|
|
4
3
|
key: string;
|
|
4
|
+
scope: string;
|
|
5
5
|
}, Promise<{
|
|
6
6
|
key: string;
|
|
7
7
|
scope: string;
|
|
8
|
-
status: "
|
|
8
|
+
status: "draft" | "running" | "stopped";
|
|
9
9
|
variants: {
|
|
10
10
|
key: string;
|
|
11
11
|
weight: number;
|
|
@@ -13,27 +13,60 @@ export declare const getExperiment: import("convex/server").RegisteredQuery<"pub
|
|
|
13
13
|
salt: string;
|
|
14
14
|
createdAt: number;
|
|
15
15
|
} | null>>;
|
|
16
|
+
/** Every experiment in a scope, optionally filtered by `status`. */
|
|
17
|
+
export declare const listExperiments: import("convex/server").RegisteredQuery<"public", {
|
|
18
|
+
scope: string;
|
|
19
|
+
status?: "draft" | "running" | "stopped" | undefined;
|
|
20
|
+
}, Promise<{
|
|
21
|
+
key: string;
|
|
22
|
+
scope: string;
|
|
23
|
+
status: "draft" | "running" | "stopped";
|
|
24
|
+
variants: {
|
|
25
|
+
key: string;
|
|
26
|
+
weight: number;
|
|
27
|
+
}[];
|
|
28
|
+
salt: string;
|
|
29
|
+
createdAt: number;
|
|
30
|
+
}[]>>;
|
|
16
31
|
/** A subject's sticky assignment for an experiment, or `null` if not enrolled. */
|
|
17
32
|
export declare const getAssignment: import("convex/server").RegisteredQuery<"public", {
|
|
18
|
-
scope: string;
|
|
19
33
|
key: string;
|
|
34
|
+
scope: string;
|
|
20
35
|
subjectRef: string;
|
|
21
36
|
}, Promise<{
|
|
22
37
|
variant: string;
|
|
23
38
|
assignedAt: number;
|
|
24
39
|
} | null>>;
|
|
25
40
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
41
|
+
* Read-only deterministic variant for a subject — the sticky variant **without
|
|
42
|
+
* persisting** anything. Returns the stored assignment if one exists, otherwise
|
|
43
|
+
* the deterministic `pickVariant` result; `{ variant: null }` when the experiment
|
|
44
|
+
* is absent or not `running`. Use this for SSR / server-component render and as a
|
|
45
|
+
* flicker-free first paint; call the `logExposure` mutation to enroll + tally.
|
|
30
46
|
*/
|
|
31
|
-
export declare const
|
|
47
|
+
export declare const peek: import("convex/server").RegisteredQuery<"public", {
|
|
48
|
+
key: string;
|
|
32
49
|
scope: string;
|
|
50
|
+
subjectRef: string;
|
|
51
|
+
}, Promise<{
|
|
52
|
+
variant: null;
|
|
53
|
+
} | {
|
|
54
|
+
variant: string;
|
|
55
|
+
}>>;
|
|
56
|
+
/**
|
|
57
|
+
* Per-variant tallies for an experiment — `assigned`, distinct `subjects` exposed,
|
|
58
|
+
* total `exposures`, and the configured `weight` (for sample-ratio-mismatch).
|
|
59
|
+
* Reads the maintained `variantTallies` rows (O(variants)), never scanning the
|
|
60
|
+
* exposure table. An experiment with no enrollment returns an empty array.
|
|
61
|
+
*/
|
|
62
|
+
export declare const results: import("convex/server").RegisteredQuery<"public", {
|
|
33
63
|
key: string;
|
|
64
|
+
scope: string;
|
|
34
65
|
}, Promise<{
|
|
35
66
|
variant: string;
|
|
67
|
+
assigned: number;
|
|
36
68
|
subjects: number;
|
|
37
69
|
exposures: number;
|
|
70
|
+
weight: number;
|
|
38
71
|
}[]>>;
|
|
39
72
|
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/component/queries.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/component/queries.ts"],"names":[],"mappings":"AAWA,8EAA8E;AAC9E,eAAO,MAAM,aAAa;;;;;;;;;;;;;UAsBxB,CAAC;AAEH,oEAAoE;AACpE,eAAO,MAAM,eAAe;;;;;;;;;;;;;KAqB1B,CAAC;AAEH,kFAAkF;AAClF,eAAO,MAAM,aAAa;;;;;;;UAkBxB,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,IAAI;;;;;;;;GAiCf,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,OAAO;;;;;;;;;KA+BlB,CAAC"}
|