用户埋点对接

本文介绍了调试工具的使用条件,包括关闭防火墙、局域网环境和手机状态要求。同时,详细阐述了埋点技术,分为基础埋点和用户信息埋点,用于收集用户和项目信息。在单点登录场景下,如何在获取用户信息接口中进行埋点以确保数据准确性。还展示了在获取用户信息后的地理位置信息处理和调用流程。
摘要由CSDN通过智能技术生成

调试工具

在这里插入图片描述
下载使用

tips:

1.电脑防火墙必须全关闭

2.必须在同一个局域网内

3.手机app扫码后 手机设备不能关闭或息屏

埋点

埋点其实就是为了平台获取一些信息的,(用户信息,项目信息等)

可以在调试工具中查看接口信息

在这里插入图片描述
分为基础埋点
和获取用户信息埋点

    setAplus() {
      console.log("基础信息埋点");
      (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://d.alicdn.com/alilog/mlog/aplus.js?id=202951085";
        f.parentNode.insertBefore(j, f);
      })(window, document, "script", "aplus_queue");
      aplus_queue.push({
        action: "aplus.setMetaInfo",
        arguments: ["aplus-waiting", "MAN"],
      });

      aplus_queue.push({
        action: "aplus.setMetaInfo",
        arguments: ["aplus-rhost-v", "alog.zjzwfw.gov.cn"],
      });

      aplus_queue.push({
        action: "aplus.setMetaInfo",
        arguments: ["aplus-rhost-g", "alog.zjzwfw.gov.cn"],
      });

      aplus_queue.push({
        action: "aplus.setMetaInfo",
        arguments: ["appId", "60506758"],
      });
      aplus_queue.push({
        action: "aplus.sendPV",
        arguments: [
          {
            is_auto: false,
          },
          {
            // ⾃定义PV参数key-value键值对(只能是这种平铺的json,不能做多层嵌套), 如:
            miniAppId: "",
            miniAppName: "",
            long: this.longitude,
            lati: this.latitude,
            userType: 1,//个人
          },
        ],
      });
    },
    setUserAplus() {
      console.log("用户信息埋点");
      (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://d.alicdn.com/alilog/mlog/aplus.js?id=202951085";
        f.parentNode.insertBefore(j, f);
      })(window, document, "script", "aplus_queue");
      aplus_queue.push({
        action: "aplus.setMetaInfo",
        arguments: ["aplus-waiting", "MAN"],
      });

      aplus_queue.push({
        action: "aplus.setMetaInfo",
        arguments: ["aplus-rhost-v", "alog.zjzwfw.gov.cn"],
      });

      aplus_queue.push({
        action: "aplus.setMetaInfo",
        arguments: ["aplus-rhost-g", "alog.zjzwfw.gov.cn"],
      });

      aplus_queue.push({
        action: "aplus.setMetaInfo",
        arguments: ["appId", "60506758"],
      });
      aplus_queue.push({
        action: "aplus.setMetaInfo",
        arguments: ["_user_nick", this.username],
      });

      aplus_queue.push({
        action: "aplus.setMetaInfo",
        arguments: ["_user_id", this.userid],
      });

      // 如采集⽤户信息是异步⾏为需要先执⾏这个BLOCK埋点
      //  aplus_queue.push({
      //      action: 'aplus.setMetaInfo',
      //       arguments: ['_hold', 'BLOCK']
      //      });

      // // 单⻚应⽤路由切换后 或 在异步获取到pv⽇志所需的参数后再执⾏sendPV:
      aplus_queue.push({
        action: "aplus.sendPV",
        arguments: [
          {
            is_auto: false,
          },
          {
            // ⾃定义PV参数key-value键值对(只能是这种平铺的json,不能做多层嵌套), 如:
            miniAppId: "",
            miniAppName: "",
            long: this.longitude,
            lati: this.latitude,
            userType: 1,
          },
        ],
      });
      // 如采集⽤户信息是异步⾏为,需要先设置完⽤户信息后再执⾏这个START埋点
      // 此时被block住的⽇志会携带上⽤户信息逐条发出
      //  aplus_queue.push({
      //      action: 'aplus.setMetaInfo',
      //      arguments: ['_hold', 'START']
      //     });
    },

如果 项目需要用户单点登录操作的话需要在
获取用户信息接口中采取埋点
为确保埋点
也可以在首页去再进行一次基础埋点

    checkTicket(value) {
      console.log("获取个人信息");
      let that = this;
      this.$mgop({
        api: "mgop.wasu.cloudjob.zlb0loginPersonal", // 必须
        host: "https://mapi.zjzwfw.gov.cn/",
        dataType: "JSON",
        type: "GET",
        timeout: 5000,
        data: {
          ticket: value,
        },
        appKey: "v3253ah0+2001895577+hnxtpy", // 必须
        //标示请求应用。可以通过应用开放平台获取
        header: {
          "X-Access-Token": "",
        },
        onSuccess: (res) => {
          console.log("请求参数-----:", { ticket: value });
          console.log("返回参数123:", res);
          if (res.data.success) {
            ZWJSBridge.setLocalStorage({
              key: "token",
              value: res.data.result.token,
            });
            ZWJSBridge.setLocalStorage({
              key: "idCard",
              value: res.data.result.idCard,
            });
            ZWJSBridge.setLocalStorage({
              key: "username",
              value: res.data.result.username,
            });
            ZWJSBridge.getLocalStorage({ key: "idCard" }).then((r) => {
              this.idCard = r.idCard;
            });
            ZWJSBridge.getLocalStorage({ key: "username" }).then((r) => {
              this.username = r.username;
            });
            getApp().globalData.token = res.data.result.token;
            this.userid = res.data.result.userid;
            ZWJSBridge.getLocation()
              .then((result) => {
                console.log(result);
                that.latitude = result.latitude;
                that.longitude = result.longitude;
                that.setUserAplus();
              })
              .catch((error) => {
                console.log(error);
              });

            that.getStudentTotal();
            that.getTalentTotal();
          } else {
            ZWJSBridge.getLocation()
              .then((result) => {
                console.log(result);
                that.latitude = result.latitude;
                that.longitude = result.longitude;
                that.setAplus();
              })
              .catch((error) => {
                console.log(error);
              });

            if (res.data.message == 1) {
              //用户登录超时需要重新登录
              uni.showToast({
                title: "用户登录超时,请重新登录",
                icon: "none",
                success: function (result) {
                  setTimeout(() => {
                    uni.navigateTo({
                      url: "../../notLogin/index",
                    });
                  }, 1000);
                },
              });
            } else if (res.data.message == 2) {
              //用户认证等级不足需要提高认证级别
              uni.showToast({
                title: "用户认证等级不足,请提高认证级别",
                icon: "none",
                success: function (result) {
                  let url =
                    "http://";
                  setTimeout(() => {
                    that.goto(url);
                  }, 1000);
                },
              });
            } else {
              uni.showToast({
                title: "无法使用",
                icon: "none",
                success: function (result) {
                  setTimeout(() => {
                    that.goto("../../notLogin/index");
                  }, 1000);
                },
              });
            }
          }
        },
        onFail: (err) => {
          console.log(err, "errerrererer");
          uni.showToast({
            title: err.ret,
            icon: "error",
            success: function (result) {
              uni.navigateTo({
                url: "../../notLogin/index",
              });
            },
          });
        },
      });
    },

over

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值