项目作者: vesparny

项目描述 :
The Fair Analytics client API
高级语言: JavaScript
项目地址: git://github.com/vesparny/fair-analytics-client-api.git
创建时间: 2017-05-05T07:23:08Z
项目社区:https://github.com/vesparny/fair-analytics-client-api

开源协议:MIT License

下载


Fair Analytics client JavaScript API

The quickest way to integrate Fair Analytics in your app

Travis
Code Coverage
David
npm
npm
JavaScript Style Guide
MIT License
gzip size

Install

This project uses node and npm. Go check them out if you don’t have them locally installed.

  1. $ npm i fair-analytics-client-api

Then with a module bundler like rollup or webpack, use as you would anything else:

  1. // using ES6 modules
  2. import fairAnalytics from 'fair-analytics-client-api'
  3. // using CommonJS modules
  4. var fairAnalytics = require('fair-analytics-client-api')

The UMD build is also available on unpkg:

  1. <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

  1. import fairAnalytics from 'fair-analytics-client-api'
  2. // create a fa instance
  3. const fa = fairAnalytics({
  4. url: 'https://fa.yoursite.com' // the URL of your hosted Fair Analytics instance
  5. })
  6. // track events
  7. fa.send({
  8. event: 'pageView', // event is mandatory and can be anything
  9. pathname: window.location.pathname
  10. })
  11. .then(res => {
  12. if (res.ok) {
  13. console.log('success')
  14. }
  15. })
  16. .catch(err => {
  17. console.error(err.message)
  18. })

Tests

  1. $ npm 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