@@ -88,6 +88,7 @@ class CountlyClass {
8888 #contentZoneTimer;
8989 #contentIframeID;
9090 #crashFilterCallback;
91+ #contentFilterCallback;
9192 #serverConfigCache;
9293 #SCNetwork;
9394 #SCSizeReqQueue;
@@ -169,6 +170,7 @@ class CountlyClass {
169170 this . #contentZoneTimer = null ;
170171 this . #contentIframeID = "cly-content-iframe" ;
171172 this . #crashFilterCallback = null ;
173+ this . #contentFilterCallback = null ;
172174 this . #SCNetwork = true ;
173175 this . #SCSizeReqQueue = getConfig ( "queue_size" , ob , configurationDefaultValues . QUEUE_SIZE ) ;
174176 this . #SCSizeEventBatch = getConfig ( "max_events" , ob , configurationDefaultValues . MAX_EVENT_BATCH ) ;
@@ -443,6 +445,7 @@ class CountlyClass {
443445 this . hcConsecutiveBackoffCount = this . #getValueFromStorage( healthCheckCounterEnum . consecutiveBackoffCount ) || 0 ;
444446 this . #lastRequestWasBackoff = false ; // Track if the previous request resulted in a backoff
445447 this . #crashFilterCallback = getConfig ( "crash_filter_callback" , ob , null ) ;
448+ this . #contentFilterCallback = getConfig ( "content_filter_callback" , ob , null ) ;
446449
447450 if ( this . storage === "cookie" ) {
448451 this . #lsSupport = false ;
@@ -4087,6 +4090,24 @@ class CountlyClass {
40874090 return ;
40884091 }
40894092
4093+ // Build query params
4094+ const queryParams = { type : "content" } ;
4095+
4096+ const qIndex = response . html . indexOf ( "?" ) ;
4097+ if ( qIndex !== - 1 ) {
4098+ const search = response . html . slice ( qIndex + 1 ) ;
4099+ new URLSearchParams ( search ) . forEach ( ( v , k ) => {
4100+ queryParams [ k ] = v ;
4101+ } ) ;
4102+ }
4103+
4104+ // Filter check
4105+ if ( typeof this . #contentFilterCallback === "function" &&
4106+ this . #contentFilterCallback( queryParams ) === false ) {
4107+ this . #log( logLevelEnums . VERBOSE , "sendContentRequest, Content was filtered out by the content filter" ) ;
4108+ return ;
4109+ }
4110+
40904111 this . #displayContent( response ) ;
40914112 clearInterval ( this . #contentZoneTimer) ; // prevent multiple content requests while one is on
40924113 window . addEventListener ( 'message' , ( event ) => {
0 commit comments