pak-tracker
v1.0.1
Published
This is a SDK to monitor the pageview, unique vistor, DOM event and JavaScript Error.
Downloads
3
Readme
pak-tracker
This is a SDK to monitor the pageview, unique vistor, DOM event and JavaScript Error.
The usage is as follows
import Tracker from 'pak-tracker'
const tr = new Tracker({
requestUrl:"xxxxxx"
})
Options introduction
/**
* @requestUrl report Url
* @historyTracker history report
* @hashTracker hash report
* @domTracker dom event report with target-key
* @historyTracker sdkVersion
* @historyTracker extra
* @jsError js error and promise rejected report
*/
export interface DefaultOptons {
uuid: string | undefined,
requestUrl: string | undefined,
historyTracker: boolean,
hashTracker: boolean,
domTracker: boolean,
sdkVersion: string | number,
extra: Record<string, any> | undefined,
jsError:boolean
}
DOM event report
When you enable the domTrakcer, this tracker will report if the event on the element with target-key is triggered. The events listened by the tracker are shown below.
const MouseEventList: string[] = ['click', 'dblclick', 'contextmenu', 'mousedown', 'mouseup', 'mouseenter', 'mouseout', 'mouseover'];
You should add the target-key like this, the tracker also send the key to backend.
<button target-key="patrick">click me!!!!!</button>
public methods
const tr = new Tracker({
requestUrl:"xxxxxx"
})
tr.setUserId('xx');
tr.setExtra({name:'patrick'});
tr.sendTracker({name:'patrick'});
- setUsetId - to set the unique ID to monitor every unique vistor
- setExtra - set the extra information to send to backend within every report
- sendTracker - send the information to backend