Write data to Initial State using NodeJS
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test Accept config object for name or access key when creating a bucket; Sep 15, 2015
.editorconfig initial state …of code; Sep 1, 2015
.eslintrc Update readme to reflect new bucket key character restrictions; Nov 29, 2018
.gitattributes
.gitignore initial state …of code; Sep 1, 2015
.nvmrc initial state …of code; Sep 1, 2015
.travis.yml Rename .travis.yaml to .travis.yml; Sep 3, 2015
CHANGELOG.md initial state …of code; Sep 1, 2015
LICENSE Update copyright year; Jan 29, 2016
README.md Provide a more interesting example in readme; Nov 29, 2018
bucket.js Accept config object for name or access key when creating a bucket; Sep 15, 2015
epoch-clock.js Further abstract timestamp handling; Sep 3, 2015
gulpfile.js Further abstract timestamp handling; Sep 3, 2015
https-request.js
index.js initial state …of code; Sep 1, 2015
node-initial-state.sublime-project initial state …of code; Sep 1, 2015
package.json 0.2.0 Sep 15, 2015

README.md

Initial State

The Initial State SDK for NodeJS.

Build Status

Installation

npm install initial-state

Example Use

var IS = require('initial-state');
var bucket = IS.bucket('BUCKET_KEY', 'YOUR_ACCESS_KEY_GOES_HERE');

// Push a count every second
var count = 0;
setTimeout(function pushNextCount() {

	// Push another event
	bucket.push('Count', ++count);

	if (count < 10) {
		// Keep counting until we reach 10
		setTimeout(pushNextCount, 1000);
	}

}, 1000);

API

IS.bucket(id, accessKey)

Create an event data bucket.

  • id – A bucket key. This key should contain only alphanumeric and underscore characters. If the bucket does not yet exist, this value will be used as the bucket name.
  • accessKey – An Initial State account access key. This argument is not needed if the access key is assigned to the environmental variable IS_API_ACCESS_KEY.

To declare a different bucket key and name, use the object override parameter:

var bucket = IS.bucket({
	name: 'My Bucket',
	id: 'BUCKET_KEY',
	accessKey: 'YOUR_ACCESS_KEY_GOES_HERE'
});

bucket.push(key, value[, date])

Send event data to Initial State.

  • key – The event key.
  • value – The event value.
  • date – The time of the event. A Date object or numeric timestamp (milliseconds since epoch). High-precision timestamps (i.e., sub-ms) can be declared as a string (e.g., '1420070400.000000001'), but must be in unix time (seconds since epoch). If not defined, a high-precision timestamp will be generated.