0.0.6 • Published 5 months ago

@w57124/front-end-tracking v0.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

front-end-tracking

@w57124/front-end-tracking sdk.

Usage

npm install @w57124/front-end-tracking --save

Usage:

import Tracker from '@w57124/front-end-tracking'

const tr = new Tracker(options)

const tr = new Tracker({
	requestUrl: 'xxxxxx',
	historyTracker: false,
    domTracker: false,
    jsError: false,
    xhrTracker: true,
})
//设置平台
tr.setPlatform("本地");
//自定义上传格式
tr.setParamsFn((data) => {
        const { platform, setParamsFn, ...params } = data;
        return { platform, content: params };
      });

options

/**
  * @requestUrl 上报接口地址
 * @historyTracker history上报 单页应用的路由
 * @hashTracker hash上报
 * @domTracker 携带Tracker-key 点击事件上报
 * @sdkVersionsdk版本
 * @extra透传字段 自定义参数上报
 * @jsError js 和 promise 报错异常上报
 * @platform 平台
 * @setParamsFn 上传格式处理函数
 * @xhrTracker 监听XMLHttpRequest请求,http或code非200就上传
 */
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;
	platform:string;
	setParamsFn?:Function;
	xhrTracker:boolean;
}