Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
xiejunping opened this issue Jan 13, 2021 · 1 comment
Open

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

xiejunping opened this issue Jan 13, 2021 · 1 comment

Comments

@xiejunping
Copy link

xiejunping commented Jan 13, 2021

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

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;
    }
@xiejunping
Copy link
Author

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

需要的联系交流

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant