visual-buried-point-platform-uni 1.0.0-alpha.6 → 1.0.0-alpha.7
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/README.md +2 -7
- package/index.js +5 -17
- package/package.json +2 -2
- package/tools.js +18 -4
package/README.md
CHANGED
|
@@ -3,16 +3,13 @@
|
|
|
3
3
|
### 1、引入方式
|
|
4
4
|
|
|
5
5
|
```js
|
|
6
|
-
npm
|
|
7
|
-
|
|
6
|
+
//内网npm链接:http://verdaccio.gogdev.cn/
|
|
7
|
+
npm install visual-buried-point-platform-uni
|
|
8
8
|
```
|
|
9
9
|
|
|
10
10
|
### 2、初始化方式
|
|
11
11
|
|
|
12
|
-
**app.js**
|
|
13
|
-
|
|
14
12
|
```js
|
|
15
|
-
//require引入
|
|
16
13
|
import { init } from 'visual-buried-point-platform-uni'
|
|
17
14
|
onLaunch: function() {
|
|
18
15
|
//初始化sdk
|
|
@@ -47,8 +44,6 @@ setUserId(123456);
|
|
|
47
44
|
setUserId("");
|
|
48
45
|
```
|
|
49
46
|
|
|
50
|
-
|
|
51
|
-
|
|
52
47
|
### 4、自定义事件上报
|
|
53
48
|
|
|
54
49
|
- sdk初始化后,可通过 ***setCustomEvent()*** 方法上报自定义埋点事件,并为事件添加属性值:
|
package/index.js
CHANGED
|
@@ -11,6 +11,8 @@ import {
|
|
|
11
11
|
getDeviceInfoError,
|
|
12
12
|
timeToStr,
|
|
13
13
|
getTrackObj,
|
|
14
|
+
getCurPath,
|
|
15
|
+
getUrl,
|
|
14
16
|
} from "./tools.js";
|
|
15
17
|
import { setReportUrl } from "./config.js";
|
|
16
18
|
|
|
@@ -81,7 +83,6 @@ function startGlobalTime() {
|
|
|
81
83
|
clearInterval(cInterval);
|
|
82
84
|
cInterval = setInterval(() => {
|
|
83
85
|
let cData = getSData();
|
|
84
|
-
// console.log("storage data " + JSON.stringify(cData));
|
|
85
86
|
if (cData) {
|
|
86
87
|
reportCustom(cData);
|
|
87
88
|
delSData();
|
|
@@ -119,13 +120,13 @@ export function setCustomEvent(data) {
|
|
|
119
120
|
pageId: MD5(_path),
|
|
120
121
|
path: _path,
|
|
121
122
|
title: _page.title ? _page.title : "",
|
|
123
|
+
url: _path ? _path : getUrl(platform),
|
|
122
124
|
},
|
|
123
125
|
path: data.$path ? data.$path : "",
|
|
124
126
|
properties: data.$extend_param ? JSON.stringify(data.$extend_param) : "",
|
|
125
127
|
traceId: "",
|
|
126
128
|
trackId: trackId,
|
|
127
129
|
triggerTime: timeToStr(Date.now()),
|
|
128
|
-
url: url,
|
|
129
130
|
};
|
|
130
131
|
if (reportData) {
|
|
131
132
|
addCache(reportData);
|
|
@@ -166,7 +167,7 @@ function reportCustom(data) {
|
|
|
166
167
|
});
|
|
167
168
|
}
|
|
168
169
|
|
|
169
|
-
//track upload
|
|
170
|
+
//track upload-registry
|
|
170
171
|
export function onStartTrack(tData) {
|
|
171
172
|
busObj = null;
|
|
172
173
|
startTime = 0;
|
|
@@ -189,7 +190,7 @@ export function onDestroyTrack() {
|
|
|
189
190
|
|
|
190
191
|
function assemblyTrackData(type) {
|
|
191
192
|
if (busObj) {
|
|
192
|
-
let obj = getTrackObj(busObj);
|
|
193
|
+
let obj = getTrackObj(busObj, platform);
|
|
193
194
|
let trackData = null;
|
|
194
195
|
if (type === "destroy") {
|
|
195
196
|
startTime = (Date.now() - startTimeLong) / 1000;
|
|
@@ -246,19 +247,6 @@ function reportTrack(data) {
|
|
|
246
247
|
});
|
|
247
248
|
}
|
|
248
249
|
|
|
249
|
-
function getCurPath() {
|
|
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 : "/";
|
|
260
|
-
}
|
|
261
|
-
|
|
262
250
|
function commonData(allData) {
|
|
263
251
|
return {
|
|
264
252
|
app: appData,
|
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.07",
|
|
4
|
+
"lsi": "e582f1f81f1398a0441584a6a87e5f80",
|
|
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
|
@@ -164,16 +164,15 @@ export function getDeviceInfoError() {
|
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
|
|
168
|
-
export function getTrackObj(busObj) {
|
|
169
|
-
//uni 通用h5、app、wx拿到当前路由栈
|
|
167
|
+
//uni 通用h5、app、wx拿到当前路由栈
|
|
168
|
+
export function getTrackObj(busObj, platform) {
|
|
170
169
|
const pages = getCurrentPages();
|
|
171
170
|
const gcp = pages[pages.length - 1];
|
|
172
171
|
if (gcp) {
|
|
173
172
|
return {
|
|
174
173
|
path: gcp.route,
|
|
175
174
|
domain: busObj.domain ? busObj.domain : "",
|
|
176
|
-
url: busObj.url ? busObj.url :
|
|
175
|
+
url: busObj.url ? busObj.url : getUrl(platform),
|
|
177
176
|
circulation: gcp.length > 1 ? 2 : 1,
|
|
178
177
|
visitPage: gcp.length,
|
|
179
178
|
sourceDomain: busObj.sourceDomain ? busObj.sourceDomain : "",
|
|
@@ -182,3 +181,18 @@ export function getTrackObj(busObj) {
|
|
|
182
181
|
};
|
|
183
182
|
}
|
|
184
183
|
}
|
|
184
|
+
|
|
185
|
+
export function getCurPath() {
|
|
186
|
+
const pages = getCurrentPages();
|
|
187
|
+
const gcp = pages[pages.length - 1];
|
|
188
|
+
return gcp ? gcp.route : "/";
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export function getUrl(platform) {
|
|
192
|
+
if (!platform) return "";
|
|
193
|
+
if (platform === "web" || platform === "h5") {
|
|
194
|
+
return window.location.href;
|
|
195
|
+
} else {
|
|
196
|
+
return "";
|
|
197
|
+
}
|
|
198
|
+
}
|