nuanyang-tracker
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

tracker

这是一个埋点 SDK This is a buried SDK

使用方法如下 The usage is as follows

import Tracker from 'nuanyang-tracker';

const tr = new Tracker({
  requestUrl: 'xxxxxx',
  historyTracker: true,
  domTracker: true,
  jsError: true,
});

Options introduction

/**
 * @requestUrl 接口地址
 * @historyTracker history上报
 * @hashTracker hash上报
 * @domTracker 携带tracker-key 点击事件上报
 * @historyTracker sdkVersion sdk版本
 * @historyTracker extra 透传字段
 * @jsError js 和 promise 报错异常上报
 */
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;
}

usage

<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script src="./dist/index.js"></script>
    <button tracker-key="btn">埋点按钮</button>
    <button>无埋点按钮</button>
    <button onclick="undefinedFunction()">js报错按钮</button>
    <script>
      new tracker({
        requestUrl: 'http://localhost:9000/api/track',
        historyTracker: true,
        domTracker: true,
        jsError: true,
      }); // 初始化
      function undefinedFunction() {
        console.log('undefinedFunction', aaaa);
      }
    </script>
  </body>
</html>

Readme

Keywords

Package Sidebar

Install

npm i nuanyang-tracker

Weekly Downloads

1

Version

1.1.2

License

ISC

Unpacked Size

16.9 kB

Total Files

7

Last publish

Collaborators

  • sun628