https://github.com/linkorb/activity-tracker
activity-tracker.js
https://github.com/linkorb/activity-tracker
Last synced: 3 months ago
JSON representation
activity-tracker.js
- Host: GitHub
- URL: https://github.com/linkorb/activity-tracker
- Owner: linkorb
- Created: 2018-05-15T09:33:22.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-10-26T22:16:17.000Z (over 1 year ago)
- Last Synced: 2025-02-06T12:38:49.852Z (4 months ago)
- Language: JavaScript
- Size: 97.7 KB
- Stars: 2
- Watchers: 5
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
activity-tracker
========activity-tracker.js is a simple way to track browser side user behavior. It is helpful for analyzing users' behavior when reading your web articles.
## Installation
```
npm install @linkorb/activity-tracker
```
To build activity-tracker into your lib with webpack:
```
require('@linkorb/activity-tracker');
```## Demo
Check the `demo/` directory for an demonstration + example on how to use activity-tracker. To run the demo for test:
```
php -S 127.0.0.1:8888
```
Then you can access the demo from: __http://localhost:8888/demo__It is possible to configure the activity-tracker:
```html// turn on debug mode. Optional
at('debug')// serverUri is required
// without serverUri nothing is recorded, nor reported// server address to report to - websocket
// at('sender', 'websocket'); // optional, the default sender is websocket
at('serverUri', 'ws://127.0.0.1:7777')// server address to report to - ajax
at('sender', 'xmlhttp')
at('serverUri', 'http://localhost/myWebserver')
// time interval to report to the server, in ms. Optional, default 5000
at('reportInterval', 6000)// custom/meta variables. Optional
at('meta', 'meRock')
at('meta', 'contentId', 6)
at('meta', 'userGroup', 'Cool people')
at('meta', 'requestId', 'aa-bb-cc-dd-eee')```
## Re-provision
When new content/page is loaded without page reload, e.g. AJAX, you can re-provision the activity-tracker:
```htmlat('meta', 'contentId', 7);
at('meta', 'requestId', 'ff-gg-hh-ii-jjj');
atProvision();```
## Subscribe only to certain events
By default, activity-tracker reports the following events: __mousemove__, __click__, __dblclick__, __keyup__, __scroll__. You can specify only certain events are reported:
```javascript
// only report click and scroll events
at('subscribe', 'click, scroll');
atProvision();
```## Inspect local activity stack
```html// list all the activity objects recorded
atStack()```
## Build from source
To change the source file and build, simply use `webpack`.
```
# generates dist/at.js
webpack -d
# generates dist/at.min.js
webpack -p
```