@be-link/cls-logger 1.0.1-beta.27 → 1.0.1-beta.29

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.
@@ -80,7 +80,7 @@ export declare abstract class ClsLoggerCore {
80
80
  * 子类可按需重写(默认检测 wx)
81
81
  */
82
82
  protected detectEnvType(): EnvType;
83
- init(options: ClsLoggerInitOptions): void;
83
+ init(options: ClsLoggerInitOptions): Promise<boolean>;
84
84
  private getBaseFields;
85
85
  /**
86
86
  * 设置页面可见性监听
@@ -1 +1 @@
1
- {"version":3,"file":"ClsLoggerCore.d.ts","sourceRoot":"","sources":["../src/ClsLoggerCore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,OAAO,EACP,UAAU,EACV,yBAAyB,EACzB,UAAU,EACV,SAAS,EACT,SAAS,EACT,aAAa,EACb,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAWjB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAYlD;;;;;GAKG;AACH,8BAAsB,aAAa;IACjC,SAAS,CAAC,GAAG,EAAE,YAAY,GAAG,IAAI,CAAQ;IAC1C,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI,CAAQ;IAC1D,SAAS,CAAC,WAAW,EAAE,OAAO,GAAG,IAAI,CAAQ;IAC7C,SAAS,CAAC,iBAAiB,EAAE,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAQ;IAC9E,SAAS,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAA;KAAE,GAAG,IAAI,CAAQ;IAC9F,SAAS,CAAC,aAAa,EAAE,OAAO,CAAC;QAAE,OAAO,EAAE,CAAC,O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AAI;CAcjG"}
package/dist/index.esm.js CHANGED
@@ -204,7 +204,7 @@ class ClsLoggerCore {
204
204
  }
205
205
  return 'browser';
206
206
  }
207
- init(options) {
207
+ async init(options) {
208
208
  this.initTs = Date.now();
209
209
  const topicId = options?.tencentCloud?.topicID ?? options?.topic_id ?? options?.topicID ?? this.topicId;
210
210
  const endpoint = options?.tencentCloud?.endpoint ?? options?.endpoint ?? this.endpoint;
@@ -213,7 +213,7 @@ class ClsLoggerCore {
213
213
  if (!topicId) {
214
214
  // eslint-disable-next-line no-console
215
215
  console.warn('ClsLogger.init 没有传 topicID/topic_id');
216
- return;
216
+ return false;
217
217
  }
218
218
  const nextEnvType = options.envType ?? this.detectEnvType();
219
219
  // envType/endpoint/retryTimes 变化时:重置 client(以及可能的 sdk)
@@ -257,9 +257,9 @@ class ClsLoggerCore {
257
257
  this.failedCacheKey = options.failedCacheKey ?? this.failedCacheKey;
258
258
  this.failedCacheMax = options.failedCacheMax ?? this.failedCacheMax;
259
259
  // 预热(避免首条日志触发 import/初始化开销)
260
- void this.getInstance().catch(() => {
261
- // ignore
262
- });
260
+ const sdkReadyPromise = this.getInstance()
261
+ .then(() => true)
262
+ .catch(() => false);
263
263
  if (this.enabled) {
264
264
  // 启动时尝试发送失败缓存
265
265
  this.flushFailed();
@@ -273,6 +273,7 @@ class ClsLoggerCore {
273
273
  // 初始化后立即启动行为埋点(PV/UV/点击)
274
274
  this.startBehaviorMonitor(options.behaviorMonitor);
275
275
  }
276
+ return sdkReadyPromise;
276
277
  }
277
278
  getBaseFields() {
278
279
  let auto = undefined;
@@ -2986,7 +2987,7 @@ function getBrowserDeviceInfo(options) {
2986
2987
  if (options.includeNetwork) {
2987
2988
  try {
2988
2989
  const conn = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
2989
- if (conn && isPlainObject(conn)) {
2990
+ if (conn && typeof conn === 'object') {
2990
2991
  if (typeof conn.effectiveType === 'string')
2991
2992
  out.netEffectiveType = conn.effectiveType;
2992
2993
  if (typeof conn.downlink === 'number')
@@ -3004,7 +3005,7 @@ function getBrowserDeviceInfo(options) {
3004
3005
  if (options.includeNetworkType) {
3005
3006
  try {
3006
3007
  const conn = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
3007
- if (conn && isPlainObject(conn)) {
3008
+ if (conn && typeof conn === 'object') {
3008
3009
  const type = conn.type;
3009
3010
  const eff = conn.effectiveType;
3010
3011
  let val = '';
@@ -3067,7 +3068,7 @@ function createWebDeviceInfoBaseFields(opts) {
3067
3068
  try {
3068
3069
  const g = globalThis;
3069
3070
  const extra = g[globalKey];
3070
- if (extra && isPlainObject(extra))
3071
+ if (extra && typeof extra === 'object')
3071
3072
  return { ...base, ...extra };
3072
3073
  }
3073
3074
  catch {
@@ -3176,7 +3177,7 @@ function createMiniDeviceInfoBaseFields(opts) {
3176
3177
  try {
3177
3178
  const g = globalThis;
3178
3179
  const extra = g[globalKey];
3179
- if (extra && isPlainObject(extra))
3180
+ if (extra && typeof extra === 'object')
3180
3181
  return { ...base, ...extra };
3181
3182
  }
3182
3183
  catch {
package/dist/index.js CHANGED
@@ -208,7 +208,7 @@ class ClsLoggerCore {
208
208
  }
209
209
  return 'browser';
210
210
  }
211
- init(options) {
211
+ async init(options) {
212
212
  this.initTs = Date.now();
213
213
  const topicId = options?.tencentCloud?.topicID ?? options?.topic_id ?? options?.topicID ?? this.topicId;
214
214
  const endpoint = options?.tencentCloud?.endpoint ?? options?.endpoint ?? this.endpoint;
@@ -217,7 +217,7 @@ class ClsLoggerCore {
217
217
  if (!topicId) {
218
218
  // eslint-disable-next-line no-console
219
219
  console.warn('ClsLogger.init 没有传 topicID/topic_id');
220
- return;
220
+ return false;
221
221
  }
222
222
  const nextEnvType = options.envType ?? this.detectEnvType();
223
223
  // envType/endpoint/retryTimes 变化时:重置 client(以及可能的 sdk)
@@ -261,9 +261,9 @@ class ClsLoggerCore {
261
261
  this.failedCacheKey = options.failedCacheKey ?? this.failedCacheKey;
262
262
  this.failedCacheMax = options.failedCacheMax ?? this.failedCacheMax;
263
263
  // 预热(避免首条日志触发 import/初始化开销)
264
- void this.getInstance().catch(() => {
265
- // ignore
266
- });
264
+ const sdkReadyPromise = this.getInstance()
265
+ .then(() => true)
266
+ .catch(() => false);
267
267
  if (this.enabled) {
268
268
  // 启动时尝试发送失败缓存
269
269
  this.flushFailed();
@@ -277,6 +277,7 @@ class ClsLoggerCore {
277
277
  // 初始化后立即启动行为埋点(PV/UV/点击)
278
278
  this.startBehaviorMonitor(options.behaviorMonitor);
279
279
  }
280
+ return sdkReadyPromise;
280
281
  }
281
282
  getBaseFields() {
282
283
  let auto = undefined;
@@ -2990,7 +2991,7 @@ function getBrowserDeviceInfo(options) {
2990
2991
  if (options.includeNetwork) {
2991
2992
  try {
2992
2993
  const conn = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
2993
- if (conn && isPlainObject(conn)) {
2994
+ if (conn && typeof conn === 'object') {
2994
2995
  if (typeof conn.effectiveType === 'string')
2995
2996
  out.netEffectiveType = conn.effectiveType;
2996
2997
  if (typeof conn.downlink === 'number')
@@ -3008,7 +3009,7 @@ function getBrowserDeviceInfo(options) {
3008
3009
  if (options.includeNetworkType) {
3009
3010
  try {
3010
3011
  const conn = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
3011
- if (conn && isPlainObject(conn)) {
3012
+ if (conn && typeof conn === 'object') {
3012
3013
  const type = conn.type;
3013
3014
  const eff = conn.effectiveType;
3014
3015
  let val = '';
@@ -3071,7 +3072,7 @@ function createWebDeviceInfoBaseFields(opts) {
3071
3072
  try {
3072
3073
  const g = globalThis;
3073
3074
  const extra = g[globalKey];
3074
- if (extra && isPlainObject(extra))
3075
+ if (extra && typeof extra === 'object')
3075
3076
  return { ...base, ...extra };
3076
3077
  }
3077
3078
  catch {
@@ -3180,7 +3181,7 @@ function createMiniDeviceInfoBaseFields(opts) {
3180
3181
  try {
3181
3182
  const g = globalThis;
3182
3183
  const extra = g[globalKey];
3183
- if (extra && isPlainObject(extra))
3184
+ if (extra && typeof extra === 'object')
3184
3185
  return { ...base, ...extra };
3185
3186
  }
3186
3187
  catch {
package/dist/index.umd.js CHANGED
@@ -210,7 +210,7 @@
210
210
  }
211
211
  return 'browser';
212
212
  }
213
- init(options) {
213
+ async init(options) {
214
214
  this.initTs = Date.now();
215
215
  const topicId = options?.tencentCloud?.topicID ?? options?.topic_id ?? options?.topicID ?? this.topicId;
216
216
  const endpoint = options?.tencentCloud?.endpoint ?? options?.endpoint ?? this.endpoint;
@@ -219,7 +219,7 @@
219
219
  if (!topicId) {
220
220
  // eslint-disable-next-line no-console
221
221
  console.warn('ClsLogger.init 没有传 topicID/topic_id');
222
- return;
222
+ return false;
223
223
  }
224
224
  const nextEnvType = options.envType ?? this.detectEnvType();
225
225
  // envType/endpoint/retryTimes 变化时:重置 client(以及可能的 sdk)
@@ -263,9 +263,9 @@
263
263
  this.failedCacheKey = options.failedCacheKey ?? this.failedCacheKey;
264
264
  this.failedCacheMax = options.failedCacheMax ?? this.failedCacheMax;
265
265
  // 预热(避免首条日志触发 import/初始化开销)
266
- void this.getInstance().catch(() => {
267
- // ignore
268
- });
266
+ const sdkReadyPromise = this.getInstance()
267
+ .then(() => true)
268
+ .catch(() => false);
269
269
  if (this.enabled) {
270
270
  // 启动时尝试发送失败缓存
271
271
  this.flushFailed();
@@ -279,6 +279,7 @@
279
279
  // 初始化后立即启动行为埋点(PV/UV/点击)
280
280
  this.startBehaviorMonitor(options.behaviorMonitor);
281
281
  }
282
+ return sdkReadyPromise;
282
283
  }
283
284
  getBaseFields() {
284
285
  let auto = undefined;
@@ -2992,7 +2993,7 @@
2992
2993
  if (options.includeNetwork) {
2993
2994
  try {
2994
2995
  const conn = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
2995
- if (conn && isPlainObject(conn)) {
2996
+ if (conn && typeof conn === 'object') {
2996
2997
  if (typeof conn.effectiveType === 'string')
2997
2998
  out.netEffectiveType = conn.effectiveType;
2998
2999
  if (typeof conn.downlink === 'number')
@@ -3010,7 +3011,7 @@
3010
3011
  if (options.includeNetworkType) {
3011
3012
  try {
3012
3013
  const conn = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
3013
- if (conn && isPlainObject(conn)) {
3014
+ if (conn && typeof conn === 'object') {
3014
3015
  const type = conn.type;
3015
3016
  const eff = conn.effectiveType;
3016
3017
  let val = '';
@@ -3073,7 +3074,7 @@
3073
3074
  try {
3074
3075
  const g = globalThis;
3075
3076
  const extra = g[globalKey];
3076
- if (extra && isPlainObject(extra))
3077
+ if (extra && typeof extra === 'object')
3077
3078
  return { ...base, ...extra };
3078
3079
  }
3079
3080
  catch {
@@ -3182,7 +3183,7 @@
3182
3183
  try {
3183
3184
  const g = globalThis;
3184
3185
  const extra = g[globalKey];
3185
- if (extra && isPlainObject(extra))
3186
+ if (extra && typeof extra === 'object')
3186
3187
  return { ...base, ...extra };
3187
3188
  }
3188
3189
  catch {
@@ -1 +1 @@
1
- {"version":3,"file":"deviceInfo.d.ts","sourceRoot":"","sources":["../../src/mini/deviceInfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAwE9D,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,OAAO,GAAG,iBAAiB,GAAG,SAAS,GAC5C,CAAC,MAAM,UAAU,CAAC,GAAG,IAAI,CAqC3B"}
1
+ {"version":3,"file":"deviceInfo.d.ts","sourceRoot":"","sources":["../../src/mini/deviceInfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAuE9D,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,OAAO,GAAG,iBAAiB,GAAG,SAAS,GAC5C,CAAC,MAAM,UAAU,CAAC,GAAG,IAAI,CAqC3B"}
package/dist/mini.esm.js CHANGED
@@ -206,7 +206,7 @@ class ClsLoggerCore {
206
206
  }
207
207
  return 'browser';
208
208
  }
209
- init(options) {
209
+ async init(options) {
210
210
  this.initTs = Date.now();
211
211
  const topicId = options?.tencentCloud?.topicID ?? options?.topic_id ?? options?.topicID ?? this.topicId;
212
212
  const endpoint = options?.tencentCloud?.endpoint ?? options?.endpoint ?? this.endpoint;
@@ -215,7 +215,7 @@ class ClsLoggerCore {
215
215
  if (!topicId) {
216
216
  // eslint-disable-next-line no-console
217
217
  console.warn('ClsLogger.init 没有传 topicID/topic_id');
218
- return;
218
+ return false;
219
219
  }
220
220
  const nextEnvType = options.envType ?? this.detectEnvType();
221
221
  // envType/endpoint/retryTimes 变化时:重置 client(以及可能的 sdk)
@@ -259,9 +259,9 @@ class ClsLoggerCore {
259
259
  this.failedCacheKey = options.failedCacheKey ?? this.failedCacheKey;
260
260
  this.failedCacheMax = options.failedCacheMax ?? this.failedCacheMax;
261
261
  // 预热(避免首条日志触发 import/初始化开销)
262
- void this.getInstance().catch(() => {
263
- // ignore
264
- });
262
+ const sdkReadyPromise = this.getInstance()
263
+ .then(() => true)
264
+ .catch(() => false);
265
265
  if (this.enabled) {
266
266
  // 启动时尝试发送失败缓存
267
267
  this.flushFailed();
@@ -275,6 +275,7 @@ class ClsLoggerCore {
275
275
  // 初始化后立即启动行为埋点(PV/UV/点击)
276
276
  this.startBehaviorMonitor(options.behaviorMonitor);
277
277
  }
278
+ return sdkReadyPromise;
278
279
  }
279
280
  getBaseFields() {
280
281
  let auto = undefined;
@@ -1917,7 +1918,7 @@ function createMiniDeviceInfoBaseFields(opts) {
1917
1918
  try {
1918
1919
  const g = globalThis;
1919
1920
  const extra = g[globalKey];
1920
- if (extra && isPlainObject(extra))
1921
+ if (extra && typeof extra === 'object')
1921
1922
  return { ...base, ...extra };
1922
1923
  }
1923
1924
  catch {
package/dist/mini.js CHANGED
@@ -229,7 +229,7 @@ class ClsLoggerCore {
229
229
  }
230
230
  return 'browser';
231
231
  }
232
- init(options) {
232
+ async init(options) {
233
233
  this.initTs = Date.now();
234
234
  const topicId = options?.tencentCloud?.topicID ?? options?.topic_id ?? options?.topicID ?? this.topicId;
235
235
  const endpoint = options?.tencentCloud?.endpoint ?? options?.endpoint ?? this.endpoint;
@@ -238,7 +238,7 @@ class ClsLoggerCore {
238
238
  if (!topicId) {
239
239
  // eslint-disable-next-line no-console
240
240
  console.warn('ClsLogger.init 没有传 topicID/topic_id');
241
- return;
241
+ return false;
242
242
  }
243
243
  const nextEnvType = options.envType ?? this.detectEnvType();
244
244
  // envType/endpoint/retryTimes 变化时:重置 client(以及可能的 sdk)
@@ -282,9 +282,9 @@ class ClsLoggerCore {
282
282
  this.failedCacheKey = options.failedCacheKey ?? this.failedCacheKey;
283
283
  this.failedCacheMax = options.failedCacheMax ?? this.failedCacheMax;
284
284
  // 预热(避免首条日志触发 import/初始化开销)
285
- void this.getInstance().catch(() => {
286
- // ignore
287
- });
285
+ const sdkReadyPromise = this.getInstance()
286
+ .then(() => true)
287
+ .catch(() => false);
288
288
  if (this.enabled) {
289
289
  // 启动时尝试发送失败缓存
290
290
  this.flushFailed();
@@ -298,6 +298,7 @@ class ClsLoggerCore {
298
298
  // 初始化后立即启动行为埋点(PV/UV/点击)
299
299
  this.startBehaviorMonitor(options.behaviorMonitor);
300
300
  }
301
+ return sdkReadyPromise;
301
302
  }
302
303
  getBaseFields() {
303
304
  let auto = undefined;
@@ -1940,7 +1941,7 @@ function createMiniDeviceInfoBaseFields(opts) {
1940
1941
  try {
1941
1942
  const g = globalThis;
1942
1943
  const extra = g[globalKey];
1943
- if (extra && isPlainObject(extra))
1944
+ if (extra && typeof extra === 'object')
1944
1945
  return { ...base, ...extra };
1945
1946
  }
1946
1947
  catch {
@@ -1 +1 @@
1
- {"version":3,"file":"deviceInfo.d.ts","sourceRoot":"","sources":["../../src/web/deviceInfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAmK9D,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,OAAO,GAAG,iBAAiB,GAAG,SAAS,GAC5C,CAAC,MAAM,UAAU,CAAC,GAAG,IAAI,CAqC3B"}
1
+ {"version":3,"file":"deviceInfo.d.ts","sourceRoot":"","sources":["../../src/web/deviceInfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAkK9D,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,OAAO,GAAG,iBAAiB,GAAG,SAAS,GAC5C,CAAC,MAAM,UAAU,CAAC,GAAG,IAAI,CAqC3B"}
package/dist/web.esm.js CHANGED
@@ -206,7 +206,7 @@ class ClsLoggerCore {
206
206
  }
207
207
  return 'browser';
208
208
  }
209
- init(options) {
209
+ async init(options) {
210
210
  this.initTs = Date.now();
211
211
  const topicId = options?.tencentCloud?.topicID ?? options?.topic_id ?? options?.topicID ?? this.topicId;
212
212
  const endpoint = options?.tencentCloud?.endpoint ?? options?.endpoint ?? this.endpoint;
@@ -215,7 +215,7 @@ class ClsLoggerCore {
215
215
  if (!topicId) {
216
216
  // eslint-disable-next-line no-console
217
217
  console.warn('ClsLogger.init 没有传 topicID/topic_id');
218
- return;
218
+ return false;
219
219
  }
220
220
  const nextEnvType = options.envType ?? this.detectEnvType();
221
221
  // envType/endpoint/retryTimes 变化时:重置 client(以及可能的 sdk)
@@ -259,9 +259,9 @@ class ClsLoggerCore {
259
259
  this.failedCacheKey = options.failedCacheKey ?? this.failedCacheKey;
260
260
  this.failedCacheMax = options.failedCacheMax ?? this.failedCacheMax;
261
261
  // 预热(避免首条日志触发 import/初始化开销)
262
- void this.getInstance().catch(() => {
263
- // ignore
264
- });
262
+ const sdkReadyPromise = this.getInstance()
263
+ .then(() => true)
264
+ .catch(() => false);
265
265
  if (this.enabled) {
266
266
  // 启动时尝试发送失败缓存
267
267
  this.flushFailed();
@@ -275,6 +275,7 @@ class ClsLoggerCore {
275
275
  // 初始化后立即启动行为埋点(PV/UV/点击)
276
276
  this.startBehaviorMonitor(options.behaviorMonitor);
277
277
  }
278
+ return sdkReadyPromise;
278
279
  }
279
280
  getBaseFields() {
280
281
  let auto = undefined;
@@ -2064,7 +2065,7 @@ function getBrowserDeviceInfo(options) {
2064
2065
  if (options.includeNetwork) {
2065
2066
  try {
2066
2067
  const conn = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
2067
- if (conn && isPlainObject(conn)) {
2068
+ if (conn && typeof conn === 'object') {
2068
2069
  if (typeof conn.effectiveType === 'string')
2069
2070
  out.netEffectiveType = conn.effectiveType;
2070
2071
  if (typeof conn.downlink === 'number')
@@ -2082,7 +2083,7 @@ function getBrowserDeviceInfo(options) {
2082
2083
  if (options.includeNetworkType) {
2083
2084
  try {
2084
2085
  const conn = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
2085
- if (conn && isPlainObject(conn)) {
2086
+ if (conn && typeof conn === 'object') {
2086
2087
  const type = conn.type;
2087
2088
  const eff = conn.effectiveType;
2088
2089
  let val = '';
@@ -2145,7 +2146,7 @@ function createWebDeviceInfoBaseFields(opts) {
2145
2146
  try {
2146
2147
  const g = globalThis;
2147
2148
  const extra = g[globalKey];
2148
- if (extra && isPlainObject(extra))
2149
+ if (extra && typeof extra === 'object')
2149
2150
  return { ...base, ...extra };
2150
2151
  }
2151
2152
  catch {
package/dist/web.js CHANGED
@@ -229,7 +229,7 @@ class ClsLoggerCore {
229
229
  }
230
230
  return 'browser';
231
231
  }
232
- init(options) {
232
+ async init(options) {
233
233
  this.initTs = Date.now();
234
234
  const topicId = options?.tencentCloud?.topicID ?? options?.topic_id ?? options?.topicID ?? this.topicId;
235
235
  const endpoint = options?.tencentCloud?.endpoint ?? options?.endpoint ?? this.endpoint;
@@ -238,7 +238,7 @@ class ClsLoggerCore {
238
238
  if (!topicId) {
239
239
  // eslint-disable-next-line no-console
240
240
  console.warn('ClsLogger.init 没有传 topicID/topic_id');
241
- return;
241
+ return false;
242
242
  }
243
243
  const nextEnvType = options.envType ?? this.detectEnvType();
244
244
  // envType/endpoint/retryTimes 变化时:重置 client(以及可能的 sdk)
@@ -282,9 +282,9 @@ class ClsLoggerCore {
282
282
  this.failedCacheKey = options.failedCacheKey ?? this.failedCacheKey;
283
283
  this.failedCacheMax = options.failedCacheMax ?? this.failedCacheMax;
284
284
  // 预热(避免首条日志触发 import/初始化开销)
285
- void this.getInstance().catch(() => {
286
- // ignore
287
- });
285
+ const sdkReadyPromise = this.getInstance()
286
+ .then(() => true)
287
+ .catch(() => false);
288
288
  if (this.enabled) {
289
289
  // 启动时尝试发送失败缓存
290
290
  this.flushFailed();
@@ -298,6 +298,7 @@ class ClsLoggerCore {
298
298
  // 初始化后立即启动行为埋点(PV/UV/点击)
299
299
  this.startBehaviorMonitor(options.behaviorMonitor);
300
300
  }
301
+ return sdkReadyPromise;
301
302
  }
302
303
  getBaseFields() {
303
304
  let auto = undefined;
@@ -2087,7 +2088,7 @@ function getBrowserDeviceInfo(options) {
2087
2088
  if (options.includeNetwork) {
2088
2089
  try {
2089
2090
  const conn = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
2090
- if (conn && isPlainObject(conn)) {
2091
+ if (conn && typeof conn === 'object') {
2091
2092
  if (typeof conn.effectiveType === 'string')
2092
2093
  out.netEffectiveType = conn.effectiveType;
2093
2094
  if (typeof conn.downlink === 'number')
@@ -2105,7 +2106,7 @@ function getBrowserDeviceInfo(options) {
2105
2106
  if (options.includeNetworkType) {
2106
2107
  try {
2107
2108
  const conn = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
2108
- if (conn && isPlainObject(conn)) {
2109
+ if (conn && typeof conn === 'object') {
2109
2110
  const type = conn.type;
2110
2111
  const eff = conn.effectiveType;
2111
2112
  let val = '';
@@ -2168,7 +2169,7 @@ function createWebDeviceInfoBaseFields(opts) {
2168
2169
  try {
2169
2170
  const g = globalThis;
2170
2171
  const extra = g[globalKey];
2171
- if (extra && isPlainObject(extra))
2172
+ if (extra && typeof extra === 'object')
2172
2173
  return { ...base, ...extra };
2173
2174
  }
2174
2175
  catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@be-link/cls-logger",
3
- "version": "1.0.1-beta.27",
3
+ "version": "1.0.1-beta.29",
4
4
  "description": "@be-link cls-logger - 腾讯云 CLS 日志上报封装",
5
5
  "homepage": "https://github.com/snowmountain-top/be-link",
6
6
  "author": "zhuiyi",