https://github.com/alexfigliolia/beaconer
A backward compatible wrapper around the Beacon API
https://github.com/alexfigliolia/beaconer
beacon beacon-api http http-requests sendbeacon
Last synced: 4 months ago
JSON representation
A backward compatible wrapper around the Beacon API
- Host: GitHub
- URL: https://github.com/alexfigliolia/beaconer
- Owner: alexfigliolia
- Created: 2023-05-23T19:09:13.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-08T20:23:31.000Z (almost 2 years ago)
- Last Synced: 2025-10-24T04:38:42.349Z (8 months ago)
- Topics: beacon, beacon-api, http, http-requests, sendbeacon
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/beaconer
- Size: 54.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Beaconer
A backward compatible wrapper around the Beacon API!
This API is commonly used for sending application analytics or diagnostics that were historically sent in the background using some combination of standard HTTP Requests with the page visibility API. A common pitfall developers would run into is that the browser, in some cases, would choose not to send out the request when a browser tab is in the background. The Beacon API was implemented to fix this issue.
This package wraps the API with an `XMLHttpRequest` fallback.
## Installation
```bash
npm i -S beaconer
yarn add beaconer
```
## Usage
The `Beaconer` has two public properties:
```typescript
import { Beaconer } from "beaconer";
const success = await Beaconer.send("url", JSON.stringify({ someData: 123 }));
const isUsingBeaconAPI = Beaconer.browserSupport;
```