openreplay/spot/entrypoints/injected.ts
Delirium e66423dcf4
Spot network refactoring (#2617)
* start refactoring network

* separate network module, refactor spot network capture

Signed-off-by: nick-delirium <nikita@openreplay.com>

* some console refactoring, display network results in ui

* detect gql error param

* fix proxy ignore file, fix network tracking, fix tab tracking

* some code quality improvements...

* handle graphql in network lib (.2 ver), update tracker to use last version of lib

* remove debug logs, change request type to gql (if its gql!) in lib, display gql in ui

---------

Signed-off-by: nick-delirium <nikita@openreplay.com>
2024-09-30 09:47:27 +02:00

24 lines
751 B
TypeScript

import { startNetwork, stopNetwork } from "~/utils/proxyNetworkTracking";
import { patchConsole } from "~/utils/consoleTracking";
export default defineUnlistedScript(() => {
window.addEventListener("message", (event) => {
if (event.data.type === "injected:c-start") {
if (!window.__or_revokeSpotPatch) {
window.__or_revokeSpotPatch = patchConsole(console, window);
}
}
if (event.data.type === "injected:n-start") {
startNetwork();
}
if (event.data.type === "injected:n-stop") {
stopNetwork();
}
if (event.data.type === "injected:c-stop") {
if (window.__or_revokeSpotPatch) {
window.__or_revokeSpotPatch();
window.__or_revokeSpotPatch = null;
}
}
});
});