Skip to content

[Feature Request] Programmatic API Access for AnalyticsΒ #253

@airano-ir

Description

@airano-ir

[Feature Request] Programmatic API Access for tRPC Analytics Endpoints

Problem

tRPC analytics endpoints currently require browser session cookies, making programmatic access impossible:

# βœ… Track API works with credentials
POST /track
Headers: openpanel-client-id, openpanel-client-secret

# ❌ Analytics requires manual browser cookie
GET /trpc/overview.stats
Cookie: session=xxx  # Must copy from browser DevTools

Impact

This blocks many important use cases:

  • πŸ€– AI integrations (MCP servers, ChatGPT, Claude)
  • πŸ”„ CI/CD analytics pipelines
  • πŸ“Š Custom dashboards and reporting
  • πŸ“± Mobile/desktop applications
  • πŸ”— Data warehouse ETL
  • ⏰ Scheduled reports and alerts

Currently, there's no way to access analytics programmatically without manually managing browser cookies.

Proposed Solution

Add an endpoint to exchange API credentials for session token:

POST /api/auth/client-login
Body: {
  "clientId": "xxx",
  "clientSecret": "xxx"
}

Response:
  Set-Cookie: session=xxx; Max-Age=86400
  {"success": true, "expiresIn": 86400}

This would:

  • βœ… Work with existing tRPC infrastructure
  • βœ… Allow automatic session refresh
  • βœ… Enable secure programmatic access
  • βœ… Require minimal code changes

Use Case Example

# MCP Server for AI Assistants (currently blocked)
client = OpenPanel(client_id="xxx", client_secret="xxx")
stats = client.get_overview_stats(project_id="my-project", range="7d")
# Should work without manual browser session!

Current Workaround (Not Sustainable)

# Users manually copy session from browser
OPENPANEL_SESSION_COOKIE=xxx

# Problems:
# - Expires unpredictably
# - Breaks when user logs out
# - Security risk
# - Not scalable

Alternative Approaches

  1. Client login endpoint (recommended - easiest)
  2. Bearer token authentication (industry standard)
  3. Dedicated REST API (most flexible, more work)

Similar Projects

  • Plausible: Authorization: Bearer {API_KEY}
  • PostHog: Personal API tokens
  • Mixpanel: Project token authentication

Questions

  1. Is there already a way to do this we're missing?
  2. Which approach would you prefer?
  3. Open to PRs? (Happy to contribute!)
  4. Any timeline/priority?

Real-World Context

We built an OpenPanel MCP server to let Claude AI access analytics. Everything works except analytics endpoints due to session cookie requirement. This affects:

  • Self-hosted OpenPanel users who want automation
  • Integration developers
  • Teams building custom analytics workflows

Thank You!

Love OpenPanel! πŸš€ This feature would unlock massive adoption in AI/automation space. Happy to help with implementation, testing, or documentation.


Priority: High (blocking production use)
Willing to contribute: Yes
Use case: MCP Server + AI integrations

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions