analytics.js
3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import {LOG_EVENT_HOST} from '../libs/config';
import {UPLOAD_LOG} from '../libs/request';
import {getYHStorageSync} from '../utils/util';
const YB_ENTER_FOREGROUND = 'YB_ENTER_FOREGROUND';
const YB_ENTER_BACKGROUND = 'YB_ENTER_BACKGROUND';
const YB_LAUNCH_APP = 'YB_LAUNCH_APP';
const YB_EXIT_APP = 'YB_EXIT_APP';
const YB_PAGE_OPEN_L = 'YB_PAGE_OPEN_L';
const YB_MAIN_TAB_C = 'YB_MAIN_TAB_C';
const YB_MY_LOGIN = 'YB_MY_LOGIN';
const YB_REGISTER_SUCCESS = 'YB_REGISTER_SUCCESS';
const YB_AWAKE_MP = 'YB_AWAKE_MP';
const YB_GRP_BUY_DT_TOG_C = 'YB_GRP_BUY_DT_TOG_C';
const YB_MAIN_POP_UP_C = 'YB_MAIN_POP_UP_C';
let logEvent = function (eventId, data, appData) {
let app = appData ? appData : getApp();
let ln;//语言
let os;//系统类型
let dm;//设备型号
let re;//屏幕大小
let osv;//系统版本
let ak = 'yoholuck_mp';//
let net = '0';
let ts = new Date().getTime() + '';
//用户id
let uid = app && app.globalData && app.globalData.userInfo && app.globalData.userInfo.uid ? app.globalData.userInfo.uid : '';
//设备id
let udid = app && app.globalData && app.globalData.udid ? app.globalData.udid : '';
//会话id
let sid = app && app.globalData && app.globalData.sid ? app.globalData.sid : '';
let cid = app && app.globalData && app.globalData.cid ? app.globalData.cid : '';
let open_id = app && app.globalData && app.globalData.openID ? app.globalData.openID : getYHStorageSync('openID', 'analytics');
let union_id = app && app.globalData && app.globalData.WXUnion_ID ? app.globalData.WXUnion_ID : getYHStorageSync('unionID', 'analytics');
let ch = app && app.globalData && app.globalData.ch ? app.globalData.ch : '';
wx.getSystemInfo({
success: function (res) {
//返回设备信息
dm = res.model;
ln = res.language;
os = res.platform;
osv = res.system;
re = res.screenWidth + '*' + res.screenHeight;
},
complete: function () {
wx.getNetworkType({
success: function (res) {
var networkType = res.networkType
if (networkType === 'wifi') {
net = '1';
} else if (networkType === '2g') {
net = '2';
} else if (networkType === '3g') {
net = '3';
} else if (networkType === '4g') {
net = '4';
} else {
net = '0';
}
},
complete: function () {
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 !== '' ? union_type + "" : ch + ""
};
let userParam = data;
userParam.C_ID = cid;
userParam.UNION_ID = union_id;
let eventParam = [{'param': userParam, 'ts': ts, 'op': eventId, 'uid': uid, 'sid': sid}]
let parameters = {'status': statusParam, 'device': deviceParam, 'events': eventParam}
UPLOAD_LOG(LOG_EVENT_HOST, parameters)
.then(function (data) {
})
.catch(function (error) {
});
}
})
}
})
};
export {
logEvent,
YB_ENTER_FOREGROUND,
YB_ENTER_BACKGROUND,
YB_LAUNCH_APP,
YB_EXIT_APP,
YB_PAGE_OPEN_L,
YB_MAIN_TAB_C,
YB_MY_LOGIN,
YB_REGISTER_SUCCESS,
YB_AWAKE_MP,
YB_GRP_BUY_DT_TOG_C,
YB_MAIN_POP_UP_C
};