-
Notifications
You must be signed in to change notification settings - Fork 277
Open
Description
[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 DevToolsImpact
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 scalableAlternative Approaches
- Client login endpoint (recommended - easiest)
- Bearer token authentication (industry standard)
- Dedicated REST API (most flexible, more work)
Similar Projects
- Plausible:
Authorization: Bearer {API_KEY} - PostHog: Personal API tokens
- Mixpanel: Project token authentication
Questions
- Is there already a way to do this we're missing?
- Which approach would you prefer?
- Open to PRs? (Happy to contribute!)
- 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
Labels
No labels