UNPKG

lifecycle-node

Version:
77 lines (68 loc) 3.71 kB
# Lifecycle Bindings for Node.js ## Installation ``` bash npm install lifecycle-node ``` ## Documentation Check out the official documentation at https://www.lifecycle.io/docs/campaign. ## API Overview Identify and Track users via your `lifecycle` instance. ### Identify Identify users to create, add, and update attributes to user data stored with Lifecycle. ``` js var lifecycle = require('lifecycle-node'); lifecycle.identify(uniqueId, [defaultAttributes], [extraAttributes], callback); ``` ##### Arguments **uniqueId** (String): *required*         Your unique identifier for the user **defaultAttributes** (Object): *optional*         ***first_name*** (String)         The first name of the user         ***last_name*** (String)         The last name of the user         ***email_address*** (String)         The email address of the user         ***phone_number*** (String)         The phone number of the user         ***apns_token*** (String)         The apns token of the user         ***gcm_token*** (String)         The gcm token of the user         ***browser_token*** (String)         The browser token of the user         ***street_address*** (String)         The street address of the user         ***city*** (String)         The city of the user         ***state*** (String)         The state of the user         ***zip_code*** (String)         The zip code of the user **extraAttributes** (Object): *optional*         Any other identifiers you use **callback** (Function): *required*         Returns error or result ### Track Track your events and the users who trigger them. ``` js var lifecycle = require('lifecycle-node'); lifecycle.track(eventId, uniqueId, [properties], callback); ``` ##### Arguments **eventId** (String): *required*         The name of your event **uniqueId** (String): *required*         Your unique identifier for the user **properties** (Object): *optional*         Any properties associated with your event **callback** (Function): *required*         Returns error or result ## Configuration Set the environment variable `LIFECYCLE_API_KEY` before running your app: ``` bash export LIFECYCLE_API_KEY='{YOUR_API_KEY}' ``` *Note: On Windows use `SET` instead of `export` for setting the `LIFECYCLE_API_KEY` environment variable.* ## License This package is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).