mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-12-01 09:24:46 +00:00
OpenABTest 0.2-draft: goal conversions
0.1 conversions are purchases with a price, so button, onboarding and landing-page experiments had nothing conformant to report. 0.2 adds a goal conversion: metrics.conversion "unique-participants-with-goal" with metrics.goal, metrics.profit "none", and conversion events carrying exactly one of price or goal (optional observed value). Backward compatible: every 0.1 document stays valid; goal forms require "0.2-draft". The reference implementation is w3bs.org/ab-testing. @logicsrc/schemas and @logicsrc/validators 0.5.0, @logicsrc/sdk 0.4.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0d0a2583b1
commit
2b9e9a6b2c
15 changed files with 256 additions and 32 deletions
|
|
@ -37,7 +37,7 @@ MIT © Profullstack, Inc.
|
|||
|
||||
Version 0.3.0 adds `OpenABTestManifest`, `OpenABTestEvent`,
|
||||
`createOpenABTestManifest` and `createOpenABTestEvent`. The constructors set
|
||||
`openabtest: "0.1-draft"`; validate their result with `@logicsrc/validators`
|
||||
`openabtest: "0.1-draft"`, or `"0.2-draft"` when the document uses a goal conversion; validate their result with `@logicsrc/validators`
|
||||
using `openabtest-manifest` or `openabtest-event` before storing it. They do not
|
||||
assign participants, authenticate events or initiate payments. See the
|
||||
[OpenABTest specification](https://logicsrc.com/docs/openabtest) and its complete
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@logicsrc/sdk",
|
||||
"version": "0.3.0",
|
||||
"version": "0.4.0",
|
||||
"description": "LogicSRC SDK contract types and client interface.",
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
/** Draft private contracts; constructors do not assign users, authorize events or pay money. */
|
||||
export type OpenABTestVersion = "0.1-draft" | "0.2-draft";
|
||||
export interface OpenABTestManifest {
|
||||
openabtest: "0.1-draft";
|
||||
openabtest: OpenABTestVersion;
|
||||
id: string;
|
||||
revision: number;
|
||||
name: string;
|
||||
|
|
@ -12,8 +13,10 @@ export interface OpenABTestManifest {
|
|||
metrics: {
|
||||
primary: "conversion-rate" | "retained-profit-per-eligible-visitor";
|
||||
denominator: "unique-eligible-participants";
|
||||
conversion: "unique-participants-with-confirmed-purchase";
|
||||
profit: "reconciled-net-retained-profit";
|
||||
/** 0.2: unique-participants-with-goal counts participants who reached metrics.goal. */
|
||||
conversion: "unique-participants-with-confirmed-purchase" | "unique-participants-with-goal";
|
||||
profit: "reconciled-net-retained-profit" | "none";
|
||||
goal?: string;
|
||||
minimumEligiblePerVariant: number;
|
||||
minimumObservationSeconds: number;
|
||||
winnerPolicy: "manual-review";
|
||||
|
|
@ -55,12 +58,12 @@ type EventDetail =
|
|||
| { kind: "eligibility"; payload: { cohortId: string; eligible: true } }
|
||||
| { kind: "assignment"; payload: Assigned & { cohortId: string } }
|
||||
| { kind: "exposure"; payload: Assigned & { offerId: string; surface: string } }
|
||||
| { kind: "conversion"; payload: Converted & { price: OpenABTestPrice } }
|
||||
| { kind: "conversion"; payload: Converted & ({ price: OpenABTestPrice; goal?: never } | { goal: string; price?: never; value?: { currency: string; amountMinor: number } }) }
|
||||
| { kind: "adjustment"; payload: Converted & { adjustmentId: string; currency: string; amountMinor: number; reason: "refund" | "chargeback" | "correction"; proofRefs: string[] } }
|
||||
| { kind: "reconciliation"; payload: OpenABTestReconciliation };
|
||||
|
||||
export type OpenABTestEvent = {
|
||||
openabtest: "0.1-draft";
|
||||
openabtest: OpenABTestVersion;
|
||||
id: string;
|
||||
producerId: string;
|
||||
manifestId: string;
|
||||
|
|
@ -71,11 +74,13 @@ export type OpenABTestEvent = {
|
|||
|
||||
/** Validate with @logicsrc/validators before storing or using the document. */
|
||||
export function createOpenABTestManifest(input: Omit<OpenABTestManifest, "openabtest">): OpenABTestManifest {
|
||||
return { ...input, openabtest: "0.1-draft" };
|
||||
const goal = input.metrics.conversion === "unique-participants-with-goal" || input.metrics.profit === "none";
|
||||
return { ...input, openabtest: goal ? "0.2-draft" : "0.1-draft" };
|
||||
}
|
||||
|
||||
type EventInput = Omit<OpenABTestEvent, "openabtest" | "kind" | "payload"> & EventDetail;
|
||||
/** The caller supplies authenticated context and durable IDs; this helper creates neither. */
|
||||
export function createOpenABTestEvent(input: EventInput): OpenABTestEvent {
|
||||
return { ...input, openabtest: "0.1-draft" };
|
||||
const goal = input.kind === "conversion" && "goal" in input.payload && input.payload.goal !== undefined;
|
||||
return { ...input, openabtest: goal ? "0.2-draft" : "0.1-draft" } as OpenABTestEvent;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue