Skip to content

Task 7.1: Publisher analytics endpoint #17

@taariq

Description

@taariq

What

Endpoint for publishers to view their template stats.

Files to touch

  • serenai-x402/gateway/src/routes/analytics.rs — extend existing or create

Endpoint

GET /api/publishers/me/analytics

Returns

  • Total invocations (by day/week/month)
  • Revenue earned
  • Error rates
  • Average latency
  • Top consuming agents (by invocation count)

Response

{
  "period": "30d",
  "totalInvocations": 1234,
  "successfulInvocations": 1200,
  "errorRate": 0.027,
  "revenue": "123.45",
  "avgLatencyMs": 2340,
  "topAgents": [
    { "wallet": "0x...", "invocations": 456 }
  ],
  "byDay": [
    { "date": "2025-12-28", "invocations": 45, "revenue": "4.50" }
  ]
}

How to test

  1. Create invocations, verify counts
  2. Test date range filtering
  3. Test empty state (no invocations)

References

  • Design spec: docs/plans/00_design_spec.md

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions