trackersdk2 1.0.2 → 1.0.3

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/dist/index.cjs.js CHANGED
@@ -297,10 +297,11 @@ class TrackerSDK {
297
297
  * @param element 点击的DOM元素
298
298
  */
299
299
  trackClick(element) {
300
+ var _element$innerText;
300
301
  const tagName = element.tagName.toLowerCase();
301
302
  const id = element.id || "";
302
303
  const classes = Array.from(element.classList).join(" ");
303
- const text = ["button", "a"].includes(tagName) ? element.innerText?.trim().slice(0, 20) : "";
304
+ const text = ["button", "a"].includes(tagName) ? (_element$innerText = element.innerText) === null || _element$innerText === void 0 ? void 0 : _element$innerText.trim().slice(0, 20) : "";
304
305
  if (this.config.enableAutoClickTagNameList.includes(tagName)) {
305
306
  this.send({
306
307
  eventType: "click",
@@ -380,13 +381,14 @@ class TrackerSDK {
380
381
  filename,
381
382
  lineno,
382
383
  colno,
383
- stack: error?.stack || "no stack"
384
+ stack: (error === null || error === void 0 ? void 0 : error.stack) || "no stack"
384
385
  }
385
386
  });
386
387
  });
387
388
  // 资源加载错误
388
389
  window.addEventListener("error", e => {
389
- if (e.target?.localName) {
390
+ var _e$target;
391
+ if ((_e$target = e.target) !== null && _e$target !== void 0 && _e$target.localName) {
390
392
  let url = e.target.src || e.target.href || "";
391
393
  url = url.trim();
392
394
  const tag = e.target;
@@ -418,13 +420,14 @@ class TrackerSDK {
418
420
  window.addEventListener("unhandledrejection", event => {
419
421
  "Promise unhandled rejection捕获了";
420
422
 
423
+ var _event$reason;
421
424
  console.log("🚀 ~ 'Promise unhandled rejection捕获了'");
422
425
  this.send({
423
426
  eventType: "error",
424
427
  event: "promise_unhandled_rejection",
425
428
  properties: {
426
429
  reason: String(event.reason),
427
- stack: event.reason?.stack || "no stack"
430
+ stack: ((_event$reason = event.reason) === null || _event$reason === void 0 ? void 0 : _event$reason.stack) || "no stack"
428
431
  }
429
432
  });
430
433
  // 阻止打印报错信息
@@ -436,6 +439,7 @@ class TrackerSDK {
436
439
  */
437
440
  setupVueErrorHandlder(app) {
438
441
  app.config.errorHandler = (err, instance, info) => {
442
+ var _instance$$options;
439
443
  console.log("🚀 ~ vue 全局错误处理器捕获了");
440
444
  // setTimeout(() => {
441
445
  // throw err;
@@ -447,7 +451,7 @@ class TrackerSDK {
447
451
  message: err.message,
448
452
  stack: err.stack || "no stack",
449
453
  componentInfo: info,
450
- componentName: instance?.$options?.name || "unknown"
454
+ componentName: (instance === null || instance === void 0 || (_instance$$options = instance.$options) === null || _instance$$options === void 0 ? void 0 : _instance$$options.name) || "unknown"
451
455
  }
452
456
  });
453
457
  };
package/dist/index.esm.js CHANGED
@@ -293,10 +293,11 @@ class TrackerSDK {
293
293
  * @param element 点击的DOM元素
294
294
  */
295
295
  trackClick(element) {
296
+ var _element$innerText;
296
297
  const tagName = element.tagName.toLowerCase();
297
298
  const id = element.id || "";
298
299
  const classes = Array.from(element.classList).join(" ");
299
- const text = ["button", "a"].includes(tagName) ? element.innerText?.trim().slice(0, 20) : "";
300
+ const text = ["button", "a"].includes(tagName) ? (_element$innerText = element.innerText) === null || _element$innerText === void 0 ? void 0 : _element$innerText.trim().slice(0, 20) : "";
300
301
  if (this.config.enableAutoClickTagNameList.includes(tagName)) {
301
302
  this.send({
302
303
  eventType: "click",
@@ -376,13 +377,14 @@ class TrackerSDK {
376
377
  filename,
377
378
  lineno,
378
379
  colno,
379
- stack: error?.stack || "no stack"
380
+ stack: (error === null || error === void 0 ? void 0 : error.stack) || "no stack"
380
381
  }
381
382
  });
382
383
  });
383
384
  // 资源加载错误
384
385
  window.addEventListener("error", e => {
385
- if (e.target?.localName) {
386
+ var _e$target;
387
+ if ((_e$target = e.target) !== null && _e$target !== void 0 && _e$target.localName) {
386
388
  let url = e.target.src || e.target.href || "";
387
389
  url = url.trim();
388
390
  const tag = e.target;
@@ -414,13 +416,14 @@ class TrackerSDK {
414
416
  window.addEventListener("unhandledrejection", event => {
415
417
  "Promise unhandled rejection捕获了";
416
418
 
419
+ var _event$reason;
417
420
  console.log("🚀 ~ 'Promise unhandled rejection捕获了'");
418
421
  this.send({
419
422
  eventType: "error",
420
423
  event: "promise_unhandled_rejection",
421
424
  properties: {
422
425
  reason: String(event.reason),
423
- stack: event.reason?.stack || "no stack"
426
+ stack: ((_event$reason = event.reason) === null || _event$reason === void 0 ? void 0 : _event$reason.stack) || "no stack"
424
427
  }
425
428
  });
426
429
  // 阻止打印报错信息
@@ -432,6 +435,7 @@ class TrackerSDK {
432
435
  */
433
436
  setupVueErrorHandlder(app) {
434
437
  app.config.errorHandler = (err, instance, info) => {
438
+ var _instance$$options;
435
439
  console.log("🚀 ~ vue 全局错误处理器捕获了");
436
440
  // setTimeout(() => {
437
441
  // throw err;
@@ -443,7 +447,7 @@ class TrackerSDK {
443
447
  message: err.message,
444
448
  stack: err.stack || "no stack",
445
449
  componentInfo: info,
446
- componentName: instance?.$options?.name || "unknown"
450
+ componentName: (instance === null || instance === void 0 || (_instance$$options = instance.$options) === null || _instance$$options === void 0 ? void 0 : _instance$$options.name) || "unknown"
447
451
  }
448
452
  });
449
453
  };
package/dist/index.js CHANGED
@@ -297,10 +297,11 @@
297
297
  * @param element 点击的DOM元素
298
298
  */
299
299
  trackClick(element) {
300
+ var _element$innerText;
300
301
  const tagName = element.tagName.toLowerCase();
301
302
  const id = element.id || "";
302
303
  const classes = Array.from(element.classList).join(" ");
303
- const text = ["button", "a"].includes(tagName) ? element.innerText?.trim().slice(0, 20) : "";
304
+ const text = ["button", "a"].includes(tagName) ? (_element$innerText = element.innerText) === null || _element$innerText === void 0 ? void 0 : _element$innerText.trim().slice(0, 20) : "";
304
305
  if (this.config.enableAutoClickTagNameList.includes(tagName)) {
305
306
  this.send({
306
307
  eventType: "click",
@@ -380,13 +381,14 @@
380
381
  filename,
381
382
  lineno,
382
383
  colno,
383
- stack: error?.stack || "no stack"
384
+ stack: (error === null || error === void 0 ? void 0 : error.stack) || "no stack"
384
385
  }
385
386
  });
386
387
  });
387
388
  // 资源加载错误
388
389
  window.addEventListener("error", e => {
389
- if (e.target?.localName) {
390
+ var _e$target;
391
+ if ((_e$target = e.target) !== null && _e$target !== void 0 && _e$target.localName) {
390
392
  let url = e.target.src || e.target.href || "";
391
393
  url = url.trim();
392
394
  const tag = e.target;
@@ -418,13 +420,14 @@
418
420
  window.addEventListener("unhandledrejection", event => {
419
421
  "Promise unhandled rejection捕获了";
420
422
 
423
+ var _event$reason;
421
424
  console.log("🚀 ~ 'Promise unhandled rejection捕获了'");
422
425
  this.send({
423
426
  eventType: "error",
424
427
  event: "promise_unhandled_rejection",
425
428
  properties: {
426
429
  reason: String(event.reason),
427
- stack: event.reason?.stack || "no stack"
430
+ stack: ((_event$reason = event.reason) === null || _event$reason === void 0 ? void 0 : _event$reason.stack) || "no stack"
428
431
  }
429
432
  });
430
433
  // 阻止打印报错信息
@@ -436,6 +439,7 @@
436
439
  */
437
440
  setupVueErrorHandlder(app) {
438
441
  app.config.errorHandler = (err, instance, info) => {
442
+ var _instance$$options;
439
443
  console.log("🚀 ~ vue 全局错误处理器捕获了");
440
444
  // setTimeout(() => {
441
445
  // throw err;
@@ -447,7 +451,7 @@
447
451
  message: err.message,
448
452
  stack: err.stack || "no stack",
449
453
  componentInfo: info,
450
- componentName: instance?.$options?.name || "unknown"
454
+ componentName: (instance === null || instance === void 0 || (_instance$$options = instance.$options) === null || _instance$$options === void 0 ? void 0 : _instance$$options.name) || "unknown"
451
455
  }
452
456
  });
453
457
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trackersdk2",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "一个适用于uni-app h5的前端埋点SDK,支持多种数据上报方式,帮助开发者轻松收集和分析用户行为数据。",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -23,6 +23,7 @@
23
23
  "homepage": "https://gitee.com/hwjstore/tracker-sdk",
24
24
  "devDependencies": {
25
25
  "@babel/core": "^7.28.5",
26
+ "@babel/plugin-transform-optional-chaining": "^7.28.5",
26
27
  "@babel/preset-env": "^7.28.5",
27
28
  "@rollup/plugin-babel": "^6.1.0",
28
29
  "rollup": "^4.55.1",
package/rollup.config.mjs CHANGED
@@ -40,6 +40,9 @@ export default [{
40
40
  ['@babel/preset-env', {
41
41
  targets: { browsers: ['> 1%', 'last 2 versions', 'not dead'] }
42
42
  }]
43
+ ],
44
+ plugins: [
45
+ '@babel/plugin-transform-optional-chaining',
43
46
  ]
44
47
  })
45
48
  ]