thisdata-node
thisdata-node is a nodejs client for the ThisData Login Intelligence API (https://thisdata.com).
Setup
Install the latest thisdata-node package from npm
npm install thisdata --save
Create a ThisData client
var ThisData = ;var thisdata = ;
Track Events
Use this method to asynchronously track events that happen in your app.
thisdata;
To track login related events, find the point in your code just after
a login success, failure or password reset and use the track
method to
send data to the ThisData API.
thisdata;
Options
ip
and user_agent
are extracted from req
but you can override these value and supply additional fields using options.
verb: 'transfer' ip: '0.0.0.0' userAgent: 'Firefox, Windows 98' user: id: 'john123455' name: 'John Titor' email: 'john+titor@thisdata.com' session: id: 'Optional' cookieExpected: true device: id: 'mobile-device-id'
user.name
- string The full name of the useruser.email
- string - An email address for sending unusual activity alerts touser.mobile
- E.164 format - An mobile number for sending unusual activity SMS alerts to. e.g. +15555555555session.id
- string - Typically a browser session id but it's up to yousession.cookieExpected
- boolean - Used in combination with ThisData Javascript. Settrue
if the script is installeddevice.id
- string - A unique device identifier. Typically used for tracking mobile devices.
Event Types
We recommend using verb constants thisdata.verbs.LOG_IN
but you can use any verb that represents the type of event that you want to track.
For a full list of verbs see http://help.thisdata.com/v1.0/docs/verbs
Verify Identity
Use the Verify
method to enable contextual authentication in your app. It accepts the same parameters as the Track
event with the exception of the event type/verb.
thisdata;
Verify will return a risk score between 0->1 which indicates our level confidence that the user is who they say they are.
score: 0 risk_level: 'green' triggers: messages:
0.0 - low risk/high confidence it's the real user
1.0 - high risk/low confidence it's the real user
thisdata;
Get a list of Events
You can get a list of events enriched with their risk score and location data for use in custom audit logs. See the docs for possible query filters and paging params.
thisdata;
Get last successful log-in time and location for a user.
thisdata;
Managing custom Rules
You can get, create, update and delete custom rules.
Create a rule
// returns a rule thisdatarules;
List all rules
thisdatarules;
Find a single rule
thisdatarules
Update a rule
// id is reqired. Other params are optional thisdatarules;
Delete a rule
// returns deleted as boolthisdatarules
Webhooks
You should validate incoming webhooks to make sure they're from ThisData. To do this you will enter a secret string
in the settings area of your ThisData account and then use that same secret to validate the webhook signature
that we send in the X-Signature
header.
var valid = thisdata;
For more information about types of webhooks you can receive see http://help.thisdata.com/docs/webhooks
API Documentation
API Documentation is available at http://help.thisdata.com/docs/apiv1events.
Test
Run the unit tests
npm test
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/thisdata/thisdata-node