Skip to content

Commit

Permalink
feat(client-evidently): This release adds support for the new segment…
Browse files Browse the repository at this point in the history
…ation feature.
  • Loading branch information
awstools committed Jul 15, 2022
1 parent 2b37799 commit a60dfd8
Show file tree
Hide file tree
Showing 18 changed files with 2,862 additions and 72 deletions.
3 changes: 2 additions & 1 deletion clients/client-evidently/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

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

<p>You can use Amazon CloudWatch Evidently to safely validate new features by serving them to a specified percentage
<p>You can use Amazon CloudWatch Evidently to safely validate new features by serving
them to a specified percentage
of your users while you roll out the feature. You can monitor the performance of the new feature
to help you decide when to ramp up traffic to your users. This helps you
reduce risk and identify unintended consequences before you fully launch the feature.</p>
Expand Down
248 changes: 244 additions & 4 deletions clients/client-evidently/src/Evidently.ts

Large diffs are not rendered by default.

24 changes: 23 additions & 1 deletion clients/client-evidently/src/EvidentlyClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ import { CreateExperimentCommandInput, CreateExperimentCommandOutput } from "./c
import { CreateFeatureCommandInput, CreateFeatureCommandOutput } from "./commands/CreateFeatureCommand";
import { CreateLaunchCommandInput, CreateLaunchCommandOutput } from "./commands/CreateLaunchCommand";
import { CreateProjectCommandInput, CreateProjectCommandOutput } from "./commands/CreateProjectCommand";
import { CreateSegmentCommandInput, CreateSegmentCommandOutput } from "./commands/CreateSegmentCommand";
import { DeleteExperimentCommandInput, DeleteExperimentCommandOutput } from "./commands/DeleteExperimentCommand";
import { DeleteFeatureCommandInput, DeleteFeatureCommandOutput } from "./commands/DeleteFeatureCommand";
import { DeleteLaunchCommandInput, DeleteLaunchCommandOutput } from "./commands/DeleteLaunchCommand";
import { DeleteProjectCommandInput, DeleteProjectCommandOutput } from "./commands/DeleteProjectCommand";
import { DeleteSegmentCommandInput, DeleteSegmentCommandOutput } from "./commands/DeleteSegmentCommand";
import { EvaluateFeatureCommandInput, EvaluateFeatureCommandOutput } from "./commands/EvaluateFeatureCommand";
import { GetExperimentCommandInput, GetExperimentCommandOutput } from "./commands/GetExperimentCommand";
import {
Expand All @@ -74,10 +76,16 @@ import {
import { GetFeatureCommandInput, GetFeatureCommandOutput } from "./commands/GetFeatureCommand";
import { GetLaunchCommandInput, GetLaunchCommandOutput } from "./commands/GetLaunchCommand";
import { GetProjectCommandInput, GetProjectCommandOutput } from "./commands/GetProjectCommand";
import { GetSegmentCommandInput, GetSegmentCommandOutput } from "./commands/GetSegmentCommand";
import { ListExperimentsCommandInput, ListExperimentsCommandOutput } from "./commands/ListExperimentsCommand";
import { ListFeaturesCommandInput, ListFeaturesCommandOutput } from "./commands/ListFeaturesCommand";
import { ListLaunchesCommandInput, ListLaunchesCommandOutput } from "./commands/ListLaunchesCommand";
import { ListProjectsCommandInput, ListProjectsCommandOutput } from "./commands/ListProjectsCommand";
import {
ListSegmentReferencesCommandInput,
ListSegmentReferencesCommandOutput,
} from "./commands/ListSegmentReferencesCommand";
import { ListSegmentsCommandInput, ListSegmentsCommandOutput } from "./commands/ListSegmentsCommand";
import {
ListTagsForResourceCommandInput,
ListTagsForResourceCommandOutput,
Expand All @@ -88,6 +96,7 @@ import { StartLaunchCommandInput, StartLaunchCommandOutput } from "./commands/St
import { StopExperimentCommandInput, StopExperimentCommandOutput } from "./commands/StopExperimentCommand";
import { StopLaunchCommandInput, StopLaunchCommandOutput } from "./commands/StopLaunchCommand";
import { TagResourceCommandInput, TagResourceCommandOutput } from "./commands/TagResourceCommand";
import { TestSegmentPatternCommandInput, TestSegmentPatternCommandOutput } from "./commands/TestSegmentPatternCommand";
import { UntagResourceCommandInput, UntagResourceCommandOutput } from "./commands/UntagResourceCommand";
import { UpdateExperimentCommandInput, UpdateExperimentCommandOutput } from "./commands/UpdateExperimentCommand";
import { UpdateFeatureCommandInput, UpdateFeatureCommandOutput } from "./commands/UpdateFeatureCommand";
Expand All @@ -105,27 +114,33 @@ export type ServiceInputTypes =
| CreateFeatureCommandInput
| CreateLaunchCommandInput
| CreateProjectCommandInput
| CreateSegmentCommandInput
| DeleteExperimentCommandInput
| DeleteFeatureCommandInput
| DeleteLaunchCommandInput
| DeleteProjectCommandInput
| DeleteSegmentCommandInput
| EvaluateFeatureCommandInput
| GetExperimentCommandInput
| GetExperimentResultsCommandInput
| GetFeatureCommandInput
| GetLaunchCommandInput
| GetProjectCommandInput
| GetSegmentCommandInput
| ListExperimentsCommandInput
| ListFeaturesCommandInput
| ListLaunchesCommandInput
| ListProjectsCommandInput
| ListSegmentReferencesCommandInput
| ListSegmentsCommandInput
| ListTagsForResourceCommandInput
| PutProjectEventsCommandInput
| StartExperimentCommandInput
| StartLaunchCommandInput
| StopExperimentCommandInput
| StopLaunchCommandInput
| TagResourceCommandInput
| TestSegmentPatternCommandInput
| UntagResourceCommandInput
| UpdateExperimentCommandInput
| UpdateFeatureCommandInput
Expand All @@ -139,27 +154,33 @@ export type ServiceOutputTypes =
| CreateFeatureCommandOutput
| CreateLaunchCommandOutput
| CreateProjectCommandOutput
| CreateSegmentCommandOutput
| DeleteExperimentCommandOutput
| DeleteFeatureCommandOutput
| DeleteLaunchCommandOutput
| DeleteProjectCommandOutput
| DeleteSegmentCommandOutput
| EvaluateFeatureCommandOutput
| GetExperimentCommandOutput
| GetExperimentResultsCommandOutput
| GetFeatureCommandOutput
| GetLaunchCommandOutput
| GetProjectCommandOutput
| GetSegmentCommandOutput
| ListExperimentsCommandOutput
| ListFeaturesCommandOutput
| ListLaunchesCommandOutput
| ListProjectsCommandOutput
| ListSegmentReferencesCommandOutput
| ListSegmentsCommandOutput
| ListTagsForResourceCommandOutput
| PutProjectEventsCommandOutput
| StartExperimentCommandOutput
| StartLaunchCommandOutput
| StopExperimentCommandOutput
| StopLaunchCommandOutput
| TagResourceCommandOutput
| TestSegmentPatternCommandOutput
| UntagResourceCommandOutput
| UpdateExperimentCommandOutput
| UpdateFeatureCommandOutput
Expand Down Expand Up @@ -321,7 +342,8 @@ type EvidentlyClientResolvedConfigType = __SmithyResolvedConfiguration<__HttpHan
export interface EvidentlyClientResolvedConfig extends EvidentlyClientResolvedConfigType {}

/**
* <p>You can use Amazon CloudWatch Evidently to safely validate new features by serving them to a specified percentage
* <p>You can use Amazon CloudWatch Evidently to safely validate new features by serving
* them to a specified percentage
* of your users while you roll out the feature. You can monitor the performance of the new feature
* to help you decide when to ramp up traffic to your users. This helps you
* reduce risk and identify unintended consequences before you fully launch the feature.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export interface CreateExperimentCommandOutput extends CreateExperimentResponse,
* decisions based on evidence and data. An experiment can test as
* many as five variations at once. Evidently collects experiment data and analyzes it by statistical methods, and provides
* clear recommendations about which variations perform better.</p>
* <p>You can optionally specify a <code>segment</code> to have the experiment consider only certain audience
* types in the experiment, such as using only user sessions from a certain location or who use a certain internet browser.</p>
* <p>Don't use this operation to update an existing experiment. Instead, use
* <a href="https://docs.aws.amazon.com/cloudwatchevidently/latest/APIReference/API_UpdateExperiment.html">UpdateExperiment</a>. </p>
* @example
Expand Down
110 changes: 110 additions & 0 deletions clients/client-evidently/src/commands/CreateSegmentCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// smithy-typescript generated code
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
import { Command as $Command } from "@aws-sdk/smithy-client";
import {
FinalizeHandlerArguments,
Handler,
HandlerExecutionContext,
HttpHandlerOptions as __HttpHandlerOptions,
MetadataBearer as __MetadataBearer,
MiddlewareStack,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";

import { EvidentlyClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../EvidentlyClient";
import { CreateSegmentRequest, CreateSegmentResponse } from "../models/models_0";
import {
deserializeAws_restJson1CreateSegmentCommand,
serializeAws_restJson1CreateSegmentCommand,
} from "../protocols/Aws_restJson1";

export interface CreateSegmentCommandInput extends CreateSegmentRequest {}
export interface CreateSegmentCommandOutput extends CreateSegmentResponse, __MetadataBearer {}

/**
* <p>Use this operation to define a <i>segment</i> of your audience. A segment
* is a portion of your audience that share one or more characteristics. Examples could be Chrome browser users,
* users in Europe, or Firefox browser users in Europe who also fit other criteria that your application collects,
* such as age.</p>
* <p>Using a segment in an experiment limits that experiment to evaluate only the users who match the segment
* criteria. Using one or more segments in a launch allow you to define different traffic splits for the different
* audience segments.</p>
*
* <p>For more information about segment pattern syntax, see
* <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Evidently-segments-syntax.html">
* Segment rule pattern syntax</a>.</p>
*
* <p>The pattern that you define for a segment is matched against the value of <code>evaluationContext</code>, which
* is passed into Evidently in the <a href="https://docs.aws.amazon.com/cloudwatchevidently/latest/APIReference/API_EvaluateFeature.html">EvaluateFeature</a> operation,
* when Evidently assigns a feature variation to a user.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { EvidentlyClient, CreateSegmentCommand } from "@aws-sdk/client-evidently"; // ES Modules import
* // const { EvidentlyClient, CreateSegmentCommand } = require("@aws-sdk/client-evidently"); // CommonJS import
* const client = new EvidentlyClient(config);
* const command = new CreateSegmentCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link CreateSegmentCommandInput} for command's `input` shape.
* @see {@link CreateSegmentCommandOutput} for command's `response` shape.
* @see {@link EvidentlyClientResolvedConfig | config} for EvidentlyClient's `config` shape.
*
*/
export class CreateSegmentCommand extends $Command<
CreateSegmentCommandInput,
CreateSegmentCommandOutput,
EvidentlyClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties

constructor(readonly input: CreateSegmentCommandInput) {
// Start section: command_constructor
super();
// End section: command_constructor
}

/**
* @internal
*/
resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: EvidentlyClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<CreateSegmentCommandInput, CreateSegmentCommandOutput> {
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));

const stack = clientStack.concat(this.middlewareStack);

const { logger } = configuration;
const clientName = "EvidentlyClient";
const commandName = "CreateSegmentCommand";
const handlerExecutionContext: HandlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog: CreateSegmentRequest.filterSensitiveLog,
outputFilterSensitiveLog: CreateSegmentResponse.filterSensitiveLog,
};
const { requestHandler } = configuration;
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as __HttpRequest, options || {}),
handlerExecutionContext
);
}

private serialize(input: CreateSegmentCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
return serializeAws_restJson1CreateSegmentCommand(input, context);
}

private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<CreateSegmentCommandOutput> {
return deserializeAws_restJson1CreateSegmentCommand(output, context);
}

// Start section: command_body_extra
// End section: command_body_extra
}
97 changes: 97 additions & 0 deletions clients/client-evidently/src/commands/DeleteSegmentCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// smithy-typescript generated code
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
import { Command as $Command } from "@aws-sdk/smithy-client";
import {
FinalizeHandlerArguments,
Handler,
HandlerExecutionContext,
HttpHandlerOptions as __HttpHandlerOptions,
MetadataBearer as __MetadataBearer,
MiddlewareStack,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";

import { EvidentlyClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../EvidentlyClient";
import { DeleteSegmentRequest, DeleteSegmentResponse } from "../models/models_0";
import {
deserializeAws_restJson1DeleteSegmentCommand,
serializeAws_restJson1DeleteSegmentCommand,
} from "../protocols/Aws_restJson1";

export interface DeleteSegmentCommandInput extends DeleteSegmentRequest {}
export interface DeleteSegmentCommandOutput extends DeleteSegmentResponse, __MetadataBearer {}

/**
* <p>Deletes a segment. You can't delete a segment that is being used in a launch or experiment, even if that
* launch or experiment is not currently running.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { EvidentlyClient, DeleteSegmentCommand } from "@aws-sdk/client-evidently"; // ES Modules import
* // const { EvidentlyClient, DeleteSegmentCommand } = require("@aws-sdk/client-evidently"); // CommonJS import
* const client = new EvidentlyClient(config);
* const command = new DeleteSegmentCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link DeleteSegmentCommandInput} for command's `input` shape.
* @see {@link DeleteSegmentCommandOutput} for command's `response` shape.
* @see {@link EvidentlyClientResolvedConfig | config} for EvidentlyClient's `config` shape.
*
*/
export class DeleteSegmentCommand extends $Command<
DeleteSegmentCommandInput,
DeleteSegmentCommandOutput,
EvidentlyClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties

constructor(readonly input: DeleteSegmentCommandInput) {
// Start section: command_constructor
super();
// End section: command_constructor
}

/**
* @internal
*/
resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: EvidentlyClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<DeleteSegmentCommandInput, DeleteSegmentCommandOutput> {
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));

const stack = clientStack.concat(this.middlewareStack);

const { logger } = configuration;
const clientName = "EvidentlyClient";
const commandName = "DeleteSegmentCommand";
const handlerExecutionContext: HandlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog: DeleteSegmentRequest.filterSensitiveLog,
outputFilterSensitiveLog: DeleteSegmentResponse.filterSensitiveLog,
};
const { requestHandler } = configuration;
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as __HttpRequest, options || {}),
handlerExecutionContext
);
}

private serialize(input: DeleteSegmentCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
return serializeAws_restJson1DeleteSegmentCommand(input, context);
}

private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<DeleteSegmentCommandOutput> {
return deserializeAws_restJson1DeleteSegmentCommand(output, context);
}

// Start section: command_body_extra
// End section: command_body_extra
}
17 changes: 14 additions & 3 deletions clients/client-evidently/src/commands/EvaluateFeatureCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,24 @@ export interface EvaluateFeatureCommandOutput extends EvaluateFeatureResponse, _
* <p>The first rules that are evaluated are the override rules. If the user's
* <code>entityID</code> matches an override rule, the user is served the variation specified
* by that rule.</p>
* <p>Next, if there is a launch of the feature, the user might be assigned to a variation in
*
* <p>If there is a current launch with this feature that uses segment overrides, and
* if the user session's <code>evaluationContext</code> matches a segment rule defined in a
* segment override, the configuration in the segment overrides is used. For more information
* about segments, see <a href="https://docs.aws.amazon.com/cloudwatchevidently/latest/APIReference/API_CreateSegment.html">CreateSegment</a>
* and
* <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Evidently-segments.html">Use segments to focus your
* audience</a>.</p>
* <p>If there is a launch with no segment overrides, the user might be assigned to a variation in
* the launch. The chance of this depends on the percentage of users that are allocated to that
* launch. If the user is enrolled in the launch, the variation they are served depends on the
* allocation of the various feature variations used for the launch.</p>
* <p>If the user is not assigned to a launch, and there is an ongoing experiment for this feature, the user might
* <p>If the user is not assigned to a launch, and there is an ongoing experiment for this feature, the user might
* be assigned to a variation in the experiment. The chance of this
* depends on the percentage of users that are allocated to that experiment. If the user is enrolled in the experiment,
* depends on the percentage of users that are allocated to that experiment.</p>
* <p>If the experiment uses a segment, then only
* user sessions with <code>evaluationContext</code> values that match the segment rule are used in the experiment.</p>
* <p>If the user is enrolled in the experiment,
* the variation they are served depends on the allocation of the various feature variations used for the experiment. </p>
* <p>If the user is not assigned to a launch or experiment, they are served the default variation.</p>
* @example
Expand Down
Loading

0 comments on commit a60dfd8

Please sign in to comment.