Skip to content

feat(metrics): tag cryptify uploads with X-Cryptify-Source: website#228

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: website#228
rubenhensen merged 1 commit into
mainfrom
feat/x-cryptify-source-header

Conversation

@rubenhensen
Copy link
Copy Markdown
Contributor

Summary

Sets X-Cryptify-Source: website on the PostGuard SDK so cryptify's per-channel upload metrics (encryption4all/cryptify#102) classify this site deterministically rather than via the Origin-host fallback.

Why

Cryptify's detect_channel checks the Origin header before falling back to User-Agent substring matching. The Outlook add-in is served from addin.*.postguard.eu, which matches cryptify's contains("postguard.") rule and shadows the User-Agent "outlook" check — so without explicit X-Cryptify-Source headers, Outlook traffic would be miscounted as website (and dev Outlook traffic as staging-website). Setting the header explicitly on each client side removes the ambiguity, and dropping reliance on Origin lets us merge staging-website into website if we ever want to.

Test plan

  • Type-check clean (npx tsc --noEmit).
  • In a dev preview build, upload a file, then in Cockpit Grafana Explore on the custom metrics DS run cryptify_uploads_total{channel="website"} — value should increment by 1.

Sets X-Cryptify-Source on the PostGuard SDK so cryptify (≥0.1.27+,
encryption4all/cryptify#102) classifies uploads from this site
deterministically rather than via the Origin-host fallback.

Origin-based detection collided with the Outlook add-in, which is
served from addin.*.postguard.eu — that host matches cryptify's
`contains("postguard.")` rule and shadows the User-Agent "outlook"
check. With the explicit header, the website always reports
`channel="website"` regardless of the deploy host.
@rubenhensen
Copy link
Copy Markdown
Contributor Author

/dobby review

@rubenhensen rubenhensen merged commit 70ee865 into main May 18, 2026
7 checks passed
@rubenhensen rubenhensen deleted the feat/x-cryptify-source-header branch May 18, 2026 17:21
@dobby-coder
Copy link
Copy Markdown
Contributor

dobby-coder Bot commented May 18, 2026

This agent sees the request, sir! Reviewing the PR now — though this agent notes it appears already merged, so will post findings as a post-merge review.

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.

Review (post-merge)

The PR was already merged by the time this agent picked up the request, but here is the verdict for the record.

Verdict: LGTM ✅

The diff is exactly what the description promises: one headers: { 'X-Cryptify-Source': 'website' } entry on the shared PostGuard client in src/lib/postguard.ts. The inline comment captures the why (Origin-header collision with the Outlook add-in on *.postguard.eu).

What this agent checked

  • Diff matches the PR description; no other files touched.
  • All CI green at merge time (Build amd64/arm64, Lint, Svelte Check, Conventional Commit).
  • pg is the single shared client instance, so every cryptify upload path (SendButton.svelte and any future caller) inherits the header — no per-call sprinkling needed.
  • Placement before the conditional uploadChunkSize spread is fine; key ordering is irrelevant here and the explicit literal is easy to grep for.

Nits (non-blocking, only if you ever touch this again)

  • The header value 'website' is a free-form magic string shared with cryptify's detect_channel. If the set of channels grows, exporting it as a constant from a shared pg-js/cryptify type would prevent drift. Not worth a follow-up for one literal.
  • Unchecked test-plan box: the "Cockpit Grafana cryptify_uploads_total{channel="website"} increments by 1" verification still needs doing on the live deploy. Worth running through once after the next release cuts.

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