Skip to content

Commit 4a5a228

Browse files
algolia-botcdhawkemillotp
committed
feat(specs): add estimate path and responses [skip-bc] (generated)
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]>
1 parent b50469b commit 4a5a228

File tree

7 files changed

+95
-5
lines changed

7 files changed

+95
-5
lines changed

packages/client-abtesting/model/effect.ts renamed to packages/client-abtesting/model/effectMetric.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
/**
44
* Metric for which you want to detect the smallest relative difference.
55
*/
6-
export type Effect = 'addToCartRate' | 'clickThroughRate' | 'conversionRate' | 'purchaseRate';
6+
export type EffectMetric = 'addToCartRate' | 'clickThroughRate' | 'conversionRate' | 'purchaseRate';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// 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.
2+
3+
import type { AddABTestsVariant } from './addABTestsVariant';
4+
import type { EstimateConfiguration } from './estimateConfiguration';
5+
6+
export type EstimateABTestRequest = {
7+
configuration: EstimateConfiguration;
8+
9+
/**
10+
* A/B test variants.
11+
*/
12+
variants: Array<AddABTestsVariant>;
13+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// 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.
2+
3+
export type EstimateABTestResponse = {
4+
/**
5+
* Estimated number of days needed to reach the sample sizes required for detecting the configured effect. This value is based on historical traffic.
6+
*/
7+
durationDays?: number;
8+
9+
/**
10+
* Number of tracked searches needed to be able to detect the configured effect for the control variant.
11+
*/
12+
controlSampleSize?: number;
13+
14+
/**
15+
* Number of tracked searches needed to be able to detect the configured effect for the experiment variant.
16+
*/
17+
experimentSampleSize?: number;
18+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// 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.
2+
3+
import type { EmptySearch } from './emptySearch';
4+
import type { MinimumDetectableEffect } from './minimumDetectableEffect';
5+
import type { Outliers } from './outliers';
6+
7+
/**
8+
* A/B test configuration for estimating the sample size and duration using minimum detectable effect.
9+
*/
10+
export type EstimateConfiguration = {
11+
outliers?: Outliers;
12+
13+
emptySearch?: EmptySearch;
14+
15+
minimumDetectableEffect: MinimumDetectableEffect;
16+
};

packages/client-abtesting/model/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ export * from './addABTestsVariant';
1010
export * from './clientMethodProps';
1111
export * from './currency';
1212
export * from './customSearchParams';
13-
export * from './effect';
13+
export * from './effectMetric';
1414
export * from './emptySearch';
1515
export * from './emptySearchFilter';
1616
export * from './errorBase';
17+
export * from './estimateABTestRequest';
18+
export * from './estimateABTestResponse';
19+
export * from './estimateConfiguration';
1720
export * from './filterEffects';
1821
export * from './listABTestsResponse';
1922
export * from './minimumDetectableEffect';
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// 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.
22

3-
import type { Effect } from './effect';
3+
import type { EffectMetric } from './effectMetric';
44

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

14-
effect?: Effect;
14+
metric: EffectMetric;
1515
};

packages/client-abtesting/src/abtestingClient.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import type { ABTest } from '../model/aBTest';
1414
import type { ABTestResponse } from '../model/aBTestResponse';
1515
import type { AddABTestsRequest } from '../model/addABTestsRequest';
1616

17+
import type { EstimateABTestRequest } from '../model/estimateABTestRequest';
18+
import type { EstimateABTestResponse } from '../model/estimateABTestResponse';
1719
import type { ListABTestsResponse } from '../model/listABTestsResponse';
1820
import type { ScheduleABTestResponse } from '../model/scheduleABTestResponse';
1921
import type { ScheduleABTestsRequest } from '../model/scheduleABTestsRequest';
@@ -298,6 +300,44 @@ export function createAbtestingClient({
298300
return transporter.request(request, requestOptions);
299301
},
300302

303+
/**
304+
* 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.
305+
*
306+
* Required API Key ACLs:
307+
* - analytics
308+
* @param estimateABTestRequest - The estimateABTestRequest object.
309+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
310+
*/
311+
estimateABTest(
312+
estimateABTestRequest: EstimateABTestRequest,
313+
requestOptions?: RequestOptions,
314+
): Promise<EstimateABTestResponse> {
315+
if (!estimateABTestRequest) {
316+
throw new Error('Parameter `estimateABTestRequest` is required when calling `estimateABTest`.');
317+
}
318+
319+
if (!estimateABTestRequest.configuration) {
320+
throw new Error('Parameter `estimateABTestRequest.configuration` is required when calling `estimateABTest`.');
321+
}
322+
if (!estimateABTestRequest.variants) {
323+
throw new Error('Parameter `estimateABTestRequest.variants` is required when calling `estimateABTest`.');
324+
}
325+
326+
const requestPath = '/2/abtests/estimate';
327+
const headers: Headers = {};
328+
const queryParameters: QueryParameters = {};
329+
330+
const request: Request = {
331+
method: 'POST',
332+
path: requestPath,
333+
queryParameters,
334+
headers,
335+
data: estimateABTestRequest,
336+
};
337+
338+
return transporter.request(request, requestOptions);
339+
},
340+
301341
/**
302342
* Retrieves the details for an A/B test by its ID.
303343
*

0 commit comments

Comments
 (0)