Skip to content

addData :上报时自定义的数据 #51

Open
@xiejunping

Description

@xiejunping

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

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;
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions