@@ -63,7 +63,7 @@ export default class Catcher {
6363 /**
6464 * Catcher Type
6565 */
66- private readonly type : string = 'errors/javascript' ;
66+ private static readonly type = 'errors/javascript' as const ;
6767
6868 /**
6969 * User project's Integration Token
@@ -91,13 +91,13 @@ export default class Catcher {
9191 * - Return `false` — the event will be dropped entirely.
9292 * - Any other value is invalid — the original event is sent as-is (a warning is logged).
9393 */
94- private readonly beforeSend : undefined | ( ( event : HawkJavaScriptEvent ) => HawkJavaScriptEvent | false | void ) ;
94+ private readonly beforeSend : undefined | ( ( event : HawkJavaScriptEvent < typeof Catcher . type > ) => HawkJavaScriptEvent < typeof Catcher . type > | false | void ) ;
9595
9696 /**
9797 * Transport for dialog between Catcher and Collector
9898 * (WebSocket decorator by default, or custom via settings.transport)
9999 */
100- private readonly transport : Transport ;
100+ private readonly transport : Transport < typeof Catcher . type > ;
101101
102102 /**
103103 * Module for parsing backtrace
@@ -410,7 +410,7 @@ export default class Catcher {
410410 *
411411 * @param errorFormatted - formatted error to send
412412 */
413- private sendErrorFormatted ( errorFormatted : CatcherMessage ) : void {
413+ private sendErrorFormatted ( errorFormatted : CatcherMessage < typeof Catcher . type > ) : void {
414414 this . transport . send ( errorFormatted )
415415 . catch ( ( sendingError ) => {
416416 log ( 'WebSocket sending error' , 'error' , sendingError ) ;
@@ -423,7 +423,7 @@ export default class Catcher {
423423 * @param error - error to format
424424 * @param context - any additional data passed by user
425425 */
426- private async prepareErrorFormatted ( error : Error | string , context ?: EventContext ) : Promise < CatcherMessage > {
426+ private async prepareErrorFormatted ( error : Error | string , context ?: EventContext ) : Promise < CatcherMessage < typeof Catcher . type > > {
427427 let payload : HawkJavaScriptEvent = {
428428 title : this . getTitle ( error ) ,
429429 type : this . getType ( error ) ,
@@ -479,7 +479,7 @@ export default class Catcher {
479479
480480 return {
481481 token : this . token ,
482- catcherType : this . type ,
482+ catcherType : Catcher . type ,
483483 payload,
484484 } ;
485485 }
@@ -516,7 +516,7 @@ export default class Catcher {
516516 * and reject() provided with text reason instead of Error()
517517 */
518518 if ( notAnError ) {
519- return null ;
519+ return undefined ;
520520 }
521521
522522 return ( error as Error ) . name ;
@@ -526,7 +526,7 @@ export default class Catcher {
526526 * Release version
527527 */
528528 private getRelease ( ) : HawkJavaScriptEvent [ 'release' ] {
529- return this . release !== undefined ? String ( this . release ) : null ;
529+ return this . release !== undefined ? String ( this . release ) : undefined ;
530530 }
531531
532532 /**
@@ -579,7 +579,7 @@ export default class Catcher {
579579 private getBreadcrumbsForEvent ( ) : HawkJavaScriptEvent [ 'breadcrumbs' ] {
580580 const breadcrumbs = this . breadcrumbManager ?. getBreadcrumbs ( ) ;
581581
582- return breadcrumbs && breadcrumbs . length > 0 ? breadcrumbs : null ;
582+ return breadcrumbs && breadcrumbs . length > 0 ? breadcrumbs : undefined ;
583583 }
584584
585585 /**
@@ -619,15 +619,15 @@ export default class Catcher {
619619 * and reject() provided with text reason instead of Error()
620620 */
621621 if ( notAnError ) {
622- return null ;
622+ return undefined ;
623623 }
624624
625625 try {
626626 return await this . stackParser . parse ( error as Error ) ;
627627 } catch ( e ) {
628628 log ( 'Can not parse stack:' , 'warn' , e ) ;
629629
630- return null ;
630+ return undefined ;
631631 }
632632 }
633633
@@ -693,7 +693,7 @@ export default class Catcher {
693693 * @param errorFormatted - Hawk event prepared for sending
694694 * @param integrationAddons - extra addons
695695 */
696- private appendIntegrationAddons ( errorFormatted : CatcherMessage , integrationAddons : JavaScriptCatcherIntegrations ) : void {
697- Object . assign ( errorFormatted . payload . addons , integrationAddons ) ;
696+ private appendIntegrationAddons ( errorFormatted : CatcherMessage < typeof Catcher . type > , integrationAddons : JavaScriptCatcherIntegrations ) : void {
697+ Object . assign ( errorFormatted . payload . addons ! , integrationAddons ) ;
698698 }
699699}
0 commit comments