JSPM

  • Created
  • Published
  • Downloads 4405
  • Score
    100M100P100Q124516F
  • License ISC

JavaScript SDK For Hackle

Package Exports

  • @hackler/javascript-sdk
  • @hackler/javascript-sdk/lib/index.browser.es.js
  • @hackler/javascript-sdk/lib/index.browser.min.js
  • @hackler/javascript-sdk/lib/index.node.min.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@hackler/javascript-sdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Hackle JavaScript SDK

Install

npm install @hackler/javascript-sdk --save
yarn add @hackler/javascript-sdk

Usage

Install & Decide the variation

const http = require("http");
const Hackle = require("@hackler/javascript-sdk");

const hackleClient = Hackle.createInstance("YOUR_SDK_KEY");

http.createServer((req, res) => {
    const user = {
      id: USER_ID
    }   
    const variation = hackleClient.variation(AB_TEST_KEY, user);
    
    if (variation === "A") {
      // AS-IS Code
    } else if (variation === "B") {
      // TO-BE Code
    }

    res.end(`Hello ${variation}!`)
}).listen(8080)

Records the event

hackleClient.track(EVENT_KEY, user);

or

const event = {
  key: EVENT_KEY,
  value: 5000,
  properties: {
    app_version: "1.0.0",
    first_paying: false,
    item_count: 5
  }
}
hackleClient.track(event, user);