当前位置:   article > 正文

【浙政钉】埋点_浙政钉稳定性监控埋点

浙政钉稳定性监控埋点

埋点官方对接文档 https://www.yuque.com/sisialing/bcg47r/ywfbnk

稳定性监控和通用采集SDK写在页面首页就行,只需加载一次

  <!-- 稳定性监控 -->
  <script src='https://wpkgate-emas.ding.zj.gov.cn/static/wpk-jssdk.1.0.2/wpkReporter.js' crossorigin='true'></script>
  <script>
    try {
      const config = {
        bid: '*************',
        signkey: '1234567890abcdef',
        gateway: 'https://wpkgate-emas.ding.zj.gov.cn'
      }
      const wpk = new wpkReporter(config)
      wpk.installAll()
      window._wpk = wpk
    } catch (err) {
      console.error('WpkReporter init fail', err)
    }
  </script>
  <!-- 通用采集 SDK -->
  <script>
    (function(w, d, s, q, i) {
      w[q] = w[q] || []
      var f = d.getElementsByTagName(s)[0],j = d.createElement(s)
      j.async = true
      j.id = 'beacon-aplus'
      j.src = 'https://alidt.alicdn.com/alilog/mlog/aplus_cloud.js'
      f.parentNode.insertBefore(j, f)
    })(window, document, 'script', 'aplus_queue')
    aplus_queue.push({
      action: 'aplus.setMetaInfo',
      arguments: ['aplus-rhost-v', 'alog-api.ding.zj.gov.cn']
    })
    aplus_queue.push({
      action: 'aplus.setMetaInfo',
      arguments: ['aplus-rhost-g', 'alog-api.ding.zj.gov.cn']
    })
    const u = navigator.userAgent
    const isAndroid = u.indexOf('Android') > -1
    const isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
    aplus_queue.push({
      action: 'aplus.setMetaInfo',
      arguments: ['appId', isAndroid ? '28302650' : isIOS ? '28328447' : '47130293']
    })
  </script>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42

基础埋点和用户信息埋点需要每一个页面都添加,可在路由变化的时候添加

router.beforeEach((to, from, next) => {
  // 埋点
  addBuryPoint(to)
  next()
})
  • 1
  • 2
  • 3
  • 4
  • 5
getLoginUser () {
  dd.getLoginUser().then(res => {
    window.sessionStorage.setItem('loginUserInfo', JSON.stringify(res))
  })
}
  • 1
  • 2
  • 3
  • 4
  • 5
// 基础埋点和用户信息埋点
export function addBuryPoint (pageInfo) {
  // 基础埋点
  aplus_queue.push({
    action: 'aplus.setMetaInfo',
    arguments: ['aplus-waiting', 'MAN']
  })
  aplus_queue.push({
    'action':'aplus.sendPV',
    'arguments':[{
      is_auto: false
    }, {
      // 当前你的应用信息,此两行请勿修改
      sapp_id: '*********',
      sapp_name: '***********',
      // 自定义PV参数key-value键值对(只能是这种平铺的json,不能做多层嵌套),如:
      page_id: pageInfo.name,
      page_name: pageInfo.meta.title,
      page_url: 'https://www.yuming.com/xxx/xxx/xxx'  // 必须完整地址 有#需要转义%23
    }]
  })
  // 用户信息埋点
  const loginUserInfo = JSON.parse(window.sessionStorage.getItem('loginUserInfo'))
  if (loginUserInfo) {
    aplus_queue.push({
      action: 'aplus.setMetaInfo',
      arguments: ['_hold', 'BLOCK']
    })
    aplus_queue.push({
      action: 'aplus.setMetaInfo',
      arguments: ['_user_nick', loginUserInfo.name]
    })
    aplus_queue.push({
      action: 'aplus.setMetaInfo',
      arguments: ['_user_id', loginUserInfo.accountId]
    })
    // aplus_queue.push({
    //   action: 'aplus.setMetaInfo',
    //   arguments: ['_dev_id', 'yourDeviceId']
    // })
    // 如采集用户信息是异步行为,需要先设置完用户信息后再执行这个START埋点
    // 此时被block住的日志会携带上用户信息逐条发出
    aplus_queue.push({
      action: 'aplus.setMetaInfo',
      arguments: ['_hold', 'START']
    })
  }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/247941
推荐阅读
相关标签
  

闽ICP备14008679号