Skip to content

Commit

Permalink
feat: Introduce configurable grouping patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
naydav committed Nov 28, 2024
1 parent bd52ec3 commit baee7c9
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 178 deletions.
14 changes: 7 additions & 7 deletions packages/spacecat-shared-rum-api-client/test/cwv.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

import { expect } from 'chai';
import cwv from '../src/functions/cwv.js';
import bundlesWithPatterns from './fixtures/cwv/bundles-for-url-patterns.json' assert { type: 'json' };
import bundles from './fixtures/bundles.json' assert { type: 'json' };
import expectedCwvWithPatternsResult from './fixtures/cwv/result-bundles-for-url-patterns.json' assert { type: 'json' };
import expectedResult from './fixtures/cwv.json' assert { type: 'json' };
import expectedCwvResult from './fixtures/cwv/result.json' assert { type: 'json' };
import bundlesForPatterns from './fixtures/cwv/bundles-for-url-patterns.json' assert { type: 'json' };
import expectedCwvResultForPatterns from './fixtures/cwv/result-for-url-patterns.json' assert { type: 'json' };

describe('CWV Queries', () => {
it('crunches cwv data', async () => {
it('should correctly process CWV data', async () => {
const result = cwv.handler(bundles.rumBundles);
expect(result).to.deep.equal(expectedResult);
expect(result).to.deep.equal(expectedCwvResult);
});

it('should correctly process CWV data with url patterns', async () => {
Expand All @@ -30,7 +30,7 @@ describe('CWV Queries', () => {
{ name: 'Static Pages', pattern: 'https://www.aem.live/pages/*' },
];

const result = cwv.handler(bundlesWithPatterns.rumBundles, groupedURLs);
expect(result).to.deep.equal(expectedCwvWithPatternsResult);
const result = cwv.handler(bundlesForPatterns.rumBundles, groupedURLs);
expect(result).to.deep.equal(expectedCwvResultForPatterns);
});
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"rumBundles": [
{
"id": "1Sdx_1",
"id": "product_1_session_1",
"host": "main--helix-website--adobe.aem.live",
"time": "2024-05-31T00:00:05.017Z",
"timeSlot": "2024-05-31T00:00:00.000Z",
Expand All @@ -11,102 +11,151 @@
"events": [
{
"checkpoint": "cwv-lcp",
"value": 100000,
"value": 10,
"timeDelta": 22458.39990234375,
"source": ".hero"
},
{
"checkpoint": "cwv-cls",
"value": 0.1,
"timeDelta": 6220.89990234375
},
{
"checkpoint": "cwv-inp",
"value": 10,
"timeDelta": 1259035.6000976562
},
{
"checkpoint": "cwv-ttfb",
"value": 10,
"timeDelta": 23753.300048828125
}
]
},
{
"id": "1Sdx_2",
"id": "product_1_session_2",
"host": "main--helix-website--adobe.aem.live",
"time": "2024-05-31T01:00:01.894Z",
"timeSlot": "2024-05-31T01:00:00.000Z",
"url": "https://www.aem.live/catalog/product-2",
"userAgent": "desktop:windows",
"time": "2024-05-31T00:00:05.017Z",
"timeSlot": "2024-05-31T00:00:00.000Z",
"url": "https://www.aem.live/catalog/product-1",
"userAgent": "desktop:mac",
"weight": 100,
"events": [
{
"checkpoint": "cwv-lcp",
"value": 20000,
"value": 20,
"timeDelta": 22458.39990234375,
"source": ".hero"
},
{
"checkpoint": "cwv-cls",
"value": 0.2,
"timeDelta": 6220.89990234375
},
{
"checkpoint": "cwv-inp",
"value": 20,
"timeDelta": 1259035.6000976562
},
{
"checkpoint": "cwv-ttfb",
"value": 20,
"timeDelta": 23753.300048828125
}
]
},
{
"id": "without_events",
"id": "product_1_session_3",
"host": "main--helix-website--adobe.aem.live",
"time": "2024-05-31T03:00:00.193Z",
"timeSlot": "2024-05-31T03:00:00.000Z",
"url": "https://www.aem.live/catalog/product-3",
"time": "2024-05-31T00:00:05.017Z",
"timeSlot": "2024-05-31T00:00:00.000Z",
"url": "https://www.aem.live/catalog/product-1",
"userAgent": "desktop:mac",
"weight": 1,
"events": []
"weight": 100,
"events": [
{
"checkpoint": "cwv-lcp",
"value": 30,
"timeDelta": 22458.39990234375,
"source": ".hero"
}
]
},
{
"id": "67Caj_1",
"id": "product_1_session_4",
"host": "main--helix-website--adobe.aem.live",
"time": "2024-05-31T03:00:00.193Z",
"timeSlot": "2024-05-31T03:00:00.000Z",
"url": "https://www.aem.live/pages/page-1",
"time": "2024-05-31T00:00:05.017Z",
"timeSlot": "2024-05-31T00:00:00.000Z",
"url": "https://www.aem.live/catalog/product-1",
"userAgent": "desktop:mac",
"weight": 10,
"weight": 100,
"events": [
{
"checkpoint": "cwv-cls",
"value": 0.1,
"timeDelta": 12343
"checkpoint": "cwv-lcp",
"value": 40,
"timeDelta": 22458.39990234375,
"source": ".hero"
}
]
},
{
"id": "67Caj_2",
"id": "product_1_session_5",
"host": "main--helix-website--adobe.aem.live",
"time": "2024-05-31T03:00:00.193Z",
"timeSlot": "2024-05-31T03:00:00.000Z",
"url": "https://www.aem.live/pages/page-2",
"time": "2024-05-31T00:00:05.017Z",
"timeSlot": "2024-05-31T00:00:00.000Z",
"url": "https://www.aem.live/catalog/product-1",
"userAgent": "desktop:mac",
"weight": 20,
"weight": 100,
"events": [
{
"checkpoint": "cwv-cls",
"value": 0.2,
"timeDelta": 12343
"checkpoint": "cwv-lcp",
"value": 50,
"timeDelta": 22458.39990234375,
"source": ".hero"
}
]
},
{
"id": "67Caj_4",
"id": "product_2_session_1",
"host": "main--helix-website--adobe.aem.live",
"time": "2024-05-31T03:00:00.193Z",
"timeSlot": "2024-05-31T03:00:00.000Z",
"url": "https://www.aem.live/docs/doc-1",
"userAgent": "desktop:mac",
"weight": 5,
"time": "2024-05-31T01:00:01.894Z",
"timeSlot": "2024-05-31T01:00:00.000Z",
"url": "https://www.aem.live/catalog/product-2",
"userAgent": "desktop:windows",
"weight": 100,
"events": [
{
"checkpoint": "cwv-lcp",
"value": 30,
"timeDelta": 22458.39990234375,
"source": ".hero"
},
{
"checkpoint": "cwv-cls",
"value": 0.1,
"timeDelta": 12343
"value": 0.3,
"timeDelta": 6220.89990234375
},
{
"checkpoint": "cwv-inp",
"value": 30,
"timeDelta": 1259035.6000976562
},
{
"checkpoint": "cwv-ttfb",
"value": 30,
"timeDelta": 23753.300048828125
}
]
},
{
"id": "67Caj_5",
"id": "product_3_session_1_without_events",
"host": "main--helix-website--adobe.aem.live",
"time": "2024-05-31T03:00:00.193Z",
"timeSlot": "2024-05-31T03:00:00.000Z",
"url": "https://www.aem.live/docs/doc-2",
"url": "https://www.aem.live/catalog/product-3",
"userAgent": "desktop:mac",
"weight": 1,
"events": [
{
"checkpoint": "cwv-lcp",
"value": 0.1,
"timeDelta": 12343
}
]
"events": []
}
]
}

This file was deleted.

Loading

0 comments on commit baee7c9

Please sign in to comment.