logicsrc/packages/schemas/schemas/logicsrc-openabtest-event.schema.json
Anthony Ettinger ef35139f04
OpenABTest 0.2-draft: goal conversions (#239)
* 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>

* contract: accept any 0.x draft status (OpenABTest is 0.2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 04:58:40 -07:00

503 lines
13 KiB
JSON

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://logicsrc.com/schemas/logicsrc-openabtest-event.schema.json",
"title": "OpenABTest authorized event (0.1 draft)",
"type": "object",
"additionalProperties": false,
"required": [
"openabtest",
"id",
"producerId",
"manifestId",
"manifestRevision",
"participantId",
"at",
"kind",
"payload"
],
"properties": {
"openabtest": {
"enum": [
"0.1-draft",
"0.2-draft"
]
},
"id": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"producerId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"manifestId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"manifestRevision": {
"type": "integer",
"minimum": 1,
"maximum": 9007199254740991
},
"participantId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"at": {
"type": "string",
"format": "date-time"
},
"kind": {
"enum": [
"eligibility",
"assignment",
"exposure",
"conversion",
"adjustment",
"reconciliation"
]
},
"payload": {
"type": "object"
}
},
"allOf": [
{
"if": {
"properties": {
"kind": {
"const": "eligibility"
}
}
},
"then": {
"properties": {
"payload": {
"type": "object",
"additionalProperties": false,
"required": [
"cohortId",
"eligible"
],
"properties": {
"cohortId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"eligible": {
"const": true
}
}
}
}
}
},
{
"if": {
"properties": {
"kind": {
"const": "assignment"
}
}
},
"then": {
"properties": {
"payload": {
"type": "object",
"additionalProperties": false,
"required": [
"assignmentId",
"variantId",
"cohortId"
],
"properties": {
"assignmentId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"variantId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"cohortId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
}
}
}
}
}
},
{
"if": {
"properties": {
"kind": {
"const": "exposure"
}
}
},
"then": {
"properties": {
"payload": {
"type": "object",
"additionalProperties": false,
"required": [
"assignmentId",
"variantId",
"offerId",
"surface"
],
"properties": {
"assignmentId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"variantId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"offerId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"surface": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
}
}
}
}
}
},
{
"if": {
"properties": {
"kind": {
"const": "conversion"
}
}
},
"then": {
"properties": {
"payload": {
"type": "object",
"additionalProperties": false,
"required": [
"assignmentId",
"variantId",
"conversionId"
],
"properties": {
"assignmentId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"variantId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"conversionId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"price": {
"type": "object",
"additionalProperties": false,
"required": [
"offerId",
"acceptedAt",
"currency",
"listUnitPriceMinor",
"chargedUnitPriceMinor",
"discountBps",
"quantityMilliUnits",
"rounding",
"totalMinor"
],
"properties": {
"offerId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"acceptedAt": {
"type": "string",
"format": "date-time"
},
"currency": {
"type": "string",
"pattern": "^[A-Z]{3}$"
},
"listUnitPriceMinor": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"chargedUnitPriceMinor": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"discountBps": {
"type": "integer",
"minimum": 0,
"maximum": 10000
},
"quantityMilliUnits": {
"type": "integer",
"minimum": 1,
"maximum": 9007199254740991
},
"rounding": {
"const": "half-up"
},
"totalMinor": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
}
},
"goal": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"value": {
"type": "object",
"additionalProperties": false,
"required": [
"currency",
"amountMinor"
],
"properties": {
"currency": {
"type": "string",
"pattern": "^[A-Z]{3}$"
},
"amountMinor": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
}
}
},
"oneOf": [
{
"required": [
"price"
],
"properties": {
"price": true
}
},
{
"required": [
"goal"
],
"properties": {
"goal": true
}
}
]
}
}
}
},
{
"if": {
"properties": {
"kind": {
"const": "adjustment"
}
}
},
"then": {
"properties": {
"payload": {
"type": "object",
"additionalProperties": false,
"required": [
"assignmentId",
"variantId",
"conversionId",
"adjustmentId",
"currency",
"amountMinor",
"reason",
"proofRefs"
],
"properties": {
"assignmentId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"variantId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"conversionId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"adjustmentId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"currency": {
"type": "string",
"pattern": "^[A-Z]{3}$"
},
"amountMinor": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"reason": {
"enum": [
"refund",
"chargeback",
"correction"
]
},
"proofRefs": {
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"uniqueItems": true,
"maxItems": 100,
"minItems": 1
}
}
}
}
}
},
{
"if": {
"properties": {
"kind": {
"const": "reconciliation"
}
}
},
"then": {
"properties": {
"payload": {
"type": "object",
"additionalProperties": false,
"required": [
"assignmentId",
"variantId",
"conversionId",
"accountingRevision",
"currency",
"state",
"revenueMinor",
"refundsMinor",
"actualCostMinor",
"feesMinor",
"affiliateMinor",
"retainedProfitMinor",
"minimumRetainedProfitMinor",
"payoutStatus",
"proofRefs"
],
"properties": {
"assignmentId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"variantId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"conversionId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"accountingRevision": {
"type": "integer",
"minimum": 1,
"maximum": 9007199254740991
},
"currency": {
"type": "string",
"pattern": "^[A-Z]{3}$"
},
"state": {
"enum": [
"pending",
"reconciled"
]
},
"revenueMinor": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"refundsMinor": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"actualCostMinor": {
"type": [
"integer",
"null"
],
"minimum": 0,
"maximum": 9007199254740991
},
"feesMinor": {
"type": [
"integer",
"null"
],
"minimum": 0,
"maximum": 9007199254740991
},
"affiliateMinor": {
"type": [
"integer",
"null"
],
"minimum": 0,
"maximum": 9007199254740991
},
"retainedProfitMinor": {
"type": [
"integer",
"null"
],
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"minimumRetainedProfitMinor": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"payoutStatus": {
"enum": [
"withheld",
"eligible"
]
},
"proofRefs": {
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"uniqueItems": true,
"maxItems": 100
}
}
}
}
}
}
]
}