mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-12-02 17:13:33 +01:00
feat(logging): label billing routes and checkout outcomes
Billing API calls and Stripe return pages were logged as route "other", so the purchase funnel could only be read from Stripe. Give them fixed labels in the app, Nginx and the collector allowlist, and record the ?billing= outcome (success, cancelled, portal) on edge requests. Only fixed values are kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d34df81c8c
commit
4099953d8a
5 files changed
+41
-3
No files matched your search
@@ -97,6 +97,19 @@ describe("bounded request monitoring", function () {
|
||||
const labels = new Set(Array.from({ length: 10000 }, (_, i) => requestRoute(`/unknown-${i}/private-${i}`, "api")));
|
||||
expect([...labels]).to.deep.equal(["other"]);
|
||||
expect(requestRoute("/healthcheck", "streamer")).to.equal("/healthcheck");
|
||||
const { LOG_ROUTES } = require("../src/core/log-diagnostic-schema");
|
||||
const nginx = require("fs").readFileSync(require("path").join(__dirname, "../deploy/nginx/anonymous-logging.conf"), "utf8");
|
||||
for (const [path, method, route] of [["/api/billing", "GET", "/api/billing"], ["/api/billing/checkout?x=1", "POST", "/api/billing/checkout"],
|
||||
["/api/billing/draft", "POST", "/api/billing/draft"], ["/api/billing/draft/3f2a-private", "GET", "/api/billing/draft/:id"],
|
||||
["/api/billing/portal", "POST", "/api/billing/portal"], ["/api/billing/refresh", "POST", "/api/billing/refresh"],
|
||||
["/api/billing/webhook", "POST", "/api/billing/webhook"], ["/api/conferences/plans", "GET", "/api/conferences/plans"],
|
||||
["/profile?billing=success", "GET", "/profile"], ["/conference/private-conf?billing=success", "GET", "/conference/:id"]]) {
|
||||
expect(requestRoute(path, "api", method)).to.equal(route);
|
||||
expect(LOG_ROUTES).to.include(route);
|
||||
expect(nginx).to.include(`"${route}";`);
|
||||
}
|
||||
expect(requestRoute("/api/billing/draft/a/b", "api")).to.equal("other");
|
||||
expect(requestRoute("/anonymize/private-repo?billingDraft=x", "api")).to.equal("/anonymize");
|
||||
const bounded = new RequestMetrics(3);
|
||||
for (let i = 0; i < 1000; i++) bounded.observe("request", String(i), "GET", 10);
|
||||
expect(bounded.size).to.equal(3); expect(bounded.dropped).to.equal(997);
|
||||
|
||||
Reference in new issue
Block a user