Repository: elastic/synthetics (ts)

Issue:
Don’t store data URI request details
Storing data URIs and showing them on the waterfall chart is misleading and confusing for users.  We have no requirement for these right now, so, along with the space saving, we should stop Synthetics from reporting these in the result data.

Pull request description:
fix: exclude data uri from network events
+ fix #267 

Patch:
diff --git a/src/plugins/network.ts b/src/plugins/network.ts
index 9eef885..f6091ea 100644
--- a/src/plugins/network.ts
+++ b/src/plugins/network.ts
@@ -64,6 +64,12 @@ export class NetworkManager {
   _onRequestWillBeSent(event: Protocol.Network.requestWillBeSentPayload) {
     const { requestId, request, timestamp, type, loaderId } = event;
     const { url, method } = request;
+    /**
+     * Data URI should not show up as network requests
+     */
+    if (url.startsWith('data:')) {
+      return;
+    }
     const isNavigationRequest = requestId == loaderId && type === 'Document';
     const record = this._findNetworkRecord(requestId);
     /**


Test patch:
diff --git a/__tests__/plugins/network.test.ts b/__tests__/plugins/network.test.ts
index b3fa368..386dd2c 100644
--- a/__tests__/plugins/network.test.ts
+++ b/__tests__/plugins/network.test.ts
@@ -64,6 +64,17 @@ describe('network', () => {
     await Gatherer.dispose(driver);
   });
 
+  it('not include data URL in network info', async () => {
+    const driver = await Gatherer.setupDriver({ wsEndpoint });
+    const network = new NetworkManager();
+    await network.start(driver.client);
+    await driver.page.goto('data:text/html,<title>Data URI test</title>');
+    const netinfo = await network.stop();
+    expect(await driver.page.content()).toContain('Data URI test');
+    expect(netinfo).toEqual([]);
+    await Gatherer.dispose(driver);
+  });
+
   it('produce distinct events for redirects', async () => {
     const driver = await Gatherer.setupDriver({ wsEndpoint });
     const network = new NetworkManager();