Skip to content

feat(metrics): tag cryptify uploads with X-Cryptify-Source: thunderbird#121

Merged
rubenhensen merged 1 commit into
mainfrom
feat/x-cryptify-source-header
May 18, 2026
Merged

feat(metrics): tag cryptify uploads with X-Cryptify-Source: thunderbird#121
rubenhensen merged 1 commit into
mainfrom
feat/x-cryptify-source-header

Conversation

@rubenhensen
Copy link
Copy Markdown
Contributor

Summary

Adds X-Cryptify-Source: thunderbird to PG_CLIENT_HEADER so cryptify's per-channel upload metrics (encryption4all/cryptify#102) classify this add-in deterministically rather than via the User-Agent substring fallback.

Why

cryptify's detect_channel walks: explicit X-Cryptify-Source → API auth → Origin substring → User-Agent substring. Thunderbird WebExtensions don't always present a stable Origin header (it can be moz-extension://<uuid> or null depending on the call site), so the existing path relied on the last-resort User-Agent substring. Setting the header explicitly here removes any environment-dependent ambiguity and is symmetric with parallel PRs in postguard-website and postguard-outlook-addon.

Test plan

  • npx tsc --noEmit clean.
  • In a dev Thunderbird with this build loaded, send an encrypted attachment.
  • In Cockpit Grafana Explore on the custom metrics DS: cryptify_uploads_total{channel="thunderbird"} should increment by 1.

Adds X-Cryptify-Source: thunderbird to PG_CLIENT_HEADER so cryptify's
per-channel upload metrics (encryption4all/cryptify#102) classify this
add-in deterministically rather than via the User-Agent substring
fallback.

Thunderbird WebExtensions don't always present a stable Origin
(can be `moz-extension://<uuid>` or null), and the User-Agent fallback
is the last layer of cryptify's detect_channel. Setting the explicit
header at the source removes any environment-dependent ambiguity and is
symmetric with parallel PRs in postguard-website and
postguard-outlook-addon.
@rubenhensen
Copy link
Copy Markdown
Contributor Author

/dobby review

@rubenhensen rubenhensen merged commit 5303710 into main May 18, 2026
3 checks passed
@rubenhensen rubenhensen deleted the feat/x-cryptify-source-header branch May 18, 2026 17:20
Copy link
Copy Markdown
Contributor

@dobby-coder dobby-coder Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing post-merge — change looks correct.

  • Single new entry on PG_CLIENT_HEADER; header value matches the channel string consumed by detect_channel per the linked cryptify#102.
  • PG_CLIENT_HEADER is reused for both pgClientHeader (passed to the popup) and headers on the cryptify upload call (background.ts:399, :616), so the new header rides along on the upload path without any further plumbing.
  • Code comment justifying the explicit header (vs. the Origin/User-Agent fallback) is on the right side of the WHY-not-WHAT line — keeps it.
  • Symmetric with the website and Outlook PRs as described, which is what makes the metric meaningful.

Test plan boxes 2 and 3 are manual (live Thunderbird + Grafana) — fine for a header-only change; no realistic unit-test surface here.

@dobby-coder
Copy link
Copy Markdown
Contributor

dobby-coder Bot commented May 18, 2026

Dobby sees the review request! This agent will take a quick look at the changes, even though the PR is already merged — better late than never.

@dobby-coder
Copy link
Copy Markdown
Contributor

dobby-coder Bot commented May 18, 2026

Post-merge review

Already merged and approved, but the bot took a look anyway:

  • Diff scope: 5 lines, one file. Adds X-Cryptify-Source: thunderbird to the shared PG_CLIENT_HEADER map in src/background/background.ts:172.
  • Propagation: the same map is passed into the encryption path (pgClientHeader arg to runBeforeSendEncryption at line 399) and the decryption popup config at line 616, so the header rides every cryptify call this add-in makes — encrypt upload and decrypt fetch.
  • Symmetry: matches the parallel changes in postguard-website#228 and postguard-outlook-addon#96, and aligns with cryptify#102's detect_channel priority order (explicit header beats Origin/UA fallbacks).
  • Build: npx tsc --noEmit clean against 5303710. CI ran green on merge.
  • Risk: zero. Header is additive, no existing key collides.

LGTM. No follow-up needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant