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

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 +24 -20
  2. package/package.json +2 -2
  3. package/tools.js +19 -21
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;
@@ -79,7 +81,7 @@ function startGlobalTime() {
79
81
  clearInterval(cInterval);
80
82
  cInterval = setInterval(() => {
81
83
  let cData = getSData();
82
- console.log("storage data " + JSON.stringify(cData));
84
+ // console.log("storage data " + JSON.stringify(cData));
83
85
  if (cData) {
84
86
  reportCustom(cData);
85
87
  delSData();
@@ -123,22 +125,24 @@ export function setCustomEvent(data) {
123
125
  traceId: "",
124
126
  trackId: trackId,
125
127
  triggerTime: timeToStr(Date.now()),
126
- url: "",
128
+ url: url,
127
129
  };
128
130
  if (reportData) {
129
131
  addCache(reportData);
130
- const data = getCache();
131
- if (data.length) {
132
- console.log("customData: ", JSON.stringify(data));
133
- addSData(data);
134
- clearCache();
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
- //console.error("please set upload data url");
145
+ console.error("please set upload data reportUrl");
142
146
  return;
143
147
  }
144
148
  const comData = commonData(data);
@@ -243,23 +247,23 @@ function reportTrack(data) {
243
247
  }
244
248
 
245
249
  function getCurPath() {
246
- if (platform) {
247
- if (platform == "wx") {
248
- let gcp = getCurrentPages();
249
- return gcp ? gcp[gcp.length - 1].route : "/";
250
- } else if (platform == "web") {
251
- return window.location.hostname;
252
- } else if (platform == "android" || platform === "ios") {
253
- return "";
254
- }
255
- }
250
+ // if (platform === "android" || platform === "ios") {
251
+ // return "";
252
+ // } else {
253
+ // const pages = getCurrentPages();
254
+ // const gcp = pages[pages.length - 1];
255
+ // return gcp ? gcp.route : "/";
256
+ // }
257
+ const pages = getCurrentPages();
258
+ const gcp = pages[pages.length - 1];
259
+ return gcp ? gcp.route : "/";
256
260
  }
257
261
 
258
262
  function commonData(allData) {
259
263
  return {
260
264
  app: appData,
261
265
  data: allData,
262
- deviceData: deviceData,
266
+ device: deviceData,
263
267
  lsi: localLsi,
264
268
  projectId: _config.token,
265
269
  userAgent: uAgent ? uAgent : "",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "visual-buried-point-platform-uni",
3
- "version": "1.0.0-alpha.04",
4
- "lsi": "278a70bc53ca1fad0e680e2aa1fe2855",
3
+ "version": "1.0.0-alpha.06",
4
+ "lsi": "dec5c3d85a97a8b63bf1219cbb31be17",
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
@@ -64,11 +64,14 @@ export function webH5Info(result) {
64
64
 
65
65
  //微信的appInfo
66
66
  export function wxInfo() {
67
- let accInfo = uni.getAccountInfoSync();
67
+ const accInfo = uni.getAccountInfoSync();
68
+ const bInfo = uni.getAppBaseInfo();
68
69
  return {
69
- name: "",
70
- packageName: accInfo ? accInfo.appId : "",
71
- version: accInfo ? accInfo.envVersion + accInfo.version : "",
70
+ name: bInfo.appName ? bInfo.appName : "",
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,28 +93,17 @@ export function getAppInfo(result) {
88
93
  if (result.romName.includes("HarmonyOS")) {
89
94
  osName = "harmonyOS";
90
95
  }
91
- app = {
92
- ...app,
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
- ...app,
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
  }
@@ -127,7 +121,11 @@ function getCurDeviceType(res, platform) {
127
121
  return 2;
128
122
  }
129
123
  } else {
130
- return 1;
124
+ if (res.deviceType === "pc") {
125
+ return 2;
126
+ } else {
127
+ return 1;
128
+ }
131
129
  }
132
130
  }
133
131