Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions crates/telemetry/src/account_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ pub(crate) fn header_label(key: &str, name: &str, choices: &[(String, String)])
}
}

/// Label for an email key whose domain is empty, so a masked key never shows
/// the `@` that marks it as an address.
const MASKED_NO_DOMAIN: &str = "account";

/// `None` for a named account or a key with no local part to hide.
fn email_cut(key: &str, name: &str) -> Option<String> {
if name != key {
Expand All @@ -236,7 +240,12 @@ fn email_cut(key: &str, name: &str) -> Option<String> {
.split('.')
.find(|part| !part.is_empty())
.unwrap_or("");
Some(format!("@{host}"))
let label = if host.is_empty() {
MASKED_NO_DOMAIN
} else {
host
};
Some(label.to_string())
}

/// A store with four events on two accounts and one skill record, for tests.
Expand Down Expand Up @@ -326,10 +335,10 @@ pub(crate) mod tests {

#[test]
fn an_unnamed_email_account_shows_only_its_domain_name() {
assert_eq!(label("dev@example.com.invalid"), "@example");
assert_eq!(label("a@example.com"), "@example");
assert_eq!(label("dev@.com"), "@com");
assert_eq!(label("dev@"), "@");
assert_eq!(label("dev@example.com.invalid"), "example");
assert_eq!(label("a@example.com"), "example");
assert_eq!(label("dev@.com"), "com");
assert_eq!(label("dev@"), MASKED_NO_DOMAIN);
}

#[test]
Expand All @@ -347,8 +356,8 @@ pub(crate) mod tests {
.map(|k| (k.to_string(), k.to_string()))
.to_vec();
let shown = |key: &str| header_label(key, key, &choices);
assert_eq!(shown("dev@example.com"), "@example (1)");
assert_eq!(shown("ana@example.com"), "@example (2)");
assert_eq!(shown("bo@work.invalid"), "@work");
assert_eq!(shown("dev@example.com"), "example (1)");
assert_eq!(shown("ana@example.com"), "example (2)");
assert_eq!(shown("bo@work.invalid"), "work");
}
}
4 changes: 2 additions & 2 deletions crates/telemetry/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,9 +568,9 @@ mod tests {
let text = summary_text(&p, Some("work@x.io")).unwrap();

// Assert
assert!(text.contains("Account: @x\n"), "{text}");
assert!(text.contains("Account: x\n"), "{text}");
assert!(!text.contains("work@x.io"), "{text}");
assert!(text.matches("@x").count() >= 2, "{text}");
assert!(!text.contains('@'), "{text}");
}

#[test]
Expand Down
6 changes: 3 additions & 3 deletions crates/telemetry/src/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ mod tests {

let text = render(&events, &[], Some(&choices));

assert!(text.contains("@example"), "{text}");
assert!(!text.contains("dev@example.com"), "{text}");
assert!(text.contains("example"), "{text}");
assert!(!text.contains('@'), "{text}");
}

#[test]
Expand All @@ -392,7 +392,7 @@ mod tests {
let text = render(&events, &[], Some(&choices));

assert!(
text.contains("@example (1)") && text.contains("@example (2)"),
text.contains("example (1)") && text.contains("example (2)"),
"{text}"
);
}
Expand Down
4 changes: 2 additions & 2 deletions crates/telemetry/src/tui/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ mod tests {
fn the_view_label_is_the_full_email_unless_the_mask_is_on() {
let view = AccountsView {
shown: "dev@example.com".into(),
masked: "@example".into(),
masked: "example".into(),
..AccountsView::default()
};

assert_eq!(view.label(false), "dev@example.com");
assert_eq!(view.label(true), "@example");
assert_eq!(view.label(true), "example");
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions crates/telemetry/src/tui/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,9 +659,9 @@ mod tests {
)
.unwrap();
assert_eq!(d.accounts.shown, "dev@example.com.br");
assert_eq!(d.accounts.masked, "@example");
assert_eq!(d.accounts.masked, "example");
assert_eq!(d.accounts.label(false), "dev@example.com.br");
assert_eq!(d.accounts.label(true), "@example");
assert_eq!(d.accounts.label(true), "example");
}

/// One event and one telemetry request per machine and account pair. The
Expand Down
4 changes: 2 additions & 2 deletions crates/telemetry/src/tui/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ mod tests {
let mut app = app_with(&[event("claude-opus-5", "alpha", 1.0)]);
if let Some(d) = app.data.as_mut() {
d.accounts.shown = "dev@example.com".to_string();
d.accounts.masked = "@example".to_string();
d.accounts.masked = "example".to_string();
}

let open = screen(&app, 120, 30);
Expand All @@ -1393,7 +1393,7 @@ mod tests {

assert!(open.contains("dev@example.com"), "{open}");
assert!(
masked.contains("@example") && !masked.contains("dev@"),
masked.contains("example") && !masked.contains("dev@"),
"{masked}"
);
}
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/config-keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Some keys may sync between your own machines: `usage.theme`, `usage.maskAccount`
| `hygiene.enabled` | `true` | `true`, `false` | The context hygiene nudge: once the main session passes 250000 tokens, it asks the model to save a handoff and tells you to run `/clear`, then `/playbook:handoff load` if it did not load. The automatic load after `/clear` happens only when the `SessionStart` hook is installed and Claude Code runs it. It never clears or compacts for you. See [hooks](../internals/01-launcher-and-hooks.md#userpromptsubmit). | You do not want the nudge to save a handoff and `/clear`. |
| `docs.convert` | `auto` | `auto`, `off` | Whether playbook suggests `playbook doc read` for PDF and Office files, when a converter is found. The command itself works whenever a converter is found. | You do not want hints to use `playbook doc read` for PDF and Office files. |
| `docs.anydocPath` | empty | a path, or empty | An `anydoc` program to run instead of the bundled converter. It wins over the bundled one, and playbook does not check that it works offline. Empty means the bundled `pbdoc`, then the first `anydoc` on PATH. | You want your own converter, not the bundled `pbdoc`. |
| `usage.maskAccount` | `false` | `true`, `false` | Whether the `pbtop` header, and the account table and `Account:` line of `--summary`, cut an unnamed email account to `@` and its domain name (`dev@example.com` shows as `@example`; two on one domain show as `@example (1)` and `@example (2)`), so a screenshot leaks no address. `--json` is never masked. `false` shows the full email, or the name you gave the account. `o` flips it inside the view and stores the choice in the `playbook-telemetry` app tier. After that, the stored choice is used instead of this key on that machine, and `o` is the way to change it. Without a config store the choice lasts for the run. | You share `pbtop` screenshots and want no email address in them. |
| `usage.maskAccount` | `false` | `true`, `false` | Whether the `pbtop` header, and the account table and `Account:` line of `--summary`, cut an unnamed email account to its domain name with no `@` (`dev@example.com` shows as `example`; two on one domain show as `example (1)` and `example (2)`), so a screenshot shows no address. `--json` is never masked. `false` shows the full email, or the name you gave the account. `o` flips it inside the view and stores the choice in the `playbook-telemetry` app tier. After that, the stored choice is used instead of this key on that machine, and `o` is the way to change it. Without a config store the choice lasts for the run. | You share `pbtop` screenshots and want no email address in them. |
| `usage.weekStart` | `monday` | `monday`, `sunday`, `saturday` | The first day of the week for the `week` and `last-week` ranges of `playbook usage` (view, `--json`, `--summary`). Days are in the chosen time zone, local unless `usage.timeZone` says `utc`. | Your week does not start on Monday. |
| `usage.timeZone` | `local` | `local`, `utc` | The time zone `playbook usage` shows times in and groups days by. `local` is your machine's zone, daylight saving included. `utc` uses UTC. `--utc` and `--local` beat the `PLAYBOOK_TELEMETRY_TZ` environment variable, which beats this key. | You want usage days in UTC, not your local zone. |
| `usage.theme` | `default` | `default`, `spectrum`, `dark`, `light`, `mono` | The color theme `playbook usage` starts with. `t` cycles the themes inside the view. `NO_COLOR` forces `mono`. | You want another color theme in `playbook usage` and `pbtop`. |
Expand Down
Loading