node package manager



CircleCI Codecov

Providing common fields for analytics integrations. Wraps the API for use on the server or client.



Proxies a field which is stored in the object.

track.proxy('traits') // { email : ' }
track.proxy('') // ''

As an added bonus, it will even pull out top level proxies that are attached to the facade

var track = new Track({ context : { setting : 'x' }});
track.proxy('options.setting'); // 'x'
var identify = new Identify({ traits : { address : { state : 'CA' }}});
// using the top level proxy
track.proxy('address.state'); // 'CA';
// through the traits

Since developers might be working in many languages, with different conventions for things like snake_case vs camelCase, .proxy will take care of that for you!

facade = new Facade({ SOME : { reallyGreat : { other_field : 'x' }}});
facade.proxy('some.reallyGreat.otherField'); // 'x'


Returns just the top level field of an object. You should generally be able to use .proxy() instead.

track.field('event')  // 'Loaded a page'
track.field('userId') // ''


Returns the full json of whatever was passed into the facade

(new Facade({ x : 'y'; })).json() // { x : 'y' }


Returns the options passed in to the facade. If you pass in an integration name, it will return the options only for that integration. If the integration isn't enabled, you won't get anything back for it

facade = new Facade({ options : { '' : { good : true }}});
facade.options(); // { '' : { good : true }}
facade.options('') // { good : true }
facade.options('') // {}
// Salesforce is disabled by default
facade.options('Salesforce') // undefined;


Returns whether the integration name is enabled:

facade = new Facade();
facade.enabled('Salesforce'); // false (off by default)
facade.enabled(''); // true


Returns the channel for where the call came from, client or server

If your integration uses browser javascript, you'll want to check all incoming facade messages to see whether to use them.; // 'server'


Returns the timestamp when the call was made

facade.timestamp(); // Thu Aug 29 2013 17:53:03 GMT-0700 (PDT)


Returns the user agent for the call if passed into the context.userAgent field.


Decides whether a call should be used to update the user who the call is for. Defaults to true, taken from

Any active call will update the user's last seen fields.


Proxies the group id via context.groupId.



return the tracked event


return the user's id for the track call


return the session id for the track call


return the event properties


return the referrer as taken from the properties


return the username from traits or the userid


return the email from the traits


convert the track call into an identify call to feed its traits into services which use super properties

var identify = track.identify();
identify.firstName(); // 'Bill',  pulled from options.traits



return the user's id


return the session id


return the passed in traits


return the email from traits and user id


return the username from the traits and user id



returns the previous user id to alias from


returns the current user id to alias to


Released under the MIT license.