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") {
} else if (variation === "B") {
}
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);