Summary
Two related defects in the X-PostGuard-Client-Version header that the launchevent's Yivi dialog sends to PKG and Cryptify. Both silently break per-client metrics — sends still succeed but the dashboards mis-attribute them.
1. Wrong client-id token (regression of PR #11)
src/yivi-dialog/yivi-dialog.ts:135 hardcodes:
"X-PostGuard-Client-Version": `Outlook,1.0,pg4outlook,${ADDIN_VERSION}`,
The PKG (postguard/pg-pkg/src/middleware/metrics.rs) keys its Prometheus counter on the third comma-separated field. Org convention is:
pg4ol for Outlook (this addon)
pg4tb for Thunderbird
pg4outlook was the v0.2.0 rewrite bug that PR #11 fixed in the taskpane, and the dialog runtime has reintroduced it. The taskpane code (src/lib/pkg-client.ts:13) already exposes CLIENT_ID = "pg4ol" and a clientHeaders() helper — the dialog should use the same.
The dialog header is also missing the X-Cryptify-Source: outlook header that clientHeaders() adds; without it, cryptify's detect_channel mis-classifies dialog-flow uploads (its origin check on addin.*.postguard.eu falls back to the website channel).
2. Stale ADDIN_VERSION = "0.1.0"
Hardcoded in three files, never matched the real package version:
src/yivi-dialog/yivi-dialog.ts:22
src/taskpane/compose-view.ts:39
src/taskpane/read-view.ts:34
package.json is at 0.4.0 and the open release-please PR (#95) bumps to 0.5.0. The fourth field of the client-version header is meant to track the deployed extension version; right now every release reports as 0.1.0, so the PKG metric cannot distinguish current vs. historical clients.
Suggested fix
- In
src/yivi-dialog/yivi-dialog.ts, replace the hardcoded headers object on line 134-136 with a call to clientHeaders(ADDIN_VERSION) from ../lib/pkg-client. (The import already brings in PKG_URL/CRYPTIFY_URL/POSTGUARD_WEBSITE_URL from that module.)
- Replace the three
const ADDIN_VERSION = "0.1.0" declarations with a single source of truth. Two options:
- Import the version from
package.json via webpack's DefinePlugin / EnvironmentPlugin (same mechanism used for PKG_URL etc.). Add process.env.ADDIN_VERSION set from require('./package.json').version.
- Or declare
export const ADDIN_VERSION = "<version>" in src/lib/pkg-client.ts and update it on release. Less reliable; release-please can probably bump it via extra-files config though.
- Optionally: extract
recipientsKey, guessContentType, and the Office.js promise wrappers into shared lib modules. Separate issue — see follow-up.
Verification
grep -rn "pg4outlook\|pg4ol" src — should only return pg4ol (in pkg-client.ts).
grep -rn "ADDIN_VERSION" src — all references should resolve to a single constant matching package.json.
- Build + lint + typecheck + manifest validate all pass.
- Manual smoke test: trigger the one-click flow (Encrypt-on-send via the dialog), confirm the network tab shows
pg4ol,<current-version> in the header on both PKG and Cryptify requests, and that X-Cryptify-Source: outlook is present on the Cryptify upload.
/dobby
Summary
Two related defects in the
X-PostGuard-Client-Versionheader that the launchevent's Yivi dialog sends to PKG and Cryptify. Both silently break per-client metrics — sends still succeed but the dashboards mis-attribute them.1. Wrong client-id token (regression of PR #11)
src/yivi-dialog/yivi-dialog.ts:135hardcodes:The PKG (
postguard/pg-pkg/src/middleware/metrics.rs) keys its Prometheus counter on the third comma-separated field. Org convention is:pg4olfor Outlook (this addon)pg4tbfor Thunderbirdpg4outlookwas the v0.2.0 rewrite bug that PR #11 fixed in the taskpane, and the dialog runtime has reintroduced it. The taskpane code (src/lib/pkg-client.ts:13) already exposesCLIENT_ID = "pg4ol"and aclientHeaders()helper — the dialog should use the same.The dialog header is also missing the
X-Cryptify-Source: outlookheader thatclientHeaders()adds; without it, cryptify'sdetect_channelmis-classifies dialog-flow uploads (its origin check onaddin.*.postguard.eufalls back to the website channel).2. Stale
ADDIN_VERSION = "0.1.0"Hardcoded in three files, never matched the real package version:
src/yivi-dialog/yivi-dialog.ts:22src/taskpane/compose-view.ts:39src/taskpane/read-view.ts:34package.jsonis at0.4.0and the open release-please PR (#95) bumps to0.5.0. The fourth field of the client-version header is meant to track the deployed extension version; right now every release reports as0.1.0, so the PKG metric cannot distinguish current vs. historical clients.Suggested fix
src/yivi-dialog/yivi-dialog.ts, replace the hardcoded headers object on line 134-136 with a call toclientHeaders(ADDIN_VERSION)from../lib/pkg-client. (The import already brings inPKG_URL/CRYPTIFY_URL/POSTGUARD_WEBSITE_URLfrom that module.)const ADDIN_VERSION = "0.1.0"declarations with a single source of truth. Two options:package.jsonvia webpack'sDefinePlugin/EnvironmentPlugin(same mechanism used forPKG_URLetc.). Addprocess.env.ADDIN_VERSIONset fromrequire('./package.json').version.export const ADDIN_VERSION = "<version>"insrc/lib/pkg-client.tsand update it on release. Less reliable; release-please can probably bump it viaextra-filesconfig though.recipientsKey,guessContentType, and the Office.js promise wrappers into shared lib modules. Separate issue — see follow-up.Verification
grep -rn "pg4outlook\|pg4ol" src— should only returnpg4ol(inpkg-client.ts).grep -rn "ADDIN_VERSION" src— all references should resolve to a single constant matchingpackage.json.pg4ol,<current-version>in the header on both PKG and Cryptify requests, and thatX-Cryptify-Source: outlookis present on the Cryptify upload./dobby