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

@optimizely/edge-delivery

Package Overview
Dependencies
Maintainers
0
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@optimizely/edge-delivery

Optimizely's Edge Delivery, a library for executing Web Experiments utilizing Cloudflare's HTMLRewriter technology.

  • 0.0.7
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Optimizely Edge Delivery SDK

Optimizely Edge Delivery lets you execute Optimizely Web experiments on Cloudflare Workers.


Prequisites

  • You must have a Cloudflare Account.
  • You must install the Wrangler CLI.

Implementing in an existing Worker

You can install the Optimizely Edge Delivery SDK in any existing Cloudflare Worker, whether you already route your incoming traffic through a Cloudflare Worker, or you'd prefer to start from scratch using Cloudflare's getting started guide.

Installing the Edge Delivery SDK

Install the Edge Delivery library using npm:

npm install @optimizely/edge-delivery

Implementing and executing experiments

The SDK requires a Snippet ID (snippetId) to know which configuration file to retrieve to execute your experiments.

Basic configuration options

It's recommended to set a Development URL (devUrl) for the SDK to use as a target when testing locally or at your worker site directly.

const options = {
    "snippetId": "29061560280",
    "devUrl": "https://example.com/"
};
applyExperiments

The applyExperiments method is used to execute experiments. This method uses the request information to make experiment bucketing decisions and apply active experiment variations to the control. Any decisions or changes that cannot be made on the edge are packaged together and added to the <head> element for execution on the browser.

import { applyExperiments } from '@optimizely/edge-delivery';
...
await applyExperiments(request, ctx, options);
Other configuration options

Optionally, you may pass a Response object as the control in the options parameter. This can be useful if you already have an existing Cloudflare Worker that, for example, makes modifications to the control outside of Optimizely experiments.

let control = await fetch(request);
...
const options = {
    // Other options
    "control": control
};

Keywords

FAQs

Package last updated on 04 Oct 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