Skip to content

Commit 7ace5d7

Browse files
authored
Merge pull request #46 from MindscapeHQ/md/sup/update-ignored-urls
Ensure the ignore lists are applied to RUM events
2 parents 15206dd + 7e059e1 commit 7ace5d7

File tree

4 files changed

+31
-23
lines changed

4 files changed

+31
-23
lines changed

sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "raygun4reactnative",
33
"title": "Raygun4reactnative",
4-
"version": "1.1.1",
4+
"version": "1.1.2",
55
"description": "Raygun React Native SDK",
66
"main": "dist/index.js",
77
"typescript": {

sdk/src/RaygunClient.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,10 @@ const init = (raygunClientOptions: RaygunClientOptions) => {
8686
disableNativeCrashReporting,
8787
disableUnhandledPromiseRejectionReporting,
8888
customCrashReportingEndpoint || '',
89-
onBeforeSendingCrashReport as BeforeSendHandler,
90-
version,
91-
maxErrorReportsStoredOnDevice,
92-
maxBreadcrumbsPerErrorReport,
93-
);
89+
onBeforeSendingCrashReport as BeforeSendHandler,
90+
version,
91+
maxErrorReportsStoredOnDevice,
92+
maxBreadcrumbsPerErrorReport);
9493

9594
if (!disableNativeCrashReporting) {
9695
RaygunNativeBridge.initCrashReportingNativeSupport(apiKey, version, customCrashReportingEndpoint);
@@ -105,8 +104,7 @@ const init = (raygunClientOptions: RaygunClientOptions) => {
105104
ignoredURLs,
106105
ignoredViews,
107106
customRealUserMonitoringEndpoint,
108-
version,
109-
);
107+
version);
110108

111109
// Add the lifecycle event listeners to the bridge.
112110
RaygunNativeBridge.initRealUserMonitoringNativeSupport();

sdk/src/RealUserMonitor.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ import {
66
} from './Types';
77
import {
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
}

sdk/src/Utils.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,4 @@ export const noAddressAt = ({methodName, ...rest}: StackFrame): StackFrame => {
108108
};
109109
};
110110

111-
export const removeProtocol = (url: string) => url.replace(/^http(s)?:\/\//i, '');
112-
113-
export const shouldIgnoreURL = (url: string, ignoredURLs: string[]): boolean => {
114-
const target = removeProtocol(url);
115-
return ignoredURLs.some((ignored) => target.startsWith(ignored));
116-
};
117-
118-
export const shouldIgnoreView = (name: string, ignoredViews: string[]): boolean => {
119-
return ignoredViews.some((ignored) => name.startsWith(ignored));
120-
};
121-
122111
export const filterOutReactFrames = (frame: StackFrame): boolean => !!frame.file && !frame.file.match(internalTrace);

0 commit comments

Comments
 (0)