Skip to content

Commit

Permalink
send only unique errors to sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
netroy committed May 12, 2023
1 parent c597a7e commit d1582c4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/cli/src/ErrorReporting.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { createHash } from 'crypto';
import config from '@/config';
import { ErrorReporterProxy, NodeError } from 'n8n-workflow';

Expand Down Expand Up @@ -32,9 +33,14 @@ export const initErrorHandling = async () => {
},
});

const seenErrors = new Set<string>();
addGlobalEventProcessor((event, { originalException }) => {
if (originalException instanceof NodeError && originalException.severity === 'warning')
return null;
if (!event.exception) return null;
const eventHash = createHash('sha1').update(JSON.stringify(event.exception)).digest('base64');
if (seenErrors.has(eventHash)) return null;
seenErrors.add(eventHash);
return event;
});

Expand Down

0 comments on commit d1582c4

Please sign in to comment.