visual-buried-point-platform-uni 1.0.0-alpha.2 → 1.0.0-alpha.4

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.
Files changed (3) hide show
  1. package/index.js +2 -5
  2. package/package.json +2 -2
  3. package/tools.js +18 -29
package/index.js CHANGED
@@ -288,7 +288,7 @@ function getBaseicInfo() {
288
288
  platform = "wx";
289
289
  appData = wxInfo();
290
290
  }
291
- deviceData = getDeviceInfo(res);
291
+ deviceData = getDeviceInfo(res, platform);
292
292
  },
293
293
  fail: function (error) {
294
294
  deviceData = getDeviceInfoError();
@@ -296,10 +296,7 @@ function getBaseicInfo() {
296
296
  complete: function () {
297
297
  uni.getNetworkType({
298
298
  success(res) {
299
- deviceData = {
300
- ...deviceData,
301
- network: res.networkType,
302
- };
299
+ deviceData.network = res.networkType;
303
300
  },
304
301
  });
305
302
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "visual-buried-point-platform-uni",
3
- "version": "1.0.0-alpha.02",
4
- "lsi": "f0ca171a9f641657370a83f2f7ed65c7",
3
+ "version": "1.0.0-alpha.04",
4
+ "lsi": "278a70bc53ca1fad0e680e2aa1fe2855",
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
@@ -114,21 +114,25 @@ export function getAppInfo(result) {
114
114
  return app;
115
115
  }
116
116
 
117
- function getCurDeviceType(ua) {
118
- const userAgent = ua.toLowerCase();
119
- if (/(windows|win32|win64|wow64)/.test(userAgent)) {
120
- return 1;
121
- } else if (/(linux|android)/.test(userAgent)) {
122
- return 2;
123
- } else if (/(macintosh|mac os x|iphone|ipad|ipod)/.test(userAgent)) {
124
- return 2;
117
+ function getCurDeviceType(res, platform) {
118
+ if (platform !== "wx") {
119
+ const userAgent = res.ua.toLowerCase();
120
+ if (/(windows|win32|win64|wow64)/.test(userAgent)) {
121
+ return 1;
122
+ } else if (/(linux|android)/.test(userAgent)) {
123
+ return 2;
124
+ } else if (/(macintosh|mac os x|iphone|ipad|ipod)/.test(userAgent)) {
125
+ return 2;
126
+ } else {
127
+ return 2;
128
+ }
125
129
  } else {
126
- return 2;
130
+ return 1;
127
131
  }
128
132
  }
129
133
 
130
134
  //获取设备信息
131
- export function getDeviceInfo(res) {
135
+ export function getDeviceInfo(res, platform) {
132
136
  let device = {
133
137
  lang: res.osLanguage ? res.osLanguage : res.hostLanguage,
134
138
  brand: res.deviceBrand + " " + res.deviceModel,
@@ -139,7 +143,7 @@ export function getDeviceInfo(res) {
139
143
  browserVersion: res.browserVersion,
140
144
  color: "",
141
145
  deviceId: res.deviceId,
142
- deviceType: getCurDeviceType(res.ua),
146
+ deviceType: getCurDeviceType(res, platform),
143
147
  network: "",
144
148
  };
145
149
  return device;
@@ -167,21 +171,6 @@ export function getTrackObj(busObj) {
167
171
  //uni 通用h5、app、wx拿到当前路由栈
168
172
  const pages = getCurrentPages();
169
173
  const gcp = pages[pages.length - 1];
170
- //h5
171
- // let wl = window.location;
172
- // let docTitle = document.title;
173
- // let refurl = document.referrer;
174
- let parsedUrl;
175
- if (refurl) {
176
- parsedUrl = new URL(refurl);
177
- } else {
178
- let busRefUrl = busObj.sourceUrl;
179
- if (busRefUrl) {
180
- parsedUrl = new URL(busRefUrl);
181
- } else {
182
- parsedUrl = "";
183
- }
184
- }
185
174
  if (gcp) {
186
175
  return {
187
176
  path: gcp.route,
@@ -189,9 +178,9 @@ export function getTrackObj(busObj) {
189
178
  url: busObj.url ? busObj.url : "",
190
179
  circulation: gcp.length > 1 ? 2 : 1,
191
180
  visitPage: gcp.length,
192
- sourceDomain: parsedUrl ? parsedUrl.hostname : "",
193
- sourceUrl: parsedUrl,
194
- title: docTitle ? docTitle : "",
181
+ sourceDomain: busObj.sourceDomain ? busObj.sourceDomain : "",
182
+ sourceUrl: busObj.sourceUrl ? busObj.sourceUrl : "",
183
+ title: busObj.title ? busObj.title : "",
195
184
  };
196
185
  }
197
186
  }