wangweianger/zanePerfor

addData :上报时自定义的数据

xiejunping opened this issue · 1 comments

接口传入的参数,服务端没有做保存,现在发现无法使用,请求作者解惑

router.afterEach(to => {
  const account = Cookies.get('ch_op_id')
  const name = Cookies.get('ch_op_name')
  if (process.env.NODE_ENV === 'production') {
    Performance.addData(data => {
      data.id = account
      data.name = name
    })
  }
})

{"time":1610518435515,"addData":{"id":"12019","name":"chengli"},"markUser":"YRy18ZGSJx1610510064329","markUv":"FFGFhM77jS1610507282054","type":1,"url":"https://tiangong.caohua.com/create/tencentlocal/plan","preUrl":"","errorList":[],"performance":{"dnst":0,"tcpt":0,"wit":54,"domt":367,"lodt":881,"radt":46,"rdit":0,"uodt":0,"reqt":29,"andt":515},.....

上报成功了,但是查这个文件,没有写入数据库,mongodb没有这个字段
service report_task.js

   // 数据操作层
    async handleData(query) {
        const type = query.type || 1;

        let item = {
            app_id: query.appId,
            create_time: new Date(query.time),
            user_agent: query.user_agent,
            ip: query.ip,
            mark_page: query.markPage || this.app.randomString(),
            mark_user: query.markUser || '',
            mark_uv: query.markUv || '',
            url: query.url,
        };

        if (type === 1) {
            // 页面级性能
            if (typeof query.isFristIn !== 'boolean') query.isFristIn = false;
            item = Object.assign(item, {
                is_first_in: query.isFristIn ? 2 : 1,
                pre_url: query.preUrl,
                performance: query.performance,
                error_list: query.errorList,
                resource_list: query.resourceList,
                screenwidth: query.screenwidth,
                screenheight: query.screenheight,
            });
        } else if (type === 2 || type === 3) {
            // AJAX性能
            item = Object.assign(item, {
                error_list: query.errorList,
                resource_list: query.resourceList,
            });
        }
        return item;
    }

手动改源码,实现了,也做了个统计脚 本,
image

需要的联系交流