simple-node-intercom-io
v1.0.1
Published
ES6 Intercom.io library.
Downloads
1,167
Maintainers
Readme
Simple node intercom.io library
A simple wrapper for intercom.io client library written in ES6.
- Loads Intercom.io tracking JavaScript library.
- Exposes a convenient interface for:
- Setting your Intercom.io API key.
- Initiating user session.
- Tracking events.
- Tracking user properties.
- Firing page change events (for single page apps).
Usage example
First, install the library.
npm install simple-node-intercom-io --save
To use:
import intercom from 'simple-node-intercom-io';
// Set key & setup must be called first.
function setupAnalytics() {
intercom.setKey(config.ANALYTICS.INTERCOM.KEY);
intercom.setup();
}
// On login, boot intercom
function loginToMyApp() {
// name, email, created timestamp, meta
intercom.boot('Bob', '[email protected]', 00000000, {
customUserProperty: 'value'
});
}
// This function should be called whenever the page changes in your app so that intercom messages are displayed
function appStateChange() {
intercom.update();
}
// The same function can also be called to update the user's data if they change it
function appStateChange() {
intercom.update({
email: '[email protected]',
customUserProperty: 'another value'
});
}
// This function should be called to track an event
function doSomethingInMyApp() {
intercom.trackEvent('Event name/key', {
customEventProperty: 'value'
});
}