ablabs-js
v1.0.9
Published
JS/NPM Client Library for ABLabs projects
Downloads
4
Readme
ABLabs JS
Demo Usage
Browser: https://ablabs.io/demo-browser.html
Node: https://ablabs.io/demo-node.html
The Node and browser API is the same, though they require different libraries.
Browser Usage
First include the ABLabsJS browser library in the browser head:
<script src="https://cdn.rawgit.com/mj1618/ablabs-js/v1.0.7/build/ablabs.min.js"></script>
You can use it directly in JS:
var ab = new ABLabs.default( '{your_key}' );
Node Usage
If you would like to run ABLabs inside a node server project follow these steps.
- Install
npm install --save ablabs-js
- Import
import ABLabs from 'ablabs-js'
- Use
const ab = new ABLabs('{your_key}');
let variation;
ab.assign( 'Blue/Green Button Experiment' ).then(res=>{
variation = res.variation;
});
...
ab.track( 'Clicked Button' );
Node testing for browser project
You may want to write some code for the browser, but test it in node.
To achieve this:
- Install in node (see above)
- Write your browser code as normal
- At the start of your testing code, declare ABLabs as global:
global.ABLabs = require('ablabs-js');