Skip to content

Commit

Permalink
Merge pull request #37 from sematext/hwa_SC-17285_fixExpNodeCollection
Browse files Browse the repository at this point in the history
Improve node collection
  • Loading branch information
hasan-wajahat authored Sep 14, 2023
2 parents 776ef20 + 40c1147 commit d3aa140
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/commands/RouteChangeObserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class RouteChangeObserver {
this.startedOffset = this.startedAt - navigationStart;
this.context = context;

this.searchForInterestingNodesOnLoad();
this.setupDomObserver();
this.setupAjaxObserver();
this.setupIdlingObserver();
Expand Down Expand Up @@ -180,7 +181,7 @@ class RouteChangeObserver {
mutation = (mutations: Array<MutationRecord>) => {
mutations.forEach((mutation) => {
if (mutation.type === 'attributes') {
this.waitForNode(mutation.target);
this.interesting = this.waitForNode(mutation.target) || this.interesting;
} else if (mutation.type === 'childList') {
let len = mutation.addedNodes.length;
let i = 0;
Expand All @@ -201,6 +202,13 @@ class RouteChangeObserver {
});
};

searchForInterestingNodesOnLoad() {
const nodes = document.querySelectorAll('img, iframe, link');
nodes.forEach((node) => {
this.interesting = this.waitForNode(node) || this.interesting;
});
}

/**
* Some nodes such as img, iframe, and link can cause additional resources to
* be downloaded. We consider these critical resources and will wait for them
Expand Down
3 changes: 2 additions & 1 deletion src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ export const getCompressedResources = (
// see https://sematext.atlassian.net/browse/SC-6210
// filter out resource types that we don't want to collect
resources.entries = resources.entries.filter(e =>
!e.name.startsWith('data:') && disabledResourceTypes.indexOf(e.initiatorType) === -1);
!e.name.startsWith('data:') && disabledResourceTypes.indexOf(e.initiatorType) === -1
&& !e.name.includes('rum-receiver.sematext.com'));

// attach resource type
resources.entries = resources.entries.map(r => ({
Expand Down

0 comments on commit d3aa140

Please sign in to comment.