@benwiley4000/fair-analytics-client-beacon-api

1.1.0-beacon.1 • Public • Published

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.

$ npm i fair-analytics-client-api

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

// using ES6 modules
import fairAnalytics from 'fair-analytics-client-api'

// using CommonJS modules
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'

// create a fa instance
const fa = fairAnalytics({
  url: 'https://fa.yoursite.com' // the URL of your hosted Fair Analytics instance
})

// track events
fa.send({
  event: 'pageView', // event is mandatory and can be anything
  pathname: window.location.pathname
})
.then(res => {
  if (res.ok) {
    console.log('success')
  }
})
.catch(err => {
  console.error(err.message)
})

Tests

$ 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

Versions

Current Tags

Version History

Package Sidebar

Install

npm i @benwiley4000/fair-analytics-client-beacon-api

Weekly Downloads

2

Version

1.1.0-beacon.1

License

MIT

Unpacked Size

10.1 kB

Total Files

6

Last publish

Collaborators

  • benwiley4000