@@ -6,11 +6,9 @@ import {
66} from './Types' ;
77import {
88 getDeviceId ,
9- shouldIgnoreURL ,
109 getCurrentUser ,
1110 getCurrentTags ,
1211 getRandomGUID ,
13- shouldIgnoreView ,
1412} from './Utils' ;
1513
1614// @ts -ignore
@@ -219,6 +217,10 @@ export default class RealUserMonitor {
219217 * @param {number } duration - The time taken for this event to fully execute.
220218 */
221219 sendNetworkTimingEvent ( name : string , sendTime : number , duration : number ) {
220+ if ( this . shouldIgnoreURL ( name ) ) {
221+ return ;
222+ }
223+
222224 const data = { name, timing : { type : RealUserMonitoringTimings . NetworkCall , duration} } ;
223225 this . transmitRealUserMonitoringEvent ( RealUserMonitoringEvents . EventTiming , data , sendTime ) . catch ( ) ;
224226 }
@@ -231,7 +233,7 @@ export default class RealUserMonitor {
231233 * @param {number } duration - The time taken for this event to fully execute.
232234 */
233235 async sendViewLoadedEvent ( name : string , duration : number ) {
234- if ( shouldIgnoreView ( name , this . ignoredViews ) ) {
236+ if ( this . shouldIgnoreView ( name ) ) {
235237 return ;
236238 }
237239 const data = { name : name , timing : { type : RealUserMonitoringTimings . ViewLoaded , duration} } ;
@@ -308,9 +310,10 @@ export default class RealUserMonitor {
308310 */
309311 handleRequestOpen ( method : 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' , url : string , xhr : any ) {
310312 // If this URL is on the IGNORE list, then do nothing.
311- if ( shouldIgnoreURL ( url , this . ignoredURLs ) ) {
313+ if ( this . shouldIgnoreURL ( url ) ) {
312314 return ;
313315 }
316+
314317 // Obtain the device ID
315318 const id = getDeviceId ( ) ;
316319
@@ -375,4 +378,22 @@ export default class RealUserMonitor {
375378 XHRInterceptor . setResponseCallback ( this . handleResponse . bind ( this ) ) ;
376379 XHRInterceptor . enableInterception ( ) ;
377380 }
381+
382+ shouldIgnoreURL ( url : string ) : boolean {
383+ for ( let i = 0 ; i < this . ignoredURLs . length ; i ++ ) {
384+ if ( url . includes ( this . ignoredURLs [ i ] ) ) {
385+ return true ;
386+ }
387+ }
388+ return false ;
389+ } ;
390+
391+ shouldIgnoreView ( name : string ) : boolean {
392+ for ( let i = 0 ; i < this . ignoredViews . length ; i ++ ) {
393+ if ( name . includes ( this . ignoredViews [ i ] ) ) {
394+ return true ;
395+ }
396+ }
397+ return false ;
398+ } ;
378399}
0 commit comments