From b7ebed3a2207b930cc5186f93dce42226a03a43a Mon Sep 17 00:00:00 2001 From: Mohamed Khelif Date: Fri, 5 Jul 2024 12:53:02 -0400 Subject: [PATCH] DEVPROD-8620 Update sentry config to send larger values (#229) --- .../src/components/ErrorHandling/Sentry.tsx | 1 + .../components/ErrorHandling/initialize.test.ts | 3 +++ .../src/components/ErrorHandling/Sentry.tsx | 11 ++++++----- .../components/ErrorHandling/initialize.test.ts | 15 +++++++++------ 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/apps/parsley/src/components/ErrorHandling/Sentry.tsx b/apps/parsley/src/components/ErrorHandling/Sentry.tsx index cad06f4be..c69645cbc 100644 --- a/apps/parsley/src/components/ErrorHandling/Sentry.tsx +++ b/apps/parsley/src/components/ErrorHandling/Sentry.tsx @@ -36,6 +36,7 @@ const initializeSentry = () => { debug: !isProduction(), dsn: getSentryDSN(), environment: getReleaseStage() || "development", + maxValueLength: 500, normalizeDepth: 5, sampleRate: 0.5, }); diff --git a/apps/parsley/src/components/ErrorHandling/initialize.test.ts b/apps/parsley/src/components/ErrorHandling/initialize.test.ts index 2e78fce58..08517672a 100644 --- a/apps/parsley/src/components/ErrorHandling/initialize.test.ts +++ b/apps/parsley/src/components/ErrorHandling/initialize.test.ts @@ -40,6 +40,7 @@ describe("should initialize error handlers according to release stage", () => { debug: false, dsn: "fake-sentry-key", environment: "production", + maxValueLength: 500, normalizeDepth: 5, sampleRate: 0.5, }); @@ -57,6 +58,7 @@ describe("should initialize error handlers according to release stage", () => { debug: true, dsn: "fake-sentry-key", environment: "beta", + maxValueLength: 500, normalizeDepth: 5, sampleRate: 0.5, }); @@ -74,6 +76,7 @@ describe("should initialize error handlers according to release stage", () => { debug: true, dsn: "fake-sentry-key", environment: "staging", + maxValueLength: 500, normalizeDepth: 5, sampleRate: 0.5, }); diff --git a/apps/spruce/src/components/ErrorHandling/Sentry.tsx b/apps/spruce/src/components/ErrorHandling/Sentry.tsx index 817b50b41..c1c77b2d2 100644 --- a/apps/spruce/src/components/ErrorHandling/Sentry.tsx +++ b/apps/spruce/src/components/ErrorHandling/Sentry.tsx @@ -19,9 +19,6 @@ import { processHtmlAttributes } from "./utils"; const initializeSentry = () => { try { init({ - // Don't send errors from unauthenticated users - beforeSend: (event) => (event.user?.id ? event : null), - sampleRate: 0.5, beforeBreadcrumb: (breadcrumb, hint) => { if (breadcrumb?.category?.startsWith("ui")) { const { target } = hint?.event ?? {}; @@ -34,10 +31,14 @@ const initializeSentry = () => { } return breadcrumb; }, - dsn: getSentryDSN(), + // Don't send errors from unauthenticated users + beforeSend: (event) => (event.user?.id ? event : null), debug: !isProduction(), - normalizeDepth: 5, + dsn: getSentryDSN(), environment: getReleaseStage() || "development", + maxValueLength: 500, + normalizeDepth: 5, + sampleRate: 0.5, }); } catch (e) { console.error("Failed to initialize Sentry", e); diff --git a/apps/spruce/src/components/ErrorHandling/initialize.test.ts b/apps/spruce/src/components/ErrorHandling/initialize.test.ts index 3759804d8..aa9ef43a6 100644 --- a/apps/spruce/src/components/ErrorHandling/initialize.test.ts +++ b/apps/spruce/src/components/ErrorHandling/initialize.test.ts @@ -41,10 +41,11 @@ describe("should initialize error handlers according to release stage", () => { expect(vi.mocked(init)).toHaveBeenCalledWith({ beforeBreadcrumb: expect.any(Function), beforeSend: expect.any(Function), - dsn: "fake-sentry-key", debug: false, - normalizeDepth: 5, + dsn: "fake-sentry-key", environment: "production", + maxValueLength: 500, + normalizeDepth: 5, sampleRate: 0.5, }); }); @@ -59,10 +60,11 @@ describe("should initialize error handlers according to release stage", () => { expect(vi.mocked(init)).toHaveBeenCalledWith({ beforeBreadcrumb: expect.any(Function), beforeSend: expect.any(Function), - dsn: "fake-sentry-key", debug: true, - normalizeDepth: 5, + dsn: "fake-sentry-key", environment: "beta", + maxValueLength: 500, + normalizeDepth: 5, sampleRate: 0.5, }); }); @@ -77,10 +79,11 @@ describe("should initialize error handlers according to release stage", () => { expect(vi.mocked(init)).toHaveBeenCalledWith({ beforeBreadcrumb: expect.any(Function), beforeSend: expect.any(Function), - dsn: "fake-sentry-key", debug: true, - normalizeDepth: 5, + dsn: "fake-sentry-key", environment: "staging", + maxValueLength: 500, + normalizeDepth: 5, sampleRate: 0.5, }); });