mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
feat(telemetry): Sentry + PostHog quality pass (#546)
Comprehensive telemetry quality improvements across Sentry and PostHog, grounded in an audit of the live data plus current best-practice research. Sentry: job_id/instance_id tags, operational fingerprinting, PII-safe settings context on bug events, web tag population + extension-noise filtering, an early-crash buffer, http status/method kept on breadcrumbs, and a gated-off-by-default performance-tracing re-enable (tracesSampler that zeroes db/redis/queue-poll root spans + drops the Redis integration) with worker job spans and canonical-host cron monitors. PostHog: history_change SPA pageviews, instance_id super property for fleet rollups, enriched tool_used (formats, byte sizes, is_batch, execution_hint, real error_kind taxonomy), the previously-dead result_saved/batch_processed/ai_bundle_prompted events fired, search click-through, editor + Automate authoring + auth instrumentation, a before_send PII boundary, and minimal opt-in landing-site pageviews.
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
resetThrottleForTests,
|
||||
safeFormatTag,
|
||||
shouldReport,
|
||||
vetSettings,
|
||||
} from "../../../apps/api/src/lib/error-report.js";
|
||||
|
||||
describe("safeFormatTag", () => {
|
||||
@@ -132,3 +133,37 @@ describe("errorSignature", () => {
|
||||
expect(errorSignature(null)).toBe("Unknown:-:-");
|
||||
});
|
||||
});
|
||||
|
||||
describe("vetSettings", () => {
|
||||
it("keeps numbers, booleans, and short enum-like string values", () => {
|
||||
expect(vetSettings({ quality: 80, lossless: true, format: "png", fit: "cover" })).toEqual({
|
||||
quality: 80,
|
||||
lossless: true,
|
||||
format: "png",
|
||||
fit: "cover",
|
||||
});
|
||||
});
|
||||
it("drops sensitive keys, free-text/PII-shaped values, objects and arrays", () => {
|
||||
// A password, a filename, and watermark text must never reach Sentry; nested
|
||||
// objects/arrays and long strings can carry user data, so drop them too.
|
||||
expect(
|
||||
vetSettings({
|
||||
password: "hunter2",
|
||||
filename: "IMG_1234.png",
|
||||
watermarkText: "Property of Jane",
|
||||
crop: { x: 1, y: 2 },
|
||||
sizes: [1, 2, 3],
|
||||
width: 1024,
|
||||
format: "webp",
|
||||
}),
|
||||
).toEqual({ width: 1024, format: "webp" });
|
||||
});
|
||||
it("returns undefined for non-objects and when nothing safe survives", () => {
|
||||
expect(vetSettings(undefined)).toBeUndefined();
|
||||
expect(vetSettings("nope")).toBeUndefined();
|
||||
expect(vetSettings([1, 2])).toBeUndefined();
|
||||
expect(
|
||||
vetSettings({ note: "a long free-text field well beyond the safe length" }),
|
||||
).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user