Skip to content

Commit

Permalink
fix: event is sometimes null (#17784)
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra authored Oct 4, 2023
1 parent b020987 commit 7f6be48
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plugin-server/src/worker/ingestion/process-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,9 @@ export const gatherConsoleLogEvents = (
const consoleLogEntries: ConsoleLogEntry[] = []

events.forEach((event) => {
if (event.type === RRWebEventType.Plugin && event.data?.plugin === 'rrweb/console@1') {
// it should be unnecessary to check for truthiness of event here,
// but we've seen null in production so 🤷
if (!!event && event.type === RRWebEventType.Plugin && event.data?.plugin === 'rrweb/console@1') {
const level = event.data.payload?.level
const message = safeString(event.data.payload?.payload)
consoleLogEntries.push({
Expand Down
1 change: 1 addition & 0 deletions plugin-server/tests/main/process-event.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1497,6 +1497,7 @@ test('simple console log processing', () => {
},
},
},
null as unknown as RRWebEvent, // see https://posthog.sentry.io/issues/4525043303
])
expect(consoleLogEntries).toEqual([
{
Expand Down

0 comments on commit 7f6be48

Please sign in to comment.