https://github.com/mparticle/mparticle-node-sdk
Node JS SDK for the mParticle Platform
https://github.com/mparticle/mparticle-node-sdk
Last synced: 10 months ago
JSON representation
Node JS SDK for the mParticle Platform
- Host: GitHub
- URL: https://github.com/mparticle/mparticle-node-sdk
- Owner: mParticle
- Created: 2017-01-13T22:39:51.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-04-17T20:15:43.000Z (about 3 years ago)
- Last Synced: 2023-08-06T23:21:33.787Z (almost 3 years ago)
- Language: JavaScript
- Size: 98.6 KB
- Stars: 3
- Watchers: 14
- Forks: 5
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

## mParticle Node SDK
This is the mParticle Node SDK - use it to send your data to the [mParticle platform](https://www.mparticle.com/) and off to 100+ data services.
### Requirements
Node JS 4.2.2 or later.
### Installation
```sh
npm install mparticle
```
## Usage
```javascript
var mParticle = require('mparticle');
var api = new mParticle.EventsApi(new mParticle.Configuration(
'REPLACE WITH API KEY',
'REPLACE WITH API SECRET'));
var batch = new mParticle.Batch(mParticle.Batch.Environment.development);
batch.user_identities = new mParticle.UserIdentities();
batch.user_identities.customerid = '123456' // identify the user (required)
batch.user_attributes = {'hair color': 'brown'}
var event = new mParticle.AppEvent(mParticle.AppEvent.CustomEventType.navigation,
'Hello World');
batch.addEvent(event);
var body = [batch]; // {[Batch]} Up to 100 Batch objects
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully.');
}
};
api.bulkUploadEvents(body, callback);
// or upload a single batch
//api.uploadEvents(body, batch)
```
### License
[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)