@rk911/tracker-sdk 1.7.19 → 1.7.20

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/config.js CHANGED
@@ -55,6 +55,13 @@ const DEFAULT_CONFIG = {
55
55
 
56
56
  batchReportUrl: '/api/point/task/trackBatch',
57
57
 
58
+ // ★ trackBatch 请求是否携带 token 头
59
+ // true(默认):与历史行为一致(店长端/小程序依赖服务端按 token 解析用户)
60
+ // false:不带 token,服务端以 payload.userId 为准(APP 内 H5 用:带 token 时服务端解析出空用户、覆盖 userId,
61
+ // 导致 H5 行 user_id 为空;与 Android/iOS/鸿蒙原生 trackBatch 均不带 token 对齐)
62
+ // 只影响 trackBatch,不影响 trackLegacy(activeReport)和业务接口
63
+ batchWithToken: true,
64
+
58
65
  // ★ 无 token 上报开关
59
66
  // false(默认):flush 时必须有 token 才上报,无 token 事件留在队列等待
60
67
  // true:无 token 也可上报(适用于不需要登录的场景)
package/core/queue.js CHANGED
@@ -146,10 +146,12 @@ export class ReportQueue {
146
146
  try {
147
147
  var headers = {
148
148
  'Content-Type': 'application/json',
149
- token: this.adapter.getToken() || '',
150
149
  appId: String(this.config.appId),
151
150
  deviceId: this.session.getDeviceId() || '',
152
151
  }
152
+ if (this.config.batchWithToken !== false) {
153
+ headers.token = this.adapter.getToken() || ''
154
+ }
153
155
  fetch(url, {
154
156
  method: 'POST',
155
157
  body: payloadStr,
@@ -194,10 +196,12 @@ export class ReportQueue {
194
196
  // Layer 3: adapter.request(小程序 / 极老浏览器降级)
195
197
  var header = {
196
198
  'content-type': 'application/json',
197
- token: this.adapter.getToken() || '',
198
199
  appId: String(this.config.appId),
199
200
  deviceId: this.session.getDeviceId() || '',
200
201
  }
202
+ if (this.config.batchWithToken !== false) {
203
+ header.token = this.adapter.getToken() || ''
204
+ }
201
205
 
202
206
  this.adapter
203
207
  .request({ method: 'POST', url: url, data: JSON.parse(payloadStr), header: header })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rk911/tracker-sdk",
3
- "version": "1.7.19",
3
+ "version": "1.7.20",
4
4
  "description": "人康多端埋点 SDK — 跨端自动化采集 + 手动埋点双写兼容",
5
5
  "main": "index.js",
6
6
  "module": "index.js",