Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aws-evidently-l2

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aws-evidently-l2

This is a fork of https://github.com/aws/aws-cdk-rfcs/issues/428 implemention (https://github.com/ljuti/aws-cdk/tree/construct/aws-evidently/packages/%40aws-cdk/aws-evidently)

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
108
decreased by-15.62%
Maintainers
1
Weekly downloads
 
Created
Source

Evidently L2

This is a fork of https://github.com/aws/aws-cdk-rfcs/issues/428 implemention (https://github.com/ljuti/aws-cdk/tree/construct/aws-evidently/packages/%40aws-cdk/aws-evidently)

Core Constructs

Project

A Project is an AWS Evidently project where you group and track features, launches and experiments.

Feature

A Feature is an AWS Evidently feature, a set of behaviour in your application that you wish to launch or test.

Launch

A Launch is an AWS Evidently launch which you use to schedule or incrementally release a feature.

Experiment

An Experiment is an AWS Evidently experiment that helps you make feature design decisions based on evidence and data.

API Walkthrough with a Use Case Example

In an AWS News Blog article, author @sebsto demonstrates how to use AWS Evidently with a web application example.

Let's see how we would use the construct library to replace AWS Console tasks of the example.

  1. Create a Project
    import * as evidently from 'aws-cdk-lib/aws_evidently';
    
    const project = new evidently.Project(this, 'GuestbookWebApp', {
    projectName: 'AWSNewsBlog',
    description: 'AWSNewsBlogDemo',
    });
    
  2. Add a Feature
    const editable = new evidently.Variation({
    variationName: 'editable',
    valueType: VariationObjectValueType.BOOLEAN,
    value: true,
    });
        
    const readonly = new evidently.Variation({
    variationName: 'readonly',
    valueType: VariationObjectValueType.BOOLEAN,
    value: false,
    });
    
    const feature = new evidently.Feature(this, 'EditableGuestbook', {
    project: project,
    featureName: 'Editing',
    variations: [
        editable,
        readonly,
    ],
    entityOverrides: [
        new EntityOverride({
        entityId: 'seb',
        variation: editable,
        });
    ],
    });
    
  3. Create a Launch
    const editableGroup = new evidently.LaunchGroup({
    groupName: 'Editable',
    feature: feature,
    variation: editable,
    });
    const readonlyGroup = new evidently.LaunchGroup({
    groupName: 'Readonly',
    feature: feature,
    variation: readonly,
    });
    
    const launchConfiguration = new StepConfig({
    groupsToWeight: [
        {
        group: editableGroup,
        splitWeight: SplitWeight.50_PCT,
        }
    ],
    startTime: <timestamp>,
    });
    
    const launch = new evidently.Launch(this, 'EditableGuestbook', {
    launchName: 'EditableGuestbook',
    description: 'Launch the editable guest book feature',
    groups: [
        editableGroup,
        readonlyGroup,
    ],
    scheduledSplitsConfig: [launchConfiguration],
    });
    
  4. Start an Experiment
    const goal = new evidently.MetricGoal({
    desiredChange: MetricGoalDesiredChange.INCREASE,
    entityIdKey: 'user',
    eventPattern: 'eventbridge-pattern',
    metricName: 'Edits',
    valueKey: 'edits',
    });
    
    const treatmentOne = new evidently.Treatment({
    feature: feature,
    treatmentName: 'editing',
    variation: editable,
    });
    
    const treatmentTwo = new evidently.Treatment({
    feature: feature,
    treatmentName: 'readonly',
    variation: readonly,
    });
    
    const config = new evidently.OnlineAbConfig({
    controlTreatmentName: treatmentOne.treatmentName,
    treatmentWeights: [
        new evidently.TreatmentToWeight({
        splitWeight: 20000,
        treatment: treatmentOne,
        }),
        new evidently.TreatmentToWeight({
        splitWeight: 80000,
        treatment: treatmentTwo,
        }),
    ],
    });
    
    const experiment = new evidently.Experiment({
    project: project,
    experimentName: 'EditableGuestBook',
    metricGoals: [goal],
    onlineAbConfig: config,
    treatments: [
        treatmentOne,
        treatmentTwo,
    ],
    });
    

More

  • If using feature flags in a web app, I strongly recommend looking at @sebsto example to deal with unauthenticated role and cognito ;)
  • DOn't forget to grant permissions to your role used to be able to leverage aws-sdk V3 and BatchEvaluateFeatureCommand and EvaluateFeatureCommand to get the feature flags values. For instance in your cdk code :
    this.unauthenticatedRole.attachInlinePolicy(
    		new Policy(this, "EvidentlyPolicy", {
    			statements: [
    				new PolicyStatement({
    					actions: [
    						"evidently:EvaluateFeature",
    						"evidently:BatchEvaluateFeature",
    					],
    					resources: [
    						`arn:aws:evidently:${Stack.of(this).region}:${Stack.of(this).account}:project/${this.featureFlagStore.project.projectName}/feature/*`,
    					],
    					effect: Effect.ALLOW,
    				}),
    			],
    		})
    	);
        ```
    

Credits

@ljuti

Keywords

FAQs

Package last updated on 11 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc