This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@tanbo/track
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-alpha.2 • Public • Published

云宝宝前端埋点采集工具

本项目是用于前端页面数据采集的工具。使用方式如下:

安装

npm install @tanbo/track

页面配置

<body>
<!-- 区块编码设置 -->
<div data-track='{"blockCode": "blockCode"}'>
  <!-- 点位编码设置 -->
  <button type="button" data-track='{"placeCode": "placeCode"}'>button</button>
</div>
</body>

引入类库

import { track } from '@tanbo/track';
import { Url } from 'url';

const codeMap = {
  '/home': '01',
  '/test': '02',
};

const urlCodeMap = new Map();

Object.keys(codeMap).reduce((newObj, currentKey) => {
  urlCodeMap.set(currentKey, codeMap[currentKey]);
}, {});

// track.debug = true; 如果需要在控制台
track.init({
  form: {
    action: 'http://www.example.com',
    name: 'name',
    method: 'POST',
  },
  userInfo: {
    userID: 'userID', // 也可以传入一个函数,返回 userID
    sessionID: 'sessionID' // 也可传入一个函数,返回 sessionID
  },
  pageCodeProvider(url: Url) {
    return urlCodeMap.get(url.pathname);
  },
  appID: 'appID',
  autoListen: true, // 默认为 true,自动监听页面点击事件,并发送数据
  attributeName: 'data-track' // 默认为 data-track,用于在 dom 元素上配置数据 
}).listen();
track.pageIn();

Readme

Keywords

none

Package Sidebar

Install

npm i @tanbo/track

Weekly Downloads

0

Version

0.0.1-alpha.2

License

ISC

Unpacked Size

184 kB

Total Files

10

Last publish

Collaborators

  • tanbo