hlg-tracker ·
无垠埋点前端 SDK,封装了一个可配置的埋点指令集,方便快速调用。
Install
npm install hlg-tracker
Usage
注册 SDK
;const trackerOptions =wind:name: 'wind'project: 'gd_web'version: '0.0.2'env: 'prod' // dev, stage, prodshowLog: truebasicFields: {} // 覆盖基础公共数据层commonFields: {} // 覆盖公共业务数据层eventFields: // 覆盖业务事件数据层scene: 'test';// 注册const isProd = processenvNODE_ENV === 'production';const debugMode = windowsessionStorage || /__tracker_debug/;tracker;/*** 用户登录,需要传用户 ID 或者匿名 ID* @param* @param* @param* @param*/tracker;// 退出登录tracker;
Vue 快捷指令
注册指令:
;; const trackerConfig = 11: event: 'default_event' 12: event: 'hover_event' user_id: 110 13: event: 'function_event_with_attribute' user_type: type 14: { ; }; Vue;
使用指令:
点击hover曝光点击
const app = { return type: 1 } { this; } methods: { this; this; }
无垠埋点插件
; // 注意需要在 setup 之后调用// 上报 utm 相关数据,需要与 RouterChangeTracker 插件一起使用。trackerWind; // 自动上报基于 vue-router 的 PV// app 为 vue 的根实例,须使用 vue-routertrackerWind; // 关于 abtest 的插件// abtest 为 abtest 库的实例trackerWind;
开发
yarn# use yarn to install depsyarn dev# visit page on http://localhost:9001/
发布
yarn npm-publish