Fair Analytics client JavaScript API
The quickest way to integrate Fair Analytics in your app
![gzip size](http://img.badgesize.io/https://unpkg.com/fair-analytics-client-api/dist/fair-analytics-client-api.umd.min.js?compression=gzip&label=gzip%20size&style=flat-square)
Install
This project uses node and npm. Go check them out if you don't have them locally installed.
$ yarn add fair-analytics-client-api
Then with a module bundler like rollup or webpack, use as you would anything else:
import fairAnalytics from 'fair-analytics-client-api'
var fairAnalytics = require('fair-analytics-client-api')
The UMD build is also available on unpkg:
<script src="https://unpkg.com/fair-analytics-client-api/dist/fair-analytics-client-api.umd.js"></script>
You can find the library on window.fairAnalytics
.
Usage
import fairAnalytics from 'fair-analytics-client-api'
const fa = fairAnalytics({
url: 'https://fa.yoursite.com'
})
fa.send({
event: 'pageView'
})
.then(res => {
if (res.ok) {
console.log('success')
}
})
.catch(err => {
console.error(err.message)
})
Tests
$ yarn run test
Change Log
This project adheres to Semantic Versioning.
Every release, along with the migration instructions, is documented in the CHANGELOG.md file.
License
MIT