@@ -971,6 +971,28 @@ var GleapNetworkIntercepter = /*#__PURE__*/function () {
971971 }
972972
973973 _createClass ( GleapNetworkIntercepter , [ {
974+ key : "isContentTypeSupported" ,
975+ value : function isContentTypeSupported ( contentType ) {
976+ if ( typeof contentType !== "string" ) {
977+ return false ;
978+ }
979+
980+ if ( contentType === "" ) {
981+ return true ;
982+ }
983+
984+ contentType = contentType . toLocaleLowerCase ( ) ;
985+ var supportedContentTypes = [ "text/" , "xml" , "json" ] ;
986+
987+ for ( var i = 0 ; i < supportedContentTypes . length ; i ++ ) {
988+ if ( contentType . includes ( supportedContentTypes [ i ] ) ) {
989+ return true ;
990+ }
991+ }
992+
993+ return false ;
994+ }
995+ } , {
974996 key : "getRequests" ,
975997 value : function getRequests ( ) {
976998 var requests = this . externalConsoleLogs . concat ( Object . values ( this . requests ) ) ;
@@ -1154,22 +1176,47 @@ var GleapNetworkIntercepter = /*#__PURE__*/function () {
11541176 _this . calcRequestTime ( bbRequestId ) ;
11551177 } catch ( exp ) { }
11561178
1157- req . text ( ) . then ( function ( responseText ) {
1158- if ( _this . requests [ bbRequestId ] ) {
1159- _this . requests [ bbRequestId ] [ "success" ] = true ;
1160- _this . requests [ bbRequestId ] [ "response" ] = {
1161- status : req . status ,
1162- statusText : req . statusText ,
1163- responseText : self . calculateTextSize ( responseText ) > 0.5 ? "<response_too_large>" : responseText
1164- } ;
1179+ try {
1180+ var contentType = "" ;
1181+
1182+ if ( req . headers && typeof req . headers . get !== "undefined" ) {
1183+ contentType = req . headers . get ( "content-type" ) ;
11651184 }
11661185
1167- _this . calcRequestTime ( bbRequestId ) ;
1186+ console . log ( contentType ) ;
11681187
1169- _this . cleanRequests ( ) ;
1170- } ) [ "catch" ] ( function ( err ) {
1171- _this . cleanRequests ( ) ;
1172- } ) ;
1188+ if ( _this . isContentTypeSupported ( contentType ) ) {
1189+ req . text ( ) . then ( function ( responseText ) {
1190+ if ( _this . requests [ bbRequestId ] ) {
1191+ _this . requests [ bbRequestId ] [ "success" ] = true ;
1192+ _this . requests [ bbRequestId ] [ "response" ] = {
1193+ status : req . status ,
1194+ statusText : req . statusText ,
1195+ responseText : self . calculateTextSize ( responseText ) > 0.5 ? "<response_too_large>" : responseText
1196+ } ;
1197+ }
1198+
1199+ _this . calcRequestTime ( bbRequestId ) ;
1200+
1201+ _this . cleanRequests ( ) ;
1202+ } ) [ "catch" ] ( function ( err ) {
1203+ _this . cleanRequests ( ) ;
1204+ } ) ;
1205+ } else {
1206+ if ( _this . requests [ bbRequestId ] ) {
1207+ _this . requests [ bbRequestId ] [ "success" ] = true ;
1208+ _this . requests [ bbRequestId ] [ "response" ] = {
1209+ status : req . status ,
1210+ statusText : req . statusText ,
1211+ responseText : "<content_type_not_supported>"
1212+ } ;
1213+ }
1214+
1215+ _this . calcRequestTime ( bbRequestId ) ;
1216+
1217+ _this . cleanRequests ( ) ;
1218+ }
1219+ } catch ( exp ) { }
11731220 } ,
11741221 onFetchFailed : function onFetchFailed ( err , bbRequestId ) {
11751222 if ( _this . stopped || ! bbRequestId || ! _this . requests || ! _this . requests [ bbRequestId ] ) {
@@ -6264,7 +6311,7 @@ var Gleap_Gleap = /*#__PURE__*/function () {
62646311 currentUrl : window . location . href ,
62656312 language : navigator . language || navigator . userLanguage ,
62666313 mobile : isMobile ( ) ,
6267- sdkVersion : "6.8.10 " ,
6314+ sdkVersion : "6.8.11 " ,
62686315 sdkType : "javascript"
62696316 } ;
62706317 }
0 commit comments