nanobeacon

1.0.4 • Public • Published

nanobeacon stability

npm version build status downloads js-standard-style

Small navigator.sendBeacon wrapper. Sends an HTTP request with priority lowest to a remote host, and ensures it arrives without blocking page navigation. Useful for sending analytics data.

Also a friendly reminder not to ever store people's IP addresses. Only store the minimum amount of data needed to inform decisions. Be kind, don't give analytics a bad name.

Usage

var nanobeacon = require('nanobeacon')
 
var url = 'http://jsfiddle.net?sendbeacon'
var ok = nanobeacon(url, { hello: 'world' })
 
var msg = ok ? 'OK' : 'NOT OK'
document.body.innerHTML = '<h1>message status: ' + msg + '</h1>'

API

ok = nanobeacon(url, [data])

Send a request with a payload to a remote host.

If user has enabled Do Not Track (window.navigator.doNotTrack) then no beacon will be sent and nanobeacon will return false.

See Also

License

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.4
    1
    • latest

Version History

Package Sidebar

Install

npm i nanobeacon

Weekly Downloads

1

Version

1.0.4

License

none

Last publish

Collaborators

  • mreinstein
  • benlyn
  • s3ththompson
  • yoshuawuyts
  • bret
  • lrlna
  • yerkopalma
  • juliangruber
  • timwis
  • ahdinosaur
  • toddself
  • sethvincent
  • maxogden
  • shama
  • freeman-lab
  • feross
  • emilbayes
  • colingourlay
  • jameskyburz
  • almost
  • slaskis
  • ungoldman
  • graforlock
  • tornqvist
  • amongiants
  • goto-bus-stop
  • mafintosh
  • jhand