Skip to content

Commit

Permalink
Update GleapNetworkIntercepter.js
Browse files Browse the repository at this point in the history
  • Loading branch information
boehlerlukas committed May 20, 2022
1 parent 25f0de3 commit aa2ca02
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/GleapNetworkIntercepter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Gleap from "./Gleap";

class GleapNetworkIntercepter {
startTimestamp = Date.now();
requestId = 0;
requests = {};
externalConsoleLogs = [];
Expand Down Expand Up @@ -84,6 +87,27 @@ class GleapNetworkIntercepter {
}
}

// Get static resources from performance.
try {
if (typeof window !== "undefined" && window.performance) {
var resources = window.performance.getEntriesByType("resource");
for (var i = 0; i < resources.length; i++) {
var resource = resources[i];
if (resource && resource.name) {
if (!requests.find(request => request.url === resource.name)) {
requests.push({
type: "RESOURCE",
date: new Date(this.startTimestamp + resource.startTime),
url: resource.name,
duration: Math.round(resource.duration),
initiatorType: resource.initiatorType
});
}
}
}
}
} catch (exp) { }

return requests;
}

Expand Down

0 comments on commit aa2ca02

Please sign in to comment.