monitor-track 1.10.1 → 1.11.0

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/CHANGELOG.md CHANGED
@@ -3,6 +3,24 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ### 1.10.2 (2023-08-25)
7
+
8
+
9
+ ### ✨ Features
10
+
11
+ * monitor ([c4da59b](https://github.com/zhoushoujian/monitor/commit/c4da59bfc6e4ffe38670cb0f3c0f9f76cdecf99a))
12
+
13
+
14
+
15
+ ### 1.10.1 (2023-08-25)
16
+
17
+
18
+ ### ✨ Features
19
+
20
+ * monitor ([c4da59b](https://github.com/zhoushoujian/monitor/commit/c4da59bfc6e4ffe38670cb0f3c0f9f76cdecf99a))
21
+
22
+
23
+
6
24
  ## 1.10.0 (2023-08-25)
7
25
 
8
26
 
@@ -23,10 +23,6 @@ export declare function getConfigValue(key: keyof IConfig): string | number | bo
23
23
  urls?: string[] | undefined;
24
24
  errors?: (string | {
25
25
  regExp: boolean;
26
- /**
27
- * @description 设置config配置项
28
- * @param config 配置项
29
- */
30
26
  input: string;
31
27
  })[] | undefined;
32
28
  apis?: string[] | undefined;
package/cjs/constant.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const shuyunTrackId = "shuyun-track-id";
2
- export declare const shuyunTrackSessionId = "shuyun-track-session-id";
1
+ export declare const monitorTrackId = "monitor-track-id";
2
+ export declare const monitorTrackSessionId = "monitor-track-session-id";
package/cjs/index.js CHANGED
@@ -57,13 +57,9 @@ function __awaiter(thisArg, _arguments, P, generator) {
57
57
  });
58
58
  }
59
59
 
60
- const shuyunTrackId = 'shuyun-track-id';
61
- const shuyunTrackSessionId = 'shuyun-track-session-id';
60
+ const monitorTrackId = 'monitor-track-id';
61
+ const monitorTrackSessionId = 'monitor-track-session-id';
62
62
 
63
- /*
64
- * @Author: Mark.Zhang
65
- * @Description 配置项相关参数及方法
66
- */
67
63
  /** */
68
64
  /**
69
65
  * @description config配置项默认值
@@ -91,11 +87,6 @@ function setConfig(config) {
91
87
  Object.assign(Config, config);
92
88
  }
93
89
 
94
- /*
95
- * @Author: Mark.Zhang
96
- * @Date: 2020-10-26 11:10:04
97
- * @Description 资源加载错误及js错误相关的处理方法
98
- */
99
90
  const eventsMatrix = [[]];
100
91
  rrweb__namespace.record({
101
92
  emit(event, isCheckout) {
@@ -616,7 +607,6 @@ function convertToSchema(data, map, redundancyData) {
616
607
  return reportData;
617
608
  }
618
609
 
619
- /* eslint-disable prefer-rest-params */
620
610
  /** 路由栈数组,存储路由变化信息 */
621
611
  let routerStack = [];
622
612
  /** 路由触发的时间 */
@@ -629,9 +619,11 @@ function _history(type) {
629
619
  const origin = history[type];
630
620
  return function () {
631
621
  // @ts-ignore
622
+ // eslint-disable-next-line prefer-rest-params
632
623
  const r = origin.apply(this, arguments);
633
624
  const e = new Event(type);
634
625
  // @ts-ignore
626
+ // eslint-disable-next-line prefer-rest-params
635
627
  e.arguments = arguments;
636
628
  window.dispatchEvent(e);
637
629
  return r;
@@ -709,13 +701,8 @@ function setRouteStack(page) {
709
701
  };
710
702
  }
711
703
 
712
- var version = "1.10.1";
704
+ var version = "1.11.0";
713
705
 
714
- /*
715
- * @Author: Mark.Zhang
716
- * @Date: 2020-10-26 15:40:16
717
- * @Description 全局配置项
718
- */
719
706
  // 上报数据
720
707
  let Report = {
721
708
  uuid: '',
@@ -801,11 +788,12 @@ function setReportValue(key, value) {
801
788
  function getReport() {
802
789
  const nav = getNavigator();
803
790
  const viewport = getViewport();
791
+ const uuid = localStorage.getItem('username') || getUid();
804
792
  return Object.assign(Object.assign(Object.assign({}, Report), nav), {
805
793
  version,
806
794
  projectID: Config.projectID,
807
795
  host: location.host,
808
- uuid: getUid(),
796
+ uuid,
809
797
  viewport,
810
798
  screen: `${screen.width} x ${screen.height}`,
811
799
  pageTitle: document.title,
@@ -974,11 +962,6 @@ const hackFetch = (XMLHttpRequestTimeout) => {
974
962
  }
975
963
  };
976
964
 
977
- /*
978
- * @Author: Mark.Zhang
979
- * @Date: 2020-10-26 11:10:04
980
- * @Description 用户行为处理方法
981
- */
982
965
  /**
983
966
  * @description 点击事件触发后的操作
984
967
  */
@@ -1040,10 +1023,10 @@ const parser = new uaParserJs.UAParser();
1040
1023
  * @description 获取uuid
1041
1024
  */
1042
1025
  function getUid() {
1043
- let uid = localStorage.getItem(shuyunTrackId) || '';
1026
+ let uid = localStorage.getItem(monitorTrackId) || '';
1044
1027
  if (!uid) {
1045
1028
  uid = uuid.v4();
1046
- localStorage.setItem(shuyunTrackId, uid);
1029
+ localStorage.setItem(monitorTrackId, uid);
1047
1030
  }
1048
1031
  return uid;
1049
1032
  }
@@ -1051,13 +1034,13 @@ function getUid() {
1051
1034
  * @description 获取session id
1052
1035
  */
1053
1036
  function getSessionId() {
1054
- const sessionId = sessionStorage.getItem(shuyunTrackSessionId);
1037
+ const sessionId = sessionStorage.getItem(monitorTrackSessionId);
1055
1038
  if (sessionId) {
1056
1039
  return sessionId;
1057
1040
  }
1058
1041
  else {
1059
1042
  const id = uuid.v4();
1060
- sessionStorage.setItem(shuyunTrackSessionId, id);
1043
+ sessionStorage.setItem(monitorTrackSessionId, id);
1061
1044
  return id;
1062
1045
  }
1063
1046
  }
@@ -1478,7 +1461,7 @@ class Track {
1478
1461
  if (Config.enableError) {
1479
1462
  off('error', handleError);
1480
1463
  }
1481
- sessionStorage.removeItem(shuyunTrackSessionId);
1464
+ sessionStorage.removeItem(monitorTrackSessionId);
1482
1465
  }
1483
1466
  }
1484
1467
 
@@ -5,11 +5,6 @@ import { setRouteStack, setPVTime } from '../handlers/pv.js';
5
5
  import { Config } from './index.js';
6
6
  import { version } from '../package.json.js';
7
7
 
8
- /*
9
- * @Author: Mark.Zhang
10
- * @Date: 2020-10-26 15:40:16
11
- * @Description 全局配置项
12
- */
13
8
  // 上报数据
14
9
  let Report = {
15
10
  uuid: '',
@@ -95,11 +90,12 @@ function setReportValue(key, value) {
95
90
  function getReport() {
96
91
  const nav = getNavigator();
97
92
  const viewport = getViewport();
93
+ const uuid = localStorage.getItem('username') || getUid();
98
94
  return Object.assign(Object.assign(Object.assign({}, Report), nav), {
99
95
  version,
100
96
  projectID: Config.projectID,
101
97
  host: location.host,
102
- uuid: getUid(),
98
+ uuid,
103
99
  viewport,
104
100
  screen: `${screen.width} x ${screen.height}`,
105
101
  pageTitle: document.title,
@@ -23,10 +23,6 @@ export declare function getConfigValue(key: keyof IConfig): string | number | bo
23
23
  urls?: string[] | undefined;
24
24
  errors?: (string | {
25
25
  regExp: boolean;
26
- /**
27
- * @description 设置config配置项
28
- * @param config 配置项
29
- */
30
26
  input: string;
31
27
  })[] | undefined;
32
28
  apis?: string[] | undefined;
@@ -1,7 +1,3 @@
1
- /*
2
- * @Author: Mark.Zhang
3
- * @Description 配置项相关参数及方法
4
- */
5
1
  /** */
6
2
  /**
7
3
  * @description config配置项默认值
package/esm/constant.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const shuyunTrackId = "shuyun-track-id";
2
- export declare const shuyunTrackSessionId = "shuyun-track-session-id";
1
+ export declare const monitorTrackId = "monitor-track-id";
2
+ export declare const monitorTrackSessionId = "monitor-track-session-id";
package/esm/constant.js CHANGED
@@ -1,4 +1,4 @@
1
- const shuyunTrackId = 'shuyun-track-id';
2
- const shuyunTrackSessionId = 'shuyun-track-session-id';
1
+ const monitorTrackId = 'monitor-track-id';
2
+ const monitorTrackSessionId = 'monitor-track-session-id';
3
3
 
4
- export { shuyunTrackId, shuyunTrackSessionId };
4
+ export { monitorTrackId, monitorTrackSessionId };
@@ -6,11 +6,6 @@ import { report } from '../reporter.js';
6
6
  import { setReportValue, getReport } from '../config/global.js';
7
7
  import { Config } from '../config/index.js';
8
8
 
9
- /*
10
- * @Author: Mark.Zhang
11
- * @Date: 2020-10-26 11:10:04
12
- * @Description 资源加载错误及js错误相关的处理方法
13
- */
14
9
  const eventsMatrix = [[]];
15
10
  rrweb.record({
16
11
  emit(event, isCheckout) {
@@ -3,7 +3,6 @@ import { report } from '../reporter.js';
3
3
  import { Config } from '../config/index.js';
4
4
  import { visualTrackFunc } from '../utils/index.js';
5
5
 
6
- /* eslint-disable prefer-rest-params */
7
6
  /** 路由栈数组,存储路由变化信息 */
8
7
  let routerStack = [];
9
8
  /** 路由触发的时间 */
@@ -16,9 +15,11 @@ function _history(type) {
16
15
  const origin = history[type];
17
16
  return function () {
18
17
  // @ts-ignore
18
+ // eslint-disable-next-line prefer-rest-params
19
19
  const r = origin.apply(this, arguments);
20
20
  const e = new Event(type);
21
21
  // @ts-ignore
22
+ // eslint-disable-next-line prefer-rest-params
22
23
  e.arguments = arguments;
23
24
  window.dispatchEvent(e);
24
25
  return r;
@@ -2,11 +2,6 @@ import { getElmPath } from '../utils/index.js';
2
2
  import { report } from '../reporter.js';
3
3
  import { setReportValue, getReport } from '../config/global.js';
4
4
 
5
- /*
6
- * @Author: Mark.Zhang
7
- * @Date: 2020-10-26 11:10:04
8
- * @Description 用户行为处理方法
9
- */
10
5
  /**
11
6
  * @description 点击事件触发后的操作
12
7
  */
package/esm/index.js CHANGED
@@ -4,7 +4,7 @@ import { initReport, recordXMLHttpRequestLog, hackFetch } from './config/global.
4
4
  import { _history, handleHistoryChange } from './handlers/pv.js';
5
5
  import { handleError } from './handlers/error.js';
6
6
  import { handleClick, handleBlur, handleScroll } from './handlers/user-activity.js';
7
- import { shuyunTrackSessionId } from './constant.js';
7
+ import { monitorTrackSessionId } from './constant.js';
8
8
 
9
9
  class Track {
10
10
  constructor() {
@@ -108,7 +108,7 @@ class Track {
108
108
  if (Config.enableError) {
109
109
  off('error', handleError);
110
110
  }
111
- sessionStorage.removeItem(shuyunTrackSessionId);
111
+ sessionStorage.removeItem(monitorTrackSessionId);
112
112
  }
113
113
  }
114
114
 
@@ -1,3 +1,3 @@
1
- var version = "1.10.1";
1
+ var version = "1.11.0";
2
2
 
3
3
  export { version };
@@ -2,7 +2,7 @@ import { __awaiter } from '../_virtual/_tslib.js';
2
2
  import axios from 'axios';
3
3
  import { v4 } from 'uuid';
4
4
  import { UAParser } from 'ua-parser-js';
5
- import { shuyunTrackSessionId, shuyunTrackId } from '../constant.js';
5
+ import { monitorTrackSessionId, monitorTrackId } from '../constant.js';
6
6
  import { setReportValue, getReport } from '../config/global.js';
7
7
  import { report } from '../reporter.js';
8
8
  import { Config } from '../config/index.js';
@@ -15,10 +15,10 @@ const parser = new UAParser();
15
15
  * @description 获取uuid
16
16
  */
17
17
  function getUid() {
18
- let uid = localStorage.getItem(shuyunTrackId) || '';
18
+ let uid = localStorage.getItem(monitorTrackId) || '';
19
19
  if (!uid) {
20
20
  uid = v4();
21
- localStorage.setItem(shuyunTrackId, uid);
21
+ localStorage.setItem(monitorTrackId, uid);
22
22
  }
23
23
  return uid;
24
24
  }
@@ -26,13 +26,13 @@ function getUid() {
26
26
  * @description 获取session id
27
27
  */
28
28
  function getSessionId() {
29
- const sessionId = sessionStorage.getItem(shuyunTrackSessionId);
29
+ const sessionId = sessionStorage.getItem(monitorTrackSessionId);
30
30
  if (sessionId) {
31
31
  return sessionId;
32
32
  }
33
33
  else {
34
34
  const id = v4();
35
- sessionStorage.setItem(shuyunTrackSessionId, id);
35
+ sessionStorage.setItem(monitorTrackSessionId, id);
36
36
  return id;
37
37
  }
38
38
  }
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var ShuyunTrack = (function (axios, uuid, uaParserJs, rrweb, ErrorStackParser, html2canvas) {
1
+ var MonitorTrack = (function (axios, uuid, uaParserJs, rrweb, ErrorStackParser, html2canvas) {
2
2
  'use strict';
3
3
 
4
4
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -95,13 +95,9 @@ var ShuyunTrack = (function (axios, uuid, uaParserJs, rrweb, ErrorStackParser, h
95
95
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
96
96
  };
97
97
 
98
- var shuyunTrackId = 'shuyun-track-id';
99
- var shuyunTrackSessionId = 'shuyun-track-session-id';
98
+ var monitorTrackId = 'monitor-track-id';
99
+ var monitorTrackSessionId = 'monitor-track-session-id';
100
100
 
101
- /*
102
- * @Author: Mark.Zhang
103
- * @Description 配置项相关参数及方法
104
- */
105
101
  /** */
106
102
  /**
107
103
  * @description config配置项默认值
@@ -129,11 +125,6 @@ var ShuyunTrack = (function (axios, uuid, uaParserJs, rrweb, ErrorStackParser, h
129
125
  Object.assign(Config, config);
130
126
  }
131
127
 
132
- /*
133
- * @Author: Mark.Zhang
134
- * @Date: 2020-10-26 11:10:04
135
- * @Description 资源加载错误及js错误相关的处理方法
136
- */
137
128
  var eventsMatrix = [[]];
138
129
  rrweb__namespace.record({
139
130
  emit: function (event, isCheckout) {
@@ -653,7 +644,6 @@ var ShuyunTrack = (function (axios, uuid, uaParserJs, rrweb, ErrorStackParser, h
653
644
  return reportData;
654
645
  }
655
646
 
656
- /* eslint-disable prefer-rest-params */
657
647
  /** 路由栈数组,存储路由变化信息 */
658
648
  var routerStack = [];
659
649
  /** 路由触发的时间 */
@@ -666,9 +656,11 @@ var ShuyunTrack = (function (axios, uuid, uaParserJs, rrweb, ErrorStackParser, h
666
656
  var origin = history[type];
667
657
  return function () {
668
658
  // @ts-ignore
659
+ // eslint-disable-next-line prefer-rest-params
669
660
  var r = origin.apply(this, arguments);
670
661
  var e = new Event(type);
671
662
  // @ts-ignore
663
+ // eslint-disable-next-line prefer-rest-params
672
664
  e.arguments = arguments;
673
665
  window.dispatchEvent(e);
674
666
  return r;
@@ -746,7 +738,7 @@ var ShuyunTrack = (function (axios, uuid, uaParserJs, rrweb, ErrorStackParser, h
746
738
  };
747
739
  }
748
740
 
749
- var version = "1.10.1";
741
+ var version = "1.11.0";
750
742
 
751
743
  // 上报数据
752
744
  var Report = {
@@ -833,11 +825,12 @@ var ShuyunTrack = (function (axios, uuid, uaParserJs, rrweb, ErrorStackParser, h
833
825
  function getReport() {
834
826
  var nav = getNavigator();
835
827
  var viewport = getViewport();
828
+ var uuid = localStorage.getItem('username') || getUid();
836
829
  return __assign(__assign(__assign({}, Report), nav), {
837
830
  version: version,
838
831
  projectID: Config.projectID,
839
832
  host: location.host,
840
- uuid: getUid(),
833
+ uuid: uuid,
841
834
  viewport: viewport,
842
835
  screen: "".concat(screen.width, " x ").concat(screen.height),
843
836
  pageTitle: document.title,
@@ -1011,11 +1004,6 @@ var ShuyunTrack = (function (axios, uuid, uaParserJs, rrweb, ErrorStackParser, h
1011
1004
  }
1012
1005
  };
1013
1006
 
1014
- /*
1015
- * @Author: Mark.Zhang
1016
- * @Date: 2020-10-26 11:10:04
1017
- * @Description 用户行为处理方法
1018
- */
1019
1007
  /**
1020
1008
  * @description 点击事件触发后的操作
1021
1009
  */
@@ -1077,10 +1065,10 @@ var ShuyunTrack = (function (axios, uuid, uaParserJs, rrweb, ErrorStackParser, h
1077
1065
  * @description 获取uuid
1078
1066
  */
1079
1067
  function getUid() {
1080
- var uid = localStorage.getItem(shuyunTrackId) || '';
1068
+ var uid = localStorage.getItem(monitorTrackId) || '';
1081
1069
  if (!uid) {
1082
1070
  uid = uuid.v4();
1083
- localStorage.setItem(shuyunTrackId, uid);
1071
+ localStorage.setItem(monitorTrackId, uid);
1084
1072
  }
1085
1073
  return uid;
1086
1074
  }
@@ -1088,13 +1076,13 @@ var ShuyunTrack = (function (axios, uuid, uaParserJs, rrweb, ErrorStackParser, h
1088
1076
  * @description 获取session id
1089
1077
  */
1090
1078
  function getSessionId() {
1091
- var sessionId = sessionStorage.getItem(shuyunTrackSessionId);
1079
+ var sessionId = sessionStorage.getItem(monitorTrackSessionId);
1092
1080
  if (sessionId) {
1093
1081
  return sessionId;
1094
1082
  }
1095
1083
  else {
1096
1084
  var id = uuid.v4();
1097
- sessionStorage.setItem(shuyunTrackSessionId, id);
1085
+ sessionStorage.setItem(monitorTrackSessionId, id);
1098
1086
  return id;
1099
1087
  }
1100
1088
  }
@@ -1524,7 +1512,7 @@ var ShuyunTrack = (function (axios, uuid, uaParserJs, rrweb, ErrorStackParser, h
1524
1512
  if (Config.enableError) {
1525
1513
  off('error', handleError);
1526
1514
  }
1527
- sessionStorage.removeItem(shuyunTrackSessionId);
1515
+ sessionStorage.removeItem(monitorTrackSessionId);
1528
1516
  };
1529
1517
  return Track;
1530
1518
  }());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monitor-track",
3
- "version": "1.10.1",
3
+ "version": "1.11.0",
4
4
  "description": "前端监控及埋点SDK工具javascript版本",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",