mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
Removes Sentry tracing entirely (BullMQ idle polling burned 4.8M transactions in 2 days at the baked 0.1 rate), decouples PostHog sampling, and replaces the type-only error scrub with a vetted-field sanitizer plus SafeError/ToolInputError contracts. One classified capture path with per-signature throttles and a per-process ceiling makes storms impossible (NODE-1E was 4,541 events from one 30s loop). Browser errors move to a dedicated web Sentry project with their own source maps. Adds the SNAPOTTER_TELEMETRY runtime kill switch and silences test fleets. Crash fixes: remote 204/304 SSRF process kill (NODE-20), conversion-preset boot crash loop (NODE-21), Redis version preflight + unhandled subscribe rejection (NODE-1T), Sign PDF on plain-http origins (NODE-1K/1M), wavesurfer/pdf.js teardown rejections (NODE-1P/1N), bundle-import ZlibError to 400 (NODE-1Z), chart-maker input errors declassified (NODE-1H/1J), asset requests skip the session DB lookup (NODE-1D).
58 lines
2.1 KiB
TypeScript
58 lines
2.1 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
|
|
// Tests for the analytics config endpoint.
|
|
// These run against the Docker container at localhost:1349.
|
|
|
|
const BASE_URL = "http://localhost:1349";
|
|
const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
|
|
test.describe("GET /api/v1/config/analytics (public)", () => {
|
|
test("returns 200 without auth token", async () => {
|
|
const res = await fetch(`${BASE_URL}/api/v1/config/analytics`);
|
|
expect(res.status).toBe(200);
|
|
});
|
|
|
|
test("response has correct analytics config shape", async () => {
|
|
const res = await fetch(`${BASE_URL}/api/v1/config/analytics`);
|
|
const config = await res.json();
|
|
|
|
expect(config).toHaveProperty("enabled");
|
|
expect(config).toHaveProperty("posthogApiKey");
|
|
expect(config).toHaveProperty("posthogHost");
|
|
expect(config).toHaveProperty("sentryDsn");
|
|
expect(config).toHaveProperty("sentryDsnWeb");
|
|
expect(config).toHaveProperty("posthogSampleRate");
|
|
expect(config).toHaveProperty("instanceId");
|
|
|
|
expect(typeof config.enabled).toBe("boolean");
|
|
expect(typeof config.posthogApiKey).toBe("string");
|
|
expect(typeof config.posthogHost).toBe("string");
|
|
expect(typeof config.sentryDsn).toBe("string");
|
|
expect(typeof config.sentryDsnWeb).toBe("string");
|
|
expect(typeof config.posthogSampleRate).toBe("number");
|
|
expect(typeof config.instanceId).toBe("string");
|
|
});
|
|
|
|
test("instanceId is a valid UUID when analytics enabled", async () => {
|
|
const res = await fetch(`${BASE_URL}/api/v1/config/analytics`);
|
|
const config = await res.json();
|
|
|
|
if (config.enabled) {
|
|
expect(config.instanceId).toMatch(UUID_REGEX);
|
|
} else {
|
|
// When disabled, instanceId is empty string
|
|
expect(config.instanceId).toBe("");
|
|
}
|
|
});
|
|
|
|
test("instanceId is consistent across multiple fetches", async () => {
|
|
const res1 = await fetch(`${BASE_URL}/api/v1/config/analytics`);
|
|
const config1 = await res1.json();
|
|
|
|
const res2 = await fetch(`${BASE_URL}/api/v1/config/analytics`);
|
|
const config2 = await res2.json();
|
|
|
|
expect(config1.instanceId).toBe(config2.instanceId);
|
|
});
|
|
});
|