data-telemetry
v0.1.2
Published
A simple event tracker for user surfing sessions
Downloads
11
Maintainers
Readme
data-telemetry
A simple event tracker for user surfing sessions.
import {Session} from 'data-telemetry';
const session = new Session(
document.body, // the root node to search for [data-telemetry]
// it's the document itself by default
true, // overwrite last move to reduce the amount of events
// it's true as default
false // use pointer events instead of mouse
// it defaults to typeof PointerEvent check
);
// ... after a while ...
// log the list of registered records
console.log(session.events);
The session is serializable as JSON too via JSON.stringify(session)
, resulting in its list of events as records.
Events
cancel
, down
, enter
, leave
, move
, out
, over
, and up
are automatically transformed via mouse
or pointer
prefix.
The value all
will try to setup all possible events per element.
To enable any telemetry event, use the data-telemetry
attribute as shown in the following example:
<div data-telemetry="move, up, down">
<input data-telemetry="keypress" placeholder="write stuff">
<button data-telemetry="click">
send stuff
</button>
</div>
The session can be confined per container, and every node will add an event to the list once such event happens.
Records
Each record will contain the following details:
target
, stored as CSS selectortype
, the event typekey
, the key info, if availablex
andy
, the event pageX/Y coordinates, if availableprimary
, the pointereventsprimary
detail, if availabletime
thetimeStamp
of the event