Skip to content

Commit ebfe326

Browse files
committed
Clarify raw API key rotation policy
1 parent 898211d commit ebfe326

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,11 @@ experiments complete <id> Ship the winner
6363
whoami Show current account & tier
6464
feedback --message "..." Send product/process feedback
6565
logout Clear saved local auth (does not revoke remote sessions)
66-
revoke-key Revoke and regenerate API key
66+
revoke-key Rotate a saved raw API key fallback
6767
```
6868

6969
The CLI is agent-session-first. It stores a renewable Agent Analytics session locally after browser approval and uses that bearer auth for API calls. Raw `aak_*` API keys still work, but only as an advanced/manual fallback for direct HTTP-style usage.
70+
Raw API-key rotation is not available to scoped agent sessions; manage keys from the dashboard or from a CLI login created with `login --token`.
7071

7172
Bounce metrics (`insights`, `pages`, `sessions`) treat a session as a bounce when it has only non-interactive events:
7273
`page_view`, `$impression`, `$scroll_depth`, `$error`, `$time_on_page`, `$performance`, `$web_vitals`.

bin/cli.mjs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -935,8 +935,23 @@ function cmdDeleteAccount() {
935935
log('');
936936
}
937937

938-
const cmdRevokeKey = withApi(async (api) => {
939-
const data = await api.revokeKey();
938+
async function cmdRevokeKey() {
939+
const auth = getStoredAuth();
940+
if (!auth) {
941+
error('Not logged in. Run: npx @agent-analytics/cli login --token <api-key>');
942+
}
943+
if (auth.access_token || auth.refresh_token) {
944+
error('revoke-key only rotates a saved raw API key. Manage API keys from https://app.agentanalytics.sh/settings or log in with --token for the API-key fallback.');
945+
}
946+
947+
const api = createApiClient(auth);
948+
let data;
949+
try {
950+
data = await api.revokeKey();
951+
} catch (err) {
952+
error(err.message);
953+
}
954+
940955
setApiKey(data.api_key);
941956

942957
warn('Old API key revoked');
@@ -945,7 +960,7 @@ const cmdRevokeKey = withApi(async (api) => {
945960
log(`${YELLOW}${data.api_key}${RESET}`);
946961
log(`${DIM}Saved to ${getConfigFile()}${RESET}\n`);
947962
warn('Update your agent with this new key!');
948-
});
963+
}
949964

950965
const cmdFeedback = withApi(async (api, opts = {}) => {
951966
if (!opts.message) {
@@ -1265,7 +1280,7 @@ ${BOLD}EXPERIMENTS${RESET} ${DIM}— A/B testing your agent can actually use${RE
12651280
12661281
${BOLD}ACCOUNT${RESET}
12671282
${CYAN}whoami${RESET} Show current account & tier
1268-
${CYAN}revoke-key${RESET} Revoke and regenerate API key
1283+
${CYAN}revoke-key${RESET} Rotate a saved raw API key fallback
12691284
${CYAN}feedback${RESET} Send product/process feedback
12701285
${CYAN}project${RESET} <id> Get single project details
12711286
${CYAN}update${RESET} <id> Update a project (--name, --origins)

0 commit comments

Comments
 (0)