@@ -165,21 +165,38 @@ export interface Client<O extends ClientOptions = ClientOptions> {
165165
166166 // HOOKS
167167 // TODO(v8): Make the hooks non-optional.
168+ /* eslint-disable @typescript-eslint/unified-signatures */
168169
169170 /**
170- * Register a callback for transaction start and finish.
171+ * Register a callback for transaction start.
172+ * Receives the transaction as argument.
171173 */
172- on ?( hook : 'startTransaction' | 'finishTransaction' , callback : ( transaction : Transaction ) => void ) : void ;
174+ on ?( hook : 'startTransaction' , callback : ( transaction : Transaction ) => void ) : void ;
175+
176+ /**
177+ * Register a callback for transaction finish.
178+ * Receives the transaction as argument.
179+ */
180+ on ?( hook : 'finishTransaction' , callback : ( transaction : Transaction ) => void ) : void ;
173181
174182 /**
175183 * Register a callback for transaction start and finish.
176184 */
177185 on ?( hook : 'beforeEnvelope' , callback : ( envelope : Envelope ) => void ) : void ;
178186
179187 /**
180- * Register a callback for before an event is sent.
188+ * Register a callback for before sending an event.
189+ * This is called right before an event is sent and should not be used to mutate the event.
190+ * Receives an Event & EventHint as arguments.
181191 */
182- on ?( hook : 'beforeSendEvent' , callback : ( event : Event , hint ?: EventHint | void ) => void ) : void ;
192+ on ?( hook : 'beforeSendEvent' , callback : ( event : Event , hint ?: EventHint | undefined ) => void ) : void ;
193+
194+ /**
195+ * Register a callback for preprocessing an event,
196+ * before it is passed to (global) event processors.
197+ * Receives an Event & EventHint as arguments.
198+ */
199+ on ?( hook : 'preprocessEvent' , callback : ( event : Event , hint ?: EventHint | undefined ) => void ) : void ;
183200
184201 /**
185202 * Register a callback for when an event has been sent.
@@ -206,23 +223,36 @@ export interface Client<O extends ClientOptions = ClientOptions> {
206223 on ?( hook : 'otelSpanEnd' , callback : ( otelSpan : unknown , mutableOptions : { drop : boolean } ) => void ) : void ;
207224
208225 /**
209- * Fire a hook event for transaction start and finish. Expects to be given a transaction as the
210- * second argument.
226+ * Fire a hook event for transaction start.
227+ * Expects to be given a transaction as the second argument.
211228 */
212- emit ?( hook : 'startTransaction' | 'finishTransaction' , transaction : Transaction ) : void ;
229+ emit ?( hook : 'startTransaction' , transaction : Transaction ) : void ;
230+
231+ /**
232+ * Fire a hook event for transaction finish.
233+ * Expects to be given a transaction as the second argument.
234+ */
235+ emit ?( hook : 'finishTransaction' , transaction : Transaction ) : void ;
213236
214237 /*
215238 * Fire a hook event for envelope creation and sending. Expects to be given an envelope as the
216239 * second argument.
217240 */
218241 emit ?( hook : 'beforeEnvelope' , envelope : Envelope ) : void ;
219242
220- /*
221- * Fire a hook event before sending an event. Expects to be given an Event & EventHint as the
222- * second/third argument.
243+ /**
244+ * Fire a hook event before sending an event.
245+ * This is called right before an event is sent and should not be used to mutate the event.
246+ * Expects to be given an Event & EventHint as the second/third argument.
223247 */
224248 emit ?( hook : 'beforeSendEvent' , event : Event , hint ?: EventHint ) : void ;
225249
250+ /**
251+ * Fire a hook event to process events before they are passed to (global) event processors.
252+ * Expects to be given an Event & EventHint as the second/third argument.
253+ */
254+ emit ?( hook : 'preprocessEvent' , event : Event , hint ?: EventHint ) : void ;
255+
226256 /*
227257 * Fire a hook event after sending an event. Expects to be given an Event as the
228258 * second argument.
@@ -245,4 +275,6 @@ export interface Client<O extends ClientOptions = ClientOptions> {
245275 * The option argument may be mutated to drop the span.
246276 */
247277 emit ?( hook : 'otelSpanEnd' , otelSpan : unknown , mutableOptions : { drop : boolean } ) : void ;
278+
279+ /* eslint-enable @typescript-eslint/unified-signatures */
248280}
0 commit comments