AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(platform): stop sending emails and IPs to Sentry and mask session replay by default (SECRT-2707) (#15705)
Krzysztof Czerwinskiace9231eb1c9
diff --git a/autogpt_platform/backend/backend/util/metrics.py b/autogpt_platform/backend/backend/util/metrics.pyindex 2faf1c447a..758cdeeff5 100644--- a/autogpt_platform/backend/backend/util/metrics.py+++ b/autogpt_platform/backend/backend/util/metrics.py@@ -89,10 +89,19 @@ _SENTRY_SENSITIVE_FIELDS = sorted("verification_url",})+# A user is known to Sentry by their id only, so their email and IP address are+# filtered wherever else they turn up, such as in extras or a frame's locals.+# Exact names only: keys like ``email_verified`` stay readable.+_SENTRY_PERSONAL_FIELDS = ("email", "user_email", "ip", "ip_address")# Matched case-insensitively against every key in the event, as sentry's# EventScrubber does (with its PII list, since send_default_pii is off)._SENTRY_SENSITIVE_KEYS = frozenset(- field.lower() for field in (*_SENTRY_SENSITIVE_FIELDS, *DEFAULT_PII_DENYLIST)+ field.lower()+ for field in (+ *_SENTRY_SENSITIVE_FIELDS,+ *DEFAULT_PII_DENYLIST,+ *_SENTRY_PERSONAL_FIELDS,+ ))_EMBEDDED_SECRET_ASSIGNMENT = re.compile(r"(?i)(?:access[_-]?token|refresh[_-]?token|id[_-]?token|api[_-]?key|"@@ -285,6 +294,8 @@ def _before_send(event, hint):if any(kw in msg for kw in _USER_AUTH_KEYWORDS):return None+ _strip_user_pii(event)+ _strip_ip_headers(event)_scrub_sentry_event(event)return event@@ -292,10 +303,61 @@ def _before_send(event, hint):def _before_send_transaction(event, hint):"""Transactions skip ``before_send`` but carry the same request data, andevery WebSocket connection is one."""+ _strip_user_pii(event)+ _strip_ip_headers(event)_redact_request_urls(event)return event+# Sentry knows a user by their id only: never their email, name or IP+# address, whichever code put them on the scope.+_SENTRY_USER_FIELDS = frozenset({"id"})+++def _strip_user_pii(event: dict) -> None:+ user = event.get("user")+ if user is None:+ return+ kept = {+ field: value for field, value in user.items() if field in _SENTRY_USER_FIELDS+ }+ if kept:+ event["user"] = kept+ else:+ del event["user"]+++# Request headers that carry the visitor's IP address or the location derived+# from it. The backends sit behind Cloudflare, which adds ``Cf-Connecting-Ip``+# and its ``Cf-Ip*`` location headers to every request; sentry-sdk only drops+# ``X-Forwarded-For`` and ``X-Real-Ip`` with PII off.+_IP_HEADER_MARKERS = (+ "forwarded",+ "proxied_for",+ "real_ip",+ "connecting_ip",+ "client_ip",+ "vercel_ip",+)+++def _is_ip_header(name: str) -> bool:+ key = name.lower().replace("-", "_")+ return key.startswith("cf_ip") or any(m in key for m in _IP_HEADER_MARKERS)+++def _strip_ip_headers(event: dict) -> None:+ request = event.get("request")+ if not isinstance(request, dict):+ return+ headers = request.get("headers")+ if not isinstance(headers, dict):+ return+ request["headers"] = {+ name: value for name, value in headers.items() if not _is_ip_header(name)+ }++def _sentry_environment() -> str:"""The environment events are tagged with. A deployment that names itself(a PR preview, say) takes precedence over the one computed from the app@@ -328,6 +390,9 @@ def sentry_init():profiles_sample_rate=1.0,release=settings.config.sentry_release.strip() or None,environment=_sentry_environment(),+ # The SDK default, pinned: no IP address, request headers with+ # personal data or cookies.+ send_default_pii=False,before_send=_before_send,before_send_transaction=_before_send_transaction,integrations=[diff --git a/autogpt_platform/backend/backend/util/metrics_test.py b/autogpt_platform/backend/backend/util/metrics_test.pyindex 663811f62e..d0ea9bdd5d 100644--- a/autogpt_platform/backend/backend/util/metrics_test.py+++ b/autogpt_platform/backend/backend/util/metrics_test.py@@ -577,3 +577,139 @@ def test_sentry_settings_are_empty_for_blank_deployment_env_vars(monkeypatch) ->config = Config()assert (config.sentry_release, config.sentry_environment) == ("", "")+++# ---------- personal data ----------+++def _event_with_personal_user() -> dict:+ return {+ "level": "error",+ "user": {+ "id": "user-1",+ "email": "[email protected]",+ "ip_address": "203.0.113.7",+ "name": "Ada Lovelace",+ "segment": "pro",+ },+ }+++def test_before_send_keeps_only_the_user_id() -> None:+ event = _before_send(_event_with_personal_user(), hint={})++ assert event is not None+ assert event["user"] == {"id": "user-1"}+++def test_before_send_transaction_keeps_only_the_user_id() -> None:+ event = metrics._before_send_transaction(_event_with_personal_user(), hint={})++ assert event["user"] == {"id": "user-1"}+++def test_sentry_init_sends_no_default_pii(monkeypatch) -> None:+ assert _sentry_init_options(monkeypatch)["send_default_pii"] is False+++def test_before_send_drops_a_user_left_with_no_id() -> None:+ event = _before_send(+ {"level": "error", "user": {"email": "[email protected]"}}, hint={}+ )++ assert event is not None+ assert "user" not in event+++def test_before_send_transaction_drops_a_user_left_with_no_id() -> None:+ event = metrics._before_send_transaction(+ {"user": {"ip_address": "203.0.113.7"}}, hint={}+ )++ assert "user" not in event+++def test_before_send_filters_emails_and_ips_from_extras_and_frame_vars() -> None:+ def notify_user():+ email = "[email protected]"+ user_email = "[email protected]"+ ip = "203.0.113.7"+ ip_address = "198.51.100.4"+ email_count = 1+ if email and user_email and ip and ip_address and email_count:+ raise RuntimeError("could not send the notification")++ try:+ notify_user()+ except RuntimeError:+ event, hint = event_from_exception(+ sys.exc_info(), client_options=DEFAULT_OPTIONS+ )+ event["extra"] = {+ "Email": "[email protected]",+ "context": {"user_email": "[email protected]", "ip": "203.0.113.7"},+ "ip_address": "198.51.100.4",+ "email_verified": True,+ "ip_allowlist_enabled": True,+ }++ scrubbed = _before_send(serialize(event), hint)++ assert scrubbed is not None+ body = json.loads(json_dumps(scrubbed))+ assert body["extra"]["Email"] == "[Filtered]"+ assert body["extra"]["context"] == {+ "user_email": "[Filtered]",+ "ip": "[Filtered]",+ }+ assert body["extra"]["ip_address"] == "[Filtered]"+ frame_vars = body["exception"]["values"][0]["stacktrace"]["frames"][-1]["vars"]+ for name in ("email", "user_email", "ip", "ip_address"):+ assert frame_vars[name] == "[Filtered]", name+ # Keys that only mention an email or IP stay readable for debugging.+ assert frame_vars["email_count"] == "1"+ assert body["extra"]["email_verified"] is True+ assert body["extra"]["ip_allowlist_enabled"] is True+++def _event_with_ip_headers() -> dict:+ return {+ "level": "error",+ "request": {+ "url": "https://backend.agpt.co/api/library",+ "headers": {+ "User-Agent": "ua",+ "Content-Type": "application/json",+ "Cf-Connecting-Ip": "203.0.113.7",+ "True-Client-Ip": "203.0.113.7",+ "Forwarded": "for=203.0.113.7",+ "X-Forwarded-For": "203.0.113.7, 10.0.0.1",+ "X-Real-Ip": "203.0.113.7",+ "Cf-Ipcountry": "PL",+ "Cf-Ipcity": "Warsaw",+ "Cf-Iplatitude": "52.2",+ "X-Vercel-Ip-City": "Warsaw",+ "Cf-Ray": "8a1b2c3d4e5f6789-WAW",+ },+ },+ }+++_KEPT_HEADERS = {+ "User-Agent": "ua",+ "Content-Type": "application/json",+ "Cf-Ray": "8a1b2c3d4e5f6789-WAW",+}+++def test_before_send_drops_the_visitors_ip_and_location_headers() -> None:+ event = _before_send(_event_with_ip_headers(), hint={})++ assert event is not None+ assert event["request"]["headers"] == _KEPT_HEADERS+++def test_before_send_transaction_drops_the_visitors_ip_and_location_headers() -> None:+ event = metrics._before_send_transaction(_event_with_ip_headers(), hint={})++ assert event["request"]["headers"] == _KEPT_HEADERSdiff --git a/autogpt_platform/frontend/instrumentation-client.ts b/autogpt_platform/frontend/instrumentation-client.tsindex 0db1aeeef7..eaa92ffa27 100644--- a/autogpt_platform/frontend/instrumentation-client.ts+++ b/autogpt_platform/frontend/instrumentation-client.ts@@ -8,6 +8,10 @@ import {isFromBot,isInjectedIframeProbe,isNextRSCNavigationFallback,+ stripLogUserPII,+ stripSpanDataPII,+ stripSpanPII,+ stripUserPII,} from "@/lib/sentry-filters";import { getSentryTunnelURL } from "@/lib/sentry-tunnel";import { setupSessionReplay } from "@/lib/session-replay";@@ -32,6 +36,10 @@ Sentry.init({// (e.g., from browser extensions or CDN-loaded CSS)ignoreErrors: CLIENT_IGNORE_ERRORS,+ // Errors are reported without consent (legitimate interest), so they carry+ // the user id only: no email, and Sentry is told not to infer the IP address.+ sendDefaultPii: false,+// Next's handled RSC fetch fallback reaches us only through console capture// and falls back to a full navigation, so it is noise (BUILDER-3QB).// Crawlers render our pages too; what breaks for them is not a user's bug.@@ -40,14 +48,19 @@ Sentry.init({// Some browsers inject a script that logs every cross-origin iframe it may// not read (BUILDER-943).beforeSend(event) {+ stripSpanPII(stripUserPII(event));if (isFromBot(navigator.userAgent)) return null;if (isLoggedRequestFailure(event)) return null;if (isInjectedIframeProbe(event)) return null;return isNextRSCNavigationFallback(event) ? null : event;},beforeSendTransaction(event) {- return isFromBot(navigator.userAgent) ? null : event;+ return isFromBot(navigator.userAgent)+ ? null+ : stripSpanPII(stripUserPII(event));},+ beforeSendSpan: stripSpanDataPII,+ beforeSendLog: stripLogUserPII,// Add optional integrations for additional featuresintegrations: [diff --git a/autogpt_platform/frontend/sentry.edge.config.ts b/autogpt_platform/frontend/sentry.edge.config.tsindex de0fd0b830..6762f63dde 100644--- a/autogpt_platform/frontend/sentry.edge.config.ts+++ b/autogpt_platform/frontend/sentry.edge.config.ts@@ -3,7 +3,13 @@// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally.// https://docs.sentry.io/platforms/javascript/guides/nextjs/-import { stripRequestCredentials } from "@/lib/sentry-filters";+import {+ stripLogUserPII,+ stripRequestCredentials,+ stripSpanDataPII,+ stripSpanPII,+ stripUserPII,+} from "@/lib/sentry-filters";import { isSentryTunnelTransaction } from "@/lib/sentry-tunnel";import { environment } from "@/services/environment";import * as Sentry from "@sentry/nextjs";@@ -26,12 +32,18 @@ Sentry.init({/^https:\/\/.*\.agpt\.co\/api/,],- beforeSend: stripRequestCredentials,+ // No email or IP address reaches Sentry; the user id is enough.+ sendDefaultPii: false,+ beforeSend(event) {+ return stripSpanPII(stripUserPII(stripRequestCredentials(event)));+ },beforeSendTransaction(event) {return isSentryTunnelTransaction(event)? null- : stripRequestCredentials(event);+ : stripSpanPII(stripUserPII(stripRequestCredentials(event)));},+ beforeSendSpan: stripSpanDataPII,+ beforeSendLog: stripLogUserPII,// Setting this option to true will print useful information to the console while you're setting up Sentry.debug: false,diff --git a/autogpt_platform/frontend/sentry.server.config.ts b/autogpt_platform/frontend/sentry.server.config.tsindex 0a6c031970..b26dfec254 100644--- a/autogpt_platform/frontend/sentry.server.config.ts+++ b/autogpt_platform/frontend/sentry.server.config.ts@@ -2,7 +2,13 @@// The config you add here will be used whenever the server handles a request.// https://docs.sentry.io/platforms/javascript/guides/nextjs/-import { stripRequestCredentials } from "@/lib/sentry-filters";+import {+ stripLogUserPII,+ stripRequestCredentials,+ stripSpanDataPII,+ stripSpanPII,+ stripUserPII,+} from "@/lib/sentry-filters";import { isSentryTunnelTransaction } from "@/lib/sentry-tunnel";import { environment } from "@/services/environment";import * as Sentry from "@sentry/nextjs";@@ -26,12 +32,18 @@ Sentry.init({/^https:\/\/.*\.agpt\.co\/api/,],- beforeSend: stripRequestCredentials,+ // No email or IP address reaches Sentry; the user id is enough.+ sendDefaultPii: false,+ beforeSend(event) {+ return stripSpanPII(stripUserPII(stripRequestCredentials(event)));+ },beforeSendTransaction(event) {return isSentryTunnelTransaction(event)? null- : stripRequestCredentials(event);+ : stripSpanPII(stripUserPII(stripRequestCredentials(event)));},+ beforeSendSpan: stripSpanDataPII,+ beforeSendLog: stripLogUserPII,// Setting this option to true will print useful information to the console while you're setting up Sentry.debug: false,diff --git a/autogpt_platform/frontend/src/__tests__/instrumentation-client.test.ts b/autogpt_platform/frontend/src/__tests__/instrumentation-client.test.tsindex bcbbfe9033..5d75a7202c 100644--- a/autogpt_platform/frontend/src/__tests__/instrumentation-client.test.ts+++ b/autogpt_platform/frontend/src/__tests__/instrumentation-client.test.ts@@ -22,7 +22,6 @@ vi.mock("@sentry/nextjs", () => {httpClientIntegration: stubIntegration("HttpClient"),featureFlagsIntegration: stubIntegration("FeatureFlags"),replayIntegration: stubIntegration("Replay"),- replayCanvasIntegration: stubIntegration("ReplayCanvas"),captureRouterTransitionStart: vi.fn(),};});@@ -101,6 +100,36 @@ describe("Sentry client instrumentation", () => {expect(beforeSend(fetchError, {})).toBe(fetchError);});+ it("sends errors whose trace context carries no IP address or email", async () => {+ await import("../../instrumentation-client");++ const { beforeSend } = initMock.mock.calls[0][0];+ const event = beforeSend(+ {+ exception: { values: [{ type: "Error", value: "boom" }] },+ contexts: {+ trace: {+ trace_id: "a".repeat(32),+ span_id: "b".repeat(16),+ data: {+ "client.address": "203.0.113.7",+ "user.email": "[email protected]",+ user: "[email protected]",+ "user.id": "user-1",+ "url.path": "/library",+ },+ },+ },+ },+ {},+ );++ expect(event.contexts.trace.data).toEqual({+ "user.id": "user-1",+ "url.path": "/library",+ });+ });+it("drops a browser-injected script's iframe probe but keeps our own frame errors", async () => {await import("../../instrumentation-client");diff --git a/autogpt_platform/frontend/src/__tests__/sentry-runtime-configs.test.ts b/autogpt_platform/frontend/src/__tests__/sentry-runtime-configs.test.tsindex 84b8b4f1c4..d40881de08 100644--- a/autogpt_platform/frontend/src/__tests__/sentry-runtime-configs.test.ts+++ b/autogpt_platform/frontend/src/__tests__/sentry-runtime-configs.test.ts@@ -141,6 +141,188 @@ describe.each([expect(beforeSendTransaction(withCredentials()).request).toEqual(stripped);});+ it("sends no user email or IP address", async () => {+ await load();++ const { sendDefaultPii, beforeSend, beforeSendTransaction } =+ initMock.mock.calls[0][0];+ function withPersonalData() {+ return {+ user: {+ id: "user-1",+ email: "[email protected]",+ ip_address: "203.0.113.7",+ name: "Ada Lovelace",+ segment: "pro",+ },+ request: {+ url: "https://platform.agpt.co/library",+ headers: {+ "user-agent": "ua",+ "X-Forwarded-For": "203.0.113.7",+ "x-real-ip": "203.0.113.7",+ "x-vercel-forwarded-for": "203.0.113.7",+ "x-vercel-ip-city": "Warsaw",+ "cf-connecting-ip": "203.0.113.7",+ forwarded: "for=203.0.113.7",+ },+ },+ };+ }++ expect(sendDefaultPii).toBe(false);+ for (const event of [+ beforeSend(withPersonalData(), {}),+ beforeSendTransaction(withPersonalData()),+ ]) {+ expect(event.user).toEqual({ id: "user-1" });+ expect(event.request.headers).toEqual({ "user-agent": "ua" });+ }+ });++ it("sends errors whose trace context carries no IP address or email", async () => {+ await load();++ const { beforeSend } = initMock.mock.calls[0][0];+ const event = beforeSend(+ {+ exception: { values: [{ type: "Error", value: "boom" }] },+ contexts: {+ trace: {+ trace_id: "a".repeat(32),+ span_id: "b".repeat(16),+ data: {+ "http.client_ip": "203.0.113.7",+ "client.address": "203.0.113.7",+ "http.request.header.x_forwarded_for": "203.0.113.7",+ "user.email": "[email protected]",+ "user.id": "user-1",+ "http.route": "/library",+ },+ },+ },+ },+ {},+ );++ expect(event.contexts.trace.data).toEqual({+ "user.id": "user-1",+ "http.route": "/library",+ });+ });++ it("sends transactions whose spans carry no IP address, email or name", async () => {+ await load();++ const { beforeSendTransaction } = initMock.mock.calls[0][0];+ const event = beforeSendTransaction({+ type: "transaction",+ transaction: "GET /library",+ contexts: {+ trace: {+ trace_id: "a".repeat(32),+ span_id: "b".repeat(16),+ data: {+ "http.client_ip": "203.0.113.7",+ "net.peer.ip": "203.0.113.7",+ "net.host.ip": "10.0.0.2",+ "client.address": "203.0.113.7",+ "network.peer.address": "203.0.113.7",+ "http.request.header.x_forwarded_for": "203.0.113.7, 10.0.0.1",+ "http.request.header.x-real-ip": "203.0.113.7",+ "http.request.header.x_vercel_ip_city": "Warsaw",+ "http.route": "/library",+ "server.address": "platform.agpt.co",+ "user.id": "user-1",+ },+ },+ },+ spans: [+ {+ trace_id: "a".repeat(32),+ span_id: "c".repeat(16),+ start_timestamp: 1,+ data: {+ "net.sock.peer.addr": "203.0.113.7",+ "net.peer.ip": "203.0.113.7",+ "user.email": "[email protected]",+ "user.name": "ada",+ "user.id": "user-1",+ "http.route": "/api/library",+ "server.address": "backend.agpt.co",+ },+ },+ ],+ });++ expect(event.contexts.trace.data).toEqual({+ "http.route": "/library",+ "server.address": "platform.agpt.co",+ "user.id": "user-1",+ });+ expect(event.spans[0].data).toEqual({+ "user.id": "user-1",+ "http.route": "/api/library",+ "server.address": "backend.agpt.co",+ });+ });++ it("sends standalone spans with no IP address, email or name", async () => {+ await load();++ const { beforeSendSpan } = initMock.mock.calls[0][0];+ const span = beforeSendSpan({+ trace_id: "a".repeat(32),+ span_id: "c".repeat(16),+ start_timestamp: 1,+ description: "GET /library",+ data: {+ user: "[email protected]",+ "user.email": "[email protected]",+ "user.id": "user-1",+ "http.client_ip": "203.0.113.7",+ "client.address": "203.0.113.7",+ "net.peer.ip": "203.0.113.7",+ "http.route": "/library",+ "server.address": "platform.agpt.co",+ },+ });++ expect(span.description).toBe("GET /library");+ expect(span.data).toEqual({+ "user.id": "user-1",+ "http.route": "/library",+ "server.address": "platform.agpt.co",+ });+ });++ it("sends logs with the user id only, and no email, name or IP address", async () => {+ await load();++ const { enableLogs, beforeSendLog } = initMock.mock.calls[0][0];+ const log = beforeSendLog({+ level: "info",+ message: "rendered the library",+ attributes: {+ "user.id": "user-1",+ "user.email": "[email protected]",+ "user.name": "ada",+ "user.ip_address": "203.0.113.7",+ "client.address": "203.0.113.7",+ "http.client_ip": "203.0.113.7",+ ip: "203.0.113.7",+ "sentry.environment": "pr-123",+ },+ });++ expect(enableLogs).toBe(true);+ expect(log).toEqual({+ level: "info",+ message: "rendered the library",+ attributes: { "user.id": "user-1", "sentry.environment": "pr-123" },+ });+ });+it("tags events with the environment the deployment names for itself", async () => {vi.stubEnv("NEXT_PUBLIC_SENTRY_ENVIRONMENT", "pr-123");diff --git a/autogpt_platform/frontend/src/__tests__/sentry-tunnel.test.ts b/autogpt_platform/frontend/src/__tests__/sentry-tunnel.test.tsindex 6c9bddf3cd..a17dd02800 100644--- a/autogpt_platform/frontend/src/__tests__/sentry-tunnel.test.ts+++ b/autogpt_platform/frontend/src/__tests__/sentry-tunnel.test.ts@@ -60,7 +60,7 @@ describe("Sentry tunnel", () => {expect(authMiddlewareMock).not.toHaveBeenCalled();});- it("forwards only the headers Sentry reads", async () => {+ it("forwards only the headers Sentry reads, and not the visitor's IP", async () => {const response = await middleware(envelopePost(getSentryTunnelURL(DSN)));expect(forwardedHeaders(response)).toEqual({@@ -68,7 +68,6 @@ describe("Sentry tunnel", () => {"content-type": "text/plain;charset=UTF-8","content-length": "3","user-agent": "Mozilla/5.0",- "x-forwarded-for": "203.0.113.7",});});@@ -138,6 +137,7 @@ function envelopePost("content-type": "text/plain;charset=UTF-8","user-agent": "Mozilla/5.0","x-forwarded-for": "203.0.113.7",+ "x-vercel-forwarded-for": "203.0.113.7","x-unlisted": "secret",...(contentLength === null ? {} : { "content-length": contentLength }),},diff --git a/autogpt_platform/frontend/src/__tests__/sentry-user-privacy.test.tsx b/autogpt_platform/frontend/src/__tests__/sentry-user-privacy.test.tsxnew file mode 100644index 0000000000..0bc5e67caa--- /dev/null+++ b/autogpt_platform/frontend/src/__tests__/sentry-user-privacy.test.tsx@@ -0,0 +1,227 @@+import { SentryUserTracker } from "@/components/monitor/SentryUserTracker";+import * as Sentry from "@sentry/nextjs";+import { cleanup, render } from "@testing-library/react";+import {+ afterAll,+ afterEach,+ beforeAll,+ beforeEach,+ describe,+ expect,+ it,+ vi,+} from "vitest";++// The client bundle runs the browser SDK; Vitest would load the Node one.+vi.mock("@sentry/nextjs", async () => {+ const { createRequire } = await import("node:module");+ const nextjs = createRequire(import.meta.url).resolve(+ "@sentry/nextjs/package.json",+ );+ const react = createRequire(nextjs).resolve("@sentry/react/package.json");+ const browser = createRequire(react).resolve("@sentry/browser/package.json");+ const sdk = await import(+ browser.replace("package.json", "build/npm/esm/prod/index.js")+ );+ return { ...sdk, captureRouterTransitionStart: () => undefined };+});++const EMAIL = "[email protected]";+const IP = "203.0.113.7";++vi.mock("@/lib/auth/hooks/useAuth", () => ({+ useAuth: () => ({+ user: { id: "user-1", email: EMAIL, role: "authenticated" },+ isUserLoading: false,+ }),+}));++type SentPayload = Sentry.Event & {+ sdk?: { settings?: { infer_ip?: string } };+};++interface SentSpan {+ data?: Record<string, unknown>;+}++interface SentLog {+ body: string;+ attributes: Record<string, { value: unknown }>;+}++// Errors, transactions, standalone spans and logs as the production client+// config would send them.+const sent: SentPayload[] = [];+const sentSpans: SentSpan[] = [];+const sentLogs: SentLog[] = [];++beforeAll(async () => {+ vi.spyOn(console, "info").mockImplementation(() => undefined);+ vi.stubEnv("NEXT_PUBLIC_SENTRY_DSN", "https://[email protected]/0");+ await import("../../instrumentation-client");+ vi.spyOn(Sentry.getClient()!.getTransport()!, "send").mockImplementation(+ async ([, items]) => {+ for (const [header, payload] of items) {+ if (header.type === "event" || header.type === "transaction") {+ sent.push(payload as SentPayload);+ }+ if (header.type === "span") {+ sentSpans.push(payload as SentSpan);+ }+ if (header.type === "log") {+ sentLogs.push(...(payload as { items: SentLog[] }).items);+ }+ }+ return {};+ },+ );+});++beforeEach(() => {+ sent.length = 0;+ sentSpans.length = 0;+ sentLogs.length = 0;+});++afterEach(() => {+ cleanup();+ Sentry.setUser(null);+});++afterAll(() => {+ vi.unstubAllEnvs();+ vi.restoreAllMocks();+});++describe("a signed-in user in Sentry", () => {+ it("is identified by id and role only, with no email or IP address", async () => {+ render(<SentryUserTracker />);++ Sentry.captureException(new Error("boom"));+ Sentry.startSpan({ name: "load page", forceTransaction: true }, () => {});+ await Sentry.flush(2000);++ expect(sent.map((payload) => payload.type ?? "error")).toEqual([+ "error",+ "transaction",+ ]);+ for (const payload of sent) {+ expect(payload.user).toEqual({ id: "user-1", role: "authenticated" });+ // Without it Sentry would fill in the IP the envelope came from.+ expect(payload.sdk?.settings?.infer_ip).toBe("never");+ expect(JSON.stringify(payload)).not.toContain(EMAIL);+ }+ });++ it("keeps only the id and role of a user other code puts on the scope", async () => {+ Sentry.setUser({+ id: "user-1",+ role: "admin",+ email: EMAIL,+ ip_address: IP,+ username: "ada",+ name: "Ada Lovelace",+ });++ Sentry.captureException(new Error("boom"));+ Sentry.startSpan({ name: "load page", forceTransaction: true }, () => {});+ await Sentry.flush(2000);++ expect(sent).toHaveLength(2);+ for (const payload of sent) {+ expect(payload.user).toEqual({ id: "user-1", role: "admin" });+ expect(JSON.stringify(payload)).not.toContain(EMAIL);+ expect(JSON.stringify(payload)).not.toContain(IP);+ expect(JSON.stringify(payload)).not.toContain("Lovelace");+ }+ });++ it("sends transactions whose spans carry no IP address or email", async () => {+ Sentry.startSpan(+ {+ name: "load page",+ forceTransaction: true,+ attributes: {+ "client.address": IP,+ "http.client_ip": IP,+ "http.route": "/library",+ },+ },+ () => {+ Sentry.startSpan(+ {+ name: "GET /api/library",+ attributes: {+ "net.peer.ip": IP,+ "user.email": EMAIL,+ "user.id": "user-1",+ "server.address": "backend.agpt.co",+ },+ },+ () => {},+ );+ },+ );+ await Sentry.flush(2000);++ expect(sent).toHaveLength(1);+ const [transaction] = sent;+ expect(transaction.contexts?.trace?.data?.["http.route"]).toBe("/library");+ expect(transaction.spans).toHaveLength(1);+ expect(transaction.spans?.[0].data).toMatchObject({+ "user.id": "user-1",+ "server.address": "backend.agpt.co",+ });+ expect(JSON.stringify(transaction)).not.toContain(IP);+ expect(JSON.stringify(transaction)).not.toContain(EMAIL);+ });++ it("sends standalone spans, like web vitals, with no IP address or email", async () => {+ Sentry.startInactiveSpan({+ name: "interaction",+ experimental: { standalone: true },+ attributes: {+ user: EMAIL,+ "user.email": EMAIL,+ "user.id": "user-1",+ "client.address": IP,+ "sentry.exclusive_time": 120,+ },+ }).end();+ await Sentry.flush(2000);++ expect(sentSpans).toHaveLength(1);+ const [span] = sentSpans;+ expect(span.data).toMatchObject({+ "user.id": "user-1",+ "sentry.exclusive_time": 120,+ });+ expect(JSON.stringify(span)).not.toContain(IP);+ expect(JSON.stringify(span)).not.toContain(EMAIL);+ });++ it("is identified by id only in logs, whatever other code puts on the scope", async () => {+ Sentry.setUser({+ id: "user-1",+ role: "admin",+ email: EMAIL,+ ip_address: IP,+ username: "ada",+ name: "Ada Lovelace",+ });++ Sentry.logger.info("loaded the library", { "client.address": IP });+ await Sentry.flush(2000);++ expect(sentLogs).toHaveLength(1);+ const [log] = sentLogs;+ expect(log.body).toBe("loaded the library");+ expect(log.attributes["user.id"]?.value).toBe("user-1");+ const userAttributes = Object.keys(log.attributes).filter((name) =>+ name.startsWith("user."),+ );+ expect(userAttributes).toEqual(["user.id"]);+ expect(JSON.stringify(log)).not.toContain(EMAIL);+ expect(JSON.stringify(log)).not.toContain(IP);+ });+});diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/ConnectionPicker.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/ConnectionPicker.tsxindex a1f2061ed1..f5ad720bc8 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/ConnectionPicker.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/ChatInput/components/ConnectionPicker/ConnectionPicker.tsx@@ -146,7 +146,6 @@ export function ConnectionPicker({type="button"variant="ghost"size={showsTier ? "icon" : "small"}- unmask={false}aria-label={showsTier? `Model tier ${label} — change`diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/RateLimitResetDialog/RateLimitResetDialog.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/RateLimitResetDialog/RateLimitResetDialog.tsxindex 67629807ec..abd699b0b8 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/RateLimitResetDialog/RateLimitResetDialog.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/RateLimitResetDialog/RateLimitResetDialog.tsx@@ -149,7 +149,6 @@ export function RateLimitResetDialog({<><Textvariant="body"- unmask={!payment}className="mb-5 !text-sm !leading-6 !text-zinc-500">{waitTitle && wait ? budgetResetSentence(wait) : copy.description}diff --git a/autogpt_platform/frontend/src/app/(platform)/copilot/components/UsageLimits/UsageLimitReachedCard/UsageLimitReachedCard.tsx b/autogpt_platform/frontend/src/app/(platform)/copilot/components/UsageLimits/UsageLimitReachedCard/UsageLimitReachedCard.tsxindex 65638d6d69..46eda06066 100644--- a/autogpt_platform/frontend/src/app/(platform)/copilot/components/UsageLimits/UsageLimitReachedCard/UsageLimitReachedCard.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/copilot/components/UsageLimits/UsageLimitReachedCard/UsageLimitReachedCard.tsx@@ -63,11 +63,7 @@ export function UsageLimitReachedCard(props: UsageNoticeContext = {}) {? budgetOutTitle(state.wait.window): copy.noticeTitle}</Text>- <Text- variant="small"- unmask={!due}- className="mt-2 !leading-5 !text-zinc-500"- >+ <Text variant="small" className="mt-2 !leading-5 !text-zinc-500">{state.isRefreshing? "Refreshing your plan and usage…": state.isError@@ -89,7 +85,6 @@ export function UsageLimitReachedCard(props: UsageNoticeContext = {}) {size="small"onClick={state.upgrade}disabled={state.offer.disabled}- unmask={!state.experience.freshProUsage}rightIcon={<Icon icon={ArrowRight02Icon} size={14} />}>{getUsageOfferAction(state.experience, state.offer)}diff --git a/autogpt_platform/frontend/src/app/(platform)/dev/brain-dump-debug/components/DebugPanel.tsx b/autogpt_platform/frontend/src/app/(platform)/dev/brain-dump-debug/components/DebugPanel.tsxindex 7b615b2ebe..8e54de3efc 100644--- a/autogpt_platform/frontend/src/app/(platform)/dev/brain-dump-debug/components/DebugPanel.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/dev/brain-dump-debug/components/DebugPanel.tsx@@ -54,7 +54,7 @@ export function DebugField({ label, value }: FieldProps) {<Text variant="label" className="text-zinc-500">{label}</Text>- <Text variant="body" unmask={false} className="break-all font-mono">+ <Text variant="body" className="break-all font-mono">{value}</Text></div>diff --git a/autogpt_platform/frontend/src/app/(platform)/home/components/AgentTeam/components/AgentRow.tsx b/autogpt_platform/frontend/src/app/(platform)/home/components/AgentTeam/components/AgentRow.tsxindex 7363e6fdfc..78c8ab3c2c 100644--- a/autogpt_platform/frontend/src/app/(platform)/home/components/AgentTeam/components/AgentRow.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/home/components/AgentTeam/components/AgentRow.tsx@@ -54,7 +54,6 @@ export function AgentRow({ agent }: Props) {variant="small"tone="muted"className="truncate tabular-nums leading-4"- unmask={false}>{secondLine}</Text>diff --git a/autogpt_platform/frontend/src/app/(platform)/home/components/HomeTileFilter/HomeTileFilter.tsx b/autogpt_platform/frontend/src/app/(platform)/home/components/HomeTileFilter/HomeTileFilter.tsxindex 355f11c05d..cac24b6018 100644--- a/autogpt_platform/frontend/src/app/(platform)/home/components/HomeTileFilter/HomeTileFilter.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/home/components/HomeTileFilter/HomeTileFilter.tsx@@ -35,7 +35,6 @@ export function HomeTileFilter({className="gap-1 px-2.5 text-zinc-600 hover:bg-zinc-100 hover:text-zinc-900"leadingIcon={FilterHorizontalIcon}aria-label={`${ariaLabelPrefix}: ${activeLabel}`}- unmask={false}>{activeLabel}</Button>diff --git a/autogpt_platform/frontend/src/app/(platform)/marketplace/components/CategoryChip/CategoryChip.tsx b/autogpt_platform/frontend/src/app/(platform)/marketplace/components/CategoryChip/CategoryChip.tsxindex 5ad4612753..100fbef8cd 100644--- a/autogpt_platform/frontend/src/app/(platform)/marketplace/components/CategoryChip/CategoryChip.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/marketplace/components/CategoryChip/CategoryChip.tsx@@ -94,7 +94,6 @@ export function CategoryChip({title={title}aria-pressed={isSelected}onClick={onClick}- unmask={false}style={color ? glossyChipStyle(color, isSelected) : undefined}leftIcon={icon ? (diff --git a/autogpt_platform/frontend/src/app/(platform)/marketplace/components/Shelf/ShelfMoreButton.tsx b/autogpt_platform/frontend/src/app/(platform)/marketplace/components/Shelf/ShelfMoreButton.tsxindex a8b9d83122..5f81a93172 100644--- a/autogpt_platform/frontend/src/app/(platform)/marketplace/components/Shelf/ShelfMoreButton.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/marketplace/components/Shelf/ShelfMoreButton.tsx@@ -20,12 +20,7 @@ export function ShelfMoreButton({onToggle,}: Props) {return (- <Button- size="small"- aria-expanded={isExpanded}- onClick={onToggle}- unmask={false}- >+ <Button size="small" aria-expanded={isExpanded} onClick={onToggle}>{isExpanded? "Show fewer": `Load ${isAll ? "all " : ""}${count.toLocaleString()} ${noun}`}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/billing/__tests__/upgrade-replay-privacy.test.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/billing/__tests__/upgrade-replay-privacy.test.tsxindex 76e81c6b9a..25a4416b25 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/billing/__tests__/upgrade-replay-privacy.test.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/settings/billing/__tests__/upgrade-replay-privacy.test.tsx@@ -56,12 +56,6 @@ it("keeps every reviewed Max amount out of replay, including the consent buttonfor (const amount of amounts) {expect(amount.closest(".sentry-unmask, [data-sentry-unmask]")).toBeNull();}- expect(- dialog.getByText("Due today").closest(".sentry-unmask"),- ).not.toBeNull();- expect(- dialog.getByRole("button", { name: "Keep Pro" }).closest(".sentry-unmask"),- ).not.toBeNull();});function StartPro() {@@ -100,12 +94,9 @@ it("keeps Pro's reviewed charge, discount, tax and full renewal terms masked infor (const value of privateValues) {expect(value.closest(".sentry-unmask, [data-sentry-unmask]")).toBeNull();}- expect(- dialog.getByRole("button", { name: "Not now" }).closest(".sentry-unmask"),- ).not.toBeNull();});-it("masks the accepted trial offer in billing while leaving static plan labels visible", async () => {+it("masks the accepted trial offer in billing", async () => {server.use(http.get("*/api/credits/subscription", () =>HttpResponse.json({ tier: "TRIAL", monthly_cost: 0 }),@@ -130,7 +121,4 @@ it("masks the accepted trial offer in billing while leaving static plan labels vfor (const amount of amounts) {expect(amount.closest(".sentry-unmask, [data-sentry-unmask]")).toBeNull();}- expect(- screen.getByText("AutoGPT Pro").closest(".sentry-unmask"),- ).not.toBeNull();});diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/AutomationCreditsTab/TransactionHistoryCard/components/ReceiptEntries.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/AutomationCreditsTab/TransactionHistoryCard/components/ReceiptEntries.tsxindex c66edfde73..f429b93c6c 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/AutomationCreditsTab/TransactionHistoryCard/components/ReceiptEntries.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/AutomationCreditsTab/TransactionHistoryCard/components/ReceiptEntries.tsx@@ -61,12 +61,7 @@ export function ReceiptEntries({ transaction }: Props) {<Text variant="small" className="text-zinc-600">{referenceLabel(transaction)}</Text>- <Text- variant="small"- as="code"- unmask={false}- className="break-all font-mono"- >+ <Text variant="small" as="code" className="break-all font-mono">{reference}</Text></div>@@ -101,7 +96,6 @@ function ChargeEntries({ transaction }: Props) {<td className="py-2 pr-3 align-top"><Textvariant="small"- unmask={false}title={posted.full}className="text-zinc-600">diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/AutomationCreditsTab/TransactionHistoryCard/components/ReceiptMetadata.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/AutomationCreditsTab/TransactionHistoryCard/components/ReceiptMetadata.tsxindex 0741f02d54..0f364c4243 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/AutomationCreditsTab/TransactionHistoryCard/components/ReceiptMetadata.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/AutomationCreditsTab/TransactionHistoryCard/components/ReceiptMetadata.tsx@@ -83,7 +83,7 @@ function MetadataField({<Text variant="small" className="text-zinc-600">{label}</Text>- <Text variant="small" unmask={false} title={title}>+ <Text variant="small" title={title}>{value}</Text></div>diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/AutomationCreditsTab/TransactionHistoryCard/components/ReceiptRelations.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/AutomationCreditsTab/TransactionHistoryCard/components/ReceiptRelations.tsxindex 922a237e19..4d41914b41 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/AutomationCreditsTab/TransactionHistoryCard/components/ReceiptRelations.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/AutomationCreditsTab/TransactionHistoryCard/components/ReceiptRelations.tsx@@ -104,7 +104,6 @@ function RelatedExecution({<Buttonvariant="ghost"size="small"- unmask={false}className="min-h-11 min-w-0 whitespace-normal px-0 text-left text-purple-700"onClick={() => onSelectRelated(execution.execution_id)}>@@ -118,9 +117,7 @@ function RelatedExecution({{name}</Link>) : (- <Text variant="small" unmask={false}>- {name}- </Text>+ <Text variant="small">{name}</Text>)}{amount != null && (<TransactionAmount amount={amount} className="text-xs" />diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/AutomationCreditsTab/TransactionHistoryCard/components/TransactionAmount.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/AutomationCreditsTab/TransactionHistoryCard/components/TransactionAmount.tsxindex 1c7b88b25d..25ad15baab 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/AutomationCreditsTab/TransactionHistoryCard/components/TransactionAmount.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/AutomationCreditsTab/TransactionHistoryCard/components/TransactionAmount.tsx@@ -9,7 +9,6 @@ export function TransactionAmount({ amount, className }: Props) {<Textvariant="body-medium"as="span"- unmask={false}className={cn("whitespace-nowrap tabular-nums",amount > 0 ? "text-green-700" : "text-textBlack",diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/AutomationCreditsTab/TransactionHistoryCard/components/TransactionRow.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/AutomationCreditsTab/TransactionHistoryCard/components/TransactionRow.tsxindex 57787306a4..7468cb397a 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/AutomationCreditsTab/TransactionHistoryCard/components/TransactionRow.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/AutomationCreditsTab/TransactionHistoryCard/components/TransactionRow.tsx@@ -46,12 +46,7 @@ export function TransactionRow({<TransactionActivity transaction={transaction} /></td><td className="p-0 sm:px-2 sm:py-4">- <Text- variant="small"- title={posted.full}- unmask={false}- className="hidden sm:block"- >+ <Text variant="small" title={posted.full} className="hidden sm:block">{posted.date}<span className="mt-1 block text-zinc-600">{posted.time}</span></Text>@@ -69,7 +64,6 @@ export function TransactionRow({id={`transaction-details-${transaction.id}`}variant="ghost"size="small"- unmask={false}className="min-h-11 w-full min-w-0 px-1 text-zinc-600"onClick={() => onToggle(transaction.id)}aria-label={`${open ? "Close" : "Open"} details for ${activityName(transaction)}, ${posted.date} at ${posted.time}`}@@ -123,18 +117,17 @@ function TransactionActivity({ transaction }: { transaction: Transaction }) {{name}</Link>) : (- <Text variant="body-medium" unmask={false} className="break-words">+ <Text variant="body-medium" className="break-words">{name}</Text>)}- <Text variant="small" unmask={false} className="mt-1 text-zinc-600">+ <Text variant="small" className="mt-1 text-zinc-600">{isRunActive(transaction)? statusLabel(transaction.execution_status || ""): activityDescription(transaction)}</Text><Textvariant="small"- unmask={false}title={posted.full}className="mt-2 text-zinc-600 sm:hidden">diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/BillingOffer.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/BillingOffer.tsxindex 7fa5239425..c93a7c2853 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/BillingOffer.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/BillingOffer.tsx@@ -113,7 +113,6 @@ export function BillingOffer({ controller }: Props) {: undefined}price={price}- isTrialOffer={isTrial}benefits={benefits}actionLabel={quietdiff --git a/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/BillingPlanOffer.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/BillingPlanOffer.tsxindex b35758a8ac..cfeae8baba 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/BillingPlanOffer.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/BillingPlanOffer.tsx@@ -9,7 +9,6 @@ interface Props {quiet?: boolean;description?: string;price: string | null;- isTrialOffer?: boolean;benefits: string[];actionLabel: string;caption: string;@@ -23,7 +22,6 @@ export function BillingPlanOffer({quiet = false,description,price,- isTrialOffer = false,benefits,actionLabel,caption,@@ -63,7 +61,6 @@ export function BillingPlanOffer({<div className="flex flex-wrap items-baseline gap-1.5"><Textvariant="h2"- unmask={!isTrialOffer}as="span"className="font-sans text-[36px] font-semibold leading-10 tracking-[-0.045em]">@@ -94,7 +91,6 @@ export function BillingPlanOffer({className="mt-auto w-full"onClick={onAction}disabled={disabled}- unmask={!isTrialOffer}>{actionLabel}</Button>diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/TrialPlanChoices/ConfirmTrialPlanDialog.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/TrialPlanChoices/ConfirmTrialPlanDialog.tsxindex a5bba31412..a248040ff1 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/TrialPlanChoices/ConfirmTrialPlanDialog.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/TrialPlanChoices/ConfirmTrialPlanDialog.tsx@@ -31,7 +31,7 @@ export function ConfirmTrialPlanDialog({}}><Dialog.Content>- <Text variant="body" unmask={false}>+ <Text variant="body">Your trial ends now and your saved card is charged {price}, plusapplicable tax.</Text>diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/TrialPlanChoices/ConfirmWithBankDialog.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/TrialPlanChoices/ConfirmWithBankDialog.tsxindex 7426815af7..1d401b8a1a 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/TrialPlanChoices/ConfirmWithBankDialog.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/TrialPlanChoices/ConfirmWithBankDialog.tsx@@ -24,7 +24,7 @@ export function ConfirmWithBankDialog({ page, onClose }: Props) {><Dialog.Content>{page ? (- <Text variant="body" unmask={false}>+ <Text variant="body">Your bank wants to confirm the {formatChoicePrice(page.plan)}{" "}payment for {page.plan.label}. Pay on Stripe's secure page and{" "}{page.plan.label} starts right away. Until then your trial stays asdiff --git a/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/TrialPlanChoices/PlanChoice.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/TrialPlanChoices/PlanChoice.tsxindex be474387b8..952a28d213 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/TrialPlanChoices/PlanChoice.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/TrialPlanChoices/PlanChoice.tsx@@ -27,12 +27,7 @@ export function PlanChoice({</Text><div className="flex flex-col gap-1"><p className="flex items-baseline gap-1.5">- <Text- variant="h4"- as="span"- unmask={false}- className="text-textBlack"- >+ <Text variant="h4" as="span" className="text-textBlack">{plan.amount}</Text><Text variant="small" as="span" tone="muted">diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/YourPlanCard/MaxUpgradeSummary.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/YourPlanCard/MaxUpgradeSummary.tsxindex b26088922c..b1e5f30eb9 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/YourPlanCard/MaxUpgradeSummary.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/YourPlanCard/MaxUpgradeSummary.tsx@@ -33,7 +33,7 @@ export function MaxUpgradeSummary({ preview }: Props) {· {preview.billing_cycle === "yearly" ? "Yearly" : "Monthly"}</span></Text>- <Text variant="small" tone="secondary" unmask={false}>+ <Text variant="small" tone="secondary">{amount(preview.recurring_amount)} / {unit}</Text></div>@@ -72,12 +72,7 @@ export function MaxUpgradeSummary({ preview }: Props) {emphasized/></div>- <Text- variant="small"- tone="secondary"- unmask={false}- className="pt-2 leading-5"- >+ <Text variant="small" tone="secondary" className="pt-2 leading-5">Next renewal: {dateLabel(preview.period_end)}. Max’s regular price is{" "}{amount(preview.recurring_amount)} {recurringTax} per {unit}, beforeany applicable discounts or account credits.@@ -106,7 +101,6 @@ function SummaryRow({</Text><Textvariant={emphasized ? "body-medium" : "small"}- unmask={false}className={`shrink-0 tabular-nums ${emphasized ? "text-zinc-900" : "text-zinc-600"}`}>{value}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/YourPlanCard/SwitchTierDialog.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/YourPlanCard/SwitchTierDialog.tsxindex 24884114ff..46f239a4fd 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/YourPlanCard/SwitchTierDialog.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/settings/billing/components/SubscriptionTab/YourPlanCard/SwitchTierDialog.tsx@@ -118,7 +118,6 @@ export function SwitchTierDialog({<><ConfirmButtonlabel={action}- unmask={!preview}disabled={cannotConfirm}isSaving={isSaving}onConfirm={onConfirm}@@ -147,7 +146,6 @@ export function SwitchTierDialog({</Button><ConfirmButtonlabel={action}- unmask={!preview}disabled={cannotConfirm}isSaving={isSaving}onConfirm={onConfirm}@@ -162,13 +160,11 @@ export function SwitchTierDialog({function ConfirmButton({label,- unmask,disabled,isSaving,onConfirm,}: {label: string;- unmask: boolean;disabled?: boolean;isSaving: boolean;onConfirm: () => void;@@ -182,7 +178,6 @@ function ConfirmButton({onClick={onConfirm}disabled={disabled}loading={isSaving}- unmask={unmask}data-fast-goal="subscription_change_confirm"data-fast-goal-surface="settings_billing">diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/memory/components/LearningHistoryCard.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/memory/components/LearningHistoryCard.tsxindex 16a7f64ec2..a470b24f6f 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/memory/components/LearningHistoryCard.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/settings/memory/components/LearningHistoryCard.tsx@@ -105,12 +105,7 @@ export function LearningHistoryCard({{formatWhen(new Date(item.created_at).toISOString())}</Text></div>- <Text- variant="small"- as="span"- unmask={false}- className="text-zinc-600"- >+ <Text variant="small" as="span" className="text-zinc-600">{item.summary}</Text><Text variant="small" as="span" className="text-zinc-500">diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/memory/components/OpenDecisionsCard.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/memory/components/OpenDecisionsCard.tsxindex cf13966f10..7516f7deef 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/memory/components/OpenDecisionsCard.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/settings/memory/components/OpenDecisionsCard.tsx@@ -58,12 +58,7 @@ export function OpenDecisionsCard({{experts.find((expert) => expert.id === proposal.expert_id)?.name ?? "Otto"}</Text>- <Text- variant="small"- as="p"- unmask={false}- className="text-zinc-600"- >+ <Text variant="small" as="p" className="text-zinc-600">{proposal.summary || proposal.description} —{" "}{proposal.state_reason}</Text>diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/memory/components/RecentMemoriesCard.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/memory/components/RecentMemoriesCard.tsxindex 0858ab8ca1..4cfee9c909 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/memory/components/RecentMemoriesCard.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/settings/memory/components/RecentMemoriesCard.tsx@@ -50,7 +50,6 @@ export function RecentMemoriesCard({<Textvariant="small"as="span"- unmask={false}className="min-w-0 flex-1 text-textBlack">{fact.fact || `${fact.source} → ${fact.target}`}@@ -58,7 +57,6 @@ export function RecentMemoriesCard({<Textvariant="small"as="span"- unmask={false}className="hidden shrink-0 text-zinc-400 sm:inline">{formatWhen(fact.created_at)}diff --git a/autogpt_platform/frontend/src/app/(platform)/team/[expertId]/components/ExpertBudgetSection.tsx b/autogpt_platform/frontend/src/app/(platform)/team/[expertId]/components/ExpertBudgetSection.tsxindex ea41899dc2..56d7d22505 100644--- a/autogpt_platform/frontend/src/app/(platform)/team/[expertId]/components/ExpertBudgetSection.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/team/[expertId]/components/ExpertBudgetSection.tsx@@ -54,7 +54,6 @@ export function ExpertBudgetSection({ expert, color, className }: Props) {<Textvariant="body-medium"tone="secondary"- unmask={false}className={cn("tabular-nums", color && "!text-inherit")}>{weeklySpenddiff --git a/autogpt_platform/frontend/src/app/(platform)/team/components/CardStats.tsx b/autogpt_platform/frontend/src/app/(platform)/team/components/CardStats.tsxindex e4cef781c0..8a8619659e 100644--- a/autogpt_platform/frontend/src/app/(platform)/team/components/CardStats.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/team/components/CardStats.tsx@@ -41,7 +41,6 @@ export function CardStat({ icon, label, singular, count }: StatProps) {<Textvariant="body-medium"as="dd"- unmask={false}className="tabular-nums !text-zinc-800">{count}diff --git a/autogpt_platform/frontend/src/app/(platform)/team/components/ExpertTeamCard/ExpertTeamCard.tsx b/autogpt_platform/frontend/src/app/(platform)/team/components/ExpertTeamCard/ExpertTeamCard.tsxindex 8eb918e310..3c0801aa1c 100644--- a/autogpt_platform/frontend/src/app/(platform)/team/components/ExpertTeamCard/ExpertTeamCard.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/team/components/ExpertTeamCard/ExpertTeamCard.tsx@@ -126,7 +126,6 @@ export function ExpertTeamCard({<Textvariant="small-medium"tone="secondary"- unmask={false}className="tabular-nums">{weeklySpenddiff --git a/autogpt_platform/frontend/src/app/(platform)/team/components/SoulDrawer/components/LearnedNotes/LearnedNotes.tsx b/autogpt_platform/frontend/src/app/(platform)/team/components/SoulDrawer/components/LearnedNotes/LearnedNotes.tsxindex 959d82a7a8..f406b451db 100644--- a/autogpt_platform/frontend/src/app/(platform)/team/components/SoulDrawer/components/LearnedNotes/LearnedNotes.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/team/components/SoulDrawer/components/LearnedNotes/LearnedNotes.tsx@@ -68,20 +68,10 @@ function NotesList({className="flex items-start justify-between gap-2 py-2.5"><div className="min-w-0 flex-1">- <Text- variant="small"- as="p"- unmask={false}- className="text-textBlack"- >+ <Text variant="small" as="p" className="text-textBlack">{fact.fact || `${fact.source} → ${fact.target}`}</Text>- <Text- variant="small"- as="span"- unmask={false}- className="text-zinc-400"- >+ <Text variant="small" as="span" className="text-zinc-400">{formatWhen(fact.created_at)}</Text></div>diff --git a/autogpt_platform/frontend/src/components/atoms/Button/Button.test.tsx b/autogpt_platform/frontend/src/components/atoms/Button/Button.test.tsxindex 6a76f42e7a..b1ee669a3d 100644--- a/autogpt_platform/frontend/src/components/atoms/Button/Button.test.tsx+++ b/autogpt_platform/frontend/src/components/atoms/Button/Button.test.tsx@@ -20,87 +20,45 @@ afterEach(() => {cleanup();});-describe("Button unmask prop", () => {- it("applies sentry-unmask class by default", () => {- renderButton({ children: "Save" });- const el = screen.getByRole("button", { name: "Save" });- expect(el.className).toContain("sentry-unmask");- });-- it("omits sentry-unmask class when unmask is false", () => {- renderButton({ unmask: false, children: "Dynamic label" });- const el = screen.getByRole("button", { name: "Dynamic label" });- expect(el.className).not.toContain("sentry-unmask");- });-- it("applies sentry-unmask when unmask is explicitly true", () => {- renderButton({ unmask: true, children: "Explicit" });- const el = screen.getByRole("button", { name: "Explicit" });- expect(el.className).toContain("sentry-unmask");- });-- it("applies sentry-unmask to link variant button", () => {- renderButton({ variant: "link", children: "Link button" });- const el = screen.getByRole("button", { name: "Link button" });- expect(el.className).toContain("sentry-unmask");- });-- it("omits sentry-unmask from link variant when unmask is false", () => {- renderButton({- variant: "link",- unmask: false,- children: "Dynamic link",- });- const el = screen.getByRole("button", { name: "Dynamic link" });- expect(el.className).not.toContain("sentry-unmask");- });-- it("applies sentry-unmask to ghost variant", () => {- renderButton({ variant: "ghost", children: "Ghost" });- const el = screen.getByRole("button", { name: "Ghost" });- expect(el.className).toContain("sentry-unmask");- });-- it("applies sentry-unmask to secondary variant", () => {- renderButton({ variant: "secondary", children: "Secondary" });- const el = screen.getByRole("button", { name: "Secondary" });- expect(el.className).toContain("sentry-unmask");- });-- it("preserves custom className alongside sentry-unmask", () => {- renderButton({ className: "my-class", children: "Styled" });- const el = screen.getByRole("button", { name: "Styled" });- expect(el.className).toContain("sentry-unmask");- expect(el.className).toContain("my-class");- });-- it("applies sentry-unmask in the loading state", () => {- renderButton({ loading: true, children: "Saving" });+describe("Button in session replay", () => {+ it.each([+ ["primary", {}],+ ["secondary", { variant: "secondary" }],+ ["ghost", { variant: "ghost" }],+ ["link", { variant: "link" }],+ ["loading", { loading: true }],+ ] as const)("is masked by default (%s)", (_, props) => {+ renderButton({ ...props, children: "Account name" });const el = screen.getByRole("button");- expect(el.className).toContain("sentry-unmask");+ expect(el.closest(".sentry-unmask, [data-sentry-unmask]")).toBeNull();});- it("omits sentry-unmask in the loading state when unmask is false", () => {- renderButton({ loading: true, unmask: false, children: "Saving" });- const el = screen.getByRole("button");+ it("is masked by default as a NextLink", () => {+ renderButton({ as: "NextLink", href: "/save", children: "Go" });+ const el = screen.getByRole("link", { name: "Go" });expect(el.className).not.toContain("sentry-unmask");});- it("applies sentry-unmask to NextLink buttons", () => {- renderButton({ as: "NextLink", href: "/save", children: "Go" });- const el = screen.getByRole("link", { name: "Go" });+ it("opts into unmasking only when asked", () => {+ renderButton({ unmask: true, className: "my-class", children: "Save" });+ const el = screen.getByRole("button", { name: "Save" });expect(el.className).toContain("sentry-unmask");+ expect(el.className).toContain("my-class");});- it("omits sentry-unmask from NextLink buttons when unmask is false", () => {+ it("opts into unmasking in the loading state and as a NextLink", () => {+ renderButton({ loading: true, unmask: true, children: "Saving" });+ expect(screen.getByRole("button").className).toContain("sentry-unmask");+ cleanup();renderButton({as: "NextLink",href: "/save",- unmask: false,- children: "Dynamic NextLink",+ unmask: true,+ children: "Go",});- const el = screen.getByRole("link", { name: "Dynamic NextLink" });- expect(el.className).not.toContain("sentry-unmask");+ expect(screen.getByRole("link", { name: "Go" }).className).toContain(+ "sentry-unmask",+ );});});diff --git a/autogpt_platform/frontend/src/components/atoms/Button/Button.tsx b/autogpt_platform/frontend/src/components/atoms/Button/Button.tsxindex af4d24f626..cb50d28527 100644--- a/autogpt_platform/frontend/src/components/atoms/Button/Button.tsx+++ b/autogpt_platform/frontend/src/components/atoms/Button/Button.tsx@@ -27,7 +27,7 @@ export function Button(props: ButtonProps) {rightIcon,children,as = "button",- unmask = true,+ unmask = false,asChild: _asChild, // Destructure to prevent passing to DOM...restProps} = props;diff --git a/autogpt_platform/frontend/src/components/atoms/Button/helpers.ts b/autogpt_platform/frontend/src/components/atoms/Button/helpers.tsindex 89e372ee7f..d662e42b7c 100644--- a/autogpt_platform/frontend/src/components/atoms/Button/helpers.ts+++ b/autogpt_platform/frontend/src/components/atoms/Button/helpers.ts@@ -87,8 +87,8 @@ type BaseButtonProps = {asChild?: boolean;withTooltip?: boolean;/**- * Adds the sentry-unmask class for static button labels.- * Disable for user-provided or dynamic strings.+ * Shows the label in session replays, which mask all text by default.+ * Only for a static label that is the same for every user.*/unmask?: boolean;} & VariantProps<typeof extendedButtonVariants>;diff --git a/autogpt_platform/frontend/src/components/atoms/Text/Text.test.tsx b/autogpt_platform/frontend/src/components/atoms/Text/Text.test.tsxindex a2bd30fa67..246f683377 100644--- a/autogpt_platform/frontend/src/components/atoms/Text/Text.test.tsx+++ b/autogpt_platform/frontend/src/components/atoms/Text/Text.test.tsx@@ -6,60 +6,29 @@ afterEach(() => {cleanup();});-describe("Text unmask prop", () => {- it("applies sentry-unmask class by default", () => {- render(<Text variant="body">Static label</Text>);- const el = screen.getByText("Static label");- expect(el.className).toContain("sentry-unmask");- });-- it("omits sentry-unmask class when unmask is false", () => {- render(- <Text variant="body" unmask={false}>- Dynamic content- </Text>,- );- const el = screen.getByText("Dynamic content");- expect(el.className).not.toContain("sentry-unmask");- });-- it("applies sentry-unmask when unmask is explicitly true", () => {- render(- <Text variant="body" unmask={true}>- Explicit unmask- </Text>,- );- const el = screen.getByText("Explicit unmask");- expect(el.className).toContain("sentry-unmask");+describe("Text in session replay", () => {+ it("is masked by default", () => {+ render(<Text variant="body">Account name</Text>);+ const el = screen.getByText("Account name");+ expect(el.closest(".sentry-unmask, [data-sentry-unmask]")).toBeNull();});- it("preserves custom className alongside sentry-unmask", () => {- render(- <Text variant="body" className="custom-class">- With custom class- </Text>,- );- const el = screen.getByText("With custom class");- expect(el.className).toContain("sentry-unmask");- expect(el.className).toContain("custom-class");- });-- it("renders correct element for heading variants with unmask", () => {+ it("is masked by default for headings too", () => {render(<Text variant="h1">Heading</Text>);const el = screen.getByText("Heading");expect(el.tagName).toBe("H1");- expect(el.className).toContain("sentry-unmask");+ expect(el.className).not.toContain("sentry-unmask");});- it("renders correct element for body variant with unmask disabled", () => {+ it("opts into unmasking only when asked", () => {render(- <Text variant="body" unmask={false}>- Body text+ <Text variant="body" unmask className="custom-class">+ Static label</Text>,);- const el = screen.getByText("Body text");- expect(el.tagName).toBe("P");- expect(el.className).not.toContain("sentry-unmask");+ const el = screen.getByText("Static label");+ expect(el.className).toContain("sentry-unmask");+ expect(el.className).toContain("custom-class");});});diff --git a/autogpt_platform/frontend/src/components/atoms/Text/Text.tsx b/autogpt_platform/frontend/src/components/atoms/Text/Text.tsxindex 592767e32a..8e63a906f2 100644--- a/autogpt_platform/frontend/src/components/atoms/Text/Text.tsx+++ b/autogpt_platform/frontend/src/components/atoms/Text/Text.tsx@@ -17,8 +17,8 @@ type CustomProps = {tone?: Tone;className?: string;/**- * Adds the sentry-unmask class for static text visibility in replays.- * Disable when rendering user-provided or dynamic content.+ * Shows the text in session replays, which mask all text by default.+ * Only for static copy that is the same for every user.*/unmask?: boolean;};@@ -34,7 +34,7 @@ export function Text({size,tone,className = "",- unmask = true,+ unmask = false,...rest}: TextProps) {const variantClasses = variants[size || variant] || variants.body;diff --git a/autogpt_platform/frontend/src/components/auth/CheckYourInbox/CheckYourInbox.tsx b/autogpt_platform/frontend/src/components/auth/CheckYourInbox/CheckYourInbox.tsxindex 486eb131bd..ba7a3d33a0 100644--- a/autogpt_platform/frontend/src/components/auth/CheckYourInbox/CheckYourInbox.tsx+++ b/autogpt_platform/frontend/src/components/auth/CheckYourInbox/CheckYourInbox.tsx@@ -49,7 +49,7 @@ export function CheckYourInbox({{copy.title}</Text>- <Text variant="body" tone="secondary" unmask={false} className="mt-3">+ <Text variant="body" tone="secondary" className="mt-3">We sent an email to{" "}<span className="break-all font-medium text-slate-950">{email}</span>.Open the link in it to {copy.action}.diff --git a/autogpt_platform/frontend/src/components/contextual/CredentialsInput/CredentialsInput.tsx b/autogpt_platform/frontend/src/components/contextual/CredentialsInput/CredentialsInput.tsxindex f5c0709f3c..dffaa57b74 100644--- a/autogpt_platform/frontend/src/components/contextual/CredentialsInput/CredentialsInput.tsx+++ b/autogpt_platform/frontend/src/components/contextual/CredentialsInput/CredentialsInput.tsx@@ -239,7 +239,7 @@ export function CredentialsInput({{removedCredentialTitle && (<Alert variant="warning" aria-live="polite" className="mt-2"><AlertDescription>- <Text variant="body" unmask={false}>+ <Text variant="body">{getRemovedCredentialMessage(removedCredentialTitle,selectedCredential,diff --git a/autogpt_platform/frontend/src/components/contextual/DeviceAuth/DeviceAuthConnectButton.tsx b/autogpt_platform/frontend/src/components/contextual/DeviceAuth/DeviceAuthConnectButton.tsxindex 64c2587d9c..b7c5cda45a 100644--- a/autogpt_platform/frontend/src/components/contextual/DeviceAuth/DeviceAuthConnectButton.tsx+++ b/autogpt_platform/frontend/src/components/contextual/DeviceAuth/DeviceAuthConnectButton.tsx@@ -69,7 +69,7 @@ export function DeviceAuthConnectButton({{/* The code is a live authorization code and the link's href can carryit too (verification_uri_complete), so PostHog skips the whole panel- and Sentry masks the code (unmask={false}). */}+ and Sentry masks the code, as it does all text. */}<div className="ph-no-capture flex flex-col gap-3 rounded-lg border border-zinc-200 bg-zinc-50 p-4"><div className="flex flex-col gap-1"><Text variant="small" className="font-medium text-zinc-500">@@ -78,7 +78,6 @@ export function DeviceAuthConnectButton({<Textvariant="h3"as="p"- unmask={false}className="select-all text-center font-mono text-2xl tracking-widest text-zinc-800">{userCode}diff --git a/autogpt_platform/frontend/src/components/contextual/DeviceAuth/__tests__/DeviceAuthConnectButton.test.tsx b/autogpt_platform/frontend/src/components/contextual/DeviceAuth/__tests__/DeviceAuthConnectButton.test.tsxindex fb4b4406bd..5c32a365e4 100644--- a/autogpt_platform/frontend/src/components/contextual/DeviceAuth/__tests__/DeviceAuthConnectButton.test.tsx+++ b/autogpt_platform/frontend/src/components/contextual/DeviceAuth/__tests__/DeviceAuthConnectButton.test.tsx@@ -46,8 +46,7 @@ describe("DeviceAuthConnectButton", () => {});it("keeps the code phrase out of session replay", () => {- // `Text` adds `sentry-unmask` by default; this is a live authorization- // code, so it must not be recorded. Regression test for that default.+ // This is a live authorization code, so it must never be recorded.state.phase = "polling";state.userCode = "glow-relish-chaste-soft";state.verificationUrl =diff --git a/autogpt_platform/frontend/src/components/layout/TopUpPrompt/TopUpForm/__tests__/TopUpForm.test.tsx b/autogpt_platform/frontend/src/components/layout/TopUpPrompt/TopUpForm/__tests__/TopUpForm.test.tsxindex 7cb66aabc0..c3f878521a 100644--- a/autogpt_platform/frontend/src/components/layout/TopUpPrompt/TopUpForm/__tests__/TopUpForm.test.tsx+++ b/autogpt_platform/frontend/src/components/layout/TopUpPrompt/TopUpForm/__tests__/TopUpForm.test.tsx@@ -1,5 +1,5 @@import { http, HttpResponse } from "msw";-import { describe, expect, test, vi } from "vitest";+import { beforeEach, describe, expect, test, vi } from "vitest";import {act,render,@@ -8,13 +8,14 @@ import {waitFor,} from "@/tests/integrations/test-utils";import { server } from "@/mocks/mock-server";-import { getPostV1RequestCreditTopUpMockHandler } from "@/app/api/__generated__/endpoints/credits/credits.msw";import { restoreFromBackForwardCache } from "@/tests/integrations/back-forward-cache";import { TopUpForm } from "../TopUpForm";const routerPush = vi.hoisted(() => vi.fn());+const CHECKOUT_URL = "https://checkout.stripe.com/pay/cs_test_top_up";+vi.mock("next/navigation", () => ({useRouter: () => ({ push: routerPush, replace: vi.fn(), prefetch: vi.fn() }),usePathname: () => "/copilot",@@ -25,16 +26,19 @@ vi.mock("next/navigation", () => ({function captureTopUpRequest() {let body: unknown = null;server.use(- getPostV1RequestCreditTopUpMockHandler(- async (info: { request: Request }) => {- body = await info.request.json();- },- ),+ http.post("*/api/credits", async ({ request }) => {+ body = await request.json();+ return HttpResponse.json({ checkout_url: CHECKOUT_URL });+ }),);return { getBody: () => body };}describe("TopUpForm", () => {+ beforeEach(() => {+ routerPush.mockClear();+ });+test("submits the entered amount converted to cents", async () => {const { getBody } = captureTopUpRequest();@@ -46,6 +50,8 @@ describe("TopUpForm", () => {fireEvent.click(screen.getByRole("button", { name: /top up/i }));await waitFor(() => expect(getBody()).toEqual({ credit_amount: 1500 }));+ await waitFor(() => expect(routerPush).toHaveBeenCalledWith(CHECKOUT_URL));+ await act(async () => {});});test("rejects amounts below the $5 minimum without calling the API", async () => {@@ -65,9 +71,10 @@ describe("TopUpForm", () => {test("disables the submit button while the checkout request is in flight", async () => {// Hold the request open so the in-flight loading state is observable.server.use(- getPostV1RequestCreditTopUpMockHandler(- () => new Promise((resolve) => setTimeout(resolve, 300)),- ),+ http.post("*/api/credits", async () => {+ await new Promise((resolve) => setTimeout(resolve, 300));+ return HttpResponse.json({ checkout_url: CHECKOUT_URL });+ }),);render(<TopUpForm />);@@ -79,6 +86,13 @@ describe("TopUpForm", () => {const button = await screen.findByRole("button", { name: /redirecting/i });expect((button as HTMLButtonElement).disabled).toBe(true);++ // Let the held request finish inside the test: settling it after the+ // file's environment is torn down fails the whole run.+ await waitFor(() => expect(routerPush).toHaveBeenCalledWith(CHECKOUT_URL), {+ timeout: 2000,+ });+ await act(async () => {});});test("stays busy while Stripe loads, and is usable again after Back restores the page", async () => {diff --git a/autogpt_platform/frontend/src/components/molecules/ExpertIdentityDetails/ExpertIdentityDetails.tsx b/autogpt_platform/frontend/src/components/molecules/ExpertIdentityDetails/ExpertIdentityDetails.tsxindex 6ffc0f25b0..e429bf8288 100644--- a/autogpt_platform/frontend/src/components/molecules/ExpertIdentityDetails/ExpertIdentityDetails.tsx+++ b/autogpt_platform/frontend/src/components/molecules/ExpertIdentityDetails/ExpertIdentityDetails.tsx@@ -57,7 +57,6 @@ export function ExpertIdentityDetails({as={size === "page" ? "h1" : "span"}variant={compact ? "body-medium" : "lead-semibold"}tone="primary"- unmask={false}className={cn("min-w-0",size === "page" ? "max-w-full break-words" : "truncate",@@ -72,7 +71,6 @@ export function ExpertIdentityDetails({as="span"variant="body"tone="secondary"- unmask={false}className={cn("min-w-0",size === "page" ? "max-w-full break-words" : "truncate",@@ -117,7 +115,6 @@ export function ExpertIdentityDetails({as="span"variant="small"tone="secondary"- unmask={false}className={cn("truncate leading-4", areaClassName)}title={area}>diff --git a/autogpt_platform/frontend/src/components/molecules/ExpertIdentityDetails/components/ExpertTagline.tsx b/autogpt_platform/frontend/src/components/molecules/ExpertIdentityDetails/components/ExpertTagline.tsxindex 0b9cac4c40..a163dee6ca 100644--- a/autogpt_platform/frontend/src/components/molecules/ExpertIdentityDetails/components/ExpertTagline.tsx+++ b/autogpt_platform/frontend/src/components/molecules/ExpertIdentityDetails/components/ExpertTagline.tsx@@ -13,7 +13,6 @@ export function ExpertTagline({ tagline, compact }: Props) {<Textvariant="body"tone="secondary"- unmask={false}className={cn("mt-2", compact && "line-clamp-2 min-h-[2lh]")}>{tagline}diff --git a/autogpt_platform/frontend/src/components/monitor/SentryUserTracker.tsx b/autogpt_platform/frontend/src/components/monitor/SentryUserTracker.tsxindex c7bc61e96c..b4813019d5 100644--- a/autogpt_platform/frontend/src/components/monitor/SentryUserTracker.tsx+++ b/autogpt_platform/frontend/src/components/monitor/SentryUserTracker.tsx@@ -22,11 +22,10 @@ export function SentryUserTracker() {// Wait until user loading is complete before setting user contextif (isUserLoading) return;- // Set user context for Sentry error tracking+ // The id is enough to find a user's errors; their email stays out of+ // Sentry. The role only tells admins apart.Sentry.setUser({id: user.id,- email: user.email ?? undefined,- // Add custom attributes...(user.role && { role: user.role }),});} else {diff --git a/autogpt_platform/frontend/src/components/organisms/BriefingCard/components/RunRow.tsx b/autogpt_platform/frontend/src/components/organisms/BriefingCard/components/RunRow.tsxindex 7e4d3dde57..ceb9167975 100644--- a/autogpt_platform/frontend/src/components/organisms/BriefingCard/components/RunRow.tsx+++ b/autogpt_platform/frontend/src/components/organisms/BriefingCard/components/RunRow.tsx@@ -28,13 +28,9 @@ export function RunRow({ item, isHidden = false }: Props) {/><div className="min-w-0 flex-1"><div className="flex items-center gap-2">- {/* Agent names and run summaries are user data: leave them masked in- session replays rather than taking Text's static-copy default. */}- <Text- variant="body-medium"- unmask={false}- className="truncate text-zinc-900"- >+ {/* Agent names and run summaries are user data: never opt them into+ unmasking in session replays. */}+ <Text variant="body-medium" className="truncate text-zinc-900">{item.agent_name}</Text>{isFailed ? (@@ -44,11 +40,7 @@ export function RunRow({ item, isHidden = false }: Props) {) : null}</div>{text ? (- <Text- variant="body"- unmask={false}- className="line-clamp-2 text-zinc-500"- >+ <Text variant="body" className="line-clamp-2 text-zinc-500">{/* Attribution matters once more than one agent reports:mirrors the thread markdown's "**{agent}**: {summary}". */}{attribution ? (diff --git a/autogpt_platform/frontend/src/components/organisms/ProActivation/ProActivationDialog.tsx b/autogpt_platform/frontend/src/components/organisms/ProActivation/ProActivationDialog.tsxindex 1f8c1734f0..1848db6e72 100644--- a/autogpt_platform/frontend/src/components/organisms/ProActivation/ProActivationDialog.tsx+++ b/autogpt_platform/frontend/src/components/organisms/ProActivation/ProActivationDialog.tsx@@ -92,7 +92,6 @@ export function ProActivationDialog({ activation }: Props) {disabled={isBusy || refreshTerms}loading={isBusy}onClick={confirm}- unmask={retryConsent}>{retryConsent? "Retry same confirmation"diff --git a/autogpt_platform/frontend/src/components/organisms/ProActivation/RenewalDetails.tsx b/autogpt_platform/frontend/src/components/organisms/ProActivation/RenewalDetails.tsxindex 2b22eb22c7..41fc1e573c 100644--- a/autogpt_platform/frontend/src/components/organisms/ProActivation/RenewalDetails.tsx+++ b/autogpt_platform/frontend/src/components/organisms/ProActivation/RenewalDetails.tsx@@ -29,12 +29,7 @@ export function RenewalDetails({ terms }: Props) {return (<div className="space-y-2">{terms.renewal_discounts?.map((discount, index) => (- <Text- key={index}- unmask={false}- variant="small"- className="text-zinc-600"- >+ <Text key={index} variant="small" className="text-zinc-600">{discountText(discount, terms.currency)}</Text>))}@@ -42,20 +37,11 @@ export function RenewalDetails({ terms }: Props) {<summary className="w-fit cursor-pointer rounded-small underline decoration-zinc-300 underline-offset-4 focus-visible:outline focus-visible:outline-2 focus-visible:outline-violet-500">Full renewal terms</summary>- <Text- variant="small"- unmask={false}- className="mt-3 leading-relaxed text-zinc-600"- >+ <Text variant="small" className="mt-3 leading-relaxed text-zinc-600">{terms.renewal_terms}</Text>{terms.renewal_tax?.rates?.map((rate, index) => (- <Text- key={index}- unmask={false}- variant="small"- className="mt-2 text-zinc-600"- >+ <Text key={index} variant="small" className="mt-2 text-zinc-600">{rate.display_name}: {rate.percentage}%{" "}{rate.inclusive ? "included" : "additional"}{[rate.country, rate.state].filter(Boolean).lengthdiff --git a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/OfferActions.tsx b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/OfferActions.tsxindex 88ce9c83ed..370514be5e 100644--- a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/OfferActions.tsx+++ b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/OfferActions.tsx@@ -75,7 +75,6 @@ function PaidPlanAction({variant={inline ? "link" : plan.highlighted ? "primary" : "secondary"}size="small"className={inline ? "h-auto min-w-0 p-0 text-xs text-zinc-500" : "w-full"}- unmask={!inline}loading={isUpdatingTier && selectedPlan === plan.key}disabled={isUpdatingTier || isStartingTrial}onClick={handleSelect}@@ -93,7 +92,7 @@ function PaidPlanAction({function TrialActionDetails(props: Props) {const { paidActionPrice } = getPlanPresentation(props.plan, props);return (- <Text variant="small" tone="muted" unmask={false}>+ <Text variant="small" tone="muted">Card required. No subscription charge today.{" "}<Buttontype="button"@@ -136,7 +135,7 @@ function AlternativeTrial({>Try {plan.name} for {offer.duration_days} days instead</Button>- <Text variant="small" tone="muted" unmask={false}>+ <Text variant="small" tone="muted">Renews at {formatTrialPrice(offer)} + applicable tax.</Text></div>diff --git a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/PlanDetailsDialog/components/TrialDetails.tsx b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/PlanDetailsDialog/components/TrialDetails.tsxindex 0ef847d48b..6dca8291f2 100644--- a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/PlanDetailsDialog/components/TrialDetails.tsx+++ b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/PlanDetailsDialog/components/TrialDetails.tsx@@ -18,7 +18,7 @@ export function TrialDetails({ offer }: Props) {<Text as="dt" variant="body">Today</Text>- <Text as="dd" variant="lead-medium" unmask={false}>+ <Text as="dd" variant="lead-medium">{formatPlanAmount(0, offer.currency)}</Text></div>@@ -26,7 +26,7 @@ export function TrialDetails({ offer }: Props) {<Text as="dt" variant="body">After {offer.duration_days} days</Text>- <Text as="dd" variant="lead-medium" unmask={false}>+ <Text as="dd" variant="lead-medium">{formatTrialPrice(offer)}</Text></div>diff --git a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/SubscriptionOffer.tsx b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/SubscriptionOffer.tsxindex 40c1470856..f1968922a5 100644--- a/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/SubscriptionOffer.tsx+++ b/autogpt_platform/frontend/src/components/organisms/SubscriptionPlans/components/SubscriptionOffer.tsx@@ -89,7 +89,6 @@ function OfferPrice({variant="h3"as="span"aria-label={presentation.price}- unmask={false}className="leading-9 text-zinc-800">{presentation.price}diff --git a/autogpt_platform/frontend/src/components/organisms/TrialCard/CancelTrialDialog.tsx b/autogpt_platform/frontend/src/components/organisms/TrialCard/CancelTrialDialog.tsxindex b84aaf28ed..8ac933acc3 100644--- a/autogpt_platform/frontend/src/components/organisms/TrialCard/CancelTrialDialog.tsx+++ b/autogpt_platform/frontend/src/components/organisms/TrialCard/CancelTrialDialog.tsx@@ -41,7 +41,7 @@ export function CancelTrialDialog({ trial, isCanceling, onCancel }: Props) {Your trial won't convert to a paid plan and your cardwon't be charged.</Text>- <Text variant="body" unmask={false} className="!text-zinc-800">+ <Text variant="body" className="!text-zinc-800">You keep full access until{" "}<strong className="font-semibold">{formatTrialEnd(trial.ends_at)}diff --git a/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialCancelPending.tsx b/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialCancelPending.tsxindex 4e6758629c..adfb3c1e67 100644--- a/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialCancelPending.tsx+++ b/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialCancelPending.tsx@@ -32,7 +32,7 @@ export function TrialCancelPending({Cancellation pending</span></div>- <Text variant="body" unmask={false} className="!text-zinc-800">+ <Text variant="body" className="!text-zinc-800">Cancellation confirmed. Your trial will not convert to a paid plan andyour card won't be charged. Trial access ends{" "}<strong className="font-semibold">@@ -41,7 +41,7 @@ export function TrialCancelPending({.</Text>{trial.ends_at ? (- <Text variant="small" unmask={false} className="!text-zinc-500">+ <Text variant="small" className="!text-zinc-500">Resume to keep the trial and start {trialPlanLabels[offer.tier]} on{" "}{formatTrialEndDate(trial.ends_at)} at {formatPlanPrice(offer)}, plusapplicable tax.diff --git a/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialCanceledDialog/TrialCanceledDialog.tsx b/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialCanceledDialog/TrialCanceledDialog.tsxindex f6d28b9e65..1aac104a84 100644--- a/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialCanceledDialog/TrialCanceledDialog.tsx+++ b/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialCanceledDialog/TrialCanceledDialog.tsx@@ -36,7 +36,7 @@ export function TrialCanceledDialog({><Dialog.Content><div className="flex flex-col gap-4">- <Text variant="body" unmask={false} className="!text-zinc-800">+ <Text variant="body" className="!text-zinc-800">Your card won't be charged.{" "}<TrialTimeLeft endsAt={trial.ends_at} /></Text>diff --git a/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialCanceledDialog/components/WorthDoingPanel.tsx b/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialCanceledDialog/components/WorthDoingPanel.tsxindex 748a3d8316..891f5f0875 100644--- a/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialCanceledDialog/components/WorthDoingPanel.tsx+++ b/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialCanceledDialog/components/WorthDoingPanel.tsx@@ -56,7 +56,7 @@ export function WorthDoingPanel({ offer, endsAt }: Props) {<Text variant="body-medium" className="!text-zinc-900">{row.title}</Text>- <Text variant="small" unmask={false} className="!text-zinc-600">+ <Text variant="small" className="!text-zinc-600">{row.body}</Text></div>diff --git a/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialOffer.tsx b/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialOffer.tsxindex a6d5906020..d15aca327b 100644--- a/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialOffer.tsx+++ b/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialOffer.tsx@@ -26,7 +26,7 @@ export function TrialOffer({ trial, isStarting, isBlocked, onStart }: Props) {No charge today</span></div>- <Text variant="body" unmask={false} className="!text-zinc-800">+ <Text variant="body" className="!text-zinc-800">Card required. No subscription charge today. Then{" "}{formatTrialPrice(offer)}, plus applicable tax, unless you cancelbefore the trial ends.diff --git a/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialStatus.tsx b/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialStatus.tsxindex f6081bd6a5..0476b213d7 100644--- a/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialStatus.tsx+++ b/autogpt_platform/frontend/src/components/organisms/TrialCard/TrialStatus.tsx@@ -51,7 +51,6 @@ export function TrialStatus({</div><Textvariant="small"- unmask={false}tone="secondary"className="max-w-[560px] leading-5">diff --git a/autogpt_platform/frontend/src/components/organisms/UsageExperience/PaymentDueAction.tsx b/autogpt_platform/frontend/src/components/organisms/UsageExperience/PaymentDueAction.tsxindex 1005147b7b..9b6bc65c82 100644--- a/autogpt_platform/frontend/src/components/organisms/UsageExperience/PaymentDueAction.tsx+++ b/autogpt_platform/frontend/src/components/organisms/UsageExperience/PaymentDueAction.tsx@@ -30,7 +30,6 @@ export function PaymentDueAction({target="_blank"rel="noopener noreferrer"size={size}- unmask={false}className={stacked ? "w-full" : undefined}rightIcon={<Icondiff --git a/autogpt_platform/frontend/src/components/organisms/UsageExperience/PaymentRecoveryCard.tsx b/autogpt_platform/frontend/src/components/organisms/UsageExperience/PaymentRecoveryCard.tsxindex 447993e18d..5f3e659a72 100644--- a/autogpt_platform/frontend/src/components/organisms/UsageExperience/PaymentRecoveryCard.tsx+++ b/autogpt_platform/frontend/src/components/organisms/UsageExperience/PaymentRecoveryCard.tsx@@ -33,7 +33,6 @@ export function PaymentRecoveryCard({ payment, fallback }: Props) {<Textvariant="small"tone="secondary"- unmask={!payment}className="max-w-[38rem] leading-6">{payment?.description ?? fallback}diff --git a/autogpt_platform/frontend/src/components/organisms/UsageExperience/PlanOffer.tsx b/autogpt_platform/frontend/src/components/organisms/UsageExperience/PlanOffer.tsxindex c70821e9ff..9a0575883d 100644--- a/autogpt_platform/frontend/src/components/organisms/UsageExperience/PlanOffer.tsx+++ b/autogpt_platform/frontend/src/components/organisms/UsageExperience/PlanOffer.tsx@@ -77,7 +77,7 @@ export function PlanOffer({</div>{amount && (<div className="shrink-0 text-right">- <Text variant="h4" className="!text-2xl" unmask={!freshUsage}>+ <Text variant="h4" className="!text-2xl">{amount}</Text><Text variant="small" className="!text-zinc-500">@@ -105,7 +105,6 @@ export function PlanOffer({className="w-full"onClick={onUpgrade}disabled={disabled}- unmask={!freshUsage}rightIcon={<Icon icon={ArrowRight02Icon} size={16} />}>{actionLabel ??diff --git a/autogpt_platform/frontend/src/lib/__tests__/sentry-filters.test.ts b/autogpt_platform/frontend/src/lib/__tests__/sentry-filters.test.tsindex 02b6162cdc..31d18739b5 100644--- a/autogpt_platform/frontend/src/lib/__tests__/sentry-filters.test.ts+++ b/autogpt_platform/frontend/src/lib/__tests__/sentry-filters.test.ts@@ -19,6 +19,10 @@ import {CLIENT_IGNORE_ERRORS,isFromBot,isNextRSCNavigationFallback,+ stripLogUserPII,+ stripSpanDataPII,+ stripSpanPII,+ stripUserPII,} from "../sentry-filters";// Drives a real Sentry client with the same console capture as@@ -157,3 +161,107 @@ describe("Sentry filter for crawler noise", () => {expect(isFromBot(userAgent)).toBe(false);});});++describe("Sentry user privacy filters", () => {+ it("drops a user left with no id or role instead of sending an empty one", () => {+ const event = stripUserPII({+ user: { email: "[email protected]", ip_address: "203.0.113.7" },+ });++ expect(event).not.toHaveProperty("user");+ });++ it("keeps log attributes that only mention an address or a user", () => {+ const log = stripLogUserPII({+ level: "info",+ message: "rendered",+ attributes: {+ "server.address": "platform.agpt.co",+ "users.count": 3,+ "ip.allowlist_enabled": true,+ },+ });++ expect(log.attributes).toEqual({+ "server.address": "platform.agpt.co",+ "users.count": 3,+ "ip.allowlist_enabled": true,+ });+ });++ // Request headers reach span attributes as http.request.header.<name>, with+ // the name lowercased and its dashes turned into underscores by the SDK, or+ // left as sent by other instrumentation.+ const IP_ATTRIBUTES = [+ "http.request.header.x_forwarded_for",+ "http.request.header.x-forwarded-for",+ "http.request.header.forwarded",+ "http.request.header.x_real_ip",+ "http.request.header.x-real-ip",+ "http.request.header.cf_connecting_ip",+ "http.request.header.true_client_ip",+ "http.request.header.x_client_ip",+ "http.request.header.x_vercel_forwarded_for",+ "http.request.header.x_vercel_proxied_for",+ "http.request.header.x_vercel_ip_city",+ "http.request.header.X-Vercel-IP-Country",+ "http.client_ip",+ "net.peer.ip",+ "net.host.ip",+ "net.sock.peer.addr",+ "network.peer.address",+ "client.address",+ "user.ip_address",+ "ip",+ ];+ const KEPT_ATTRIBUTES = {+ "server.address": "platform.agpt.co",+ "http.route": "/library",+ "http.request.header.user_agent": "Mozilla/5.0",+ "http.request.header.accept_language": "en",+ "ip.allowlist_enabled": true,+ "users.count": 3,+ "user.id": "user-1",+ };++ function withIPAttributes() {+ return {+ ...Object.fromEntries(IP_ATTRIBUTES.map((key) => [key, "203.0.113.7"])),+ ...KEPT_ATTRIBUTES,+ };+ }++ it("drops every IP attribute from logs, transactions and spans", () => {+ const trace = { trace_id: "a".repeat(32), span_id: "b".repeat(16) };+ const span = { ...trace, start_timestamp: 1 };++ const log = stripLogUserPII({+ level: "info",+ message: "rendered",+ attributes: withIPAttributes(),+ });+ const transaction = stripSpanPII({+ type: "transaction",+ contexts: { trace: { ...trace, data: withIPAttributes() } },+ spans: [{ ...span, data: withIPAttributes() }],+ });+ const standalone = stripSpanDataPII({ ...span, data: withIPAttributes() });++ expect(log.attributes).toEqual(KEPT_ATTRIBUTES);+ expect(transaction.contexts?.trace?.data).toEqual(KEPT_ATTRIBUTES);+ expect(transaction.spans?.[0].data).toEqual(KEPT_ATTRIBUTES);+ expect(standalone.data).toEqual(KEPT_ATTRIBUTES);+ });++ it("leaves a transaction with no span data as it is", () => {+ const trace = { trace_id: "a".repeat(32), span_id: "b".repeat(16) };+ const event = { type: "transaction" as const, contexts: { trace } };++ expect(stripSpanPII(event)).toEqual({+ type: "transaction",+ contexts: {+ trace: { trace_id: "a".repeat(32), span_id: "b".repeat(16) },+ },+ });+ });+});diff --git a/autogpt_platform/frontend/src/lib/__tests__/session-replay.test.ts b/autogpt_platform/frontend/src/lib/__tests__/session-replay.test.tsindex 2d3bc99c9b..4d24a99374 100644--- a/autogpt_platform/frontend/src/lib/__tests__/session-replay.test.ts+++ b/autogpt_platform/frontend/src/lib/__tests__/session-replay.test.ts@@ -38,10 +38,7 @@ describe("setupSessionReplay", () => {it("installs replay at init when monitoring consent is already stored", () => {installCookiebot({ statistics: true });- expect(integrationNames(setupSessionReplay())).toEqual([- "ReplayCanvas",- "Replay",- ]);+ expect(integrationNames(setupSessionReplay())).toEqual(["Replay"]);});it("records nothing before consent, then adds replay once it is granted", () => {@@ -54,10 +51,30 @@ describe("setupSessionReplay", () => {expect(Sentry.addIntegration).not.toHaveBeenCalled();answerCookiebot({ statistics: true });- expect(addedIntegrationNames()).toEqual(["ReplayCanvas", "Replay"]);+ expect(addedIntegrationNames()).toEqual(["Replay"]);answerCookiebot({ statistics: true, marketing: true });- expect(Sentry.addIntegration).toHaveBeenCalledTimes(2);+ expect(Sentry.addIntegration).toHaveBeenCalledTimes(1);+ });++ it("masks all text, inputs and media unless an element opts in", () => {+ installCookiebot({ statistics: true });+ setupSessionReplay();++ expect(Sentry.replayIntegration).toHaveBeenCalledExactlyOnceWith({+ maskAllText: true,+ maskAllInputs: true,+ blockAllMedia: true,+ unmask: [".sentry-unmask, [data-sentry-unmask]"],+ });+ });++ // Canvas pixels are recorded as drawn, with no masking at all.+ it("records no canvas", () => {+ installCookiebot({ statistics: true });+ setupSessionReplay();++ expect(Sentry.replayCanvasIntegration).not.toHaveBeenCalled();});it("never installs replay without a consent banner", () => {diff --git a/autogpt_platform/frontend/src/lib/sentry-filters.ts b/autogpt_platform/frontend/src/lib/sentry-filters.tsindex 3cca79c152..5ec44d298e 100644--- a/autogpt_platform/frontend/src/lib/sentry-filters.ts+++ b/autogpt_platform/frontend/src/lib/sentry-filters.ts@@ -1,4 +1,4 @@-import type { Event } from "@sentry/nextjs";+import type { Event, init } from "@sentry/nextjs";// Next.js logs exactly this when a client-side navigation cannot fetch the RSC// payload (flaky network, tab backgrounded, deploy in progress). It then does a@@ -66,10 +66,31 @@ export function isFromBot(userAgent: string | undefined) {return BOT_USER_AGENT.test(userAgent);}-const CREDENTIAL_HEADERS = new Set(["cookie", "authorization"]);+// Credentials, and the headers proxies put the visitor's IP address (and+// Vercel the location it resolves from it) in.+const PRIVATE_HEADERS = new Set([+ "cookie",+ "authorization",+ "x-forwarded-for",+ "x-real-ip",+ "x-vercel-forwarded-for",+ "x-vercel-proxied-for",+ "cf-connecting-ip",+ "true-client-ip",+ "x-client-ip",+ "forwarded",+]);+const PRIVATE_HEADER_PREFIX = "x-vercel-ip-";-// Keeps the request's body, cookies and credential headers out of server and-// edge events.+function isPrivateHeader(name: string) {+ const header = name.toLowerCase();+ return (+ PRIVATE_HEADERS.has(header) || header.startsWith(PRIVATE_HEADER_PREFIX)+ );+}++// Keeps the request's body, cookies, credential headers and the visitor's IP+// address out of server and edge events.export function stripRequestCredentials<T extends Event>(event: T): T {const { request } = event;if (!request) return event;@@ -77,9 +98,92 @@ export function stripRequestCredentials<T extends Event>(event: T): T {delete request.cookies;if (!request.headers) return event;request.headers = Object.fromEntries(- Object.entries(request.headers).filter(- ([name]) => !CREDENTIAL_HEADERS.has(name.toLowerCase()),+ Object.entries(request.headers).filter(([name]) => !isPrivateHeader(name)),+ );+ return event;+}++const SENTRY_USER_FIELDS = new Set(["id", "role"]);++// Error monitoring runs without consent (legitimate interest), so a user is+// known to Sentry by their id and role only: never their email, name or IP+// address, whichever code put them on the scope.+export function stripUserPII<T extends Event>(event: T): T {+ if (!event.user) return event;+ const user = Object.fromEntries(+ Object.entries(event.user).filter(([field]) =>+ SENTRY_USER_FIELDS.has(field),),);+ if (Object.keys(user).length) event.user = user;+ else delete event.user;+ return event;+}++// The SDK copies the scope's user id, email and username into every log's and+// span's attributes, web vital spans name the user by email in a bare `user`,+// and server spans carry the visitor's address both as attributes of their own+// (`http.client_ip`, `net.peer.ip`, `client.address`, `network.peer.address`)+// and in every request header (`http.request.header.x_forwarded_for`,+// `…x-real-ip`, `…x_vercel_ip_city`). Names are matched with dots and dashes+// read as underscores, so one fragment covers every spelling.+const IP_ATTRIBUTE_FRAGMENTS = [+ "forwarded",+ "proxied_for",+ "real_ip",+ "connecting_ip",+ "client_ip",+ "vercel_ip",+ "peer_ip",+ "peer_addr",+ "client_address",+ "ip_address",+];++function isIPAttribute(name: string) {+ const key = name.toLowerCase().replace(/[.-]/g, "_");+ if (key === "ip" || key.endsWith("_ip")) return true;+ return IP_ATTRIBUTE_FRAGMENTS.some((fragment) => key.includes(fragment));+}++function isPrivateAttribute(name: string) {+ if (name === "user") return true;+ if (name.startsWith("user.")) return name !== "user.id";+ return isIPAttribute(name);+}++function withoutPrivateAttributes<V>(attributes: Record<string, V>) {+ return Object.fromEntries(+ Object.entries(attributes).filter(([name]) => !isPrivateAttribute(name)),+ );+}++type SentryOptions = NonNullable<Parameters<typeof init>[0]>;+type SentryLog = Parameters<NonNullable<SentryOptions["beforeSendLog"]>>[0];+type SentrySpan = Parameters<NonNullable<SentryOptions["beforeSendSpan"]>>[0];++// Logs are known to Sentry by the user id only, like errors and transactions.+export function stripLogUserPII(log: SentryLog): SentryLog {+ if (!log.attributes) return log;+ log.attributes = withoutPrivateAttributes(log.attributes);+ return log;+}++// Transactions carry their root span's attributes in the trace context and+// every child span's in its own data; an error raised inside a span carries+// that span's attributes in its trace context too. beforeSend and+// beforeSendTransaction are the last places to take the visitor's IP+// address, email and name out of them.+export function stripSpanPII<T extends Event>(event: T): T {+ const trace = event.contexts?.trace;+ if (trace?.data) trace.data = withoutPrivateAttributes(trace.data);+ event.spans?.forEach(stripSpanDataPII);return event;}++// Standalone spans, such as the browser's web vitals, skip+// beforeSendTransaction and pass through beforeSendSpan only.+export function stripSpanDataPII(span: SentrySpan): SentrySpan {+ if (span.data) span.data = withoutPrivateAttributes(span.data);+ return span;+}diff --git a/autogpt_platform/frontend/src/lib/sentry-tunnel-middleware.ts b/autogpt_platform/frontend/src/lib/sentry-tunnel-middleware.tsindex 92a2ab9df7..cceff22a6b 100644--- a/autogpt_platform/frontend/src/lib/sentry-tunnel-middleware.ts+++ b/autogpt_platform/frontend/src/lib/sentry-tunnel-middleware.ts@@ -2,8 +2,8 @@ import { getSentryTunnelURL } from "@/lib/sentry-tunnel";import { environment } from "@/services/environment";import { NextResponse, type NextRequest } from "next/server";-// What Sentry's ingest reads. The forwarded-for headers keep the user's IP,-// which Sentry records; cookies and Authorization never leave.+// What Sentry's ingest reads. The visitor's IP address (the forwarded-for+// headers), cookies and Authorization never leave.const FORWARDED_HEADERS = ["content-type","content-length",@@ -15,8 +15,6 @@ const FORWARDED_HEADERS = ["sec-ch-ua-platform-version","origin","referer",- "x-forwarded-for",- "x-vercel-forwarded-for",];// Above Replay's ~20 MB event buffer, the largest envelope the browser SDK sends.diff --git a/autogpt_platform/frontend/src/lib/session-replay.ts b/autogpt_platform/frontend/src/lib/session-replay.tsindex add036cb79..5dd53efeca 100644--- a/autogpt_platform/frontend/src/lib/session-replay.ts+++ b/autogpt_platform/frontend/src/lib/session-replay.ts@@ -2,10 +2,14 @@ import { hasConsentFor, subscribeToConsent } from "@/services/consent/consent";import * as Sentry from "@sentry/nextjs";function createReplayIntegrations() {- // Canvas first: Replay looks it up by name when it sets up.+ // Everything on screen is masked unless an element opts in with+ // `sentry-unmask`, which only copy that is the same for every user should.+ // No canvas recording: its pixels are sent as drawn, with no masking.return [- Sentry.replayCanvasIntegration(),Sentry.replayIntegration({+ maskAllText: true,+ maskAllInputs: true,+ blockAllMedia: true,unmask: [".sentry-unmask, [data-sentry-unmask]"],}),];diff --git a/autogpt_platform/frontend/src/services/consent/consent.ts b/autogpt_platform/frontend/src/services/consent/consent.tsindex 91f379d5a8..6093be470e 100644--- a/autogpt_platform/frontend/src/services/consent/consent.ts+++ b/autogpt_platform/frontend/src/services/consent/consent.ts@@ -8,6 +8,8 @@ import {type CookiebotConsent,} from "./cookiebot";+// "monitoring" gates Sentry session replay only. Error monitoring is part of+// running the service (legitimate interest), so it needs no consent.export type ConsentCategory = "analytics" | "monitoring" | "advertising";export type ConsentState = Readonly<Record<ConsentCategory, boolean>>;