1.0.1 • Published 10 months ago

pointsdk v1.0.1

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

这是一个数据埋点的插件

使用方法如下

import Tracker from './dist/index.esm.js'
new Tracker({
  requestUrl: "http://loaclhost:9000/tracker",
  historyTracker: true,
  domTracker: true,
  jsError: true
})

需要传的参数,接口地址 必传,其余不必传

/**
 * @requestUrl 接口地址
 * @historyTracker history上报
 * @hashTracker hash上报
 * @domTracker 携带Tracker-key 点击事件上报
 * @sdkVersionsdk版本
 * @extra透传字段
 * @jsError js 和 promise 报错异常上报
 * @pvKey pv上报的key
*/
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,
  pvKey: string | undefined
}

手动上报

const tracker = new Tracker()
btn.onclick = () => {
  tracker.sendTracker({
    requestUrl: "http://loaclhost:9000/tracker",
    message: "1234"
  })
}

设置用户id

const tracker = new Tracker()
tracker.setUserId("123")

设置额外参数

const tracker = new Tracker()
tracker.setExtra({})
1.0.1

10 months ago

1.0.0

10 months ago