visual-buried-point-platform-uni 1.0.0-alpha.3 → 1.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +14 -13
- package/package.json +2 -2
- package/tools.js +33 -31
package/index.js
CHANGED
|
@@ -29,6 +29,8 @@ let _config = {
|
|
|
29
29
|
srcDomain: "",
|
|
30
30
|
flushInterval: 15,
|
|
31
31
|
};
|
|
32
|
+
//custom
|
|
33
|
+
let timer = null;
|
|
32
34
|
//track upload interval
|
|
33
35
|
let tInterval = null;
|
|
34
36
|
let busObj = null;
|
|
@@ -127,18 +129,20 @@ export function setCustomEvent(data) {
|
|
|
127
129
|
};
|
|
128
130
|
if (reportData) {
|
|
129
131
|
addCache(reportData);
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
clearTimeout(timer);
|
|
133
|
+
timer = setTimeout(() => {
|
|
134
|
+
const data = getCache();
|
|
135
|
+
if (data.length) {
|
|
136
|
+
addSData(data);
|
|
137
|
+
clearCache();
|
|
138
|
+
}
|
|
139
|
+
}, 1000);
|
|
136
140
|
}
|
|
137
141
|
}
|
|
138
142
|
|
|
139
143
|
function reportCustom(data) {
|
|
140
144
|
if (!reportUrl) {
|
|
141
|
-
|
|
145
|
+
console.error("please set upload data reportUrl");
|
|
142
146
|
return;
|
|
143
147
|
}
|
|
144
148
|
const comData = commonData(data);
|
|
@@ -259,7 +263,7 @@ function commonData(allData) {
|
|
|
259
263
|
return {
|
|
260
264
|
app: appData,
|
|
261
265
|
data: allData,
|
|
262
|
-
|
|
266
|
+
device: deviceData,
|
|
263
267
|
lsi: localLsi,
|
|
264
268
|
projectId: _config.token,
|
|
265
269
|
userAgent: uAgent ? uAgent : "",
|
|
@@ -288,7 +292,7 @@ function getBaseicInfo() {
|
|
|
288
292
|
platform = "wx";
|
|
289
293
|
appData = wxInfo();
|
|
290
294
|
}
|
|
291
|
-
deviceData = getDeviceInfo(res);
|
|
295
|
+
deviceData = getDeviceInfo(res, platform);
|
|
292
296
|
},
|
|
293
297
|
fail: function (error) {
|
|
294
298
|
deviceData = getDeviceInfoError();
|
|
@@ -296,10 +300,7 @@ function getBaseicInfo() {
|
|
|
296
300
|
complete: function () {
|
|
297
301
|
uni.getNetworkType({
|
|
298
302
|
success(res) {
|
|
299
|
-
deviceData =
|
|
300
|
-
...deviceData,
|
|
301
|
-
network: res.networkType,
|
|
302
|
-
};
|
|
303
|
+
deviceData.network = res.networkType;
|
|
303
304
|
},
|
|
304
305
|
});
|
|
305
306
|
},
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "visual-buried-point-platform-uni",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
4
|
-
"lsi": "
|
|
3
|
+
"version": "1.0.0-alpha.05",
|
|
4
|
+
"lsi": "50ba3c2ac38fa587d3ff435ae1a0fb21",
|
|
5
5
|
"description": "To make it easy for you to get started with GitLab, here's a list of recommended next steps.",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"scripts": {
|
package/tools.js
CHANGED
|
@@ -65,10 +65,13 @@ export function webH5Info(result) {
|
|
|
65
65
|
//微信的appInfo
|
|
66
66
|
export function wxInfo() {
|
|
67
67
|
let accInfo = uni.getAccountInfoSync();
|
|
68
|
+
console.log("baseinfo " + JSON.stringify(uni.getAppBaseInfo()));
|
|
68
69
|
return {
|
|
69
70
|
name: "",
|
|
70
|
-
packageName: accInfo ? accInfo.appId : "",
|
|
71
|
-
version: accInfo
|
|
71
|
+
packageName: accInfo ? accInfo.miniProgram.appId : "",
|
|
72
|
+
version: accInfo
|
|
73
|
+
? accInfo.miniProgram.envVersion + accInfo.miniProgram.version
|
|
74
|
+
: "",
|
|
72
75
|
carrier: "mini",
|
|
73
76
|
ecology: "wechat",
|
|
74
77
|
};
|
|
@@ -81,6 +84,8 @@ export function getAppInfo(result) {
|
|
|
81
84
|
name: result.appName,
|
|
82
85
|
version: version ? version : "",
|
|
83
86
|
carrier: "app",
|
|
87
|
+
packageName: "",
|
|
88
|
+
ecology: "",
|
|
84
89
|
};
|
|
85
90
|
if (result.platform === "android") {
|
|
86
91
|
let osName = "android";
|
|
@@ -88,47 +93,44 @@ export function getAppInfo(result) {
|
|
|
88
93
|
if (result.romName.includes("HarmonyOS")) {
|
|
89
94
|
osName = "harmonyOS";
|
|
90
95
|
}
|
|
91
|
-
app =
|
|
92
|
-
|
|
93
|
-
packageName: pkName ? pkName : "",
|
|
94
|
-
ecology: osName,
|
|
95
|
-
};
|
|
96
|
+
app.packageName = pkName ? pkName : "";
|
|
97
|
+
app.ecology = osName;
|
|
96
98
|
} else if (result.platform === "ios") {
|
|
97
99
|
let pkName = plus.ios
|
|
98
100
|
.importClass("NSBundle")
|
|
99
101
|
.mainBundle()
|
|
100
102
|
.bundleIdentifier();
|
|
101
|
-
app =
|
|
102
|
-
|
|
103
|
-
packageName: pkName ? pkName : "",
|
|
104
|
-
ecology: "ios",
|
|
105
|
-
};
|
|
103
|
+
app.packageName = pkName ? pkName : "";
|
|
104
|
+
app.ecology = "ios";
|
|
106
105
|
} else {
|
|
107
|
-
app =
|
|
108
|
-
...app,
|
|
109
|
-
packageName: "",
|
|
110
|
-
version: "",
|
|
111
|
-
ecology: "unknown",
|
|
112
|
-
};
|
|
106
|
+
app.ecology = "unknown";
|
|
113
107
|
}
|
|
114
108
|
return app;
|
|
115
109
|
}
|
|
116
110
|
|
|
117
|
-
function getCurDeviceType(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
111
|
+
function getCurDeviceType(res, platform) {
|
|
112
|
+
if (platform !== "wx") {
|
|
113
|
+
const userAgent = res.ua.toLowerCase();
|
|
114
|
+
if (/(windows|win32|win64|wow64)/.test(userAgent)) {
|
|
115
|
+
return 1;
|
|
116
|
+
} else if (/(linux|android)/.test(userAgent)) {
|
|
117
|
+
return 2;
|
|
118
|
+
} else if (/(macintosh|mac os x|iphone|ipad|ipod)/.test(userAgent)) {
|
|
119
|
+
return 2;
|
|
120
|
+
} else {
|
|
121
|
+
return 2;
|
|
122
|
+
}
|
|
125
123
|
} else {
|
|
126
|
-
|
|
124
|
+
if (res.deviceType === "pc") {
|
|
125
|
+
return 2;
|
|
126
|
+
} else {
|
|
127
|
+
return 1;
|
|
128
|
+
}
|
|
127
129
|
}
|
|
128
130
|
}
|
|
129
131
|
|
|
130
132
|
//获取设备信息
|
|
131
|
-
export function getDeviceInfo(res) {
|
|
133
|
+
export function getDeviceInfo(res, platform) {
|
|
132
134
|
let device = {
|
|
133
135
|
lang: res.osLanguage ? res.osLanguage : res.hostLanguage,
|
|
134
136
|
brand: res.deviceBrand + " " + res.deviceModel,
|
|
@@ -139,7 +141,7 @@ export function getDeviceInfo(res) {
|
|
|
139
141
|
browserVersion: res.browserVersion,
|
|
140
142
|
color: "",
|
|
141
143
|
deviceId: res.deviceId,
|
|
142
|
-
deviceType: getCurDeviceType(res
|
|
144
|
+
deviceType: getCurDeviceType(res, platform),
|
|
143
145
|
network: "",
|
|
144
146
|
};
|
|
145
147
|
return device;
|
|
@@ -174,8 +176,8 @@ export function getTrackObj(busObj) {
|
|
|
174
176
|
url: busObj.url ? busObj.url : "",
|
|
175
177
|
circulation: gcp.length > 1 ? 2 : 1,
|
|
176
178
|
visitPage: gcp.length,
|
|
177
|
-
sourceDomain: busObj.sourceDomain? busObj.sourceDomain : "",
|
|
178
|
-
sourceUrl: busObj.sourceUrl? busObj.sourceUrl : "",
|
|
179
|
+
sourceDomain: busObj.sourceDomain ? busObj.sourceDomain : "",
|
|
180
|
+
sourceUrl: busObj.sourceUrl ? busObj.sourceUrl : "",
|
|
179
181
|
title: busObj.title ? busObj.title : "",
|
|
180
182
|
};
|
|
181
183
|
}
|