Repository
target-cdn-experimentation-nodejs-sdk
Allows A/B testing on edge workers for WebSDK clients.
README
Target CDN Experimentation NodeJS SDK
Goals
This project aims to provide an SDK for Target CDN based experimentation on different CDN environments using AEP endpoints.
The project is structured as a monorepo with the following packages:
- sdk: The main SDK package that provides the core functionality.
- sdk-akamai: The Akamai Edge Worker package that provides the functionality to run the SDK on Akamai Edge Workers.
- sdk-nodejs: The NodeJS package that provides the functionality to run the SDK on NodeJS.
Features
- Focused on CDN experimentation
- Compatible with Adobe Experience Platform Web SDK API
- Uses Adobe Alloy endpoints
Non-Goals
- It doesn't provide a full-fledged experimentation library.
- The client is responsible to interpret and the decisions in their projects.
Installation
npm run install:all
Akamai SDK
All the libraries specific to the platform are registered through a singleton store Container and the TOKENS object.
In the Client we register Akamai specific libraries:
- logger that is used instead of the NodeJS
console.log - http-request that is used instead of the NodeJS Fetch API
- crypto that is used instead of the NodeJS Crypto API
/sdk-akamai/src/uuid/rng.js- we are usingcrypto.getRandomValues()instead of the missing NodeJSrandomFillSync()method/sdk-akamai/src/md5.js- we are using a custom library instead of the missing NodeJScreateHash()method
Pre-requisites
-
You must setup the Akamai authentication credentials in the
.edgercfile. You can find the instructions here. -
To use the Akamai SDK you need to have the Akamai CLI installed and configured. You can find the installation instructions here.
You must install the CLI edgeworker and sandbox packages. -
Depending on your project update the
sdk-akamai/demo/bundle.jsonwith the correct starting EdgeWorker version -
Update the
sdk-akamai/.envfile with the correct EDGEWORKER_ID
Usage
npm run format- Runs the linter on the project.npm run lint- Runs the linter on the project.npm run test- Runs the tests with the coverage enabled. We are using Jest with--experimental-vm-modulesto support native ECMA Modulesnpm run build- Builds in/dist/the Akamai Demo project and the Library; It will automatically increment thebundle.jsonversion and updateEDGEWORKER_VERSIONin the.envfilenpm run edgeworker:deploy- Deploys the Akamai build to the Akamai networknpm run edgeworker:activate- Activates the build on the Akamai staging networknpm run edgeworker:status- Checks the activation statusnpm run sandbox:build- Builds the project for the sandbox servernpm run sandbox:start- Starts the default sandbox servernpm run sandbox:deploy- Deploys the build to the sandbox server
NodeJS SDK
All the libraries specific to the platform are registered though a singleton store sdk/src/container.js and the TOKENS object.
In the Client we register NodeJS specific libraries:
- logger is using the NodeJS console.log
- http-client is using the NodeJS Fetch API
- crypto is using the NodeJS Crypto API
/sdk-nodejs/src/uuid/rng.js- we are usingrandomFillSync()method/sdk-nodejs/src/md5.js- we are usingcreateHash()method
Installation
Run npm run install:all at the root of the project to install all the dependencies.
Usage
npm run format- Runs the linter on the project.npm run lint- Runs the linter on the project.npm run test- Runs the tests with the coverage enabled. We are using Jest with--experimental-vm-modulesto support native ECMA Modulesnpm run build- Builds in/dist/the NodeJS Demo project and the Librarynpm run start- Starts the demo server
Contributing
Contributions are welcomed! Read the Contributing Guide for more information.
Licensing
This project is licensed under the Apache V2 License. See LICENSE for more information.