inspetor
Inspetor Frontend Library for Javascript
Last updated 2 months ago by inspetor .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install inspetor 
SYNC missed versions from official npm registry.

Inspetor Logo

Inspetor Antifraud

Inspetor's antrifraud SDK for Javascript (browser) integrations.

Description

Inspetor is a product developed to help your company to avoid fraudulent transactions. This README file should help you to integrate the Inspetor Javascript library into your product with a couple steps.

How to use

The Inspetor Javascript Library can be installed through npm or by a <script> (Global Variable) tag.

We recommend you to use the <script> tag (Global Variable) since this is a browser library.

Npm Method

First, install it:

npm install inspetor

After that you can import the library as usual:

import inspetor from 'inspetor'

or using require

const inspetor = require('inspetor')

PS: If you are using Browserify check on how to make our variable global

Script Tag (Global Variable)

You can also use the latest release from our CDN and import the build directly in your HTML:

<script src="https://files.inspcdn.net/inspetor-js/inspetor.min.js" />

The library will be available as the global variable inspetor.

API Docs

You can find more in-depth documentation about our frontend libraries and integrations in general here.

Library setup

In order to properly relay information to Inspetor's processing pipeline, you'll need to provide your customer-specific authentication credential:

  • authToken (provided by Inspetor)

P.S: Remember to use the sandbox authToken when you are not in production

With these, you can instantiate the Inspetor tracking instance. Our integration library instantiates a singleton instance to prevent multiple trackers from being instantiated, which could otherwise result in duplicate or inconsistent data being relayed to Inspetor.

The singleton instance is instantiated as follows:

  inspetor.sharedInstance().setup(authToken="authToken", requestLocation=false);

Be advised, that this function can throw an exception if you pass invalids (empty strings or not in the format required) authToken.

All the access to the Inspetor functions is made via calling the inspetor.sharedInstance().

The parameters passed are the following, in order:

Parameter Required Type Description
authToken Yes String An unique identifier that the Inspetor Team will provide to you
requestLocation Yes Boolean If set to true we will ask for the user's permission (which will help us provide more accurate results)

Library Calls

If you've already read the general Inspetor files, you should be aware of all of Inspetor requests and collection functions.

Here we will show you some details to be aware of if you are calling the Inspetor tracking functions.

All of out track functions can throw exceptions, but the only exception they will through is if you forget to configure the Inspetor Library before calling one of them. Because of that the Inspetor class have a function called isConfigured() that returns a boolean saying if you have configured or not the Inspetor Library. We recommend that when you call any of our tracking functions you check if the Inspetor Library is configured. Here is an example on how to do that:

if (inspetor.sharedInstance().isConfigured()) {
    inspetor.sharedInstance().trackAccountCreation("123");
}

trackPageView

Pageview tracking is performed automatically by the library every time the user reloads the page or changes the url. We do provide the option to manually trigger "pseudo pageview" events (pageviews that do not change the page or do not change the url of the page). You should be careful when manually tracking pageviews since it can lead to duplicate pageview events. We recommend that you contact the Inspetor team to get advice when using the trackPageView function.

Here you can see an example of manually triggering the trackPageView function:

if (inspetor.sharedInstance().isConfigured()) {
    inspetor.sharedInstance().trackPageView("Pseudo PageView")
}

Models

If you are coming from one of our backend libraries you will notice that we do not use models (e.g. Account, Sale) in our frontend libraries. Here you just need to send us the id of the model (e.g. sale ID, account ID).

More Information

For more info you should check the Inspetor Frontend docs

Current Tags

  • 1.1.3                                ...           latest (2 months ago)

2 Versions

  • 1.1.3                                ...           2 months ago
  • 1.1.2                                ...           2 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 3
Dependencies (5)
Dev Dependencies (11)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |