lib/countly-bulk

Description:
  • CountlyBulk module providing object to manage the internal queue and send bulk requests to Countly server.
Source:
CountlyBulk module providing object to manage the internal queue and send bulk requests to Countly server.

Example

var CountlyBulk = require("countly-sdk-nodejs").Bulk;

var server = new CountlyBulk({
  app_key: "{YOUR-APP-KEY}",
  url: "https://API_HOST/",
  debug: true
});

//start processing queued requests or next ones that will be added
server.start()

//adding raw request
server.add_request({begin_session:1, metrics:{_os:"Linux"}, device_id:"users_device_id", events:[{key:"Test", count:1}]});

Methods

(static) add_request(query) → {module:lib/countly-bulk}

Description:
  • Add raw request with provided query string parameters
Source:
Example
var server = new CountlyBulk({
  app_key: "{YOUR-API-KEY}",
  url: "https://API_HOST/",
  debug: true
});
server.add_request({app_key:"somekey", devide_id:"someid", events:"[{'key':'val','count':1}]", begin_session:1});
Parameters:
Name Type Description
query Object object with key/values which will be used as query string parameters
Returns:
instance
Type
module:lib/countly-bulk

(static) add_bulk_request(requests) → {module:lib/countly-bulk}

Description:
  • Add multiple raw requests each with provided query string parameters
Source:
Example
var server = new CountlyBulk({
  app_key: "{YOUR-API-KEY}",
  url: "https://API_HOST/",
  debug: true
});
server.add_bulk_request([{app_key:"somekey", devide_id:"someid", begin_session:1}, {app_key:"somekey", devide_id:"someid", events:"[{'key':'val','count':1}]"}]);
Parameters:
Name Type Description
requests Array array with multiple request objects that can be provided with CountlyBulk.add_request
Returns:
instance
Type
module:lib/countly-bulk

(static) add_event(device_id, event) → {module:lib/countly-bulk}

Description:
  • Add raw event data for specific user (events are bulked by users)
Source:
Example
var server = new CountlyBulk({
  app_key: "{YOUR-API-KEY}",
  url: "https://API_HOST/",
  debug: true
});
server.add_event("my_device_id", {'key':'val','count':1});
Parameters:
Name Type Description
device_id String user or device identification
event Object event object
Properties
Name Type Attributes Default Description
key string name or id of the event
count number <optional>
1 how many times did event occur
sum number <optional>
sum to report with event (if any)
dur number <optional>
duration to report with event (if any)
segmentation Object <optional>
object with segments key /values
timestamp number <optional>
timestamp when event occurred
Returns:
instance
Type
module:lib/countly-bulk

(static) start(callback) → {module:lib/countly-bulk}

Description:
  • Start processing requests
Source:
Example
var server = new CountlyBulk({
  app_key: "{YOUR-API-KEY}",
  url: "https://API_HOST/",
  debug: true
});
server.start();
Parameters:
Name Type Description
callback function to call when queue is empty and you can stop server
Returns:
instance
Type
module:lib/countly-bulk

(static) stop() → {module:lib/countly-bulk}

Description:
  • Stop processing requests
Source:
Example
var server = new CountlyBulk({
  app_key: "{YOUR-API-KEY}",
  url: "https://API_HOST/",
  debug: true
});
server.stop();
Returns:
instance
Type
module:lib/countly-bulk

(static) queue_size() → {number}

Description:
  • Manually check queue size
Source:
Example
var server = new CountlyBulk({
  app_key: "{YOUR-API-KEY}",
  url: "https://API_HOST/",
  debug: true
});
server.add_request({device_id:"id", app_key:"key", begin_session:1});
server.queue_size(); //should return 1
Returns:
amount of items in queue
Type
number

(static) add_user(userConf) → {module:lib/countly-bulk-user}

Description:
  • Create specific user to easier send information about specific user
Source:
Example
var server = new CountlyBulk({
  app_key: "{YOUR-API-KEY}",
  url: "https://API_HOST/",
  debug: true
});
var user = server.add_user({device_id:"my_device_id"});
Parameters:
Name Type Description
userConf Object CountlyBulkUser configuration options
Properties
Name Type Attributes Description
device_id string identification of the user
country_code string <optional>
country code for your user
city string <optional>
name of the city of your user
ip_address string <optional>
ip address of your user
Returns:
instance
Type
module:lib/countly-bulk-user