You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@devlake.apache.org by "salim8898 (via GitHub)" <gi...@apache.org> on 2026/07/07 12:36:46 UTC

[I] [Bug][Plugin/ClaudeCode] Claude Code plugin fails for Claude Console organizations — wrong Analytics API endpoint [devlake]

salim8898 opened a new issue, #8977:
URL: https://github.com/apache/devlake/issues/8977

   ### Search before asking
   
   - [x] I had searched in the [issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and found no similar issues.
   
   
   ### What happened
   
   When using a Claude Console Admin API key (`sk-ant-admin01-...`), the connection test passes but data collection fails with:
   permission_error: Missing required scopes. Got: ['api:admin'] Needed: ['read:analytics']
   
   The plugin calls these **Claude Enterprise** endpoints which require `read:analytics` scope on an `sk-ant-api01-...` key (only available to Claude Enterprise / `claude.ai` customers):
   - `v1/organizations/analytics/users`
   - `v1/organizations/analytics/summaries`
   - `v1/organizations/analytics/connectors`
   
   **Claude Console** organizations (`platform.claude.com`) use a different API entirely:
   - `v1/organizations/usage_report/claude_code` (query param: `starting_at` instead of `date`)
   
   Claude Console Admin keys (`sk-ant-admin01-...`) have full access to the Console endpoint but the plugin never calls it, so Console orgs have no way to collect analytics data.
   
   **API differences:**
   
   | | Enterprise API | Console API |
   |---|---|---|
   | Endpoint | `v1/organizations/analytics/users` | `v1/organizations/usage_report/claude_code` |
   | Date param | `date` | `starting_at` |
   | User field | `user.id` / `user.email_address` | `actor.type` + `actor.email_address` |
   | Sessions | `claude_code_metrics.core_metrics.distinct_session_count` | `core_metrics.num_sessions` |
   | Commits | `claude_code_metrics.core_metrics.commit_count` | `core_metrics.commits_by_claude_code` |
   | Lines added | `claude_code_metrics.core_metrics.lines_of_code.added_count` | `core_metrics.lines_of_code.added` |
   | Tool accepted | `tool_actions.edit_tool.accepted_count` | `tool_actions.edit_tool.accepted` |
   | Chat metrics | Yes | No |
   | Model cost breakdown | No | Yes |
   
   Pagination envelope (`data`, `has_more`, `next_page`) is identical across both APIs.
   
   References:
   - [Claude Code Analytics API (Console)](https://docs.anthropic.com/en/api/claude-code-analytics-api)
   - [Create an Admin API key](https://docs.anthropic.com/en/docs/manage-claude/admin-api-keys)
   
   ### What do you expect to happen
   
   Organizations using Claude Console (`platform.claude.com`) with `sk-ant-admin01-...` Admin API keys should be able to collect Claude Code analytics data via `v1/organizations/usage_report/claude_code`.
   
   Suggested fix: detect API type from key prefix (`sk-ant-admin01-` = Console, `sk-ant-api01-` = Enterprise) or add an explicit `ApiType` field to the connection model. For Console orgs, the `analytics/summaries` and `analytics/connectors` collectors should be skipped gracefully since those endpoints have no Console equivalent. All core Claude Code metrics (sessions, commits, PRs, lines of code, tool actions) are available in the Console API and can map to the existing `ClaudeCodeUserActivity` model.
   
   ### How to reproduce
   
   1. Create a Claude Console Admin API key at `platform.claude.com/settings/admin-keys` (key starts with `sk-ant-admin01-`)
   2. In DevLake, go to Connections → Claude Code → create a new connection
   3. Paste the `sk-ant-admin01-...` key and fill in the Organization ID
   4. Click **Test Connection** — it succeeds
   5. Add a scope and trigger a data sync
   6. Sync fails with:
   permission_error: Missing required scopes. Got: ['api:admin'] Needed: ['read:analytics']
   
   
   
   **Environment:**
   - DevLake version: v1.0.3-beta13
   - Anthropic account type: Claude Console (`platform.claude.com`)
   - Admin key prefix: `sk-ant-admin01-...`
   
   ### Anything else
   
   _No response_
   
   ### Version
   
   v1.0.3-beta13
   
   ### Are you willing to submit PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@devlake.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug][Plugin/ClaudeCode] Claude Code plugin fails for Claude Console organizations - wrong Analytics API endpoint [devlake]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed issue #8977: [Bug][Plugin/ClaudeCode] Claude Code plugin fails for Claude Console organizations - wrong Analytics API endpoint
URL: https://github.com/apache/devlake/issues/8977


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug][Plugin/ClaudeCode] Claude Code plugin fails for Claude Console organizations - wrong Analytics API endpoint [devlake]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #8977:
URL: https://github.com/apache/devlake/issues/8977#issuecomment-5555857702

   This issue has been automatically marked as stale because it has been inactive for 60 days. It will be closed in next 7 days if no further activity occurs.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug][Plugin/ClaudeCode] Claude Code plugin fails for Claude Console organizations - wrong Analytics API endpoint [devlake]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #8977:
URL: https://github.com/apache/devlake/issues/8977#issuecomment-5649740763

   This issue has been closed because it has been inactive for a long time. You can reopen it if you encounter the similar problem in the future.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org