Giter Club home page Giter Club logo

cjm-tracker's Introduction

超级码埋点 cjm-tracker

My NodeJs Version: v14.20.0

Features

  • 采用gif图片上报
  • 支持自定义上报类型,自定义上报参数,自定义上报地址
  • PV采集
  • 元素点击采集

Install

$ npm install
$ npm run build

Usage

  1. 采用script标签引入的方式: 注意需要带上版本号,不带版本默认最新
<script src="https://unpkg.com/cjm-tracker@{version}/dist/umd/cjm-tracker.min.js"></script>
  1. 采用npm引入的方式
$ npm install cjm-tracker

在项目中引入

import {CjmTracker} from 'cjm-tracker';

初始化参数需要根据实际业务来决定,以下为示例

window.cjmTracker = new CjmTracker({
  reportUrl: '/api/xxxxx', // 上报地址
  debug: false, // 是否开启调试模式
  enablePVEvent: true, // 是否开启PV采集
  enableWebClickEvent: true, // 是否开启元素点击采集
}, {
  project: 'xxx', // 项目唯一标识
});

自定义上报,例如:采集功能点击事件

window.cjmTracker.track(
  'feature_click', // 自定义上报事件英文名
  {
    funId: 'xxx', // 功能id
    funName: 'xxx', // 功能名称
  }, 
  () => {
    // 上报成功后的回调,可不填,同步执行
  }
);

API

new CjmTracker(options, defaultConfigs)

  • options {Object} 配置项
    • reportUrl {String} 上报地址, 必填
    • debug {Boolean} 是否开启调试模式, 默认false
    • enablePVEvent {Boolean} 是否开启PV采集, 默认false
    • enableWebClickEvent {Boolean} 是否开启元素点击采集, 默认false
  • defaultConfigs {Object} 默认上报参数
    • project {String} 项目唯一标识,必填

tracker.track(eventName, properties?, callback?)

  • eventName {String} 自定义上报事件英文名, 必填
  • properties {Object} 自定义上报参数, 可选
  • callback {Function} 上报成功后的回调,可不填,同步执行

cjm-tracker's People

Contributors

liulunsheng avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.