CountlyBulk module providing object to manage the internal queue and send bulk requests to Countly server.
- Description:
- CountlyBulk module providing object to manage the internal queue and send bulk requests to Countly server.
- Source:
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
(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
(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
|
Returns:
instance
(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
(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
(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
|
Returns:
instance
(static) _getBulkEventQueue() → {Object}
- Description:
- getBulkEventQueue is a testing purposed method which returns the event queue object
- Source:
Returns:
eventQueue
- Type
- Object
(static) _getBulkRequestQueue() → {Object}
- Description:
- getBulkRequestQueue is a testing purposed method which returns the request queue object
- Source:
Returns:
requestQueue
- Type
- Object
(static) _getBulkQueue() → {Object}
- Description:
- getBulkQueue is a testing purposed method which returns the bulk queue object
- Source:
Returns:
bulkQueue
- Type
- Object