Skip to content

Commit

Permalink
feat: replace 404 checkpoints with 404 sources
Browse files Browse the repository at this point in the history
  • Loading branch information
alinarublea committed Dec 14, 2023
1 parent 165e377 commit fcd0199
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 12 deletions.
27 changes: 27 additions & 0 deletions packages/spacecat-shared-rum-api-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
```
Expand Down
8 changes: 4 additions & 4 deletions packages/spacecat-shared-rum-api-client/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ export declare class RUMAPIClient {
getRUMDashboard(params: object): Promise<Array<object>>;

/**
* 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<Array<object>>;
get404Sources(params: object): Promise<Array<object>>;

/**
* Asynchronous method to return an array with the domain for a specific url
Expand Down
6 changes: 3 additions & 3 deletions packages/spacecat-shared-rum-api-client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 },
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit fcd0199

Please sign in to comment.