@rk911/tracker-sdk 1.7.4 → 1.7.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.
- package/core/session.js +1 -1
- package/index.js +2 -2
- package/package.json +1 -1
- package/platforms/web.js +16 -1
- package/plugins/api-watch.js +17 -1
- package/plugins/app-lifecycle.js +9 -2
package/core/session.js
CHANGED
|
@@ -152,7 +152,7 @@ export class SessionManager {
|
|
|
152
152
|
this._createNew()
|
|
153
153
|
}
|
|
154
154
|
if (!this.userId) {
|
|
155
|
-
this.userId = this.adapter.getStorage('userId') || null
|
|
155
|
+
this.userId = this.adapter.getStorage('userId') || this.adapter.getStorage('unionid') || null
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
|
package/index.js
CHANGED
|
@@ -211,8 +211,8 @@ function _ensureUserId(tracker) {
|
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
var adapter = tracker.getAdapter()
|
|
214
|
-
//
|
|
215
|
-
var uid = adapter.getStorage('userId')
|
|
214
|
+
// 从源头实时读取(支持 userId 与 unionid 双向兼容)
|
|
215
|
+
var uid = adapter.getStorage('userId') || adapter.getStorage('unionid')
|
|
216
216
|
// 降级:从 cookie 读(rkfeb-userId)
|
|
217
217
|
if (!uid && typeof document !== 'undefined') {
|
|
218
218
|
var match = document.cookie.match(/(?:^|;\s*)rkfeb-userId=([^;]+)/)
|
package/package.json
CHANGED
package/platforms/web.js
CHANGED
|
@@ -3,10 +3,23 @@ export const ROUTE_TITLE_MAP = {
|
|
|
3
3
|
'/pages/circle/index': '银友圈',
|
|
4
4
|
'/pages/circle/circleOfFriends/sendFriends/sendFriends': '发布动态',
|
|
5
5
|
'/pages/circle/circleOfFriends/sendFriends/circleClass/circleClass': '圈子分类',
|
|
6
|
+
'/pages/circle/userHome/otherHome': '个人主页',
|
|
6
7
|
'/healthFu/index/index': '健康福/AI助手',
|
|
8
|
+
'/healthMonitor/pages/index': '健康监测/体检',
|
|
9
|
+
'/videoNote/index/index': '视频笔记',
|
|
10
|
+
'/pagesA/app/videoAnswerList': '答题精选',
|
|
11
|
+
'/pagesA/index/activity/activity': '活动中心',
|
|
12
|
+
'/pagesA/index/game/game': '游戏中心',
|
|
13
|
+
'/pagesA/member/videoRanking': '视频排行榜',
|
|
14
|
+
'/pages/VoicePunchIn/VoicePunchIn': '语音打卡',
|
|
15
|
+
'/taskCenter/index/index': '任务中心',
|
|
16
|
+
'/yangji/index/index': '福利活动',
|
|
7
17
|
'/pages/mall/goods/goodsList': '商品列表',
|
|
18
|
+
'/pages/mall/goods/goodsInfo': '商品详情',
|
|
8
19
|
'/pages/mall/goods/goodsDetail': '商品详情',
|
|
9
20
|
'/pages/mall/goods/order': '商品下单',
|
|
21
|
+
'/pages/mall/searchGoods/searchGoods': '商品搜索',
|
|
22
|
+
'/pages/mall/goods/shopAddressList': '收货地址',
|
|
10
23
|
'/pages/my/store/index': '我的小店',
|
|
11
24
|
'/pages/my/store/withdrawalList': '提现记录',
|
|
12
25
|
'/pages/integralMall/integralMall': '积分商城',
|
|
@@ -235,8 +248,10 @@ export class WebAdapter {
|
|
|
235
248
|
try {
|
|
236
249
|
const info = uni.getSystemInfoSync()
|
|
237
250
|
var ua = (typeof navigator !== 'undefined' ? navigator.userAgent : '').toLowerCase()
|
|
251
|
+
var rawBrand = info.brand || this._judgeBrand(ua, info.model) || ''
|
|
252
|
+
var brand = rawBrand.toUpperCase() === 'OPPO' ? 'OPPO' : rawBrand
|
|
238
253
|
return {
|
|
239
|
-
brand:
|
|
254
|
+
brand: brand,
|
|
240
255
|
model: info.model || '',
|
|
241
256
|
platform: (info.platform || '').toLowerCase() === 'android' ? 'Android' : (info.platform || ''),
|
|
242
257
|
system: (info.system || '').toLowerCase().startsWith('android') ? ('Android ' + (info.system.split(' ')[1] || '')) : (info.system || ''),
|
package/plugins/api-watch.js
CHANGED
|
@@ -94,6 +94,21 @@ export class ApiWatchPlugin {
|
|
|
94
94
|
)
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
_extractApiPath(url) {
|
|
98
|
+
if (!url || typeof url !== 'string') return ''
|
|
99
|
+
try {
|
|
100
|
+
var clean = url.split('?')[0]
|
|
101
|
+
var schemeIdx = clean.indexOf('://')
|
|
102
|
+
if (schemeIdx >= 0) {
|
|
103
|
+
var pathIdx = clean.indexOf('/', schemeIdx + 3)
|
|
104
|
+
if (pathIdx >= 0) return clean.substring(pathIdx)
|
|
105
|
+
}
|
|
106
|
+
return clean
|
|
107
|
+
} catch (e) {
|
|
108
|
+
return url
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
97
112
|
_setupWebInterceptors() {
|
|
98
113
|
var self = this
|
|
99
114
|
|
|
@@ -244,8 +259,9 @@ export class ApiWatchPlugin {
|
|
|
244
259
|
data.error = err.errMsg || String(err)
|
|
245
260
|
}
|
|
246
261
|
|
|
262
|
+
var apiPath = this._extractApiPath(data.url)
|
|
247
263
|
this.tracker.track('api_request', {
|
|
248
|
-
eventName: data.url,
|
|
264
|
+
eventName: apiPath || data.url,
|
|
249
265
|
extraData: data,
|
|
250
266
|
})
|
|
251
267
|
}
|
package/plugins/app-lifecycle.js
CHANGED
|
@@ -4,6 +4,7 @@ export class AppLifecyclePlugin {
|
|
|
4
4
|
this.tracker = null
|
|
5
5
|
this._visibilityHandler = null
|
|
6
6
|
this._lastState = 'foreground'
|
|
7
|
+
this._lastToggleTime = 0
|
|
7
8
|
this._debounceTimer = null
|
|
8
9
|
}
|
|
9
10
|
|
|
@@ -26,27 +27,33 @@ export class AppLifecyclePlugin {
|
|
|
26
27
|
this._visibilityHandler = function () {
|
|
27
28
|
var state = document.visibilityState
|
|
28
29
|
if (state === 'hidden') {
|
|
29
|
-
// 延迟
|
|
30
|
+
// 延迟 800ms 上报,防窗口焦点抖动与后台 Tab 惊群
|
|
30
31
|
if (self._debounceTimer) {
|
|
31
32
|
clearTimeout(self._debounceTimer)
|
|
32
33
|
}
|
|
33
34
|
self._debounceTimer = setTimeout(function () {
|
|
34
35
|
self._debounceTimer = null
|
|
36
|
+
var now = Date.now()
|
|
37
|
+
if (now - self._lastToggleTime < 2000) return
|
|
35
38
|
if (self._lastState !== 'background') {
|
|
36
39
|
self._lastState = 'background'
|
|
40
|
+
self._lastToggleTime = now
|
|
37
41
|
self.tracker.track('app_lifecycle', {
|
|
38
42
|
eventName: 'background',
|
|
39
43
|
})
|
|
40
44
|
self.tracker.getQueue().flush()
|
|
41
45
|
}
|
|
42
|
-
},
|
|
46
|
+
}, 800)
|
|
43
47
|
} else if (state === 'visible') {
|
|
44
48
|
if (self._debounceTimer) {
|
|
45
49
|
clearTimeout(self._debounceTimer)
|
|
46
50
|
self._debounceTimer = null
|
|
47
51
|
}
|
|
52
|
+
var now = Date.now()
|
|
53
|
+
if (now - self._lastToggleTime < 2000) return
|
|
48
54
|
if (self._lastState !== 'foreground') {
|
|
49
55
|
self._lastState = 'foreground'
|
|
56
|
+
self._lastToggleTime = now
|
|
50
57
|
self.tracker.track('app_lifecycle', {
|
|
51
58
|
eventName: 'foreground',
|
|
52
59
|
})
|