From 1facd3ad64eb7f386686e6456ba485a089c19eec Mon Sep 17 00:00:00 2001 From: David Newell Date: Tue, 12 Nov 2024 14:04:35 +0000 Subject: [PATCH] chore: add type to Sentry exception --- cypress/e2e/error-tracking.cy.ts | 1 + src/extensions/sentry-integration.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/error-tracking.cy.ts b/cypress/e2e/error-tracking.cy.ts index 4a84ed9ee..419d436ee 100644 --- a/cypress/e2e/error-tracking.cy.ts +++ b/cypress/e2e/error-tracking.cy.ts @@ -50,6 +50,7 @@ describe('Exception capture', () => { cy.phCaptures({ full: true }).then((captures) => { expect(captures.map((c) => c.event)).to.deep.equal(['$pageview', '$autocapture', '$exception']) expect(captures[2].event).to.be.eql('$exception') + expect(captures[2].properties.$exception_list[0].stacktrace.type).to.be.eq('raw') expect(captures[2].properties.$exception_list[0].stacktrace.frames.length).to.be.eq(1) expect(captures[2].properties.$exception_list[0].stacktrace.frames[0].function).to.be.eq( 'HTMLButtonElement.onclick' diff --git a/src/extensions/sentry-integration.ts b/src/extensions/sentry-integration.ts index b3864365d..940655dd0 100644 --- a/src/extensions/sentry-integration.ts +++ b/src/extensions/sentry-integration.ts @@ -34,6 +34,7 @@ import { SeverityLevel } from '../types' // Uncomment the above and comment the below to get type checking for development type _SentryEvent = any +type _SentryException = any type _SentryEventProcessor = any type _SentryHub = any @@ -90,7 +91,13 @@ export function createEventProcessor( event.tags['PostHog Recording URL'] = _posthog.get_session_replay_url({ withTimestamp: true }) } - const exceptions = event.exception?.values || [] + const exceptions: _SentryException[] = event.exception?.values || [] + + exceptions.map((exception) => { + if (exception.stacktrace) { + exception.stacktrace.type = 'raw' + } + }) const data: SentryExceptionProperties & { // two properties added to match any exception auto-capture