README
Sift Science
Sift Science NodeJS Client
Install
npm:
Using$ npm install siftscience
Usage
import SiftScience from 'siftscience';
const siftScience = new SiftScience(API_KEY);
Once you initilize the client, you can start send events to Sift Science.
Features
- Events API
- createOrder
- updateOrder
- transaction
- createAccount
- updateAccount
- createContent
- updateContent
- contentStatus
- flagContent
- addPromotion
- addItemToCart
- removeItemFromCart
- submitReview
- sendMessage
- login
- logout
- linkSessionToUser
- chargeback
- orderStatus
- Score API
- getScore
Events API
siftScience.events.[eventName](data, options)
Parameters:
- data: Data to send to Sift Science
- options
- options.return_score: boolean
Return:
- Promise - Result from Sift Science
Example
siftScience.events.createAccount(
{ $user_id: userId, $session_id: sessionId },
{ return_score: true }
)
.then((res) => {
console.log(res);
});
Score API
siftScience.getScore(userId)
Parameters:
- userId: The user ID
Return:
- Promise - Result from Sift Science
Example
siftScience.getScore(userId)
.then((res) => {
console.log(res);
});
Contribute
Gulp Tasks | Description |
---|---|
gulp lint |
Runs eslint on your source code and tests. |
gulp babel |
Transpile your source code, outputting into the dist/ |
gulp test |
Run your mocha test you'll add to test/ out putting the result to the your console, great for running the tests locally. |
gulp test-ci |
Same as test, except it outputs the results in junit format to the test-results.xml. Mainly when running the tests on a CI server, or if your feeling frisky. |
gulp build |
Run lint, test & babel in sequence, so you can check the full process runnitng smooth. |
gulp build-ci |
Runs lint, test-ci & babel. Main command in the circle-ci config. |