Skip to content

Commit

Permalink
feat(specs): add estimate path and responses [skip-bc] (generated)
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#4057

Co-authored-by: algolia-bot <[email protected]>
Co-authored-by: Christopher Hawke <[email protected]>
Co-authored-by: Pierre Millot <[email protected]>
  • Loading branch information
3 people committed Nov 7, 2024
1 parent b50469b commit 4a5a228
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
/**
* Metric for which you want to detect the smallest relative difference.
*/
export type Effect = 'addToCartRate' | 'clickThroughRate' | 'conversionRate' | 'purchaseRate';
export type EffectMetric = 'addToCartRate' | 'clickThroughRate' | 'conversionRate' | 'purchaseRate';
13 changes: 13 additions & 0 deletions packages/client-abtesting/model/estimateABTestRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

import type { AddABTestsVariant } from './addABTestsVariant';
import type { EstimateConfiguration } from './estimateConfiguration';

export type EstimateABTestRequest = {
configuration: EstimateConfiguration;

/**
* A/B test variants.
*/
variants: Array<AddABTestsVariant>;
};
18 changes: 18 additions & 0 deletions packages/client-abtesting/model/estimateABTestResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

export type EstimateABTestResponse = {
/**
* Estimated number of days needed to reach the sample sizes required for detecting the configured effect. This value is based on historical traffic.
*/
durationDays?: number;

/**
* Number of tracked searches needed to be able to detect the configured effect for the control variant.
*/
controlSampleSize?: number;

/**
* Number of tracked searches needed to be able to detect the configured effect for the experiment variant.
*/
experimentSampleSize?: number;
};
16 changes: 16 additions & 0 deletions packages/client-abtesting/model/estimateConfiguration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

import type { EmptySearch } from './emptySearch';
import type { MinimumDetectableEffect } from './minimumDetectableEffect';
import type { Outliers } from './outliers';

/**
* A/B test configuration for estimating the sample size and duration using minimum detectable effect.
*/
export type EstimateConfiguration = {
outliers?: Outliers;

emptySearch?: EmptySearch;

minimumDetectableEffect: MinimumDetectableEffect;
};
5 changes: 4 additions & 1 deletion packages/client-abtesting/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ export * from './addABTestsVariant';
export * from './clientMethodProps';
export * from './currency';
export * from './customSearchParams';
export * from './effect';
export * from './effectMetric';
export * from './emptySearch';
export * from './emptySearchFilter';
export * from './errorBase';
export * from './estimateABTestRequest';
export * from './estimateABTestResponse';
export * from './estimateConfiguration';
export * from './filterEffects';
export * from './listABTestsResponse';
export * from './minimumDetectableEffect';
Expand Down
6 changes: 3 additions & 3 deletions packages/client-abtesting/model/minimumDetectableEffect.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

import type { Effect } from './effect';
import type { EffectMetric } from './effectMetric';

/**
* Configuration for the smallest difference between test variants you want to detect.
Expand All @@ -9,7 +9,7 @@ export type MinimumDetectableEffect = {
/**
* Smallest difference in an observable metric between variants. For example, to detect a 10% difference between variants, set this value to 0.1.
*/
size?: number;
size: number;

effect?: Effect;
metric: EffectMetric;
};
40 changes: 40 additions & 0 deletions packages/client-abtesting/src/abtestingClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import type { ABTest } from '../model/aBTest';
import type { ABTestResponse } from '../model/aBTestResponse';
import type { AddABTestsRequest } from '../model/addABTestsRequest';

import type { EstimateABTestRequest } from '../model/estimateABTestRequest';
import type { EstimateABTestResponse } from '../model/estimateABTestResponse';
import type { ListABTestsResponse } from '../model/listABTestsResponse';
import type { ScheduleABTestResponse } from '../model/scheduleABTestResponse';
import type { ScheduleABTestsRequest } from '../model/scheduleABTestsRequest';
Expand Down Expand Up @@ -298,6 +300,44 @@ export function createAbtestingClient({
return transporter.request(request, requestOptions);
},

/**
* Given the traffic percentage and the expected effect size, this endpoint estimates the sample size and duration of an A/B test based on historical traffic.
*
* Required API Key ACLs:
* - analytics
* @param estimateABTestRequest - The estimateABTestRequest object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
estimateABTest(
estimateABTestRequest: EstimateABTestRequest,
requestOptions?: RequestOptions,
): Promise<EstimateABTestResponse> {
if (!estimateABTestRequest) {
throw new Error('Parameter `estimateABTestRequest` is required when calling `estimateABTest`.');
}

if (!estimateABTestRequest.configuration) {
throw new Error('Parameter `estimateABTestRequest.configuration` is required when calling `estimateABTest`.');
}
if (!estimateABTestRequest.variants) {
throw new Error('Parameter `estimateABTestRequest.variants` is required when calling `estimateABTest`.');
}

const requestPath = '/2/abtests/estimate';
const headers: Headers = {};
const queryParameters: QueryParameters = {};

const request: Request = {
method: 'POST',
path: requestPath,
queryParameters,
headers,
data: estimateABTestRequest,
};

return transporter.request(request, requestOptions);
},

/**
* Retrieves the details for an A/B test by its ID.
*
Expand Down

0 comments on commit 4a5a228

Please sign in to comment.