Authored by yyq

report

... ... @@ -31,16 +31,35 @@ export function createApp(context) {
return false;
},
methods: {
getAnalyticAppData() {
return new Promise(resolve => {
if (this._updated) {
return resolve();
}
this.$yoho.getAnalyticAppData('', data => {
this._updated = true;
reportApp.updateDeviceInfo(data);
resolve();
});
setTimeout(function () {
resolve();
}, 500);
});
},
async reportApp(type, pn, params = {}, pt) {
let user = await this.$sdk.getUser();
if (!params.ei) {
params.ei = get(this.$router, 'history.current.name', '');
await this.getAnalyticAppData();
if (!params.mst) {
params.mst = get(this.$router, 'history.current.name', '');
}
reportApp.report(type, pt || 'BUSINESS', pn, params, get(user, 'uid'));
},
reportAppStart() {
this.reportApp('start', 'BUSINESS_PLAN_A_ENTER', {locfun: 'mounted'});
this.reportApp('', 'BUSINESS_PLAN_A_ENTER', {locfun: 'mounted'});
}
},
render: h => h(App)
... ...
... ... @@ -20,6 +20,24 @@ export default class reportApp {
host: '',
locfun: ''
};
this.device = {
ak: `yohobuy_${params.isiOS ? 'ios' : 'android'}${params.isApp ? '' : '_h5'}`,
udid: params.udid || '',
ch: '',
os: params.isiOS ? 'IOS' : 'Android',
osv: params.osVersion,
dm: '',
};
}
updateDeviceInfo(info = {}) {
info.ch && (this.device.ch = info.ch);
info.dm && (this.device.dm = info.dm);
info.udid && (this.device.udid = info.udid);
info.av && (this.events.av = info.av);
info.ab && (this.events.ab = info.ab);
info.sid && (this.events.sid = info.sid);
}
report(type, pt, pn, params = {}, uid = 0) {
if (!this.isProd) {
... ... @@ -40,8 +58,8 @@ export default class reportApp {
url: '',
method: 'POST',
data: {
type,
device: {},
type: '',
device: this.device,
events: [
Object.assign({
uid: uid,
... ...
... ... @@ -574,6 +574,18 @@ const yoho = {
// tip(tipInfo);
}
},
getAnalyticAppData(args, success, fail) {
if (this.isYohoBuy && window.yohoInterface) {
window.yohoInterface.triggerEvent(success || nullFun, fail || nullFun, {
method: 'get.analyticAppData',
arguments: args
});
} else {
// tip(tipInfo);
}
}
};
... ...
... ... @@ -96,7 +96,7 @@ export default {
this.$yoho.goPage('go.ufo', { pagename: 'MerchantEntry' });
}
this.$root.reportApp('hb', 'BUSINESS_PLAN_A_EVENT', {
this.$root.reportApp('', 'BUSINESS_PLAN_A_EVENT', {
locfun: 'click:storeNow'
});
}
... ...
... ... @@ -87,9 +87,6 @@ export default {
this.fetchBankList();
}
this.$root.reportAppStart();
this.$root.reportApp('hb', 'BUSINESS_PLAN_A_EVEVT', {
locfun: 'click:bindBankCard'
});
},
computed: {
...mapState(['banks', 'bankCardList']),
... ... @@ -182,7 +179,7 @@ export default {
}
},
bindBankCardInfo(info) {
this.$root.reportApp('hb', 'BUSINESS_PLAN_A_EVENT', {
this.$root.reportApp('', 'BUSINESS_PLAN_A_EVENT', {
locfun: 'click:bindBankCard'
});
... ...
... ... @@ -12,6 +12,7 @@ export default {
name: 'cardList',
mounted() {
this.$refs.cards.init();
this.$root.reportAppStart();
},
components: {
... ...
... ... @@ -56,6 +56,14 @@ module.exports = (req, res, next) => {
// client ip
req.yoho.clientIp = _getClientIp(req);
if (req.yoho.isApp) {
req.yoho.udid = _.get(req, 'query.udid', '');
}
if (!req.yoho.udid) {
req.yoho.udid = _.get(req, 'cookies.udid', '');
}
Object.assign(res.locals, req.yoho);
next();
... ...
... ... @@ -12,7 +12,7 @@ const {createBundleRenderer} = require('vue-server-renderer');
const logger = global.yoho.logger;
const config = global.yoho.config;
const isProd = process.env.NODE_ENV === 'production';
const isProd = true || process.env.NODE_ENV === 'production';
const isDev = process.env.NODE_ENV === 'development' || !process.env.NODE_ENV;
let renderer;
... ... @@ -40,14 +40,16 @@ const getContext = (req) => {
title: '',
user: req.user,
env: {
udid: req.yoho.udid,
isApp: req.yoho.isApp,
isiOS: req.yoho.isiOS,
isAndroid: req.yoho.isAndroid,
isYohoApp: req.yoho.isYohoApp,
clientIp: req.yoho.clientIp,
version: pkg.version,
version: req.query.app_version || pkg.version,
osVersion: req.query.os_version || '',
buildId: req.app.locals.buildId,
visitId: md5(`${req.query.udid}_${new Date().getTime()}`)
visitId: md5(`${req.yoho.udid}_${new Date().getTime()}`)
},
ua: req.get('user-agent'),
hostname: os.hostname(),
... ...