diff --git a/packages/spacecat-shared-rum-api-client/README.md b/packages/spacecat-shared-rum-api-client/README.md index a6aadcec..06944372 100644 --- a/packages/spacecat-shared-rum-api-client/README.md +++ b/packages/spacecat-shared-rum-api-client/README.md @@ -39,6 +39,33 @@ const backlink = await rumApiClient.createBacklink(url, expiry); console.log(`Backlink created: ${backlink}`) ``` +### Getting RUM Dashboard Data + +```js +const url = "example.com"; + +const rumData = await rumApiClient.getRUMDashboard({ url }); +console.log(`RUM data: ${rumData}`) +``` + +### Getting 404 checkpoints + +```js +const url = "example.com"; + +const backlink = await rumApiClient.get404Sources({ url }); +console.log(`404 Checkpoints: ${backlink}`) +``` + +### Getting Edge Delivery Services Domains + +```js +const url = "all"; + +const domains = await rumApiClient.getDomainList({}, url); +console.log(`Backlink created: ${backlink}`) +``` + ## Testing Run the included tests with the following command: ``` diff --git a/packages/spacecat-shared-rum-api-client/src/index.d.ts b/packages/spacecat-shared-rum-api-client/src/index.d.ts index c96175bc..74bd158c 100644 --- a/packages/spacecat-shared-rum-api-client/src/index.d.ts +++ b/packages/spacecat-shared-rum-api-client/src/index.d.ts @@ -50,12 +50,12 @@ export declare class RUMAPIClient { getRUMDashboard(params: object): Promise>; /** - * Asynchronous method to return the 404 checkpoints API call response data. + * Asynchronous method to return the 404 sources API call response data. * @param {object} params - An object representing the parameters to be included - * for the 404 Checkpoints API call. - * @returns A Promise resolving to the 404 checkpoints response data. + * for the 404 sources API call. + * @returns A Promise resolving to the 404 sources response data. */ - get404Checkpoints(params: object): Promise>; + get404Sources(params: object): Promise>; /** * Asynchronous method to return an array with the domain for a specific url diff --git a/packages/spacecat-shared-rum-api-client/src/index.js b/packages/spacecat-shared-rum-api-client/src/index.js index 9158d064..49b6b6ab 100644 --- a/packages/spacecat-shared-rum-api-client/src/index.js +++ b/packages/spacecat-shared-rum-api-client/src/index.js @@ -20,7 +20,7 @@ const APIS = { RUM_DASHBOARD_UI: 'https://main--franklin-dashboard--adobe.hlx.live/views/rum-dashboard', RUM_DASHBOARD: 'https://helix-pages.anywhere.run/helix-services/run-query@v3/rum-dashboard', DOMAIN_LIST: 'https://helix-pages.anywhere.run/helix-services/run-query@v3/dash/domain-list', - NOT_FOUND_CHECKPOINTS: 'https://helix-pages.anywhere.run/helix-services/run-query@v3/rum-checkpoint-urls', + RUM_SOURCES: 'https://helix-pages.anywhere.run/helix-services/run-query@v3/rum-sources', }; export const isAuditForAll = (url) => url.toUpperCase() === 'ALL'; @@ -97,9 +97,9 @@ export default class RUMAPIClient { )); } - async get404Checkpoints(params) { + async get404Sources(params) { return sendRequest(createUrl( - APIS.NOT_FOUND_CHECKPOINTS, + APIS.RUM_SOURCES, { domainkey: this.domainkey, checkpoint: 404, ...params }, )); } diff --git a/packages/spacecat-shared-rum-api-client/test/rum-api-client.test.js b/packages/spacecat-shared-rum-api-client/test/rum-api-client.test.js index 5972b6ba..d8fba307 100644 --- a/packages/spacecat-shared-rum-api-client/test/rum-api-client.test.js +++ b/packages/spacecat-shared-rum-api-client/test/rum-api-client.test.js @@ -88,17 +88,17 @@ describe('rum api client', () => { }]); }); - it('returns data when get404Checkpoints api is successful', async () => { + it('returns data when get404Sources api is successful', async () => { nock('https://helix-pages.anywhere.run/helix-services') - .get('/run-query@v3/rum-checkpoint-urls') + .get('/run-query@v3/rum-sources') .query({ domainkey: 'hebele', checkpoint: 404, }) - .reply(200, JSON.stringify({ results: { data: [{ url: 'http://spacecar.com', views: 100 }] } })); + .reply(200, JSON.stringify({ results: { data: [{ url: 'http://spacecar.com', views: 100, sources: 'www.google.com' }] } })); const rumApiClient = RUMAPIClient.createFrom({ env: { RUM_API_KEY: 'hebele' } }); - await expect(rumApiClient.get404Checkpoints()) - .to.eventually.eql([{ url: 'http://spacecar.com', views: 100 }]); + await expect(rumApiClient.get404Sources()) + .to.eventually.eql([{ url: 'http://spacecar.com', views: 100, sources: 'www.google.com' }]); }); it('returns data when getDomainList api is successful for all', async () => {