Skip to content

Commit a60dfd8

Browse files
author
awstools
committed
feat(client-evidently): This release adds support for the new segmentation feature.
1 parent 2b37799 commit a60dfd8

18 files changed

+2862
-72
lines changed

clients/client-evidently/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
AWS SDK for JavaScript Evidently Client for Node.js, Browser and React Native.
1111

12-
<p>You can use Amazon CloudWatch Evidently to safely validate new features by serving them to a specified percentage
12+
<p>You can use Amazon CloudWatch Evidently to safely validate new features by serving
13+
them to a specified percentage
1314
of your users while you roll out the feature. You can monitor the performance of the new feature
1415
to help you decide when to ramp up traffic to your users. This helps you
1516
reduce risk and identify unintended consequences before you fully launch the feature.</p>

clients/client-evidently/src/Evidently.ts

Lines changed: 244 additions & 4 deletions
Large diffs are not rendered by default.

clients/client-evidently/src/EvidentlyClient.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ import { CreateExperimentCommandInput, CreateExperimentCommandOutput } from "./c
6161
import { CreateFeatureCommandInput, CreateFeatureCommandOutput } from "./commands/CreateFeatureCommand";
6262
import { CreateLaunchCommandInput, CreateLaunchCommandOutput } from "./commands/CreateLaunchCommand";
6363
import { CreateProjectCommandInput, CreateProjectCommandOutput } from "./commands/CreateProjectCommand";
64+
import { CreateSegmentCommandInput, CreateSegmentCommandOutput } from "./commands/CreateSegmentCommand";
6465
import { DeleteExperimentCommandInput, DeleteExperimentCommandOutput } from "./commands/DeleteExperimentCommand";
6566
import { DeleteFeatureCommandInput, DeleteFeatureCommandOutput } from "./commands/DeleteFeatureCommand";
6667
import { DeleteLaunchCommandInput, DeleteLaunchCommandOutput } from "./commands/DeleteLaunchCommand";
6768
import { DeleteProjectCommandInput, DeleteProjectCommandOutput } from "./commands/DeleteProjectCommand";
69+
import { DeleteSegmentCommandInput, DeleteSegmentCommandOutput } from "./commands/DeleteSegmentCommand";
6870
import { EvaluateFeatureCommandInput, EvaluateFeatureCommandOutput } from "./commands/EvaluateFeatureCommand";
6971
import { GetExperimentCommandInput, GetExperimentCommandOutput } from "./commands/GetExperimentCommand";
7072
import {
@@ -74,10 +76,16 @@ import {
7476
import { GetFeatureCommandInput, GetFeatureCommandOutput } from "./commands/GetFeatureCommand";
7577
import { GetLaunchCommandInput, GetLaunchCommandOutput } from "./commands/GetLaunchCommand";
7678
import { GetProjectCommandInput, GetProjectCommandOutput } from "./commands/GetProjectCommand";
79+
import { GetSegmentCommandInput, GetSegmentCommandOutput } from "./commands/GetSegmentCommand";
7780
import { ListExperimentsCommandInput, ListExperimentsCommandOutput } from "./commands/ListExperimentsCommand";
7881
import { ListFeaturesCommandInput, ListFeaturesCommandOutput } from "./commands/ListFeaturesCommand";
7982
import { ListLaunchesCommandInput, ListLaunchesCommandOutput } from "./commands/ListLaunchesCommand";
8083
import { ListProjectsCommandInput, ListProjectsCommandOutput } from "./commands/ListProjectsCommand";
84+
import {
85+
ListSegmentReferencesCommandInput,
86+
ListSegmentReferencesCommandOutput,
87+
} from "./commands/ListSegmentReferencesCommand";
88+
import { ListSegmentsCommandInput, ListSegmentsCommandOutput } from "./commands/ListSegmentsCommand";
8189
import {
8290
ListTagsForResourceCommandInput,
8391
ListTagsForResourceCommandOutput,
@@ -88,6 +96,7 @@ import { StartLaunchCommandInput, StartLaunchCommandOutput } from "./commands/St
8896
import { StopExperimentCommandInput, StopExperimentCommandOutput } from "./commands/StopExperimentCommand";
8997
import { StopLaunchCommandInput, StopLaunchCommandOutput } from "./commands/StopLaunchCommand";
9098
import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand";
99+
import { TestSegmentPatternCommandInput, TestSegmentPatternCommandOutput } from "./commands/TestSegmentPatternCommand";
91100
import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand";
92101
import { UpdateExperimentCommandInput, UpdateExperimentCommandOutput } from "./commands/UpdateExperimentCommand";
93102
import { UpdateFeatureCommandInput, UpdateFeatureCommandOutput } from "./commands/UpdateFeatureCommand";
@@ -105,27 +114,33 @@ export type ServiceInputTypes =
105114
| CreateFeatureCommandInput
106115
| CreateLaunchCommandInput
107116
| CreateProjectCommandInput
117+
| CreateSegmentCommandInput
108118
| DeleteExperimentCommandInput
109119
| DeleteFeatureCommandInput
110120
| DeleteLaunchCommandInput
111121
| DeleteProjectCommandInput
122+
| DeleteSegmentCommandInput
112123
| EvaluateFeatureCommandInput
113124
| GetExperimentCommandInput
114125
| GetExperimentResultsCommandInput
115126
| GetFeatureCommandInput
116127
| GetLaunchCommandInput
117128
| GetProjectCommandInput
129+
| GetSegmentCommandInput
118130
| ListExperimentsCommandInput
119131
| ListFeaturesCommandInput
120132
| ListLaunchesCommandInput
121133
| ListProjectsCommandInput
134+
| ListSegmentReferencesCommandInput
135+
| ListSegmentsCommandInput
122136
| ListTagsForResourceCommandInput
123137
| PutProjectEventsCommandInput
124138
| StartExperimentCommandInput
125139
| StartLaunchCommandInput
126140
| StopExperimentCommandInput
127141
| StopLaunchCommandInput
128142
| TagResourceCommandInput
143+
| TestSegmentPatternCommandInput
129144
| UntagResourceCommandInput
130145
| UpdateExperimentCommandInput
131146
| UpdateFeatureCommandInput
@@ -139,27 +154,33 @@ export type ServiceOutputTypes =
139154
| CreateFeatureCommandOutput
140155
| CreateLaunchCommandOutput
141156
| CreateProjectCommandOutput
157+
| CreateSegmentCommandOutput
142158
| DeleteExperimentCommandOutput
143159
| DeleteFeatureCommandOutput
144160
| DeleteLaunchCommandOutput
145161
| DeleteProjectCommandOutput
162+
| DeleteSegmentCommandOutput
146163
| EvaluateFeatureCommandOutput
147164
| GetExperimentCommandOutput
148165
| GetExperimentResultsCommandOutput
149166
| GetFeatureCommandOutput
150167
| GetLaunchCommandOutput
151168
| GetProjectCommandOutput
169+
| GetSegmentCommandOutput
152170
| ListExperimentsCommandOutput
153171
| ListFeaturesCommandOutput
154172
| ListLaunchesCommandOutput
155173
| ListProjectsCommandOutput
174+
| ListSegmentReferencesCommandOutput
175+
| ListSegmentsCommandOutput
156176
| ListTagsForResourceCommandOutput
157177
| PutProjectEventsCommandOutput
158178
| StartExperimentCommandOutput
159179
| StartLaunchCommandOutput
160180
| StopExperimentCommandOutput
161181
| StopLaunchCommandOutput
162182
| TagResourceCommandOutput
183+
| TestSegmentPatternCommandOutput
163184
| UntagResourceCommandOutput
164185
| UpdateExperimentCommandOutput
165186
| UpdateFeatureCommandOutput
@@ -321,7 +342,8 @@ type EvidentlyClientResolvedConfigType = __SmithyResolvedConfiguration<__HttpHan
321342
export interface EvidentlyClientResolvedConfig extends EvidentlyClientResolvedConfigType {}
322343

323344
/**
324-
* <p>You can use Amazon CloudWatch Evidently to safely validate new features by serving them to a specified percentage
345+
* <p>You can use Amazon CloudWatch Evidently to safely validate new features by serving
346+
* them to a specified percentage
325347
* of your users while you roll out the feature. You can monitor the performance of the new feature
326348
* to help you decide when to ramp up traffic to your users. This helps you
327349
* reduce risk and identify unintended consequences before you fully launch the feature.</p>

clients/client-evidently/src/commands/CreateExperimentCommand.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export interface CreateExperimentCommandOutput extends CreateExperimentResponse,
2929
* decisions based on evidence and data. An experiment can test as
3030
* many as five variations at once. Evidently collects experiment data and analyzes it by statistical methods, and provides
3131
* clear recommendations about which variations perform better.</p>
32+
* <p>You can optionally specify a <code>segment</code> to have the experiment consider only certain audience
33+
* types in the experiment, such as using only user sessions from a certain location or who use a certain internet browser.</p>
3234
* <p>Don't use this operation to update an existing experiment. Instead, use
3335
* <a href="https://docs.aws.amazon.com/cloudwatchevidently/latest/APIReference/API_UpdateExperiment.html">UpdateExperiment</a>. </p>
3436
* @example
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
// smithy-typescript generated code
2+
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
3+
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
4+
import { Command as $Command } from "@aws-sdk/smithy-client";
5+
import {
6+
FinalizeHandlerArguments,
7+
Handler,
8+
HandlerExecutionContext,
9+
HttpHandlerOptions as __HttpHandlerOptions,
10+
MetadataBearer as __MetadataBearer,
11+
MiddlewareStack,
12+
SerdeContext as __SerdeContext,
13+
} from "@aws-sdk/types";
14+
15+
import { EvidentlyClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../EvidentlyClient";
16+
import { CreateSegmentRequest, CreateSegmentResponse } from "../models/models_0";
17+
import {
18+
deserializeAws_restJson1CreateSegmentCommand,
19+
serializeAws_restJson1CreateSegmentCommand,
20+
} from "../protocols/Aws_restJson1";
21+
22+
export interface CreateSegmentCommandInput extends CreateSegmentRequest {}
23+
export interface CreateSegmentCommandOutput extends CreateSegmentResponse, __MetadataBearer {}
24+
25+
/**
26+
* <p>Use this operation to define a <i>segment</i> of your audience. A segment
27+
* is a portion of your audience that share one or more characteristics. Examples could be Chrome browser users,
28+
* users in Europe, or Firefox browser users in Europe who also fit other criteria that your application collects,
29+
* such as age.</p>
30+
* <p>Using a segment in an experiment limits that experiment to evaluate only the users who match the segment
31+
* criteria. Using one or more segments in a launch allow you to define different traffic splits for the different
32+
* audience segments.</p>
33+
*
34+
* <p>For more information about segment pattern syntax, see
35+
* <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Evidently-segments-syntax.html">
36+
* Segment rule pattern syntax</a>.</p>
37+
*
38+
* <p>The pattern that you define for a segment is matched against the value of <code>evaluationContext</code>, which
39+
* is passed into Evidently in the <a href="https://docs.aws.amazon.com/cloudwatchevidently/latest/APIReference/API_EvaluateFeature.html">EvaluateFeature</a> operation,
40+
* when Evidently assigns a feature variation to a user.</p>
41+
* @example
42+
* Use a bare-bones client and the command you need to make an API call.
43+
* ```javascript
44+
* import { EvidentlyClient, CreateSegmentCommand } from "@aws-sdk/client-evidently"; // ES Modules import
45+
* // const { EvidentlyClient, CreateSegmentCommand } = require("@aws-sdk/client-evidently"); // CommonJS import
46+
* const client = new EvidentlyClient(config);
47+
* const command = new CreateSegmentCommand(input);
48+
* const response = await client.send(command);
49+
* ```
50+
*
51+
* @see {@link CreateSegmentCommandInput} for command's `input` shape.
52+
* @see {@link CreateSegmentCommandOutput} for command's `response` shape.
53+
* @see {@link EvidentlyClientResolvedConfig | config} for EvidentlyClient's `config` shape.
54+
*
55+
*/
56+
export class CreateSegmentCommand extends $Command<
57+
CreateSegmentCommandInput,
58+
CreateSegmentCommandOutput,
59+
EvidentlyClientResolvedConfig
60+
> {
61+
// Start section: command_properties
62+
// End section: command_properties
63+
64+
constructor(readonly input: CreateSegmentCommandInput) {
65+
// Start section: command_constructor
66+
super();
67+
// End section: command_constructor
68+
}
69+
70+
/**
71+
* @internal
72+
*/
73+
resolveMiddleware(
74+
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
75+
configuration: EvidentlyClientResolvedConfig,
76+
options?: __HttpHandlerOptions
77+
): Handler<CreateSegmentCommandInput, CreateSegmentCommandOutput> {
78+
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
79+
80+
const stack = clientStack.concat(this.middlewareStack);
81+
82+
const { logger } = configuration;
83+
const clientName = "EvidentlyClient";
84+
const commandName = "CreateSegmentCommand";
85+
const handlerExecutionContext: HandlerExecutionContext = {
86+
logger,
87+
clientName,
88+
commandName,
89+
inputFilterSensitiveLog: CreateSegmentRequest.filterSensitiveLog,
90+
outputFilterSensitiveLog: CreateSegmentResponse.filterSensitiveLog,
91+
};
92+
const { requestHandler } = configuration;
93+
return stack.resolve(
94+
(request: FinalizeHandlerArguments<any>) =>
95+
requestHandler.handle(request.request as __HttpRequest, options || {}),
96+
handlerExecutionContext
97+
);
98+
}
99+
100+
private serialize(input: CreateSegmentCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
101+
return serializeAws_restJson1CreateSegmentCommand(input, context);
102+
}
103+
104+
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<CreateSegmentCommandOutput> {
105+
return deserializeAws_restJson1CreateSegmentCommand(output, context);
106+
}
107+
108+
// Start section: command_body_extra
109+
// End section: command_body_extra
110+
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// smithy-typescript generated code
2+
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
3+
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
4+
import { Command as $Command } from "@aws-sdk/smithy-client";
5+
import {
6+
FinalizeHandlerArguments,
7+
Handler,
8+
HandlerExecutionContext,
9+
HttpHandlerOptions as __HttpHandlerOptions,
10+
MetadataBearer as __MetadataBearer,
11+
MiddlewareStack,
12+
SerdeContext as __SerdeContext,
13+
} from "@aws-sdk/types";
14+
15+
import { EvidentlyClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../EvidentlyClient";
16+
import { DeleteSegmentRequest, DeleteSegmentResponse } from "../models/models_0";
17+
import {
18+
deserializeAws_restJson1DeleteSegmentCommand,
19+
serializeAws_restJson1DeleteSegmentCommand,
20+
} from "../protocols/Aws_restJson1";
21+
22+
export interface DeleteSegmentCommandInput extends DeleteSegmentRequest {}
23+
export interface DeleteSegmentCommandOutput extends DeleteSegmentResponse, __MetadataBearer {}
24+
25+
/**
26+
* <p>Deletes a segment. You can't delete a segment that is being used in a launch or experiment, even if that
27+
* launch or experiment is not currently running.</p>
28+
* @example
29+
* Use a bare-bones client and the command you need to make an API call.
30+
* ```javascript
31+
* import { EvidentlyClient, DeleteSegmentCommand } from "@aws-sdk/client-evidently"; // ES Modules import
32+
* // const { EvidentlyClient, DeleteSegmentCommand } = require("@aws-sdk/client-evidently"); // CommonJS import
33+
* const client = new EvidentlyClient(config);
34+
* const command = new DeleteSegmentCommand(input);
35+
* const response = await client.send(command);
36+
* ```
37+
*
38+
* @see {@link DeleteSegmentCommandInput} for command's `input` shape.
39+
* @see {@link DeleteSegmentCommandOutput} for command's `response` shape.
40+
* @see {@link EvidentlyClientResolvedConfig | config} for EvidentlyClient's `config` shape.
41+
*
42+
*/
43+
export class DeleteSegmentCommand extends $Command<
44+
DeleteSegmentCommandInput,
45+
DeleteSegmentCommandOutput,
46+
EvidentlyClientResolvedConfig
47+
> {
48+
// Start section: command_properties
49+
// End section: command_properties
50+
51+
constructor(readonly input: DeleteSegmentCommandInput) {
52+
// Start section: command_constructor
53+
super();
54+
// End section: command_constructor
55+
}
56+
57+
/**
58+
* @internal
59+
*/
60+
resolveMiddleware(
61+
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
62+
configuration: EvidentlyClientResolvedConfig,
63+
options?: __HttpHandlerOptions
64+
): Handler<DeleteSegmentCommandInput, DeleteSegmentCommandOutput> {
65+
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
66+
67+
const stack = clientStack.concat(this.middlewareStack);
68+
69+
const { logger } = configuration;
70+
const clientName = "EvidentlyClient";
71+
const commandName = "DeleteSegmentCommand";
72+
const handlerExecutionContext: HandlerExecutionContext = {
73+
logger,
74+
clientName,
75+
commandName,
76+
inputFilterSensitiveLog: DeleteSegmentRequest.filterSensitiveLog,
77+
outputFilterSensitiveLog: DeleteSegmentResponse.filterSensitiveLog,
78+
};
79+
const { requestHandler } = configuration;
80+
return stack.resolve(
81+
(request: FinalizeHandlerArguments<any>) =>
82+
requestHandler.handle(request.request as __HttpRequest, options || {}),
83+
handlerExecutionContext
84+
);
85+
}
86+
87+
private serialize(input: DeleteSegmentCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
88+
return serializeAws_restJson1DeleteSegmentCommand(input, context);
89+
}
90+
91+
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<DeleteSegmentCommandOutput> {
92+
return deserializeAws_restJson1DeleteSegmentCommand(output, context);
93+
}
94+
95+
// Start section: command_body_extra
96+
// End section: command_body_extra
97+
}

clients/client-evidently/src/commands/EvaluateFeatureCommand.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,24 @@ export interface EvaluateFeatureCommandOutput extends EvaluateFeatureResponse, _
2929
* <p>The first rules that are evaluated are the override rules. If the user's
3030
* <code>entityID</code> matches an override rule, the user is served the variation specified
3131
* by that rule.</p>
32-
* <p>Next, if there is a launch of the feature, the user might be assigned to a variation in
32+
*
33+
* <p>If there is a current launch with this feature that uses segment overrides, and
34+
* if the user session's <code>evaluationContext</code> matches a segment rule defined in a
35+
* segment override, the configuration in the segment overrides is used. For more information
36+
* about segments, see <a href="https://docs.aws.amazon.com/cloudwatchevidently/latest/APIReference/API_CreateSegment.html">CreateSegment</a>
37+
* and
38+
* <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Evidently-segments.html">Use segments to focus your
39+
* audience</a>.</p>
40+
* <p>If there is a launch with no segment overrides, the user might be assigned to a variation in
3341
* the launch. The chance of this depends on the percentage of users that are allocated to that
3442
* launch. If the user is enrolled in the launch, the variation they are served depends on the
3543
* allocation of the various feature variations used for the launch.</p>
36-
* <p>If the user is not assigned to a launch, and there is an ongoing experiment for this feature, the user might
44+
* <p>If the user is not assigned to a launch, and there is an ongoing experiment for this feature, the user might
3745
* be assigned to a variation in the experiment. The chance of this
38-
* depends on the percentage of users that are allocated to that experiment. If the user is enrolled in the experiment,
46+
* depends on the percentage of users that are allocated to that experiment.</p>
47+
* <p>If the experiment uses a segment, then only
48+
* user sessions with <code>evaluationContext</code> values that match the segment rule are used in the experiment.</p>
49+
* <p>If the user is enrolled in the experiment,
3950
* the variation they are served depends on the allocation of the various feature variations used for the experiment. </p>
4051
* <p>If the user is not assigned to a launch or experiment, they are served the default variation.</p>
4152
* @example

0 commit comments

Comments
 (0)