visual-buried-point-platform-uni 1.0.0-alpha.1 → 1.0.0-alpha.3

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 +18 -19
  2. package/package.json +2 -2
  3. package/tools.js +5 -32
package/index.js CHANGED
@@ -74,14 +74,14 @@ export function init(config) {
74
74
  startGlobalTime();
75
75
  }
76
76
 
77
- //the general custom report interval is enabled
77
+ //the general custom reportCustom interval is enabled
78
78
  function startGlobalTime() {
79
79
  clearInterval(cInterval);
80
80
  cInterval = setInterval(() => {
81
81
  let cData = getSData();
82
- console.log("storage data " + cData);
82
+ console.log("storage data " + JSON.stringify(cData));
83
83
  if (cData) {
84
- report(cData);
84
+ reportCustom(cData);
85
85
  delSData();
86
86
  }
87
87
  }, _config.flushInterval * 1000);
@@ -129,13 +129,14 @@ export function setCustomEvent(data) {
129
129
  addCache(reportData);
130
130
  const data = getCache();
131
131
  if (data.length) {
132
+ console.log("customData: ", JSON.stringify(data));
132
133
  addSData(data);
133
134
  clearCache();
134
135
  }
135
136
  }
136
137
  }
137
138
 
138
- function report(data) {
139
+ function reportCustom(data) {
139
140
  if (!reportUrl) {
140
141
  //console.error("please set upload data url");
141
142
  return;
@@ -145,21 +146,19 @@ function report(data) {
145
146
  ...comData,
146
147
  dataAbstract: MD5(JSON.stringify(comData)),
147
148
  };
148
- uni.nextTick(function () {
149
- uni.request({
150
- url: reportUrl,
151
- method: "POST",
152
- header: {
153
- "Content-Type": "application/json",
154
- appKey: _config.token,
155
- projectId: _config.token,
156
- },
157
- data: reportData,
158
- success: function (res) {},
159
- fail: function (error) {
160
- console.error(error);
161
- },
162
- });
149
+ uni.request({
150
+ url: reportUrl,
151
+ method: "POST",
152
+ header: {
153
+ "Content-Type": "application/json",
154
+ appKey: _config.token,
155
+ projectId: _config.token,
156
+ },
157
+ data: reportData,
158
+ success: function (res) {},
159
+ fail: function (error) {
160
+ console.error(error);
161
+ },
163
162
  });
164
163
  }
165
164
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "visual-buried-point-platform-uni",
3
- "version": "1.0.0-alpha.01",
4
- "lsi": "e640f6dcca0160bfded7c074ba108e9f",
3
+ "version": "1.0.0-alpha.03",
4
+ "lsi": "9b6bb5e44edfe8d4f2b9bfaad5c392fb",
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
@@ -167,43 +167,16 @@ export function getTrackObj(busObj) {
167
167
  //uni 通用h5、app、wx拿到当前路由栈
168
168
  const pages = getCurrentPages();
169
169
  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
170
  if (gcp) {
186
- let domain = "";
187
- let url = "";
188
- if (busObj.domain) {
189
- domain = busObj.domain;
190
- } else {
191
- domain = wl.hostname ? wl.hostname : "";
192
- }
193
- if (busObj.url) {
194
- url = busObj.url;
195
- } else {
196
- url = wl.href ? wl.href : "";
197
- }
198
171
  return {
199
172
  path: gcp.route,
200
- domain: domain,
201
- url: url,
173
+ domain: busObj.domain ? busObj.domain : "",
174
+ url: busObj.url ? busObj.url : "",
202
175
  circulation: gcp.length > 1 ? 2 : 1,
203
176
  visitPage: gcp.length,
204
- sourceDomain: parsedUrl ? parsedUrl.hostname : "",
205
- sourceUrl: parsedUrl,
206
- title: docTitle ? docTitle : "",
177
+ sourceDomain: busObj.sourceDomain? busObj.sourceDomain : "",
178
+ sourceUrl: busObj.sourceUrl? busObj.sourceUrl : "",
179
+ title: busObj.title ? busObj.title : "",
207
180
  };
208
181
  }
209
182
  }