Skip to content

Commit

Permalink
feat(UA-9399): added getEventsProblems call (#863)
Browse files Browse the repository at this point in the history
* feat(UA-9399): added getEventsProblems call

* feat(UA-9399): small fix

* feat(UA-9399): small fix

* feat(UA-9399): small fix

* Update src/resources/UsageAnalytics/Read/DataHealth/DataHealthInterfaces.ts

Co-authored-by: Frederic Beaudoin <[email protected]>

* Update src/resources/UsageAnalytics/Read/DataHealth/DataHealthInterfaces.ts

Co-authored-by: Frederic Beaudoin <[email protected]>

* Update src/resources/UsageAnalytics/Read/DataHealth/DataHealthInterfaces.ts

Co-authored-by: Frederic Beaudoin <[email protected]>

* Update src/resources/UsageAnalytics/Read/DataHealth/DataHealthInterfaces.ts

Co-authored-by: Frederic Beaudoin <[email protected]>

* Update src/resources/UsageAnalytics/Read/DataHealth/DataHealthInterfaces.ts

Co-authored-by: Frederic Beaudoin <[email protected]>

* Update src/resources/UsageAnalytics/Read/DataHealth/DataHealthInterfaces.ts

Co-authored-by: Frederic Beaudoin <[email protected]>

* Update src/resources/UsageAnalytics/Read/DataHealth/DataHealthInterfaces.ts

Co-authored-by: Frederic Beaudoin <[email protected]>

* Update src/resources/UsageAnalytics/Read/DataHealth/DataHealthInterfaces.ts

Co-authored-by: Frederic Beaudoin <[email protected]>

* Update src/resources/UsageAnalytics/Read/DataHealth/DataHealthInterfaces.ts

Co-authored-by: Frederic Beaudoin <[email protected]>

* Update src/resources/UsageAnalytics/Read/DataHealth/DataHealthInterfaces.ts

Co-authored-by: Frederic Beaudoin <[email protected]>

* Update src/resources/UsageAnalytics/Read/DataHealth/DataHealthInterfaces.ts

Co-authored-by: Frederic Beaudoin <[email protected]>

* Update src/resources/UsageAnalytics/Read/DataHealth/DataHealthInterfaces.ts

Co-authored-by: Frederic Beaudoin <[email protected]>

* Update src/resources/UsageAnalytics/Read/DataHealth/DataHealthInterfaces.ts

Co-authored-by: Frederic Beaudoin <[email protected]>

* feat(UA-9134): review changes

---------

Co-authored-by: Frederic Beaudoin <[email protected]>
  • Loading branch information
AdamMartineau-Coveo and fbeaudoincoveo authored Oct 1, 2024
1 parent 6bf06f6 commit 66712f4
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 0 deletions.
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 @@ -16,6 +16,8 @@ import {
DataHealthListEventsResponse,
DataHealthListFacetsResponse,
DataHealthListFacetValueParams,
EventProblemsResponse,
DataHealthGetEventProblemsParams,
} from './DataHealthInterfaces.js';

export default class DataHealth extends ReadServiceResource {
Expand Down Expand Up @@ -84,6 +86,15 @@ export default class DataHealth extends ReadServiceResource {
);
}

/**
* Get problems about events.
*/
getEventsProblems(params: DataHealthGetEventProblemsParams) {
return this.api.get<EventProblemsResponse>(
this.buildPathWithOrg(`${DataHealth.baseUrl}/events/problems`, params),
);
}

/**
* Get failed instances for a data health criterion
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,3 +364,80 @@ export interface DataHealthFailedInstanceEntry {
* The scope of a datahealth rule.
*/
type DataHealthRuleScope = 'EVENT' | 'VISIT';

export interface DataHealthGetEventProblemsParams extends OrganizationParamParts, TimeRangeParamParts, Paginated {
/**
* The event types to get event problems for.
* By default, all event types will be considered.
* See https://docs.coveo.com/en/2949/analyze-usage-data/events
*/
eventType?: string[];
/**
* The search hubs to get event problems for.
* By default, all search hubs will be considered.
*/
searchHub?: string[];
/**
* The tracking ID to get event problems for.
* By default, all tracking IDs will be considered.
*/
trackingId?: string[];
}
export interface EventProblemsResponse extends PaginatedResponse {
/**
* The event problems that match the specified filters.
*/
problems: EventProblemsResponseItem[];
}

export interface EventProblemsResponseItem {
/**
* The type of events in this response item.
* See https://docs.coveo.com/en/2949/analyze-usage-data/events
*/
eventType: string;
/**
* The tracking ID the events in this response item were logged with.
*/
trackingId: string;
/**
* The search hub the events in this response item were logged from.
*/
searchHub: string;
/**
* The number of failed events.
*/
failedEvents: number;
/**
* The total number of failed events.
*/
totalEvents: number;
/**
* The validation errors.
*/
validationErrors: ValidationErrors[];
/**
* A list of sample events that have the validation problems.
*/
sampleEvents: string[];
/**
* Timestamps from the sample events.
*/
sampleEventsTimestamps: string[];
}

interface ValidationErrors {
/**
* The validation error code.
*/
code: string;
/**
* The validation error path.
* See https://docs.coveo.com/en/nbde0312/analyze-usage-data/event-errors
*/
path: string;
/**
* The validation error message.
*/
message: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
DataHealthGetTrackingIdsParams,
DataHealthListEventsParameters,
DataHealthListFacetValueParams,
DataHealthGetEventProblemsParams,
} from '../DataHealthInterfaces.js';

jest.mock('../../../../../APICore.js');
Expand Down Expand Up @@ -127,6 +128,19 @@ describe('DataHealth', () => {
});
});

describe('getEventsProblems', () => {
it('should make a GET call to the data health get events problems url', () => {
const datahealthGetEventsProblemsParams: DataHealthGetEventProblemsParams = {
...baseParams,
};
dataHealth.getEventsProblems(datahealthGetEventsProblemsParams);
expect(api.get).toHaveBeenCalledTimes(1);
expect(api.get).toHaveBeenCalledWith(
`${DataHealth.baseUrl}/events/problems?org=someOrgId&from=1986-04-26T01%3A23%3A58.000Z&to=1986-04-27T02%3A32%3A15.000Z`,
);
});
});

describe('getFailedInstances', () => {
it('should make a GET call to the data health get failed instances url', async () => {
const datahealthGetFailedInstancesParams: DataHealthGetFailedInstancesParams = {
Expand Down

0 comments on commit 66712f4

Please sign in to comment.