@@ -58,6 +58,8 @@ import {
5858 DefaultAppInitData ,
5959 AllEmbedViewConfig as ViewConfig ,
6060 EmbedErrorDetailsEvent ,
61+ ErrorDetailsTypes ,
62+ ErrorDetailsSources ,
6163} from '../types' ;
6264import { uploadMixpanelEvent , MIXPANEL_EVENT } from '../mixpanel-service' ;
6365import { processEventData , processAuthFailure } from '../utils/processData' ;
@@ -219,7 +221,7 @@ export class TsEmbed {
219221 * Throws error encountered during initialization.
220222 */
221223 private throwInitError ( ) {
222- this . handleError ( ERROR_MESSAGE . INIT_SDK_REQUIRED , { errorType : ' VALIDATION_ERROR' , message : ERROR_MESSAGE . INIT_SDK_REQUIRED , code : ERROR_CODE . INIT_ERROR , source : ' SDK' , details : { } , } as EmbedErrorDetailsEvent ) ;
224+ this . handleError ( ERROR_MESSAGE . INIT_SDK_REQUIRED , { errorType : ErrorDetailsTypes . VALIDATION_ERROR , message : ERROR_MESSAGE . INIT_SDK_REQUIRED , code : ERROR_CODE . INIT_ERROR , source : ErrorDetailsSources . SDK , details : { } , } as EmbedErrorDetailsEvent ) ;
223225 }
224226
225227 /**
@@ -332,7 +334,7 @@ export class TsEmbed {
332334 this . executeCallbacks ( EmbedEvent . Error , {
333335 offlineWarning,
334336 } ) ;
335- const errorDetails = { errorType : ' NETWORK' , message : ERROR_MESSAGE . OFFLINE_WARNING , code : ERROR_CODE . NETWORK_ERROR , source : ' NETWORK' , details : { event : e , } } as EmbedErrorDetailsEvent ;
337+ const errorDetails = { errorType : ErrorDetailsTypes . NETWORK , message : ERROR_MESSAGE . OFFLINE_WARNING , code : ERROR_CODE . NETWORK_ERROR , source : ErrorDetailsSources . NETWORK , details : { event : e , } } as EmbedErrorDetailsEvent ;
336338 this . executeCallbacks ( EmbedEvent . ErrorDetails , errorDetails ) ;
337339 logger . warn ( errorDetails ) ;
338340 } ;
@@ -448,7 +450,7 @@ export class TsEmbed {
448450 ...( this . embedConfig . customActions || [ ] )
449451 ] ) ;
450452 if ( customActionsResult . errors . length > 0 ) {
451- this . handleError ( { type : ERROR_CODE . CUSTOM_ACTION_VALIDATION , message : customActionsResult . errors } , { errorType : ' VALIDATION_ERROR' , message : customActionsResult . errors , code : ERROR_CODE . CUSTOM_ACTION_VALIDATION , source : ' SDK' , details : { } } as EmbedErrorDetailsEvent ) ;
453+ this . handleError ( { type : ERROR_CODE . CUSTOM_ACTION_VALIDATION , message : customActionsResult . errors } , { errorType : ErrorDetailsTypes . VALIDATION_ERROR , message : customActionsResult . errors , code : ERROR_CODE . CUSTOM_ACTION_VALIDATION , source : ErrorDetailsSources . SDK , details : { } } as EmbedErrorDetailsEvent ) ;
452454 }
453455 const baseInitData = {
454456 customisations : getCustomisations ( this . embedConfig , this . viewConfig ) ,
@@ -660,12 +662,12 @@ export class TsEmbed {
660662 } ;
661663
662664 if ( Array . isArray ( visibleActions ) && Array . isArray ( hiddenActions ) ) {
663- this . handleError ( ERROR_MESSAGE . CONFLICTING_ACTIONS_CONFIG , { errorType : ' VALIDATION_ERROR' , message : ERROR_MESSAGE . CONFLICTING_ACTIONS_CONFIG , code : ERROR_CODE . CONFLICTING_ACTIONS_CONFIG , source : ' SDK' , details : { } } as EmbedErrorDetailsEvent ) ;
665+ this . handleError ( ERROR_MESSAGE . CONFLICTING_ACTIONS_CONFIG , { errorType : ErrorDetailsTypes . VALIDATION_ERROR , message : ERROR_MESSAGE . CONFLICTING_ACTIONS_CONFIG , code : ERROR_CODE . CONFLICTING_ACTIONS_CONFIG , source : ErrorDetailsSources . SDK , details : { } } as EmbedErrorDetailsEvent ) ;
664666 return queryParams ;
665667 }
666668
667669 if ( Array . isArray ( visibleTabs ) && Array . isArray ( hiddenTabs ) ) {
668- this . handleError ( ERROR_MESSAGE . CONFLICTING_TABS_CONFIG , { errorType : ' VALIDATION_ERROR' , message : ERROR_MESSAGE . CONFLICTING_TABS_CONFIG , code : ERROR_CODE . CONFLICTING_TABS_CONFIG , source : ' SDK' , details : { } } as EmbedErrorDetailsEvent ) ;
670+ this . handleError ( ERROR_MESSAGE . CONFLICTING_TABS_CONFIG , { errorType : ErrorDetailsTypes . VALIDATION_ERROR , message : ERROR_MESSAGE . CONFLICTING_TABS_CONFIG , code : ERROR_CODE . CONFLICTING_TABS_CONFIG , source : ErrorDetailsSources . SDK , details : { } } as EmbedErrorDetailsEvent ) ;
669671 return queryParams ;
670672 }
671673 if ( primaryAction ) {
@@ -918,7 +920,7 @@ export class TsEmbed {
918920 error : JSON . stringify ( error ) ,
919921 } ) ;
920922 this . handleInsertionIntoDOM ( this . embedConfig . loginFailedMessage ) ;
921- this . handleError ( ERROR_MESSAGE . LOGIN_FAILED , { errorType : ' API' , message : error . message || ERROR_MESSAGE . LOGIN_FAILED , code : ERROR_CODE . LOGIN_FAILED , source : ' SDK' , details : { } } as EmbedErrorDetailsEvent ) ;
923+ this . handleError ( ERROR_MESSAGE . LOGIN_FAILED , { errorType : ErrorDetailsTypes . API , message : error . message || ERROR_MESSAGE . LOGIN_FAILED , code : ERROR_CODE . LOGIN_FAILED , source : ErrorDetailsSources . SDK , details : { } } as EmbedErrorDetailsEvent ) ;
922924 } ) ;
923925 } ) ;
924926 }
@@ -1325,12 +1327,12 @@ export class TsEmbed {
13251327 uploadMixpanelEvent ( `${ MIXPANEL_EVENT . VISUAL_SDK_TRIGGER } -${ messageType } ` ) ;
13261328
13271329 if ( ! this . isRendered ) {
1328- this . handleError ( ERROR_MESSAGE . RENDER_BEFORE_EVENTS_REQUIRED , { errorType : ' VALIDATION_ERROR' , message : ERROR_MESSAGE . RENDER_BEFORE_EVENTS_REQUIRED , code : ERROR_CODE . RENDER_NOT_CALLED , source : ' SDK' , details : { } } as EmbedErrorDetailsEvent ) ;
1330+ this . handleError ( ERROR_MESSAGE . RENDER_BEFORE_EVENTS_REQUIRED , { errorType : ErrorDetailsTypes . VALIDATION_ERROR , message : ERROR_MESSAGE . RENDER_BEFORE_EVENTS_REQUIRED , code : ERROR_CODE . RENDER_NOT_CALLED , source : ErrorDetailsSources . SDK , details : { } } as EmbedErrorDetailsEvent ) ;
13291331 return null ;
13301332 }
13311333
13321334 if ( ! messageType ) {
1333- this . handleError ( ERROR_MESSAGE . HOST_EVENT_TYPE_UNDEFINED , { errorType : ' VALIDATION_ERROR' , message : ERROR_MESSAGE . HOST_EVENT_TYPE_UNDEFINED , code : ERROR_CODE . HOST_EVENT_TYPE_UNDEFINED , source : ' SDK' , details : { } } as EmbedErrorDetailsEvent ) ;
1335+ this . handleError ( ERROR_MESSAGE . HOST_EVENT_TYPE_UNDEFINED , { errorType : ErrorDetailsTypes . VALIDATION_ERROR , message : ERROR_MESSAGE . HOST_EVENT_TYPE_UNDEFINED , code : ERROR_CODE . HOST_EVENT_TYPE_UNDEFINED , source : ErrorDetailsSources . SDK , details : { } } as EmbedErrorDetailsEvent ) ;
13341336 return null ;
13351337 }
13361338
0 commit comments