mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-10-02 20:57:03 +00:00
Add OpenABTest draft experiment and accounting contracts (#180)
This commit is contained in:
parent
123ba2e39a
commit
d8b3126782
25 changed files with 1410 additions and 12 deletions
460
packages/schemas/schemas/logicsrc-openabtest-event.schema.json
Normal file
460
packages/schemas/schemas/logicsrc-openabtest-event.schema.json
Normal file
|
|
@ -0,0 +1,460 @@
|
|||
{
|
||||
"$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": {
|
||||
"const": "0.1-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",
|
||||
"price"
|
||||
],
|
||||
"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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,291 @@
|
|||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://logicsrc.com/schemas/logicsrc-openabtest-manifest.schema.json",
|
||||
"title": "OpenABTest experiment manifest (0.1 draft)",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"openabtest",
|
||||
"id",
|
||||
"revision",
|
||||
"name",
|
||||
"state",
|
||||
"cohort",
|
||||
"assignment",
|
||||
"variants",
|
||||
"window",
|
||||
"metrics",
|
||||
"guardrails"
|
||||
],
|
||||
"properties": {
|
||||
"openabtest": {
|
||||
"const": "0.1-draft"
|
||||
},
|
||||
"id": {
|
||||
"type": "string",
|
||||
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
|
||||
},
|
||||
"revision": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"maximum": 9007199254740991
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 1000
|
||||
},
|
||||
"state": {
|
||||
"enum": [
|
||||
"draft",
|
||||
"running",
|
||||
"paused",
|
||||
"closed"
|
||||
]
|
||||
},
|
||||
"cohort": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"id",
|
||||
"eligibilityRule",
|
||||
"purchaseScope"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
|
||||
},
|
||||
"eligibilityRule": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 1000
|
||||
},
|
||||
"purchaseScope": {
|
||||
"enum": [
|
||||
"all-referred-purchases",
|
||||
"all-eligible-purchases",
|
||||
"first-eligible-purchase",
|
||||
"custom"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"assignment": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"unit",
|
||||
"authority",
|
||||
"keyVersion",
|
||||
"algorithm",
|
||||
"persistence"
|
||||
],
|
||||
"properties": {
|
||||
"unit": {
|
||||
"enum": [
|
||||
"user",
|
||||
"account",
|
||||
"session",
|
||||
"device",
|
||||
"custom"
|
||||
]
|
||||
},
|
||||
"authority": {
|
||||
"const": "server"
|
||||
},
|
||||
"keyVersion": {
|
||||
"type": "string",
|
||||
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
|
||||
},
|
||||
"algorithm": {
|
||||
"type": "string",
|
||||
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
|
||||
},
|
||||
"persistence": {
|
||||
"const": "sticky"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variants": {
|
||||
"type": "array",
|
||||
"minItems": 2,
|
||||
"maxItems": 100,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"id",
|
||||
"weight",
|
||||
"parameters"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
|
||||
},
|
||||
"weight": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"maximum": 9007199254740991
|
||||
},
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"minProperties": 1,
|
||||
"maxProperties": 50,
|
||||
"propertyNames": {
|
||||
"type": "string",
|
||||
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
|
||||
},
|
||||
"additionalProperties": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"window": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"startsAt",
|
||||
"endsAt"
|
||||
],
|
||||
"properties": {
|
||||
"startsAt": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"endsAt": {
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
}
|
||||
}
|
||||
},
|
||||
"metrics": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"primary",
|
||||
"denominator",
|
||||
"conversion",
|
||||
"profit",
|
||||
"minimumEligiblePerVariant",
|
||||
"minimumObservationSeconds",
|
||||
"winnerPolicy"
|
||||
],
|
||||
"properties": {
|
||||
"primary": {
|
||||
"enum": [
|
||||
"conversion-rate",
|
||||
"retained-profit-per-eligible-visitor"
|
||||
]
|
||||
},
|
||||
"denominator": {
|
||||
"const": "unique-eligible-participants"
|
||||
},
|
||||
"conversion": {
|
||||
"const": "unique-participants-with-confirmed-purchase"
|
||||
},
|
||||
"profit": {
|
||||
"const": "reconciled-net-retained-profit"
|
||||
},
|
||||
"minimumEligiblePerVariant": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"maximum": 9007199254740991
|
||||
},
|
||||
"minimumObservationSeconds": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"maximum": 9007199254740991
|
||||
},
|
||||
"winnerPolicy": {
|
||||
"const": "manual-review"
|
||||
}
|
||||
}
|
||||
},
|
||||
"guardrails": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"preserveAcceptedOffers",
|
||||
"preserveAccruedCommissions",
|
||||
"requireReconciledCostsForPayout",
|
||||
"onBreach"
|
||||
],
|
||||
"properties": {
|
||||
"preserveAcceptedOffers": {
|
||||
"const": true
|
||||
},
|
||||
"preserveAccruedCommissions": {
|
||||
"const": true
|
||||
},
|
||||
"requireReconciledCostsForPayout": {
|
||||
"const": true
|
||||
},
|
||||
"onBreach": {
|
||||
"const": "pause-new-assignments"
|
||||
}
|
||||
}
|
||||
},
|
||||
"economics": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"currency",
|
||||
"minorUnitExponent",
|
||||
"unit",
|
||||
"listUnitPriceMinor",
|
||||
"modeledUnitCostMinor",
|
||||
"minimumRetainedUnitProfitMinor"
|
||||
],
|
||||
"properties": {
|
||||
"currency": {
|
||||
"type": "string",
|
||||
"pattern": "^[A-Z]{3}$"
|
||||
},
|
||||
"minorUnitExponent": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 6
|
||||
},
|
||||
"unit": {
|
||||
"type": "string",
|
||||
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
|
||||
},
|
||||
"listUnitPriceMinor": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 9007199254740991
|
||||
},
|
||||
"modeledUnitCostMinor": {
|
||||
"type": [
|
||||
"integer",
|
||||
"null"
|
||||
],
|
||||
"minimum": 0,
|
||||
"maximum": 9007199254740991
|
||||
},
|
||||
"minimumRetainedUnitProfitMinor": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 9007199254740991
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue