@rk911/tracker-sdk 1.7.10 → 1.7.12

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 CHANGED
@@ -61,10 +61,6 @@ export class SessionManager {
61
61
  }
62
62
 
63
63
  setUser(userId, isNative = false) {
64
- if (!userId && this.userId && !isNative) {
65
- // 防误置空:外部未准备好用户身份传空时,若内存中已有合法 userId,绝不置空;清空需调用 resetSession
66
- return
67
- }
68
64
  this.userId = userId || null
69
65
  this.isNativeUserId = !!isNative
70
66
  if (userId) {
@@ -72,7 +68,7 @@ export class SessionManager {
72
68
  if (!isNative) {
73
69
  this.adapter.setStorage('userId', userId)
74
70
  }
75
- } else if (!userId && !isNative) {
71
+ } else if (!userId) {
76
72
  this.adapter.removeStorage('userId')
77
73
  this.adapter.removeStorage('_tracker_user_id')
78
74
  }
@@ -169,6 +165,7 @@ export class SessionManager {
169
165
  resetSession() {
170
166
  this.adapter.removeSessionStorage(this._storageKey)
171
167
  this.adapter.removeStorage('_tracker_user_id')
168
+ this.adapter.removeStorage('userId')
172
169
  this.userId = null
173
170
  this.isNativeUserId = false
174
171
  this.isNativeSessionId = false
@@ -245,6 +245,18 @@ public class AndroidTracker implements Application.ActivityLifecycleCallbacks {
245
245
  return deviceId;
246
246
  }
247
247
 
248
+ public String getUserId() {
249
+ return userId != null ? userId : "";
250
+ }
251
+
252
+ public String getPhone() {
253
+ return phone != null ? phone : "";
254
+ }
255
+
256
+ public String getStoreName() {
257
+ return storeName != null ? storeName : "";
258
+ }
259
+
248
260
  public void setUserId(String userId) {
249
261
  updateUser(userId, null, null);
250
262
  }
@@ -520,6 +532,10 @@ public class AndroidTracker implements Application.ActivityLifecycleCallbacks {
520
532
  event.put("eventName", eventName);
521
533
  event.put("timestamp", System.currentTimeMillis());
522
534
  event.put("sequence", sequence);
535
+ event.put("sessionId", sessionId);
536
+ if (!TextUtils.isEmpty(userId)) {
537
+ event.put("userId", userId);
538
+ }
523
539
  event.put("pageRoute", currentPageRoute);
524
540
  String autoTitle = getFriendlyPageTitle(currentPageRoute);
525
541
  if (!TextUtils.isEmpty(autoTitle)) {
@@ -657,9 +673,23 @@ public class AndroidTracker implements Application.ActivityLifecycleCallbacks {
657
673
  try {
658
674
  JSONObject body = new JSONObject();
659
675
  body.put("appId", Integer.parseInt(appId));
660
- body.put("sessionId", sessionId);
661
- body.put("deviceId", deviceId);
662
- body.put("userId", userId != null ? userId : "");
676
+
677
+ // 批次级别会话与用户身份防护:优先取首条事件自身的 sessionId 与 userId,防切换账号后历史批次被新身份篡改
678
+ String batchSessionId = sessionId;
679
+ String batchUserId = userId != null ? userId : "";
680
+ if (!records.isEmpty()) {
681
+ JSONObject firstEvt = records.get(0).json;
682
+ if (firstEvt.has("sessionId") && !TextUtils.isEmpty(firstEvt.optString("sessionId"))) {
683
+ batchSessionId = firstEvt.optString("sessionId");
684
+ }
685
+ if (firstEvt.has("userId") && !TextUtils.isEmpty(firstEvt.optString("userId"))) {
686
+ batchUserId = firstEvt.optString("userId");
687
+ }
688
+ }
689
+
690
+ body.put("sessionId", batchSessionId);
691
+ body.put("deviceId", deviceId != null ? deviceId : "");
692
+ body.put("userId", batchUserId);
663
693
  body.put("phone", phone != null ? phone : "");
664
694
  body.put("storeName", storeName != null ? storeName : "");
665
695
  body.put("platform", "android");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rk911/tracker-sdk",
3
- "version": "1.7.10",
3
+ "version": "1.7.12",
4
4
  "description": "人康多端埋点 SDK — 跨端自动化采集 + 手动埋点双写兼容",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
package/platforms/web.js CHANGED
@@ -26,6 +26,12 @@ export const ROUTE_TITLE_MAP = {
26
26
  '/pages/integralMall/integralGoodsInfo': '积分商品详情',
27
27
  '/pages/my/setting/setting': '设置',
28
28
  '/pages/selfInvoice/index': '自助开票',
29
+ '/pages/circle/userHome/userHome': '个人主页',
30
+ '/pages/circle/rank': '圈子排行榜',
31
+ '/pages/pickup/list': '自提订单',
32
+ '/pages/mall/order/index': '我的订单',
33
+ '/pages/my/userInfo': '个人资料',
34
+ '/live/index/log': '直播记录',
29
35
  }
30
36
 
31
37
  export class WebAdapter {