Giter Club home page Giter Club logo

akamai-edgeworker-starter-kit's Introduction

Optimizely Akamai Edgeworkers Starter Kit

This repository houses the Akamai Edgeworkers Starter Kit which provides a quickstart for users who would like to use Optimizely Feature Experimentation and Optimizely Full Stack (legacy) with Akamai Edgeworkers.

Optimizely Feature Experimentation is an A/B testing and feature management tool for product development teams that enables you to experiment at every step. Using Optimizely Feature Experimentation allows for every feature on your roadmap to be an opportunity to discover hidden insights. Learn more at Optimizely.com, or see the developer documentation.

Optimizely Rollouts is free feature flags for development teams. You can easily roll out and roll back features in any application without code deploys, mitigating risk for every feature on your roadmap.

Get Started

Refer to the Optimizely Akamai EdgeWorkers Starter Kit documentation for detailed instructions about using this starter kit.

Prerequisites

  1. You will need an Optimizely Account. If you do not have an account, you can register for a free account.

  2. You will need to have an Akamai Account with EdgeWorkers Access. For more information, visit the official Akamai Edgworkers product page here.

Requirements

You must first have an Akamai EdgeWorker set up. To do so, you may take the following steps:

  1. Create an EdgeWorker ID.

  2. Add the EdgeWorker Behavior.

  3. Install the Akamai CLI.

  4. Install the EdgeWorkers CLI.

    akamai install edgeworkers
    
  5. Setup Authentication credentials.

Install the Starter Kit

After you succesfully have an Akamai EdgeWorker set up, you can clone this starter kit, edit it, build it, and upload the build to your EdgeWorker.

  1. Create a new folder and pull the code from this Starter kit.

    curl -L https://github.com/optimizely/akamai-edgeworker-starter-kit/tarball/main | tar --strip-components=1 -zx
    

    or

    wget --no-check-certificate https://github.com/optimizely/akamai-edgeworker-starter-kit/tarball/main -O - | tar --strip-components=1 -zx
    
  2. Install node modules.

    npm install
    
  3. Add your Optimizely SDK key and flag in src/main.js. Your SDK keys can be found in the Optimizely application under Settings.

  4. Build the bundle.

    npm run build
    
  5. Upload the bundle

    akamai edgeworkers upload --bundle="dist/bundle.tgz" {WORKER_ID}
    
  6. Activate the version

    akamai edgeworkers activate {WORKER_ID} {ENVIRONMENT} {EDGEWORKER_VERSION}
    

    WORKER_ID: Unique ID for your EdgeWorker. This can be obtained from the Akamai control center.
    ENVIRONMENT: The environment the EdgeWorker is being deployed on.
    EDGEWORKER_VERSION: The custom version of the EdgeWorker as mentioned in bundle.json. This should be updated on every new deployment.

  7. Enable Advanced debug headers to receive debug logs in the response headers.

Use the Akamai EdgeWorkers Starter Kit

The Optimizely starter kit for Akamai's EdgeWorkers embeds and extends our Javascript (Node) SDK. For a guide to getting started with our platform more generally, you can reference our Javascript (Node) Quickstart developer documentation.

Note: This starter kit in particular makes use of the "Lite" version of our Javascript SDK for Node.js which explicitly excludes the datafile manager and event processor features for better performance. As a result, it is expected that you will provide the datafile manually to the Optimizely SDK either through a local file reference or by using the provided platform-specific getDatafile() helper to load in your Optimizely project's datafile.

Initialization

Sample code is included in src/main.js that shows examples of initializing and using the Optimizely JavaScript (Node) SDK interface for performing common functions such as creating user context, adding a notification listener, and making a decision based on the created user context.

Additional platform-specific code is included in src/optimizely_helper.js which provide workarounds for otherwise common features of the Optimizely SDK.

Additional Resources and Concepts

Identity Management

Out of the box, Optimizely's Feature Experimentation SDKs require a user-provided identifier to be passed in at runtime to drive experiment and feature flag decisions. This example generates a unique ID, stores it in a cookie and reuses it to make the decisions sticky. Alternatively, you can use an existing unique identifier available within your application and pass it in as the value for the OPTIMIZELY_USER_ID cookie.

Bucketing

For more information on how Optimizely Feature Experimentation SDKs assign users to feature flags and experiments, see the documentation on how bucketing works.

Akamai EdgeWorkers

For more information about Akamai EdgeWorkers, you may visit the following resources:

SDK Development

Contributing

Please see CONTRIBUTING.

Other Optimizely SDKs

Other Optimizely Edge Starter Kits

akamai-edgeworker-starter-kit's People

Contributors

opti-jnguyen avatar trishahanlon avatar zashraf1985 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

akamai-edgeworker-starter-kit's Issues

Issue: `cpuTimeoutError` onClientResponse/onClientRequest

Thank you for providing this example! We've successfully deployed the code to an Akamai tier 200 Edgeworker and for the most part things are working great.

About 20% of the time we see a cpuTimeoutError though. We've added retrying using https://techdocs.akamai.com/edgeworkers/docs/site-failover#retry-the-request which works well for Get and other idempotent requests, but this won't work for requests that modify state. For example, if we're making a post request to add an item to the cart, if that fails, and then gets retried we may end up with an error or two items in the cart, etc.

I'm wondering if you have run into this issue and/or have any advice

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.