@be-link/cls-logger 1.0.1-beta.0 → 1.0.1-beta.2

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 CHANGED
@@ -28,3 +28,38 @@ clsLogger.putJson({ event: 'click', x: 1, y: 2 });
28
28
  // 入队(写入 localStorage,默认 15 条自动 flush)
29
29
  clsLogger.enqueue({ event: 'page_view', page: '/home' });
30
30
  ```
31
+
32
+ ## 请求监控(requestMonitor)
33
+
34
+ 初始化后默认会开启 HTTP 请求监控(Web/H5:`fetch`/`XMLHttpRequest`;小程序:`wx.request`/`cloud.callFunction`),并把请求信息通过 `track('http', payload)` 上报。
35
+
36
+ - **关闭**:`clsLogger.init({ requestMonitor: false })`
37
+ - **忽略上报请求避免递归**:默认会忽略 CLS 上报域名(会把 `endpoint` 自动加入 `ignoreUrls`),并在内部增加了“上报发送”保护,避免上报请求在跨域失败时出现递归上报/死循环。
38
+ - **自定义忽略**:`clsLogger.init({ requestMonitor: { ignoreUrls: ['example.com', /\\/internal\\//] } })`
39
+
40
+ ## 性能监控(performanceMonitor)
41
+
42
+ 初始化后默认会开启性能监控,并通过 `track('perf', payload)` 上报,包含:
43
+
44
+ - **Web Vitals**:FCP/LCP/CLS/FID
45
+ - **Navigation Timing**:TTFB 等
46
+ - **Resource Timing**:资源加载耗时(`PerformanceObserver({ type: 'resource', buffered: true })`,首屏会比较多)
47
+
48
+ 常见降噪配置:
49
+
50
+ ```ts
51
+ import clsLogger from '@be-link/cls-logger';
52
+
53
+ clsLogger.init({
54
+ topic_id: 'xxx',
55
+ projectName: 'my-project',
56
+ performanceMonitor: {
57
+ // 降低采样(0~1)
58
+ sampleRate: 0.1,
59
+ // 忽略本地开发资源 & sourcemap(按你的资源特征调整)
60
+ ignoreUrls: ['localhost:8080', /\\.map$/],
61
+ },
62
+ // 可选:启动阶段合并窗口,减少首屏 perf/resource 被 intervalMs 拆成多次上报
63
+ // batch: { startupDelayMs: 2000 },
64
+ });
65
+ ```
@@ -19,6 +19,9 @@ export declare class ClsLogger {
19
19
  private batchMaxSize;
20
20
  private batchIntervalMs;
21
21
  private batchTimer;
22
+ private batchTimerDueAt;
23
+ private initTs;
24
+ private startupDelayMs;
22
25
  private failedCacheKey;
23
26
  private failedCacheMax;
24
27
  private requestMonitorStarted;
@@ -26,6 +29,8 @@ export declare class ClsLogger {
26
29
  private performanceMonitorStarted;
27
30
  private behaviorMonitorStarted;
28
31
  private behaviorMonitorCleanup;
32
+ userId: unknown;
33
+ userName: unknown;
29
34
  init(options: ClsLoggerInitOptions): void;
30
35
  private getBaseFields;
31
36
  private startRequestMonitor;
@@ -66,6 +71,7 @@ export declare class ClsLogger {
66
71
  * 参考《一、概述》:统一上报入口(内存队列 + 批量发送)
67
72
  */
68
73
  report(log: ReportLog): void;
74
+ private getDesiredBatchFlushDueAt;
69
75
  info(message: string, data?: FlatFields): void;
70
76
  warn(message: string, data?: FlatFields): void;
71
77
  error(message: string, data?: FlatFields): void;
@@ -1 +1 @@
1
- {"version":3,"file":"ClsLogger.d.ts","sourceRoot":"","sources":["../src/ClsLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAiC,MAAM,6BAA6B,CAAC;AAEzF,OAAO,KAAK,EACV,oBAAoB,EAGpB,UAAU,EAEV,UAAU,EACV,SAAS,EACT,SAAS,EAEV,MAAM,SAAS,CAAC;AAiBjB,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,QAAQ,CAAmC;IACnD,OAAO,CAAC,UAAU,CAAM;IACxB,OAAO,CAAC,MAAM,CAAe;IAE7B,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,WAAW,CAAM;IACzB,OAAO,CAAC,KAAK,CAAM;IACnB,OAAO,CAAC,UAAU,CAAM;IACxB,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,sBAAsB,CAAmC;I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CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI;IA+BlC;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI;IAyC5B,OAAO,CAAC,yBAAyB;IAUjC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,UAAe,GAAG,IAAI;IAKlD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,UAAe,GAAG,IAAI;IAKlD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,UAAe,GAAG,IAAI;IAKnD,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,GAAE,UAAe,GAAG,IAAI;IASrD;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAkBjC,OAAO,CAAC,iBAAiB;YAmBX,cAAc;IA+B5B,OAAO,CAAC,mBAAmB;IAgB3B,OAAO,CAAC,qBAAqB;IAc7B,WAAW,IAAI,IAAI;IAkBnB;;OAEG;IACH,IAAI,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,IAAI;CAcjG"}
package/dist/index.esm.js CHANGED
@@ -134,6 +134,10 @@ function stringifyLogValue(v) {
134
134
  }
135
135
 
136
136
  const DEFAULT_IGNORE$1 = ['cls.tencentcs.com', /\/cls\//i];
137
+ function isClsSendingNow() {
138
+ const g = globalThis;
139
+ return (g.__beLinkClsLoggerSendingCount__ ?? 0) > 0;
140
+ }
137
141
  function shouldIgnoreUrl$1(url, ignoreUrls) {
138
142
  for (const rule of ignoreUrls) {
139
143
  if (typeof rule === 'string') {
@@ -211,6 +215,9 @@ function installBrowserFetch(report, options) {
211
215
  w.__beLinkClsLoggerFetchInstalled__ = true;
212
216
  w.__beLinkClsLoggerRawFetch__ = w.fetch;
213
217
  w.fetch = async (input, init) => {
218
+ // 避免 CLS SDK 上报请求被 requestMonitor 捕获后递归上报(尤其在跨域失败时会“上报失败→再上报”)
219
+ if (isClsSendingNow())
220
+ return w.__beLinkClsLoggerRawFetch__(input, init);
214
221
  let url = '';
215
222
  let method = '';
216
223
  let body = undefined;
@@ -300,6 +307,9 @@ function installBrowserXhr(report, options) {
300
307
  return rawOpen.apply(this, args);
301
308
  };
302
309
  XHR.prototype.send = function (...args) {
310
+ // CLS SDK 发起上报时:跳过监控,避免递归上报
311
+ if (isClsSendingNow())
312
+ return rawSend.apply(this, args);
303
313
  const startTs = Date.now();
304
314
  try {
305
315
  const method = String(this.__beLinkClsLoggerMethod__ ?? 'GET');
@@ -1816,6 +1826,15 @@ function createAutoDeviceInfoBaseFields(envType, opts) {
1816
1826
  };
1817
1827
  }
1818
1828
 
1829
+ function enterClsSendingGuard() {
1830
+ const g = globalThis;
1831
+ const next = (g.__beLinkClsLoggerSendingCount__ ?? 0) + 1;
1832
+ g.__beLinkClsLoggerSendingCount__ = next;
1833
+ return () => {
1834
+ const cur = g.__beLinkClsLoggerSendingCount__ ?? 0;
1835
+ g.__beLinkClsLoggerSendingCount__ = cur > 0 ? cur - 1 : 0;
1836
+ };
1837
+ }
1819
1838
  class ClsLogger {
1820
1839
  constructor() {
1821
1840
  this.client = null;
@@ -1837,6 +1856,9 @@ class ClsLogger {
1837
1856
  this.batchMaxSize = 20;
1838
1857
  this.batchIntervalMs = 500;
1839
1858
  this.batchTimer = null;
1859
+ this.batchTimerDueAt = null;
1860
+ this.initTs = 0;
1861
+ this.startupDelayMs = 0;
1840
1862
  // 参考文档:失败缓存 + 重试
1841
1863
  this.failedCacheKey = 'cls_failed_logs';
1842
1864
  this.failedCacheMax = 200;
@@ -1847,6 +1869,7 @@ class ClsLogger {
1847
1869
  this.behaviorMonitorCleanup = null;
1848
1870
  }
1849
1871
  init(options) {
1872
+ this.initTs = Date.now();
1850
1873
  const topicId = options?.tencentCloud?.topicID ?? options?.topic_id ?? options?.topicID ?? this.topicId ?? null;
1851
1874
  const endpoint = options?.tencentCloud?.endpoint ?? options?.endpoint ?? this.endpoint;
1852
1875
  const retryTimes = options?.tencentCloud?.retry_times ?? options?.retry_times ?? this.retryTimes;
@@ -1860,6 +1883,8 @@ class ClsLogger {
1860
1883
  this.endpoint = endpoint;
1861
1884
  this.retryTimes = retryTimes;
1862
1885
  this.source = source;
1886
+ this.userId = options.userId ?? this.userId;
1887
+ this.userName = options.userName ?? this.userName;
1863
1888
  this.projectId = options.projectId ?? this.projectId;
1864
1889
  this.projectName = options.projectName ?? this.projectName;
1865
1890
  this.appId = options.appId ?? this.appId;
@@ -1871,6 +1896,7 @@ class ClsLogger {
1871
1896
  this.batchSize = options.batchSize ?? this.batchSize;
1872
1897
  this.batchMaxSize = options.batch?.maxSize ?? this.batchMaxSize;
1873
1898
  this.batchIntervalMs = options.batch?.intervalMs ?? this.batchIntervalMs;
1899
+ this.startupDelayMs = options.batch?.startupDelayMs ?? this.startupDelayMs;
1874
1900
  this.failedCacheKey = options.failedCacheKey ?? this.failedCacheKey;
1875
1901
  this.failedCacheMax = options.failedCacheMax ?? this.failedCacheMax;
1876
1902
  // 预热 client
@@ -1899,7 +1925,7 @@ class ClsLogger {
1899
1925
  try {
1900
1926
  const userRaw = this.userGenerateBaseFields ? this.userGenerateBaseFields() : undefined;
1901
1927
  if (userRaw && isPlainObject(userRaw))
1902
- user = normalizeFlatFields(userRaw, 'generateBaseFields');
1928
+ user = normalizeFlatFields({ ...userRaw, userId: this.userId, userName: this.userName }, 'generateBaseFields');
1903
1929
  }
1904
1930
  catch {
1905
1931
  user = undefined;
@@ -2026,7 +2052,13 @@ class ClsLogger {
2026
2052
  }
2027
2053
  logGroup.addLog(log);
2028
2054
  const request = new PutLogsRequest(this.topicId, logGroup);
2029
- client.PutLogs(request);
2055
+ const exit = enterClsSendingGuard();
2056
+ try {
2057
+ client.PutLogs(request);
2058
+ }
2059
+ finally {
2060
+ exit();
2061
+ }
2030
2062
  }
2031
2063
  /**
2032
2064
  * 直接上报:把 data 序列化后放入指定 key(默认 “日志内容”)
@@ -2099,7 +2131,13 @@ class ClsLogger {
2099
2131
  if (logGroup.getLogs().length === 0)
2100
2132
  return;
2101
2133
  const request = new PutLogsRequest(this.topicId, logGroup);
2102
- client.PutLogs(request);
2134
+ const exit = enterClsSendingGuard();
2135
+ try {
2136
+ client.PutLogs(request);
2137
+ }
2138
+ finally {
2139
+ exit();
2140
+ }
2103
2141
  }
2104
2142
  /**
2105
2143
  * 参考《一、概述》:统一上报入口(内存队列 + 批量发送)
@@ -2117,11 +2155,39 @@ class ClsLogger {
2117
2155
  void this.flushBatch();
2118
2156
  return;
2119
2157
  }
2158
+ const now = Date.now();
2159
+ const desiredDueAt = this.getDesiredBatchFlushDueAt(now);
2160
+ const desiredDelay = Math.max(0, desiredDueAt - now);
2120
2161
  if (!this.batchTimer) {
2162
+ this.batchTimerDueAt = desiredDueAt;
2121
2163
  this.batchTimer = setTimeout(() => {
2122
2164
  void this.flushBatch();
2123
- }, this.batchIntervalMs);
2165
+ }, desiredDelay);
2166
+ return;
2124
2167
  }
2168
+ // 启动合并窗口内:如果当前 timer 会“更早”触发,则延后到窗口结束,尽量减少多次发送
2169
+ if (this.batchTimerDueAt !== null && this.batchTimerDueAt < desiredDueAt) {
2170
+ try {
2171
+ clearTimeout(this.batchTimer);
2172
+ }
2173
+ catch {
2174
+ // ignore
2175
+ }
2176
+ this.batchTimerDueAt = desiredDueAt;
2177
+ this.batchTimer = setTimeout(() => {
2178
+ void this.flushBatch();
2179
+ }, desiredDelay);
2180
+ }
2181
+ }
2182
+ getDesiredBatchFlushDueAt(nowTs) {
2183
+ const start = this.initTs || nowTs;
2184
+ const startupDelay = Number.isFinite(this.startupDelayMs) ? Math.max(0, this.startupDelayMs) : 0;
2185
+ if (startupDelay > 0) {
2186
+ const end = start + startupDelay;
2187
+ if (nowTs < end)
2188
+ return end;
2189
+ }
2190
+ return nowTs + this.batchIntervalMs;
2125
2191
  }
2126
2192
  info(message, data = {}) {
2127
2193
  const payload = normalizeFlatFields({ message, ...data }, 'info');
@@ -2152,6 +2218,7 @@ class ClsLogger {
2152
2218
  clearTimeout(this.batchTimer);
2153
2219
  this.batchTimer = null;
2154
2220
  }
2221
+ this.batchTimerDueAt = null;
2155
2222
  if (this.memoryQueue.length === 0)
2156
2223
  return;
2157
2224
  const logs = [...this.memoryQueue];
@@ -2177,7 +2244,7 @@ class ClsLogger {
2177
2244
  appId: this.appId || undefined,
2178
2245
  appVersion: this.appVersion || undefined,
2179
2246
  // 保证“一维字段”:业务数据以 JSON 字符串形式落到 CLS
2180
- data: stringifyLogValue(mergedData),
2247
+ ...mergedData,
2181
2248
  };
2182
2249
  }
2183
2250
  async sendReportLogs(logs) {
@@ -2197,7 +2264,16 @@ class ClsLogger {
2197
2264
  logGroup.addLog(log);
2198
2265
  }
2199
2266
  const request = new PutLogsRequest(this.topicId, logGroup);
2200
- await client.PutLogs(request);
2267
+ // 只在“发起网络请求”的同步阶段打标记,避免 requestMonitor 监控 CLS 上报请求导致递归
2268
+ const exit = enterClsSendingGuard();
2269
+ let p;
2270
+ try {
2271
+ p = client.PutLogs(request);
2272
+ }
2273
+ finally {
2274
+ exit();
2275
+ }
2276
+ await p;
2201
2277
  }
2202
2278
  retrySendReportLogs(logs, retryCount) {
2203
2279
  if (retryCount > this.retryTimes) {
package/dist/index.js CHANGED
@@ -138,6 +138,10 @@ function stringifyLogValue(v) {
138
138
  }
139
139
 
140
140
  const DEFAULT_IGNORE$1 = ['cls.tencentcs.com', /\/cls\//i];
141
+ function isClsSendingNow() {
142
+ const g = globalThis;
143
+ return (g.__beLinkClsLoggerSendingCount__ ?? 0) > 0;
144
+ }
141
145
  function shouldIgnoreUrl$1(url, ignoreUrls) {
142
146
  for (const rule of ignoreUrls) {
143
147
  if (typeof rule === 'string') {
@@ -215,6 +219,9 @@ function installBrowserFetch(report, options) {
215
219
  w.__beLinkClsLoggerFetchInstalled__ = true;
216
220
  w.__beLinkClsLoggerRawFetch__ = w.fetch;
217
221
  w.fetch = async (input, init) => {
222
+ // 避免 CLS SDK 上报请求被 requestMonitor 捕获后递归上报(尤其在跨域失败时会“上报失败→再上报”)
223
+ if (isClsSendingNow())
224
+ return w.__beLinkClsLoggerRawFetch__(input, init);
218
225
  let url = '';
219
226
  let method = '';
220
227
  let body = undefined;
@@ -304,6 +311,9 @@ function installBrowserXhr(report, options) {
304
311
  return rawOpen.apply(this, args);
305
312
  };
306
313
  XHR.prototype.send = function (...args) {
314
+ // CLS SDK 发起上报时:跳过监控,避免递归上报
315
+ if (isClsSendingNow())
316
+ return rawSend.apply(this, args);
307
317
  const startTs = Date.now();
308
318
  try {
309
319
  const method = String(this.__beLinkClsLoggerMethod__ ?? 'GET');
@@ -1820,6 +1830,15 @@ function createAutoDeviceInfoBaseFields(envType, opts) {
1820
1830
  };
1821
1831
  }
1822
1832
 
1833
+ function enterClsSendingGuard() {
1834
+ const g = globalThis;
1835
+ const next = (g.__beLinkClsLoggerSendingCount__ ?? 0) + 1;
1836
+ g.__beLinkClsLoggerSendingCount__ = next;
1837
+ return () => {
1838
+ const cur = g.__beLinkClsLoggerSendingCount__ ?? 0;
1839
+ g.__beLinkClsLoggerSendingCount__ = cur > 0 ? cur - 1 : 0;
1840
+ };
1841
+ }
1823
1842
  class ClsLogger {
1824
1843
  constructor() {
1825
1844
  this.client = null;
@@ -1841,6 +1860,9 @@ class ClsLogger {
1841
1860
  this.batchMaxSize = 20;
1842
1861
  this.batchIntervalMs = 500;
1843
1862
  this.batchTimer = null;
1863
+ this.batchTimerDueAt = null;
1864
+ this.initTs = 0;
1865
+ this.startupDelayMs = 0;
1844
1866
  // 参考文档:失败缓存 + 重试
1845
1867
  this.failedCacheKey = 'cls_failed_logs';
1846
1868
  this.failedCacheMax = 200;
@@ -1851,6 +1873,7 @@ class ClsLogger {
1851
1873
  this.behaviorMonitorCleanup = null;
1852
1874
  }
1853
1875
  init(options) {
1876
+ this.initTs = Date.now();
1854
1877
  const topicId = options?.tencentCloud?.topicID ?? options?.topic_id ?? options?.topicID ?? this.topicId ?? null;
1855
1878
  const endpoint = options?.tencentCloud?.endpoint ?? options?.endpoint ?? this.endpoint;
1856
1879
  const retryTimes = options?.tencentCloud?.retry_times ?? options?.retry_times ?? this.retryTimes;
@@ -1864,6 +1887,8 @@ class ClsLogger {
1864
1887
  this.endpoint = endpoint;
1865
1888
  this.retryTimes = retryTimes;
1866
1889
  this.source = source;
1890
+ this.userId = options.userId ?? this.userId;
1891
+ this.userName = options.userName ?? this.userName;
1867
1892
  this.projectId = options.projectId ?? this.projectId;
1868
1893
  this.projectName = options.projectName ?? this.projectName;
1869
1894
  this.appId = options.appId ?? this.appId;
@@ -1875,6 +1900,7 @@ class ClsLogger {
1875
1900
  this.batchSize = options.batchSize ?? this.batchSize;
1876
1901
  this.batchMaxSize = options.batch?.maxSize ?? this.batchMaxSize;
1877
1902
  this.batchIntervalMs = options.batch?.intervalMs ?? this.batchIntervalMs;
1903
+ this.startupDelayMs = options.batch?.startupDelayMs ?? this.startupDelayMs;
1878
1904
  this.failedCacheKey = options.failedCacheKey ?? this.failedCacheKey;
1879
1905
  this.failedCacheMax = options.failedCacheMax ?? this.failedCacheMax;
1880
1906
  // 预热 client
@@ -1903,7 +1929,7 @@ class ClsLogger {
1903
1929
  try {
1904
1930
  const userRaw = this.userGenerateBaseFields ? this.userGenerateBaseFields() : undefined;
1905
1931
  if (userRaw && isPlainObject(userRaw))
1906
- user = normalizeFlatFields(userRaw, 'generateBaseFields');
1932
+ user = normalizeFlatFields({ ...userRaw, userId: this.userId, userName: this.userName }, 'generateBaseFields');
1907
1933
  }
1908
1934
  catch {
1909
1935
  user = undefined;
@@ -2030,7 +2056,13 @@ class ClsLogger {
2030
2056
  }
2031
2057
  logGroup.addLog(log);
2032
2058
  const request = new tencentcloudClsSdkJsWeb.PutLogsRequest(this.topicId, logGroup);
2033
- client.PutLogs(request);
2059
+ const exit = enterClsSendingGuard();
2060
+ try {
2061
+ client.PutLogs(request);
2062
+ }
2063
+ finally {
2064
+ exit();
2065
+ }
2034
2066
  }
2035
2067
  /**
2036
2068
  * 直接上报:把 data 序列化后放入指定 key(默认 “日志内容”)
@@ -2103,7 +2135,13 @@ class ClsLogger {
2103
2135
  if (logGroup.getLogs().length === 0)
2104
2136
  return;
2105
2137
  const request = new tencentcloudClsSdkJsWeb.PutLogsRequest(this.topicId, logGroup);
2106
- client.PutLogs(request);
2138
+ const exit = enterClsSendingGuard();
2139
+ try {
2140
+ client.PutLogs(request);
2141
+ }
2142
+ finally {
2143
+ exit();
2144
+ }
2107
2145
  }
2108
2146
  /**
2109
2147
  * 参考《一、概述》:统一上报入口(内存队列 + 批量发送)
@@ -2121,11 +2159,39 @@ class ClsLogger {
2121
2159
  void this.flushBatch();
2122
2160
  return;
2123
2161
  }
2162
+ const now = Date.now();
2163
+ const desiredDueAt = this.getDesiredBatchFlushDueAt(now);
2164
+ const desiredDelay = Math.max(0, desiredDueAt - now);
2124
2165
  if (!this.batchTimer) {
2166
+ this.batchTimerDueAt = desiredDueAt;
2125
2167
  this.batchTimer = setTimeout(() => {
2126
2168
  void this.flushBatch();
2127
- }, this.batchIntervalMs);
2169
+ }, desiredDelay);
2170
+ return;
2128
2171
  }
2172
+ // 启动合并窗口内:如果当前 timer 会“更早”触发,则延后到窗口结束,尽量减少多次发送
2173
+ if (this.batchTimerDueAt !== null && this.batchTimerDueAt < desiredDueAt) {
2174
+ try {
2175
+ clearTimeout(this.batchTimer);
2176
+ }
2177
+ catch {
2178
+ // ignore
2179
+ }
2180
+ this.batchTimerDueAt = desiredDueAt;
2181
+ this.batchTimer = setTimeout(() => {
2182
+ void this.flushBatch();
2183
+ }, desiredDelay);
2184
+ }
2185
+ }
2186
+ getDesiredBatchFlushDueAt(nowTs) {
2187
+ const start = this.initTs || nowTs;
2188
+ const startupDelay = Number.isFinite(this.startupDelayMs) ? Math.max(0, this.startupDelayMs) : 0;
2189
+ if (startupDelay > 0) {
2190
+ const end = start + startupDelay;
2191
+ if (nowTs < end)
2192
+ return end;
2193
+ }
2194
+ return nowTs + this.batchIntervalMs;
2129
2195
  }
2130
2196
  info(message, data = {}) {
2131
2197
  const payload = normalizeFlatFields({ message, ...data }, 'info');
@@ -2156,6 +2222,7 @@ class ClsLogger {
2156
2222
  clearTimeout(this.batchTimer);
2157
2223
  this.batchTimer = null;
2158
2224
  }
2225
+ this.batchTimerDueAt = null;
2159
2226
  if (this.memoryQueue.length === 0)
2160
2227
  return;
2161
2228
  const logs = [...this.memoryQueue];
@@ -2181,7 +2248,7 @@ class ClsLogger {
2181
2248
  appId: this.appId || undefined,
2182
2249
  appVersion: this.appVersion || undefined,
2183
2250
  // 保证“一维字段”:业务数据以 JSON 字符串形式落到 CLS
2184
- data: stringifyLogValue(mergedData),
2251
+ ...mergedData,
2185
2252
  };
2186
2253
  }
2187
2254
  async sendReportLogs(logs) {
@@ -2201,7 +2268,16 @@ class ClsLogger {
2201
2268
  logGroup.addLog(log);
2202
2269
  }
2203
2270
  const request = new tencentcloudClsSdkJsWeb.PutLogsRequest(this.topicId, logGroup);
2204
- await client.PutLogs(request);
2271
+ // 只在“发起网络请求”的同步阶段打标记,避免 requestMonitor 监控 CLS 上报请求导致递归
2272
+ const exit = enterClsSendingGuard();
2273
+ let p;
2274
+ try {
2275
+ p = client.PutLogs(request);
2276
+ }
2277
+ finally {
2278
+ exit();
2279
+ }
2280
+ await p;
2205
2281
  }
2206
2282
  retrySendReportLogs(logs, retryCount) {
2207
2283
  if (retryCount > this.retryTimes) {
package/dist/index.umd.js CHANGED
@@ -138,6 +138,10 @@
138
138
  }
139
139
 
140
140
  const DEFAULT_IGNORE$1 = ['cls.tencentcs.com', /\/cls\//i];
141
+ function isClsSendingNow() {
142
+ const g = globalThis;
143
+ return (g.__beLinkClsLoggerSendingCount__ ?? 0) > 0;
144
+ }
141
145
  function shouldIgnoreUrl$1(url, ignoreUrls) {
142
146
  for (const rule of ignoreUrls) {
143
147
  if (typeof rule === 'string') {
@@ -215,6 +219,9 @@
215
219
  w.__beLinkClsLoggerFetchInstalled__ = true;
216
220
  w.__beLinkClsLoggerRawFetch__ = w.fetch;
217
221
  w.fetch = async (input, init) => {
222
+ // 避免 CLS SDK 上报请求被 requestMonitor 捕获后递归上报(尤其在跨域失败时会“上报失败→再上报”)
223
+ if (isClsSendingNow())
224
+ return w.__beLinkClsLoggerRawFetch__(input, init);
218
225
  let url = '';
219
226
  let method = '';
220
227
  let body = undefined;
@@ -304,6 +311,9 @@
304
311
  return rawOpen.apply(this, args);
305
312
  };
306
313
  XHR.prototype.send = function (...args) {
314
+ // CLS SDK 发起上报时:跳过监控,避免递归上报
315
+ if (isClsSendingNow())
316
+ return rawSend.apply(this, args);
307
317
  const startTs = Date.now();
308
318
  try {
309
319
  const method = String(this.__beLinkClsLoggerMethod__ ?? 'GET');
@@ -1820,6 +1830,15 @@
1820
1830
  };
1821
1831
  }
1822
1832
 
1833
+ function enterClsSendingGuard() {
1834
+ const g = globalThis;
1835
+ const next = (g.__beLinkClsLoggerSendingCount__ ?? 0) + 1;
1836
+ g.__beLinkClsLoggerSendingCount__ = next;
1837
+ return () => {
1838
+ const cur = g.__beLinkClsLoggerSendingCount__ ?? 0;
1839
+ g.__beLinkClsLoggerSendingCount__ = cur > 0 ? cur - 1 : 0;
1840
+ };
1841
+ }
1823
1842
  class ClsLogger {
1824
1843
  constructor() {
1825
1844
  this.client = null;
@@ -1841,6 +1860,9 @@
1841
1860
  this.batchMaxSize = 20;
1842
1861
  this.batchIntervalMs = 500;
1843
1862
  this.batchTimer = null;
1863
+ this.batchTimerDueAt = null;
1864
+ this.initTs = 0;
1865
+ this.startupDelayMs = 0;
1844
1866
  // 参考文档:失败缓存 + 重试
1845
1867
  this.failedCacheKey = 'cls_failed_logs';
1846
1868
  this.failedCacheMax = 200;
@@ -1851,6 +1873,7 @@
1851
1873
  this.behaviorMonitorCleanup = null;
1852
1874
  }
1853
1875
  init(options) {
1876
+ this.initTs = Date.now();
1854
1877
  const topicId = options?.tencentCloud?.topicID ?? options?.topic_id ?? options?.topicID ?? this.topicId ?? null;
1855
1878
  const endpoint = options?.tencentCloud?.endpoint ?? options?.endpoint ?? this.endpoint;
1856
1879
  const retryTimes = options?.tencentCloud?.retry_times ?? options?.retry_times ?? this.retryTimes;
@@ -1864,6 +1887,8 @@
1864
1887
  this.endpoint = endpoint;
1865
1888
  this.retryTimes = retryTimes;
1866
1889
  this.source = source;
1890
+ this.userId = options.userId ?? this.userId;
1891
+ this.userName = options.userName ?? this.userName;
1867
1892
  this.projectId = options.projectId ?? this.projectId;
1868
1893
  this.projectName = options.projectName ?? this.projectName;
1869
1894
  this.appId = options.appId ?? this.appId;
@@ -1875,6 +1900,7 @@
1875
1900
  this.batchSize = options.batchSize ?? this.batchSize;
1876
1901
  this.batchMaxSize = options.batch?.maxSize ?? this.batchMaxSize;
1877
1902
  this.batchIntervalMs = options.batch?.intervalMs ?? this.batchIntervalMs;
1903
+ this.startupDelayMs = options.batch?.startupDelayMs ?? this.startupDelayMs;
1878
1904
  this.failedCacheKey = options.failedCacheKey ?? this.failedCacheKey;
1879
1905
  this.failedCacheMax = options.failedCacheMax ?? this.failedCacheMax;
1880
1906
  // 预热 client
@@ -1903,7 +1929,7 @@
1903
1929
  try {
1904
1930
  const userRaw = this.userGenerateBaseFields ? this.userGenerateBaseFields() : undefined;
1905
1931
  if (userRaw && isPlainObject(userRaw))
1906
- user = normalizeFlatFields(userRaw, 'generateBaseFields');
1932
+ user = normalizeFlatFields({ ...userRaw, userId: this.userId, userName: this.userName }, 'generateBaseFields');
1907
1933
  }
1908
1934
  catch {
1909
1935
  user = undefined;
@@ -2030,7 +2056,13 @@
2030
2056
  }
2031
2057
  logGroup.addLog(log);
2032
2058
  const request = new tencentcloudClsSdkJsWeb.PutLogsRequest(this.topicId, logGroup);
2033
- client.PutLogs(request);
2059
+ const exit = enterClsSendingGuard();
2060
+ try {
2061
+ client.PutLogs(request);
2062
+ }
2063
+ finally {
2064
+ exit();
2065
+ }
2034
2066
  }
2035
2067
  /**
2036
2068
  * 直接上报:把 data 序列化后放入指定 key(默认 “日志内容”)
@@ -2103,7 +2135,13 @@
2103
2135
  if (logGroup.getLogs().length === 0)
2104
2136
  return;
2105
2137
  const request = new tencentcloudClsSdkJsWeb.PutLogsRequest(this.topicId, logGroup);
2106
- client.PutLogs(request);
2138
+ const exit = enterClsSendingGuard();
2139
+ try {
2140
+ client.PutLogs(request);
2141
+ }
2142
+ finally {
2143
+ exit();
2144
+ }
2107
2145
  }
2108
2146
  /**
2109
2147
  * 参考《一、概述》:统一上报入口(内存队列 + 批量发送)
@@ -2121,11 +2159,39 @@
2121
2159
  void this.flushBatch();
2122
2160
  return;
2123
2161
  }
2162
+ const now = Date.now();
2163
+ const desiredDueAt = this.getDesiredBatchFlushDueAt(now);
2164
+ const desiredDelay = Math.max(0, desiredDueAt - now);
2124
2165
  if (!this.batchTimer) {
2166
+ this.batchTimerDueAt = desiredDueAt;
2125
2167
  this.batchTimer = setTimeout(() => {
2126
2168
  void this.flushBatch();
2127
- }, this.batchIntervalMs);
2169
+ }, desiredDelay);
2170
+ return;
2128
2171
  }
2172
+ // 启动合并窗口内:如果当前 timer 会“更早”触发,则延后到窗口结束,尽量减少多次发送
2173
+ if (this.batchTimerDueAt !== null && this.batchTimerDueAt < desiredDueAt) {
2174
+ try {
2175
+ clearTimeout(this.batchTimer);
2176
+ }
2177
+ catch {
2178
+ // ignore
2179
+ }
2180
+ this.batchTimerDueAt = desiredDueAt;
2181
+ this.batchTimer = setTimeout(() => {
2182
+ void this.flushBatch();
2183
+ }, desiredDelay);
2184
+ }
2185
+ }
2186
+ getDesiredBatchFlushDueAt(nowTs) {
2187
+ const start = this.initTs || nowTs;
2188
+ const startupDelay = Number.isFinite(this.startupDelayMs) ? Math.max(0, this.startupDelayMs) : 0;
2189
+ if (startupDelay > 0) {
2190
+ const end = start + startupDelay;
2191
+ if (nowTs < end)
2192
+ return end;
2193
+ }
2194
+ return nowTs + this.batchIntervalMs;
2129
2195
  }
2130
2196
  info(message, data = {}) {
2131
2197
  const payload = normalizeFlatFields({ message, ...data }, 'info');
@@ -2156,6 +2222,7 @@
2156
2222
  clearTimeout(this.batchTimer);
2157
2223
  this.batchTimer = null;
2158
2224
  }
2225
+ this.batchTimerDueAt = null;
2159
2226
  if (this.memoryQueue.length === 0)
2160
2227
  return;
2161
2228
  const logs = [...this.memoryQueue];
@@ -2181,7 +2248,7 @@
2181
2248
  appId: this.appId || undefined,
2182
2249
  appVersion: this.appVersion || undefined,
2183
2250
  // 保证“一维字段”:业务数据以 JSON 字符串形式落到 CLS
2184
- data: stringifyLogValue(mergedData),
2251
+ ...mergedData,
2185
2252
  };
2186
2253
  }
2187
2254
  async sendReportLogs(logs) {
@@ -2201,7 +2268,16 @@
2201
2268
  logGroup.addLog(log);
2202
2269
  }
2203
2270
  const request = new tencentcloudClsSdkJsWeb.PutLogsRequest(this.topicId, logGroup);
2204
- await client.PutLogs(request);
2271
+ // 只在“发起网络请求”的同步阶段打标记,避免 requestMonitor 监控 CLS 上报请求导致递归
2272
+ const exit = enterClsSendingGuard();
2273
+ let p;
2274
+ try {
2275
+ p = client.PutLogs(request);
2276
+ }
2277
+ finally {
2278
+ exit();
2279
+ }
2280
+ await p;
2205
2281
  }
2206
2282
  retrySendReportLogs(logs, retryCount) {
2207
2283
  if (retryCount > this.retryTimes) {
@@ -1 +1 @@
1
- {"version":3,"file":"requestMonitor.d.ts","sourceRoot":"","sources":["../src/requestMonitor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAGjE,KAAK,QAAQ,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;AAEzD,UAAU,cAAe,SAAQ,qBAAqB;IACpD,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AA0XD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,GAAE,cAAmB,GAAG,IAAI,CA2BvF"}
1
+ {"version":3,"file":"requestMonitor.d.ts","sourceRoot":"","sources":["../src/requestMonitor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAGjE,KAAK,QAAQ,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;AAEzD,UAAU,cAAe,SAAQ,qBAAqB;IACpD,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAqYD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,GAAE,cAAmB,GAAG,IAAI,CA2BvF"}
package/dist/types.d.ts CHANGED
@@ -28,6 +28,13 @@ export interface BatchOptions {
28
28
  maxSize?: number;
29
29
  /** 多久批量发送一次,默认 500ms */
30
30
  intervalMs?: number;
31
+ /**
32
+ * 启动阶段合并窗口(ms)
33
+ * - 目的:减少初始化/首屏阶段(perf/resource 等日志密集期)被 intervalMs 拆成多次上报
34
+ * - 行为:在该窗口内尽量延迟 flush 到窗口结束(但仍受 maxSize 约束,达到阈值会立即发送)
35
+ * - 默认:0(不开启)
36
+ */
37
+ startupDelayMs?: number;
31
38
  }
32
39
  export interface ClsLoggerInitOptions {
33
40
  /**
@@ -57,6 +64,8 @@ export interface ClsLoggerInitOptions {
57
64
  endpoint?: string;
58
65
  retry_times?: number;
59
66
  source?: string;
67
+ userId?: string;
68
+ userName?: string;
60
69
  /**
61
70
  * 生成基础字段(比如用户信息、环境信息等),每次上报都会合并进去
62
71
  * - 返回值需要是 plain object
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;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AC,EAAE,MAAM,MAAM,CAAC;IAE3B;;OAEG;IACH,YAAY,CAAC,EAAE;QACb;;;;WAIG;QACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;QAC1B,yBAAyB;QACzB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@be-link/cls-logger",
3
- "version": "1.0.1-beta.0",
3
+ "version": "1.0.1-beta.2",
4
4
  "description": "@be-link cls-logger - 腾讯云 CLS 日志上报封装",
5
5
  "homepage": "https://github.com/snowmountain-top/be-link",
6
6
  "author": "zhuiyi",