Skip to main content
Analytics events track when users view project usage data, metrics, and statistics. These events are triggered whenever analytics dashboards or API endpoints are accessed.

analytics.view

Triggered when a user accesses project analytics data including request counts, latency metrics, or safety statistics. This event captures the time range and granularity of the data being viewed.

Event Schema

action
string
required
Always set to "analytics.view"
actor
object
required
The user viewing analytics data
targets
array
required
The project whose analytics are being viewed
context
object
required
metadata
object
required

Example

{
  "action": "analytics.view",
  "occurredAt": "2024-11-02T19:15:00.000Z",
  "version": 1,
  "actor": {
    "type": "user",
    "id": "user_01JBKQ8Z...",
    "name": "Alice Johnson",
    "metadata": {
      "first_name": "Alice",
      "last_name": "Johnson",
      "email": "alice@company.com",
      "impersonator_email": "",
      "impersonator_reason": ""
    }
  },
  "targets": [
    {
      "type": "project",
      "id": "proj_abc123",
      "name": "Production API",
      "metadata": {
        "name": "Production API",
        "organization_id": "org_xyz789"
      }
    }
  ],
  "context": {
    "location": "203.0.113.1",
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)"
  },
  "metadata": {
    "source": "/projects/proj_abc123/analytics",
    "start_date": "2024-10-26T00:00:00.000Z",
    "end_date": "2024-11-02T23:59:59.999Z",
    "interval": "day"
  }
}

Common Patterns

Date Range Limitations

Analytics queries are limited to a 30-day date range. Users querying longer periods receive validation errors before the audit event is created.

Multiple Events Per Page View

Each analytics page view generates three separate audit events:
  1. Summary statistics - Overall totals, averages, and percentiles (empty interval field)
  2. Requests over time - Time-series chart showing request counts (includes interval)
  3. Latency over time - Time-series chart showing response times (includes interval)
All three events share the same start_date and end_date but differ in their interval values.

Interval Selection

The interval field is automatically determined based on the date range:
  • Date ranges ≤ 7 days: interval set to "hour" for hourly granularity
  • Date ranges > 7 days: interval set to "day" for daily granularity
  • Summary views: interval is empty (no time-series grouping)
Users do not manually select the interval—it’s automatically chosen based on the selected date range to provide appropriate chart detail.
Analytics events track data access for compliance and security auditing. Organizations can use these events to monitor which team members are viewing usage metrics and when.

API Key Filtering

When analytics are filtered by a specific API key, the same event structure applies. The project target remains the project containing the API key, and the date range parameters reflect the filtered query.