Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rum client createRUMURL function #137

Merged
merged 9 commits into from
Feb 6, 2024
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 11 additions & 7 deletions packages/spacecat-shared-rum-api-client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,21 @@ export default class RUMAPIClient {
);
}

async getRUMDashboard(params = {}) {
return sendRequest(createUrl(
createRUMURL(params = {}) {
return createUrl(
APIS.RUM_DASHBOARD,
{ domainkey: this.domainkey, ...RUM_DEFAULT_PARAMS, ...params },
));
{
domainkey: this.domainkey, ...RUM_DEFAULT_PARAMS, ...params,
},
);
}

async getRUMDashboard(params = {}) {
return sendRequest(this.createRUMURL(params));
}

async get404Sources(params = {}) {
return sendRequest(this.create404URL(
params,
));
return sendRequest(this.create404URL(params));
}

async getDomainList(params = {}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ describe('rum api client', () => {
.to.eql('https://helix-pages.anywhere.run/helix-services/run-query@v3/rum-sources?domainkey=hebele&interval=7&offset=0&limit=101&checkpoint=404&url=http%3A%2F%2Fspacecar.com');
});

it('returns the URL to call the getRUMDashboard', () => {
const rumApiClient = RUMAPIClient.createFrom({ env: { RUM_DOMAIN_KEY: 'hebele' } });
expect(rumApiClient.createRUMURL({ url: 'http://spacecar.com' }))
.to.eql('https://helix-pages.anywhere.run/helix-services/run-query@v3/rum-dashboard?domainkey=hebele&interval=7&offset=0&limit=101&url=http%3A%2F%2Fspacecar.com');
});

it('returns data when get404Sources api is successful', async () => {
nock('https://helix-pages.anywhere.run/helix-services')
.get('/run-query@v3/rum-sources')
Expand Down
Loading