clevertap-node
![CI Status](http://img.shields.io/travis/CleverTap/clevertap-node.svg?style=flat)
Fully async Node.js server module for accessing the CleverTap Server API
Install
npm install clevertap
Usage
const CleverTap = require('clevertap');
const clevertap = CleverTap.init(YOUR_CLEVERTAP_ACCOUNT_ID, YOUR_CLEVERTAP_ACCOUNT_PASSCODE);
clevertap.upload(data, {"debug":1, batchSize:50}, (res) => {console.log(res)});
clevertap.upload(data, {"debug":1, batchSize:50}).then( (res) => {console.log(res)} );
var query = {"event_name":"choseNewFavoriteFood",
"props":
[{"name":"value","operator":"contains", "value":"piz"}],
"from": 20150810,
"to": 20151025
};
clevertap.events(query, {debug:1, batchSize:500}, (res) => {console.log(res)});
clevertap.events(query, {debug:1, batchSize:500}).then( (res) => {console.log(res)} );
var query = {"event_name":"choseNewFavoriteFood",
"props":
[{"name":"value","operator":"contains", "value":"piz"}],
"from": 20150810,
"to": 20151025
}
clevertap.profiles(query, {debug:1, batchSize:200}, (res) => {console.log(res)});
clevertap.profiles(query, {debug:1, batchSize:200}).then( (res) => {console.log(res)} );
var createPayload = {
"name": "green freedom",
"when": "now",
"where": {
"event_name": "App Launched",
"from": 20160101,
"to": 20160317,
},
"content":{
"title":"Hello!",
"body":"Strictly Green Lantern fans only!",
"platform_specific": {
"ios": {
"deep_link": "judepereira.com",
"sound_file": "judepereira.wav",
"category": "reactive",
"badge_count": 1,
"foo": "bar_ios"
},
"android": {
"background_image": "http://judepereira.com/a.jpg",
"default_sound": true,
"deep_link": "judepereira.com",
"foo": "bar_android"
}
}
},
"devices": [
"ios"
],
}
clevertap.targets(clevertap.TARGET_CREATE, createPayload, {"debug":1}, (res) => {console.log(res)} );
clevertap.targets(clevertap.TARGET_CREATE, createPayload, {"debug":1}).then( (res) => {console.log(res)} );
See example.js for more detailed usage.
Also please see our Server API documentation.
Tests
npm install
npm test // all tests
npm run testpush // just push specific tests