@@ -181,12 +181,14 @@ export interface Client<O extends ClientOptions = ClientOptions> {
181181 /**
182182 * Register a callback for whenever a span is started.
183183 * Receives the span as argument.
184+ * @returns A function that, when executed, removes the registered callback.
184185 */
185- on ( hook : 'spanStart' , callback : ( span : Span ) => void ) : void ;
186+ on ( hook : 'spanStart' , callback : ( span : Span ) => void ) : ( ) => void ;
186187
187188 /**
188189 * Register a callback before span sampling runs. Receives a `samplingDecision` object argument with a `decision`
189190 * property that can be used to make a sampling decision that will be enforced, before any span sampling runs.
191+ * @returns A function that, when executed, removes the registered callback.
190192 */
191193 on (
192194 hook : 'beforeSampling' ,
@@ -204,83 +206,96 @@ export interface Client<O extends ClientOptions = ClientOptions> {
204206 /**
205207 * Register a callback for whenever a span is ended.
206208 * Receives the span as argument.
209+ * @returns A function that, when executed, removes the registered callback.
207210 */
208- on ( hook : 'spanEnd' , callback : ( span : Span ) => void ) : void ;
211+ on ( hook : 'spanEnd' , callback : ( span : Span ) => void ) : ( ) => void ;
209212
210213 /**
211214 * Register a callback for when an idle span is allowed to auto-finish.
215+ * @returns A function that, when executed, removes the registered callback.
212216 */
213- on ( hook : 'idleSpanEnableAutoFinish' , callback : ( span : Span ) => void ) : void ;
217+ on ( hook : 'idleSpanEnableAutoFinish' , callback : ( span : Span ) => void ) : ( ) => void ;
214218
215219 /**
216220 * Register a callback for transaction start and finish.
221+ * @returns A function that, when executed, removes the registered callback.
217222 */
218- on ( hook : 'beforeEnvelope' , callback : ( envelope : Envelope ) => void ) : void ;
223+ on ( hook : 'beforeEnvelope' , callback : ( envelope : Envelope ) => void ) : ( ) => void ;
219224
220225 /**
221226 * Register a callback for before sending an event.
222227 * This is called right before an event is sent and should not be used to mutate the event.
223228 * Receives an Event & EventHint as arguments.
229+ * @returns A function that, when executed, removes the registered callback.
224230 */
225- on ( hook : 'beforeSendEvent' , callback : ( event : Event , hint ?: EventHint | undefined ) => void ) : void ;
231+ on ( hook : 'beforeSendEvent' , callback : ( event : Event , hint ?: EventHint | undefined ) => void ) : ( ) => void ;
226232
227233 /**
228234 * Register a callback for preprocessing an event,
229235 * before it is passed to (global) event processors.
230236 * Receives an Event & EventHint as arguments.
237+ * @returns A function that, when executed, removes the registered callback.
231238 */
232- on ( hook : 'preprocessEvent' , callback : ( event : Event , hint ?: EventHint | undefined ) => void ) : void ;
239+ on ( hook : 'preprocessEvent' , callback : ( event : Event , hint ?: EventHint | undefined ) => void ) : ( ) => void ;
233240
234241 /**
235242 * Register a callback for when an event has been sent.
243+ * @returns A function that, when executed, removes the registered callback.
236244 */
237- on ( hook : 'afterSendEvent' , callback : ( event : Event , sendResponse : TransportMakeRequestResponse ) => void ) : void ;
245+ on ( hook : 'afterSendEvent' , callback : ( event : Event , sendResponse : TransportMakeRequestResponse ) => void ) : ( ) => void ;
238246
239247 /**
240248 * Register a callback before a breadcrumb is added.
249+ * @returns A function that, when executed, removes the registered callback.
241250 */
242- on ( hook : 'beforeAddBreadcrumb' , callback : ( breadcrumb : Breadcrumb , hint ?: BreadcrumbHint ) => void ) : void ;
251+ on ( hook : 'beforeAddBreadcrumb' , callback : ( breadcrumb : Breadcrumb , hint ?: BreadcrumbHint ) => void ) : ( ) => void ;
243252
244253 /**
245254 * Register a callback when a DSC (Dynamic Sampling Context) is created.
255+ * @returns A function that, when executed, removes the registered callback.
246256 */
247- on ( hook : 'createDsc' , callback : ( dsc : DynamicSamplingContext , rootSpan ?: Span ) => void ) : void ;
257+ on ( hook : 'createDsc' , callback : ( dsc : DynamicSamplingContext , rootSpan ?: Span ) => void ) : ( ) => void ;
248258
249259 /**
250260 * Register a callback when a Feedback event has been prepared.
251261 * This should be used to mutate the event. The options argument can hint
252262 * about what kind of mutation it expects.
263+ * @returns A function that, when executed, removes the registered callback.
253264 */
254265 on (
255266 hook : 'beforeSendFeedback' ,
256267 callback : ( feedback : FeedbackEvent , options ?: { includeReplay ?: boolean } ) => void ,
257- ) : void ;
268+ ) : ( ) => void ;
258269
259270 /**
260271 * A hook for the browser tracing integrations to trigger a span start for a page load.
272+ * @returns A function that, when executed, removes the registered callback.
261273 */
262274 on (
263275 hook : 'startPageLoadSpan' ,
264276 callback : (
265277 options : StartSpanOptions ,
266278 traceOptions ?: { sentryTrace ?: string | undefined ; baggage ?: string | undefined } ,
267279 ) => void ,
268- ) : void ;
280+ ) : ( ) => void ;
269281
270282 /**
271283 * A hook for browser tracing integrations to trigger a span for a navigation.
284+ * @returns A function that, when executed, removes the registered callback.
272285 */
273- on ( hook : 'startNavigationSpan' , callback : ( options : StartSpanOptions ) => void ) : void ;
286+ on ( hook : 'startNavigationSpan' , callback : ( options : StartSpanOptions ) => void ) : ( ) => void ;
274287
275288 /**
276289 * A hook that is called when the client is flushing
290+ * @returns A function that, when executed, removes the registered callback.
277291 */
278- on ( hook : 'flush' , callback : ( ) => void ) : void ;
292+ on ( hook : 'flush' , callback : ( ) => void ) : ( ) => void ;
279293
280294 /**
281295 * A hook that is called when the client is closing
296+ * @returns A function that, when executed, removes the registered callback.
282297 */
283- on ( hook : 'close' , callback : ( ) => void ) : void ;
298+ on ( hook : 'close' , callback : ( ) => void ) : ( ) => void ;
284299
285300 /** Fire a hook whener a span starts. */
286301 emit ( hook : 'spanStart' , span : Span ) : void ;
0 commit comments