Package Exports
- yield-siftscience
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (yield-siftscience) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Yield Sift Science
A promise-wrapped helper lib for yielding Sift Science API calls.
Installation
Using npm:
$ npm install yield-siftscienceUsage
Require with API key:
var siftscience = require('yield-siftscience')('YOUR_SIFT_SCIENCE_REST_API_KEY');Send Event:
var result = yield siftscience.event.create_account({
'$session_id': 'abcdefghijklmnopqrstuvwxyz',
'$user_id': '12345',
'$user_email': 'example@email.com'
});
console.log(result);Send Generic Custom Event:
var score = yield siftscience.custom_event('submit_comment', {
'$session_id': 'abcdefghijklmnopqrstuvwxyz',
'$user_id': '12345',
'$user_email': 'example@email.com',
'content': 'blah blah blah comment'
});
console.log(score);Inject Custom Events:
Optionally, you can pass in an array of custom event names to add to the lib
var custom_events = ['submit_comment', ...];
var siftscience = require('yield-siftscience')('YOUR_SIFT_SCIENCE_REST_API_KEY', null, custom_events);Then you could use
var result = yield siftscience.event.submit_comment({
'$session_id': 'abcdefghijklmnopqrstuvwxyz',
'$user_id': '12345',
'$user_email': 'example@email.com',
'content': 'blah blah blah comment'
});
console.log(result);Send Label:
var result = yield siftscience.label('user_id', {
'$is_bad': true,
'$reasons': [ '$spam', '$chargeback' ],
'$description': 'Because they are spamming and abusing our system'
});
console.log(result);Get Score:
var score = yield siftscience.score('user_id');
console.log(score);