sd 统计封装


License
ISC
Install
npm install sd-track-core@0.1.2

Documentation

SD 统计封装

安装使用

npm i sd-track-core@0.0.5 --save

Demo

创建

import trackService from 'sd-track-core'

const track = trackService.create({
  showLog: true,
  commonParams: () => {
    return {
      biz: 'SDH',
      channel: '****',
      platform: '****',
    }
  },
  handleTrack: (trackData, controlArg) => {
    console.warn('统计怎么发要自己写啦,handleTrack: (trackData, controlArg) => {}')
  }
})

调用

track({
  elementCode: 12345,
  extInfo: {
    id: 22,
    name: 'extName'
  }
})

扩展

创建

import trackService from 'sd-track-core'

const track = trackService.wxLittleCreate({
  // ...
})

+++ const wrap = trackService.createWrap(send)

调用

...
      <button @tap="login">login</button>
      <button @tap="logout">logout</button>
      <button @tap="bannerClick">bannerClick</button>
...
  handleLogin = () => {
    console.log('promote login')
  }
  handleLogout = () => {
    console.log('promote logout')
  }
  handleBannerClick = (index) => {
    console.log(`promote banner click with index: ${index}`)
  }
  methods = {
    login: trackService.wrap({op: 'login'})(this.handleLogin),
    logout: trackService.wrap(() => {
      return {op: 'logout'}
    })(this.handleLogin),
    bannerClick: trackService.wrap(index => {
      return {op: 'bannerClick', index}
    })(this.handleBannerClick)
  }
...

更新日志