https://github.com/cuppilekkia/event-tracker
A tiny Javascript utility to push browsers' interaction events information to an API endpoint or a server (Node, API Gateway, etc...) using Beacon API
https://github.com/cuppilekkia/event-tracker
beacon-api browser-events event-tracker interaction-tracker javascript javascript-library js sendbeacon tracker
Last synced: about 1 month ago
JSON representation
A tiny Javascript utility to push browsers' interaction events information to an API endpoint or a server (Node, API Gateway, etc...) using Beacon API
- Host: GitHub
- URL: https://github.com/cuppilekkia/event-tracker
- Owner: cuppilekkia
- License: other
- Created: 2019-12-13T19:43:36.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-05T13:33:00.000Z (about 2 years ago)
- Last Synced: 2025-03-17T21:51:51.118Z (2 months ago)
- Topics: beacon-api, browser-events, event-tracker, interaction-tracker, javascript, javascript-library, js, sendbeacon, tracker
- Language: JavaScript
- Homepage:
- Size: 2.97 MB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Event Tracker
## @cuppilekkia/event-tracker - JS Event Tracking### [Code coverage](./coverage/lcov-report/index.html)
Collect and send data to an API endpoint, uses the SendBeacon method if available in the browser, otherwise classic POST request.
This package is built using webpack 4.
## Getting started
### Download
Via npm
```bash
$ npm install @cuppilekkia/event-tracker --save
```### Usage
#### ES6 modules
```javascript
import { Tracker } from '@cuppilekkia/event-tracker';
```#### CommonJS
```javascript
const Tracker = require('@cuppilekkia/event-tracker');
```### Initialization
```javascript
window.trackerClient = new Tracker({
api: '[API PATH i.e. "/data" ]',
host: '[API HOST i.e. "https://mydatacollector.com"]',
});
```#### File include [WIP]
Link `tracker.js` in your HTML :
```html
var trackerClient = new tracker.Tracker({
api: '[API PATH i.e. "/data" ]',
host: '[API HOST i.e. "https://mydatacollector.com"]'
});```
### Send data
Send any kind of object as payload, containing all the data you want to send.```javascript
var payload = {
key1: value,
key2: {...},
...
}
trackerClient.push(payload);
```## DEVELOPMENT
[add here development notes]
this package uses `semantic release` so please follow the sintax like:| Commit message | Release type |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------|
| `fix(pencil): stop graphite breaking when too much pressure applied` | Patch Release |
| `feat(pencil): add 'graphiteWidth' option` | ~~Minor~~ Feature Release |
| `perf(pencil): remove graphiteWidth option`
`BREAKING CHANGE: The graphiteWidth option has been removed.`
`The default graphite width of 10mm is always used for performance reasons.` | ~~Major~~ Breaking Release |## TODO
- build a demo page with additionally a test node server
- find a way to test cookie creation
- fix coverage building and job to move into public