File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,11 +44,13 @@ export interface ErrorSnapshot {
4444 */
4545export interface MessageProcessor < T extends CatcherMessageType = CatcherMessageType > {
4646 /**
47- * Handles input message. May mutate or replace it.
47+ * Handles input message. May mutate, replace or drop it.
48+ *
49+ * Dropped message won't be sent.
4850 *
4951 * @param payload - processed event message payload with partially-built addons
5052 * @param snapshot - additional context with original error
51- * @returns modified payload, or `null` to drop event
53+ * @returns modified payload, or `null` to drop message
5254 */
5355 apply (
5456 payload : ProcessingPayload < T > ,
Original file line number Diff line number Diff line change @@ -217,6 +217,10 @@ export default class Catcher {
217217 this . messageProcessors . push ( new DebugAddonMessageProcessor ( ) ) ;
218218 }
219219
220+ if ( settings . messageProcessors ) {
221+ this . messageProcessors . push ( ...settings . messageProcessors ) ;
222+ }
223+
220224 /**
221225 * Set global handlers
222226 */
Original file line number Diff line number Diff line change 11import type { AffectedUser , EventContext } from '@hawk.so/types' ;
22import type { HawkJavaScriptEvent } from './event' ;
3- import type { Transport } from '@hawk.so/core' ;
3+ import type { MessageProcessor , Transport } from '@hawk.so/core' ;
44import type { BreadcrumbsOptions } from '../addons/breadcrumbs' ;
55
66/**
@@ -98,4 +98,11 @@ export interface HawkInitialSettings {
9898 * If not provided, default WebSocket transport is used.
9999 */
100100 transport ?: Transport ;
101+
102+ /**
103+ * Custom message processors.
104+ * Used to prepare event message before send.
105+ * May modify original event payload or return null to drop it.
106+ */
107+ messageProcessors ?: MessageProcessor < 'errors/javascript' > [ ] ;
101108}
You can’t perform that action at this time.
0 commit comments