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(UA-9134): added the getFailedInstances call in the datahealth resource #861

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/resources/UsageAnalytics/Read/DataHealth/DataHealth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import ReadServiceResource from '../ReadServiceResource.js';
import {
DataHealthEventPayloadResponse,
DataHealthGetEventPayloadParams,
DataHealthGetFailedInstancesParams,
DataHealthGetFailedInstancesResponse,
DataHealthGetGroupDetailParams,
DataHealthGetGroupDetailResponse,
DataHealthGetGroupListingParams,
Expand Down Expand Up @@ -93,4 +95,13 @@ export default class DataHealth extends ReadServiceResource {
protected buildPathWithOrg(route: string, queryParams?: any): string {
return super.buildPath(route, {org: this.api.organizationId, ...queryParams});
}

/**
* Get failed instances for a data health criterion
*/
AdamMartineau-Coveo marked this conversation as resolved.
Show resolved Hide resolved
getFailedInstances(params: DataHealthGetFailedInstancesParams, args?: RequestInit) {
return this.api.get<DataHealthGetFailedInstancesResponse>(
this.buildPathWithOrg(`${DataHealth.baseUrl}/criteria/failedInstances`, params),
mpayne-coveo marked this conversation as resolved.
Show resolved Hide resolved
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,57 @@ export interface DataHealthGetTrackingIdsResponse {
*/
values: DataHealthFacetValue[];
}

export interface DataHealthGetFailedInstancesParams extends OrganizationParamParts, TimeRangeParamParts {
AdamMartineau-Coveo marked this conversation as resolved.
Show resolved Hide resolved
/**
* The data health criterion for which the failed instances should be returned.
*/
criterionId: string;
/**
* The group for which data health information should be returned.
*/
group: string;
/**
* The value of the criterion scope for which failed instances should be returned.
*/
scopeValue: string;
/**
* The tracking IDs for which the results should be returned.
*/
trackingId: string[];
}

export interface DataHealthGetFailedInstancesResponse extends PaginatedResponse {
/**
* A collection of failed instances.
*/
failedInstances: DataHealthFailedInstanceEntry[];
}

export interface DataHealthFailedInstanceEntry {
AdamMartineau-Coveo marked this conversation as resolved.
Show resolved Hide resolved
/**
* The timestamp of the failed instance.
*/
timestamp: string;
/**
* The id of the event.
AdamMartineau-Coveo marked this conversation as resolved.
Show resolved Hide resolved
*/
eventId: string;
/**
* The id of the visit.
AdamMartineau-Coveo marked this conversation as resolved.
Show resolved Hide resolved
*/
visitId: string;
/**
* The client id of the event.
AdamMartineau-Coveo marked this conversation as resolved.
Show resolved Hide resolved
*/
clientId: string;
/**
* The scope of the datahealth rule, either event or visit.
AdamMartineau-Coveo marked this conversation as resolved.
Show resolved Hide resolved
*/
scope: DataHealthRuleScope;
}

/**
* The scope of the datahealth rule, either event or visit.
AdamMartineau-Coveo marked this conversation as resolved.
Show resolved Hide resolved
*/
type DataHealthRuleScope = 'EVENT' | 'VISIT';
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import API from '../../../../../APICore.js';
import DataHealth from '../DataHealth.js';
import {
DataHealthGetEventPayloadParams,
DataHealthGetFailedInstancesParams,
DataHealthGetGroupDetailParams,
DataHealthGetGroupListingParams,
DataHealthGetOverviewParams,
Expand Down Expand Up @@ -125,4 +126,21 @@ describe('DataHealth', () => {
);
});
});

describe('getFailedInstances', () => {
it('should make a GET call to the data health get tracking id url', () => {
const datahealthGetFailedInstancesParams: DataHealthGetFailedInstancesParams = {
...baseParams,
criterionId: 'criterion',
group: 'group',
scopeValue: '',
trackingId: [''],
AdamMartineau-Coveo marked this conversation as resolved.
Show resolved Hide resolved
};
dataHealth.getFailedInstances(datahealthGetFailedInstancesParams);
AdamMartineau-Coveo marked this conversation as resolved.
Show resolved Hide resolved
expect(api.get).toHaveBeenCalledTimes(1);
expect(api.get).toHaveBeenCalledWith(
`${DataHealth.baseUrl}/criteria/failedInstances?org=someOrgId&from=1986-04-26T01%3A23%3A58.000Z&to=1986-04-27T02%3A32%3A15.000Z&criterionId=criterion&group=group`,
);
});
});
});