yas-report.js 1.65 KB
import dataUtils from './data-utils.js';
import api from './api.js';

export const yasReport = async function (eventId = '', data = {}, app) {
  let systemInfo = dataUtils.getGlobalDataByKey('systemInfo');
  let dm = systemInfo.model; //设备型号
  let ln = systemInfo.language;//语言
  let os = systemInfo.platform;//系统类型
  let osv = systemInfo.system;//系统版本
  let re = systemInfo.screenWidth + '*' + systemInfo.screenHeight;//屏幕大小
  let net = await dataUtils.getNetworkType() || '0'
  let ak = dataUtils.getConfig().reportParams.ak;
  let ts = new Date().getTime() + '';
  //用户id
  let uid = dataUtils.getUid();
  //设备id
  let udid = dataUtils.getGlobalDataByKey('udid');
  //会话id
  let sid = dataUtils.getGlobalDataByKey('sid') || '';

  let cid = dataUtils.getConfig().reportParams.cid;

  let union_id = dataUtils.getGlobalDataByKey('WXUnion_ID');

  let union_type = app.getUnion_type();

  let statusParam = { 'net': net, 'ln': ln };
  let deviceParam = { 'res': re, 'osv': osv, 'os': os, 'ak': ak, 'dm': dm, 'udid': udid, 'ch': `${union_type}` };

  let userParam = data;
  userParam.C_ID = cid;
  userParam.UNION_ID = union_id;
  if (eventId == 'YB_REGISTER_SUCCESS') { // 邀新注册
    userParam.UNION_TYPE = union_type
    let source = dataUtils.getGlobalDataByKey('source')
    if (source) {
      userParam.source = source
    }
    dataUtils.setGlobalData('source', '')
  }

  let eventParam = [{ 'param': userParam, 'ts': ts, 'op': eventId, 'uid': uid, 'sid': sid }]
  let parameters = { 'status': statusParam, 'device': deviceParam, 'events': eventParam }

  api.uploadLog(parameters)

}