浙政钉埋点(Vue2代码)

本文详细描述了如何在开发浙政钉H5应用时,集成VConsole和Eruda调试工具,以及使用wpkReporter进行稳定性与流量性埋点的过程,包括配置参数和注意事项,以满足政府审核要求。
摘要由CSDN通过智能技术生成

前言

现在更新h5到浙政钉居然要审核(上传源码用IRS平台打包,很容易不兼容 ),巨麻烦,特此写文章总结。
bid、sapp_id等我都用*****代替,具体信息谁让你干这活儿的找谁要。

用的mixin(router当然更优,毕竟打包小一些)

参考网址

代码(vue2)

1、检测工具

vconsole可以查看xxxxx/upload,这是稳定性埋点
eruda开启 Snippets - Load Timing Plugin,可以查看xxxxx.gif,这是流量性埋点

这俩工具只能各检测一种(很有专业性)
切记,做完的时候记得各存一份埋点的各种数据,不然政府办事员他们,可能要向你要数据手动确认(挺负责的,还指出哪里不符合要求)

index.html
<!-- <script src="//cdn.jsdelivr.net/npm/eruda"></script>
    <script>
      eruda.init();
    </script> -->

main.js
// import Vconsole from "vconsole";
// const vConsole = new Vconsole();
// Vue.use(vConsole);
2、index.html

在header中放入以下代码,需要改bid
专有云地址也看甲方发来的文档确认一下

    <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: "*************************************", //只需要修改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>

    <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",
        //专有云应用,第二个参数在部署时请替换为正确的专有云地址dalog-api.ding.zj.gov.cn
        arguments: ["aplus-rhost-v", "alog-api.ding.zj.gov.cn"],
      });
      aplus_queue.push({
        action: "aplus.setMetaInfo",
        //专有云应用,第二个参数在部署时请替换为正确的专有云地址alog-api.ding.zj.gov.cn
        arguments: ["aplus-rhost-g", "alog-api.ding.zj.gov.cn"],
      });

      var u = navigator.userAgent;
      var isAndroid = u.indexOf("Android") > -1;
      var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);

      aplus_queue.push({
        action: "aplus.setMetaInfo",
        arguments: ["appId", isAndroid ? "28302650" : isIOS ? "28328447" : "47130293"],
      });
    </script>
3、utils/zzdmd.js
/* eslint-disable */
export function setMd(page_id, page_name, page_url, _user_id) {
  aplus_queue.push({
    action: "aplus.setMetaInfo",
    arguments: ["_hold", "BLOCK"],
  });
  // 用户信息埋点----------------------------------------
  // 单页应用 或 “单个页面”需异步补充PV日志参数还需进行如下埋点 ------
  /* eslint-disable-next-line */
  aplus_queue.push({
    action: "aplus.setMetaInfo",
    arguments: ["aplus-waiting", "MAN"],
  });
  /* eslint-disable-next-line */
  aplus_queue.push({
    action: "aplus.sendPV",
    arguments: [
      {
        is_auto: false,
      },
      {
        // 当前你的应用信息,此两行按应用实际参数修改,不可自定义。
        sapp_id: "*******",
        sapp_name: "*******",
        page_id: page_id, // 可以用this.$route.meta.pagePath代替
        page_name: page_name, // 可以用this.$route.meta.name代替
        page_url: page_url, // 可以用this.$route.meta.pagePath代替
      },
    ],
  });
  // 设置会员昵称(没要求,先不设置了)
  /* eslint-disable-next-line */
  // aplus_queue.push({
  //   action: "aplus.setMetaInfo",
  //   arguments: ["_user_nick", _user_nick], // 需替换为当前登录的浙政钉用户名字,uni.getStorageSync('userInfo').employeeName
  // });
  // 设置会员ID
  /* eslint-disable-next-line */
  aplus_queue.push({
    action: "aplus.setMetaInfo",
    arguments: ["_user_id", _user_id], // 需替换为当前登录的浙政钉用户id,
  });
  /* eslint-disable-next-line */
  aplus_queue.push({
    action: "aplus.setMetaInfo",
    arguments: ["_dev_id", "yourDeviceId"],
  });
  // 如采集用户信息是异步行为,需要先设置完用户信息后再执行这个START埋点
  // 此时被block住的日志会携带上用户信息逐条发出
  /* eslint-disable-next-line */
  aplus_queue.push({
    action: "aplus.setMetaInfo",
    arguments: ["_hold", "START"],
  });
}

4、utils/zzdmdmx.js

accountId一般是登录成功就会给的,记得转为String

/* eslint-disable */
import { setMd } from "./zzdmd.js";

export default {
  data() {
    return {};
  },
  mounted() {
    const that = this;
    that.$nextTick(() => {
      that.zzdmdStart();
    });
  },
  methods: {
    zzdmdStart() {
    // 分别是当前页的英文名(home)、当前页的中文名(主页),当前的完整url,用户的accountId
      setMd(this.$route.name, this.$route.meta.title, "https://aaaaaaa.com/#" + this.$route.path, this.$store.state.user.accountId);
    },
  },
};

5、main.js
import zzdmdmx from "@/utils/zzdmdmx.js";
Vue.mixin(zzdmdmx);
其他

里面的各种字段,一定要String格式,不然不接收

开了vconsole或eruda等调试工具时,点击调试工具按钮,页面会报一个错误。无伤大雅,如果谁能解决那个问题,请留言

在线urldecode

看到这里点个赞鼓励下吧,求求

  • 7
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 8
    评论
回答: 在浙里办中使用Vue进行埋点的方法如下: 1. 首先,确保你的代码在npm run build打包后生成的index.html能正常显示业务内容。如果页面空白,可能是config里面的文件目录写错了。 2. 浙里办接收的文件目录是/build,但是Vue CLI生成打包后文件的目录是dist。你可以在文件夹根目录(和package.json同级)新增gbc.json文件,告诉浙里办你的输出目录。示例gbc.json文件内容如下: ``` { "type": "gov-build-config", "version": "1", "outputPath": "dist", "entryHtml": "/index.html" } ``` 3. 上传并编译成功后,你可以查看页面是否正常显示。但是注意,异步请求和单点登录等功能可能还没有实现。关于这些难点,可以参考下文。 4. 对于异步请求,你可以使用mgop进行处理。你可以下载@aligov/jssdk-mgop,并引入import { mgop } from '@aligov/jssdk-mgop'。然后按照官网的用法进行调用。 5. 关于埋点,你可以在网上搜索相关资料,可能会有一些教程或指南。你可以根据自己的需求进行查看和学习。 6. 这些是我目前能想到的方法,如果后续有其他想法,我会再告诉你。希望对你有帮助! #### 引用[.reference_title] - *1* *3* [浙里办接入流程(施工完毕)](https://blog.csdn.net/dom_l_z/article/details/126655637)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [浙里办接入h5(vue项目)------相关流程说明](https://blog.csdn.net/y_yinkedada/article/details/121402514)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值