← Receivers

analytics:revenue

analytics family

Workspace inference cost and revenue rollup over a date window — cost by model, cost per resolution, and a NAMED list of the figures that are not wired yet

Effect
ask
Awaits an outcome — the call returns the response below.
Caller
manage_workspace
The class of authority the caller must already hold, decided from the attested context with no round trip.
Authority action
read_revenue
Also gated per node — the caller must be permitted this action over the workspace it names.
Cost
free
What one call costs, so you can budget before acting.
Reversible
yes
The effect can be undone by a later call.
Idempotent
yes
Safe to retry as-is.
Version
1.0.0
Pin this to keep a contract stable; additive bumps never break callers.

Send it with your agent

One click hands your coding agent a prompt that registers the substrate, reads this contract, and makes the call. Launch opens the app; the others copy the prompt.

Claude Code
Codex
Cursor
Gemini CLI
Claude Desktop
ChatGPT
curl -X POST https://one.ie/api/ask/analytics:revenue \
  -H "Authorization: Bearer $ONE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"data": { "workspace": "one" }}'

The key is never in a link. npx -y @oneie/cli login writes it to ~/.config/oneie/key on your machine.

Request

Validated before dispatch — an invalid payload is refused with the fix, never half-applied.

  • workspace string optional Workspace slug; defaults to the attested caller's.
  • from number optional Window start, epoch ms. Default: 30 days before `to`. CLAMPED to at most 366 days before `to` — the window actually read comes back as `from`.
  • to number optional Window end, epoch ms. Default: now.

Response

What comes back from the call.

  • ok boolean
  • workspace string
  • from number The window actually read, after the clamp — compare it against what you asked for
  • to number
  • totalTokens number
  • totalCost number Inference cost in credits/100000, from credit_burns
  • costPerResolution number totalCost / journey-complete events; 0 when there were none
  • revenue number
  • ltv number
  • tokensByAgent object[] By MODEL, ranked by cost, top 30
  • tokensBySkill object[]
  • attribution any[]
  • pending string[] THE FIELDS WHOSE ZERO IS NOT A MEASUREMENT — no signal carries a skill field and payment events do not reach this rollup yet, so tokensBySkill/revenue/attribution are empty by wiring, not by finding. Read revenue:0 as 'unbuilt', never as 'earned nothing'.
  • error string no_db | workspace required | forbidden

Traffic

Every call to analytics:revenue, counted where it is dispatched — over HTTP or in-process alike. Aggregate only — no actor, no payload, no workspace.

Counting…

Wiring

Every place in the open source that names analytics:revenue, and the file that answers it. Read from the tree at build time — a receiver is reached by NAME through one door, so there is no import edge to follow and a grep is the honest shape of the question. Structure, not volume — the count is in Traffic above.

Called from

API route 3
  • one.ie/web/src/lib/analytics/revenue.ts:33
  • one.ie/web/src/lib/receiver-index.generated.ts:27
  • one.ie/web/src/pages/api/analytics/revenue.ts:11

Answered by

analytics:revenue one.ie/web/src/lib/resolvers/analytics.ts:41 Dispatched through POST /api/ask/analytics:revenue, after the envelope validates the payload.
JSON Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "workspace": {
      "description": "Workspace slug; defaults to the attested caller's.",
      "type": "string"
    },
    "from": {
      "description": "Window start, epoch ms. Default: 30 days before `to`. CLAMPED to at most 366 days before `to` — the window actually read comes back as `from`.",
      "type": "number"
    },
    "to": {
      "description": "Window end, epoch ms. Default: now.",
      "type": "number"
    }
  }
}
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "ok": {
      "type": "boolean"
    },
    "workspace": {
      "type": "string"
    },
    "from": {
      "description": "The window actually read, after the clamp — compare it against what you asked for",
      "type": "number"
    },
    "to": {
      "type": "number"
    },
    "totalTokens": {
      "type": "number"
    },
    "totalCost": {
      "description": "Inference cost in credits/100000, from credit_burns",
      "type": "number"
    },
    "costPerResolution": {
      "description": "totalCost / journey-complete events; 0 when there were none",
      "type": "number"
    },
    "revenue": {
      "type": "number"
    },
    "ltv": {
      "type": "number"
    },
    "tokensByAgent": {
      "description": "By MODEL, ranked by cost, top 30",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string"
          },
          "tokens": {
            "type": "number"
          },
          "cost": {
            "type": "number"
          }
        },
        "required": [
          "label",
          "tokens",
          "cost"
        ]
      }
    },
    "tokensBySkill": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string"
          },
          "tokens": {
            "type": "number"
          },
          "cost": {
            "type": "number"
          }
        },
        "required": [
          "label",
          "tokens",
          "cost"
        ]
      }
    },
    "attribution": {
      "type": "array",
      "items": {}
    },
    "pending": {
      "description": "THE FIELDS WHOSE ZERO IS NOT A MEASUREMENT — no signal carries a skill field and payment events do not reach this rollup yet, so tokensBySkill/revenue/attribution are empty by wiring, not by finding. Read revenue:0 as 'unbuilt', never as 'earned nothing'.",
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "error": {
      "description": "no_db | workspace required | forbidden",
      "type": "string"
    }
  },
  "required": [
    "ok"
  ]
}