@cloudcare/rum-uniapp 2.1.18 → 2.1.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.
Files changed (105) hide show
  1. package/README.md +42 -34
  2. package/cjs/boot/buildEnv.js +3 -4
  3. package/cjs/boot/rum.entry.js +11 -36
  4. package/cjs/boot/rum.js +2 -25
  5. package/cjs/core/baseInfo.js +6 -25
  6. package/cjs/core/boundedBuffer.js +1 -7
  7. package/cjs/core/configuration.js +15 -27
  8. package/cjs/core/contextManager.js +5 -17
  9. package/cjs/core/dataMap.js +5 -10
  10. package/cjs/core/downloadProxy.js +4 -26
  11. package/cjs/core/errorCollection.js +5 -35
  12. package/cjs/core/errorFilter.js +0 -8
  13. package/cjs/core/errorTools.js +2 -10
  14. package/cjs/core/heavyCustomerDataWarning.js +3 -9
  15. package/cjs/core/lifeCycle.js +8 -18
  16. package/cjs/core/observable.js +7 -13
  17. package/cjs/core/sdk.js +4 -13
  18. package/cjs/core/sessionManagement.js +8 -17
  19. package/cjs/core/transport.js +6 -53
  20. package/cjs/core/user.js +2 -7
  21. package/cjs/core/xhrProxy.js +4 -26
  22. package/cjs/helper/byteUtils.js +6 -12
  23. package/cjs/helper/commonContext.js +2 -3
  24. package/cjs/helper/enums.js +17 -28
  25. package/cjs/helper/jsonStringify.js +5 -12
  26. package/cjs/helper/limitModification.js +3 -21
  27. package/cjs/helper/tracekit.js +33 -145
  28. package/cjs/helper/utils.js +92 -306
  29. package/cjs/index.js +0 -1
  30. package/cjs/rumEventsCollection/action/actionCollection.js +0 -9
  31. package/cjs/rumEventsCollection/action/trackActions.js +6 -28
  32. package/cjs/rumEventsCollection/app/appCollection.js +0 -6
  33. package/cjs/rumEventsCollection/app/index.js +14 -26
  34. package/cjs/rumEventsCollection/assembly.js +0 -14
  35. package/cjs/rumEventsCollection/error/errorCollection.js +1 -16
  36. package/cjs/rumEventsCollection/internalContext.js +0 -2
  37. package/cjs/rumEventsCollection/page/index.js +5 -43
  38. package/cjs/rumEventsCollection/page/viewCollection.js +0 -8
  39. package/cjs/rumEventsCollection/parentContexts.js +3 -20
  40. package/cjs/rumEventsCollection/performanceCollection.js +0 -4
  41. package/cjs/rumEventsCollection/requestCollection.js +1 -14
  42. package/cjs/rumEventsCollection/resource/resourceCollection.js +0 -11
  43. package/cjs/rumEventsCollection/resource/resourceUtils.js +50 -46
  44. package/cjs/rumEventsCollection/setDataCollection.js +0 -16
  45. package/cjs/rumEventsCollection/tracing/ddtraceTracer.js +0 -6
  46. package/cjs/rumEventsCollection/tracing/jaegerTracer.js +3 -9
  47. package/cjs/rumEventsCollection/tracing/skywalkingTracer.js +3 -10
  48. package/cjs/rumEventsCollection/tracing/tracer.js +1 -25
  49. package/cjs/rumEventsCollection/tracing/w3cTraceParentTracer.js +1 -6
  50. package/cjs/rumEventsCollection/tracing/zipkinMultiTracer.js +3 -10
  51. package/cjs/rumEventsCollection/tracing/zipkinSingleTracer.js +1 -6
  52. package/cjs/rumEventsCollection/trackEventCounts.js +0 -8
  53. package/cjs/rumEventsCollection/trackPageActiveites.js +10 -33
  54. package/cjs/rumEventsCollection/transport/batch.js +0 -9
  55. package/esm/boot/buildEnv.js +1 -1
  56. package/esm/boot/rum.entry.js +8 -20
  57. package/esm/boot/rum.js +0 -4
  58. package/esm/core/baseInfo.js +0 -11
  59. package/esm/core/boundedBuffer.js +0 -3
  60. package/esm/core/configuration.js +13 -21
  61. package/esm/core/contextManager.js +3 -8
  62. package/esm/core/dataMap.js +2 -2
  63. package/esm/core/downloadProxy.js +2 -17
  64. package/esm/core/errorCollection.js +2 -15
  65. package/esm/core/errorFilter.js +0 -5
  66. package/esm/core/errorTools.js +0 -3
  67. package/esm/core/heavyCustomerDataWarning.js +3 -3
  68. package/esm/core/lifeCycle.js +0 -5
  69. package/esm/core/observable.js +0 -3
  70. package/esm/core/sdk.js +1 -6
  71. package/esm/core/sessionManagement.js +0 -3
  72. package/esm/core/transport.js +4 -38
  73. package/esm/core/user.js +2 -4
  74. package/esm/core/xhrProxy.js +2 -17
  75. package/esm/helper/byteUtils.js +4 -7
  76. package/esm/helper/commonContext.js +2 -2
  77. package/esm/helper/jsonStringify.js +4 -7
  78. package/esm/helper/limitModification.js +1 -11
  79. package/esm/helper/tracekit.js +30 -130
  80. package/esm/helper/utils.js +27 -125
  81. package/esm/rumEventsCollection/action/actionCollection.js +0 -4
  82. package/esm/rumEventsCollection/action/trackActions.js +6 -20
  83. package/esm/rumEventsCollection/app/appCollection.js +0 -1
  84. package/esm/rumEventsCollection/app/index.js +12 -18
  85. package/esm/rumEventsCollection/assembly.js +0 -6
  86. package/esm/rumEventsCollection/error/errorCollection.js +0 -7
  87. package/esm/rumEventsCollection/internalContext.js +0 -1
  88. package/esm/rumEventsCollection/page/index.js +5 -37
  89. package/esm/rumEventsCollection/page/viewCollection.js +0 -3
  90. package/esm/rumEventsCollection/parentContexts.js +0 -10
  91. package/esm/rumEventsCollection/requestCollection.js +0 -4
  92. package/esm/rumEventsCollection/resource/resourceCollection.js +0 -5
  93. package/esm/rumEventsCollection/resource/resourceUtils.js +48 -39
  94. package/esm/rumEventsCollection/setDataCollection.js +0 -13
  95. package/esm/rumEventsCollection/tracing/ddtraceTracer.js +0 -4
  96. package/esm/rumEventsCollection/tracing/jaegerTracer.js +3 -7
  97. package/esm/rumEventsCollection/tracing/skywalkingTracer.js +5 -9
  98. package/esm/rumEventsCollection/tracing/tracer.js +0 -14
  99. package/esm/rumEventsCollection/tracing/w3cTraceParentTracer.js +1 -4
  100. package/esm/rumEventsCollection/tracing/zipkinMultiTracer.js +3 -8
  101. package/esm/rumEventsCollection/tracing/zipkinSingleTracer.js +1 -4
  102. package/esm/rumEventsCollection/trackEventCounts.js +0 -4
  103. package/esm/rumEventsCollection/trackPageActiveites.js +9 -22
  104. package/esm/rumEventsCollection/transport/batch.js +0 -5
  105. package/package.json +6 -3
@@ -6,15 +6,14 @@ import { ActionType } from '../../helper/enums';
6
6
  import { tracker } from '../../core/sdk';
7
7
  var WHITE_METHOD = ['setup'];
8
8
  export function trackActions(lifeCycle, Vue) {
9
- var action = startActionManagement(lifeCycle); // New views trigger the discard of the current pending Action
9
+ var action = startActionManagement(lifeCycle);
10
10
 
11
+ // New views trigger the discard of the current pending Action
11
12
  lifeCycle.subscribe(LifeCycleEventType.VIEW_CREATED, function () {
12
13
  action.discardCurrent();
13
14
  });
14
-
15
15
  if (Vue && Vue.extend) {
16
16
  var originVueExtend = Vue.extend;
17
-
18
17
  Vue.extend = function (vueOptions) {
19
18
  proxyInstance(vueOptions, action, lifeCycle);
20
19
  return originVueExtend.call(this, vueOptions);
@@ -22,25 +21,23 @@ export function trackActions(lifeCycle, Vue) {
22
21
  } else {
23
22
  if (!tracker) return;
24
23
  var originCreatePage = tracker.createPage;
25
-
26
24
  tracker.createPage = function (page) {
27
25
  // methods 方法
28
26
  proxyInstance(page, action, lifeCycle);
29
27
  return originCreatePage.call(this, page);
30
28
  };
31
-
32
29
  var originCreateComponent = tracker.createComponent;
33
-
34
30
  tracker.createComponent = function (component) {
35
31
  proxyInstance(component, action, lifeCycle);
36
32
  return originCreateComponent.call(this, component);
37
33
  };
38
- } // var originVueExtend = Vue.extend
39
-
34
+ }
35
+ // var originVueExtend = Vue.extend
40
36
 
41
37
  return {
42
38
  stop: function stop() {
43
- action.discardCurrent(); // stopListener()
39
+ action.discardCurrent();
40
+ // stopListener()
44
41
  }
45
42
  };
46
43
  }
@@ -55,7 +52,6 @@ function proxyInstance(options, action, lifeCycle) {
55
52
  }, lifeCycle);
56
53
  });
57
54
  }
58
-
59
55
  var originMethods = getMethods(options);
60
56
  originMethods.forEach(methodName => {
61
57
  clickProxy(options, methodName, function (_action) {
@@ -63,20 +59,16 @@ function proxyInstance(options, action, lifeCycle) {
63
59
  }, lifeCycle);
64
60
  });
65
61
  }
66
-
67
62
  function clickProxy(origin, methodName, callback, lifeCycle) {
68
63
  if (WHITE_METHOD.indexOf(methodName) > -1) return;
69
64
  var originMethod = origin[methodName];
70
-
71
65
  origin[methodName] = function () {
72
66
  var result = originMethod.apply(this, arguments);
73
67
  var action = {};
74
-
75
68
  if (isObject(arguments[0])) {
76
69
  var currentTarget = arguments[0].currentTarget || {};
77
70
  var dataset = currentTarget.dataset || {};
78
71
  var actionType = arguments[0].type;
79
-
80
72
  if (actionType && ActionType[actionType]) {
81
73
  action.type = actionType;
82
74
  action.name = dataset.name || dataset.content || dataset.type;
@@ -105,11 +97,9 @@ function clickProxy(origin, methodName, callback, lifeCycle) {
105
97
  lifeCycle.notify(LifeCycleEventType.PAGE_ALIAS_ACTION, true);
106
98
  }
107
99
  }
108
-
109
100
  return result;
110
101
  };
111
102
  }
112
-
113
103
  function startActionManagement(lifeCycle) {
114
104
  var currentAction;
115
105
  var currentIdlePageActivitySubscription;
@@ -119,7 +109,6 @@ function startActionManagement(lifeCycle) {
119
109
  // Ignore any new action if another one is already occurring.
120
110
  return;
121
111
  }
122
-
123
112
  var pendingAutoAction = new PendingAutoAction(lifeCycle, type, name);
124
113
  currentAction = pendingAutoAction;
125
114
  currentIdlePageActivitySubscription = waitIdlePageActivity(lifeCycle, function (params) {
@@ -128,7 +117,6 @@ function startActionManagement(lifeCycle) {
128
117
  } else {
129
118
  pendingAutoAction.discard();
130
119
  }
131
-
132
120
  currentAction = undefined;
133
121
  });
134
122
  },
@@ -141,7 +129,6 @@ function startActionManagement(lifeCycle) {
141
129
  }
142
130
  };
143
131
  }
144
-
145
132
  var PendingAutoAction = function PendingAutoAction(lifeCycle, type, name) {
146
133
  this.id = UUID();
147
134
  this.startClocks = now();
@@ -154,7 +141,6 @@ var PendingAutoAction = function PendingAutoAction(lifeCycle, type, name) {
154
141
  startClocks: this.startClocks
155
142
  });
156
143
  };
157
-
158
144
  PendingAutoAction.prototype = {
159
145
  complete: function complete(endTime) {
160
146
  var eventCounts = this.eventCountsSubscription.eventCounts;
@@ -8,7 +8,6 @@ export function startAppCollection(lifeCycle, configuration) {
8
8
  });
9
9
  return rewriteApp(configuration, lifeCycle);
10
10
  }
11
-
12
11
  function processAppUpdate(appinfo) {
13
12
  var appEvent = {
14
13
  date: appinfo.startTime,
@@ -1,6 +1,7 @@
1
1
  import { now, areInOrder, UUID } from '../../helper/utils';
2
- import { LifeCycleEventType } from '../../core/lifeCycle'; // 劫持原小程序App方法
2
+ import { LifeCycleEventType } from '../../core/lifeCycle';
3
3
 
4
+ // 劫持原小程序App方法
4
5
  export var THROTTLE_VIEW_UPDATE_PERIOD = 3000;
5
6
  export var startupTypes = {
6
7
  COLD: 'cold',
@@ -10,16 +11,15 @@ export function rewriteApp(configuration, lifeCycle, Vue) {
10
11
  var originApp = App;
11
12
  var appInfo = {
12
13
  isStartUp: false // 是否启动
13
-
14
14
  };
15
- var startTime;
16
15
 
16
+ var startTime;
17
17
  App = function App(app) {
18
- startTime = now() // 合并方法,插入记录脚本
18
+ startTime = now()
19
+ // 合并方法,插入记录脚本
19
20
  ;
20
21
  ['onLaunch', 'onShow', 'onHide'].forEach(methodName => {
21
22
  var userDefinedMethod = app[methodName]; // 暂存用户定义的方法
22
-
23
23
  app[methodName] = function (options) {
24
24
  if (methodName === 'onLaunch') {
25
25
  appInfo.isStartUp = true;
@@ -28,28 +28,25 @@ export function rewriteApp(configuration, lifeCycle, Vue) {
28
28
  } else if (methodName === 'onShow') {
29
29
  if (appInfo.isStartUp && appInfo.isHide) {
30
30
  // 判断是热启动
31
- appInfo.startupType = startupTypes.HOT; // appUpdate()
31
+ appInfo.startupType = startupTypes.HOT;
32
+ // appUpdate()
32
33
  }
33
34
  } else if (methodName === 'onHide') {
34
35
  lifeCycle.notify(LifeCycleEventType.APP_HIDE);
35
36
  appInfo.isHide = true;
36
37
  }
37
-
38
38
  return userDefinedMethod && userDefinedMethod.call(this, options);
39
39
  };
40
40
  });
41
41
  return originApp(app);
42
42
  };
43
-
44
43
  startPerformanceObservable(lifeCycle);
45
44
  }
46
-
47
45
  function startPerformanceObservable(lifeCycle) {
48
46
  var subscribe = lifeCycle.subscribe(LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, function (entitys) {
49
47
  // 过滤掉其他页面监听,只保留首次启动
50
48
  var codeDownloadDuration;
51
49
  var launchEntity = entitys.find(entity => entity.entryType === 'navigation' && entity.navigationType === 'appLaunch');
52
-
53
50
  if (typeof launchEntity !== 'undefined') {
54
51
  lifeCycle.notify(LifeCycleEventType.APP_UPDATE, {
55
52
  startTime: launchEntity.startTime,
@@ -59,9 +56,7 @@ function startPerformanceObservable(lifeCycle) {
59
56
  duration: launchEntity.duration
60
57
  });
61
58
  }
62
-
63
59
  var scriptentity = entitys.find(entity => entity.entryType === 'script' && entity.name === 'evaluateScript');
64
-
65
60
  if (typeof scriptentity !== 'undefined') {
66
61
  lifeCycle.notify(LifeCycleEventType.APP_UPDATE, {
67
62
  startTime: scriptentity.startTime,
@@ -71,25 +66,24 @@ function startPerformanceObservable(lifeCycle) {
71
66
  duration: scriptentity.duration
72
67
  });
73
68
  }
74
-
75
69
  var firstEntity = entitys.find(entity => entity.entryType === 'render' && entity.name === 'firstRender');
76
-
77
70
  if (firstEntity && scriptentity && launchEntity) {
78
71
  if (!areInOrder(firstEntity.duration, launchEntity.duration) || !areInOrder(scriptentity.duration, launchEntity.duration)) {
79
72
  return;
80
73
  }
81
-
82
- codeDownloadDuration = launchEntity.duration - firstEntity.duration - scriptentity.duration; // 资源下载耗时
83
-
74
+ codeDownloadDuration = launchEntity.duration - firstEntity.duration - scriptentity.duration;
75
+ // 资源下载耗时
84
76
  lifeCycle.notify(LifeCycleEventType.APP_UPDATE, {
85
77
  startTime: launchEntity.startTime,
86
78
  name: '小程序包下载',
87
79
  type: 'package_download',
88
80
  id: UUID(),
89
81
  duration: codeDownloadDuration
90
- }); // 资源下载时间暂时定为:首次启动时间-脚本加载时间-初次渲染时间
82
+ });
83
+ // 资源下载时间暂时定为:首次启动时间-脚本加载时间-初次渲染时间
91
84
  }
92
85
  });
86
+
93
87
  return {
94
88
  stop: subscribe.unsubscribe
95
89
  };
@@ -24,7 +24,6 @@ export function startRumAssembly(applicationId, configuration, session, lifeCycl
24
24
  launch: baseInfo.getLaunchOptions()
25
25
  }
26
26
  };
27
-
28
27
  if (session.isTracked() && (viewContext || rawRumEvent.type === RumEventType.APP)) {
29
28
  var actionContext = parentContexts.findAction(startTime);
30
29
  var commonContext = savedCommonContext || getCommonContext();
@@ -54,11 +53,9 @@ export function startRumAssembly(applicationId, configuration, session, lifeCycl
54
53
  var rumEvent = extend2Lev(rumContext, deviceContext, appContext, viewContext, actionContext, rawRumEvent);
55
54
  var serverRumEvent = withSnakeCaseKeys(rumEvent);
56
55
  var context = extend2Lev({}, commonContext.context, customerContext);
57
-
58
56
  if (!isEmptyObject(context)) {
59
57
  serverRumEvent.tags = context;
60
58
  }
61
-
62
59
  if (!isEmptyObject(commonContext.user)) {
63
60
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
64
61
  serverRumEvent.user = extend2Lev({
@@ -66,18 +63,15 @@ export function startRumAssembly(applicationId, configuration, session, lifeCycl
66
63
  is_signin: 'T'
67
64
  }, commonContext.user);
68
65
  }
69
-
70
66
  if (shouldSend(serverRumEvent, errorFilter)) {
71
67
  lifeCycle.notify(LifeCycleEventType.RUM_EVENT_COLLECTED, serverRumEvent);
72
68
  }
73
69
  }
74
70
  });
75
71
  }
76
-
77
72
  function shouldSend(event, errorFilter) {
78
73
  if (event.type === RumEventType.ERROR) {
79
74
  return !errorFilter.isLimitReached();
80
75
  }
81
-
82
76
  return true;
83
77
  }
@@ -26,7 +26,6 @@ export function doStartErrorCollection(lifeCycle) {
26
26
  }
27
27
  };
28
28
  }
29
-
30
29
  function computeRawError(error, startTime, context) {
31
30
  var stackTrace = error instanceof Error ? computeStackTrace(error) : undefined;
32
31
  return extend({
@@ -35,11 +34,9 @@ function computeRawError(error, startTime, context) {
35
34
  context
36
35
  }, formatUnknownError(stackTrace, error, 'Provided'));
37
36
  }
38
-
39
37
  function processError(error) {
40
38
  var resource = error.resource;
41
39
  var tracingInfo;
42
-
43
40
  if (resource) {
44
41
  tracingInfo = computeRequestTracingInfo(resource);
45
42
  var urlObj = urlParse(error.resource.url).getParse();
@@ -53,7 +50,6 @@ function processError(error) {
53
50
  urlPathGroup: replaceNumberCharByPath(urlObj.Path)
54
51
  };
55
52
  }
56
-
57
53
  var rawRumEvent = extend2Lev({
58
54
  date: error.startTime,
59
55
  error: {
@@ -72,14 +68,11 @@ function processError(error) {
72
68
  startTime: error.startTime
73
69
  };
74
70
  }
75
-
76
71
  function computeRequestTracingInfo(request) {
77
72
  var hasBeenTraced = request.traceId && request.spanId;
78
-
79
73
  if (!hasBeenTraced) {
80
74
  return undefined;
81
75
  }
82
-
83
76
  return {
84
77
  _dd: {
85
78
  spanId: request.spanId,
@@ -6,7 +6,6 @@ export function startInternalContext(applicationId, session, parentContexts) {
6
6
  return {
7
7
  get: function get(startTime) {
8
8
  var viewContext = parentContexts.findView(startTime);
9
-
10
9
  if (session.isTracked() && viewContext) {
11
10
  var actionContext = parentContexts.findAction(startTime);
12
11
  return {
@@ -1,70 +1,58 @@
1
1
  import { now, throttle, UUID, isNumber, getActivePage } from '../../helper/utils';
2
2
  import { trackEventCounts } from '../trackEventCounts';
3
- import { LifeCycleEventType } from '../../core/lifeCycle'; // 劫持原小程序App方法
3
+ import { LifeCycleEventType } from '../../core/lifeCycle';
4
4
 
5
+ // 劫持原小程序App方法
5
6
  export var THROTTLE_VIEW_UPDATE_PERIOD = 3000;
6
-
7
7
  function proxyPage(pageOptions, lifeCycle) {
8
8
  // 合并方法,插入记录脚本
9
9
  var currentView,
10
- startTime = now();
10
+ startTime = now();
11
11
  ['onReady', 'onShow', 'onLoad', 'onUnload', 'onHide'].forEach(methodName => {
12
12
  var userDefinedMethod = pageOptions[methodName];
13
-
14
13
  pageOptions[methodName] = function () {
15
14
  var mpType = this.mpType || this.$vm.mpType;
16
-
17
15
  if (mpType !== 'page') {
18
16
  return userDefinedMethod && userDefinedMethod.apply(this, arguments);
19
- } // 只处理page类型
20
-
21
-
17
+ }
18
+ // 只处理page类型
22
19
  if (methodName === 'onShow' || methodName === 'onLoad') {
23
20
  if (typeof currentView === 'undefined') {
24
21
  var activePage = getActivePage();
25
22
  currentView = newView(lifeCycle, activePage && activePage.route, startTime);
26
23
  }
27
24
  }
28
-
29
25
  currentView && currentView.setLoadEventEnd(methodName);
30
-
31
26
  if ((methodName === 'onUnload' || methodName === 'onHide' || methodName === 'onShow') && currentView) {
32
27
  currentView.triggerUpdate();
33
-
34
28
  if (methodName === 'onUnload' || methodName === 'onHide') {
35
29
  currentView.end();
36
30
  currentView = undefined;
37
31
  }
38
32
  }
39
-
40
33
  return userDefinedMethod && userDefinedMethod.apply(this, arguments);
41
34
  };
42
35
  });
43
36
  }
44
-
45
37
  export function rewritePage(configuration, lifeCycle, Vue) {
46
38
  if (Vue && Vue.extend) {
47
39
  var originVueExtend = Vue.extend;
48
-
49
40
  Vue.extend = function (vueOptions) {
50
41
  proxyPage(vueOptions, lifeCycle);
51
42
  return originVueExtend.call(this, vueOptions);
52
43
  };
53
44
  } else {
54
45
  var originComponent = Component;
55
-
56
46
  Component = function Component(pageOptions) {
57
47
  proxyPage(pageOptions.methods, lifeCycle);
58
48
  return originComponent.call(this, pageOptions);
59
49
  };
60
50
  }
61
51
  }
62
-
63
52
  function newView(lifeCycle, route, startTime) {
64
53
  if (typeof startTime === 'undefined' || Number(startTime) === 0) {
65
54
  startTime = now();
66
55
  }
67
-
68
56
  var id = UUID();
69
57
  var isActive = true;
70
58
  var eventCounts = {
@@ -92,21 +80,16 @@ function newView(lifeCycle, route, startTime) {
92
80
  });
93
81
  var scheduleViewUpdate = scheduleViewThrottled.throttled;
94
82
  var cancelScheduleViewUpdate = scheduleViewThrottled.cancel;
95
-
96
83
  var _trackEventCounts = trackEventCounts(lifeCycle, function (newEventCounts) {
97
84
  eventCounts = newEventCounts;
98
85
  scheduleViewUpdate();
99
86
  });
100
-
101
87
  var stopEventCountsTracking = _trackEventCounts.stop;
102
-
103
88
  var _trackFptTime = trackFptTime(lifeCycle, function (duration) {
104
89
  fpt = duration;
105
90
  scheduleViewUpdate();
106
91
  });
107
-
108
92
  var stopFptTracking = _trackFptTime.stop;
109
-
110
93
  var _trackSetDataTime = trackSetDataTime(lifeCycle, function (duration) {
111
94
  if (isNumber(duration)) {
112
95
  setdataDuration += duration;
@@ -114,25 +97,20 @@ function newView(lifeCycle, route, startTime) {
114
97
  scheduleViewUpdate();
115
98
  }
116
99
  });
117
-
118
100
  var stopSetDataTracking = _trackSetDataTime.stop;
119
-
120
101
  var _trackLoadingTime = trackLoadingTime(lifeCycle, function (duration) {
121
102
  if (isNumber(duration)) {
122
103
  loadingDuration = duration;
123
104
  scheduleViewUpdate();
124
105
  }
125
106
  });
126
-
127
107
  var stopLoadingTimeTracking = _trackLoadingTime.stop;
128
-
129
108
  var setLoadEventEnd = function setLoadEventEnd(type) {
130
109
  if (type === 'onLoad') {
131
110
  loadingTime = now();
132
111
  loadingDuration = loadingTime - startTime;
133
112
  } else if (type === 'onShow') {
134
113
  showTime = now();
135
-
136
114
  if (typeof onload2onshowTime === 'undefined' && typeof loadingTime !== 'undefined') {
137
115
  onload2onshowTime = showTime - loadingTime;
138
116
  }
@@ -140,7 +118,6 @@ function newView(lifeCycle, route, startTime) {
140
118
  if (typeof onshow2onready === 'undefined' && typeof showTime !== 'undefined') {
141
119
  onshow2onready = now() - showTime;
142
120
  }
143
-
144
121
  if (typeof fmp === 'undefined') {
145
122
  fmp = now() - startTime; // 从开发者角度看,小程序首屏渲染完成的标志是首页 Page.onReady 事件触发。
146
123
  }
@@ -148,13 +125,10 @@ function newView(lifeCycle, route, startTime) {
148
125
  if (typeof showTime !== 'undefined') {
149
126
  stayTime = now() - showTime;
150
127
  }
151
-
152
128
  isActive = false;
153
129
  }
154
-
155
130
  triggerViewUpdate();
156
131
  };
157
-
158
132
  function triggerViewUpdate() {
159
133
  documentVersion += 1;
160
134
  lifeCycle.notify(LifeCycleEventType.VIEW_UPDATED, {
@@ -175,7 +149,6 @@ function newView(lifeCycle, route, startTime) {
175
149
  isActive: isActive
176
150
  });
177
151
  }
178
-
179
152
  return {
180
153
  scheduleUpdate: scheduleViewUpdate,
181
154
  setLoadEventEnd,
@@ -195,11 +168,9 @@ function newView(lifeCycle, route, startTime) {
195
168
  }
196
169
  };
197
170
  }
198
-
199
171
  function trackFptTime(lifeCycle, callback) {
200
172
  var subscribe = lifeCycle.subscribe(LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, function (entitys) {
201
173
  var firstRenderEntity = entitys.find(entity => entity.entryType === 'render' && entity.name === 'firstRender');
202
-
203
174
  if (typeof firstRenderEntity !== 'undefined') {
204
175
  callback(firstRenderEntity.duration);
205
176
  }
@@ -208,11 +179,9 @@ function trackFptTime(lifeCycle, callback) {
208
179
  stop: subscribe.unsubscribe
209
180
  };
210
181
  }
211
-
212
182
  function trackLoadingTime(lifeCycle, callback) {
213
183
  var subscribe = lifeCycle.subscribe(LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, function (entitys) {
214
184
  var navigationEnity = entitys.find(entity => entity.entryType === 'navigation');
215
-
216
185
  if (typeof navigationEnity !== 'undefined') {
217
186
  callback(navigationEnity.duration);
218
187
  }
@@ -221,7 +190,6 @@ function trackLoadingTime(lifeCycle, callback) {
221
190
  stop: subscribe.unsubscribe
222
191
  };
223
192
  }
224
-
225
193
  function trackSetDataTime(lifeCycle, callback) {
226
194
  var subscribe = lifeCycle.subscribe(LifeCycleEventType.PAGE_SET_DATA_UPDATE, function (data) {
227
195
  if (!data) return;
@@ -8,15 +8,12 @@ export function startViewCollection(lifeCycle, configuration, Vue) {
8
8
  });
9
9
  return rewritePage(configuration, lifeCycle, Vue);
10
10
  }
11
-
12
11
  function processViewUpdate(view) {
13
12
  var apdexLevel;
14
-
15
13
  if (view.fmp) {
16
14
  apdexLevel = parseInt(Number(view.fmp) / 1000);
17
15
  apdexLevel = apdexLevel > 9 ? 9 : apdexLevel;
18
16
  }
19
-
20
17
  var viewEvent = {
21
18
  _dd: {
22
19
  documentVersion: view.documentVersion
@@ -39,7 +39,6 @@ export function startParentContexts(lifeCycle) {
39
39
  startTime: currentAction.startClocks
40
40
  });
41
41
  }
42
-
43
42
  currentAction = undefined;
44
43
  });
45
44
  lifeCycle.subscribe(LifeCycleEventType.AUTO_ACTION_DISCARDED, function () {
@@ -54,15 +53,12 @@ export function startParentContexts(lifeCycle) {
54
53
  var clearOldContextsInterval = setInterval(function () {
55
54
  clearOldContexts(previousViews, VIEW_CONTEXT_TIME_OUT_DELAY);
56
55
  }, CLEAR_OLD_CONTEXTS_INTERVAL);
57
-
58
56
  function clearOldContexts(previousContexts, timeOutDelay) {
59
57
  var oldTimeThreshold = now() - timeOutDelay;
60
-
61
58
  while (previousContexts.length > 0 && previousContexts[previousContexts.length - 1].startTime < oldTimeThreshold) {
62
59
  previousContexts.pop();
63
60
  }
64
61
  }
65
-
66
62
  function buildCurrentActionContext() {
67
63
  return {
68
64
  userAction: {
@@ -70,7 +66,6 @@ export function startParentContexts(lifeCycle) {
70
66
  }
71
67
  };
72
68
  }
73
-
74
69
  function buildCurrentViewContext() {
75
70
  return {
76
71
  page: {
@@ -80,22 +75,18 @@ export function startParentContexts(lifeCycle) {
80
75
  }
81
76
  };
82
77
  }
83
-
84
78
  function findContext(buildContext, previousContexts, currentContext, startTime) {
85
79
  if (startTime === undefined) {
86
80
  return currentContext ? buildContext() : undefined;
87
81
  }
88
-
89
82
  if (currentContext && startTime >= currentContext.startTime) {
90
83
  return buildContext();
91
84
  }
92
-
93
85
  var flag = undefined;
94
86
  each(previousContexts, function (previousContext) {
95
87
  if (startTime > previousContext.endTime) {
96
88
  return false;
97
89
  }
98
-
99
90
  if (startTime >= previousContext.startTime) {
100
91
  flag = previousContext.context;
101
92
  return false;
@@ -103,7 +94,6 @@ export function startParentContexts(lifeCycle) {
103
94
  });
104
95
  return flag;
105
96
  }
106
-
107
97
  var parentContexts = {
108
98
  findView: function findView(startTime) {
109
99
  return findContext(buildCurrentViewContext, previousViews, currentView, startTime);
@@ -10,7 +10,6 @@ export function startRequestCollection(lifeCycle, configuration) {
10
10
  trackXhr(lifeCycle, configuration, tracer);
11
11
  trackDownload(lifeCycle, configuration);
12
12
  }
13
-
14
13
  function parseHeader(header) {
15
14
  // 大小写兼容
16
15
  if (!isObject(header)) return header;
@@ -20,7 +19,6 @@ function parseHeader(header) {
20
19
  });
21
20
  return res;
22
21
  }
23
-
24
22
  function getHeaderString(header) {
25
23
  if (!isObject(header)) return header;
26
24
  var headerStr = '';
@@ -29,7 +27,6 @@ function getHeaderString(header) {
29
27
  });
30
28
  return headerStr;
31
29
  }
32
-
33
30
  export function trackXhr(lifeCycle, configuration, tracer) {
34
31
  var xhrProxy = startXhrProxy(configuration);
35
32
  xhrProxy.beforeSend(function (context) {
@@ -88,7 +85,6 @@ export function trackDownload(lifeCycle, configuration) {
88
85
  });
89
86
  return dwonloadProxy;
90
87
  }
91
-
92
88
  function getNextRequestIndex() {
93
89
  var result = nextRequestIndex;
94
90
  nextRequestIndex += 1;
@@ -8,7 +8,6 @@ export function startResourceCollection(lifeCycle, configuration) {
8
8
  lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, processRequest(request));
9
9
  });
10
10
  }
11
-
12
11
  function processRequest(request) {
13
12
  var type = request.type;
14
13
  var timing = request.performance;
@@ -37,14 +36,11 @@ function processRequest(request) {
37
36
  rawRumEvent: resourceEvent
38
37
  };
39
38
  }
40
-
41
39
  function computeRequestTracingInfo(request) {
42
40
  var hasBeenTraced = request.traceId && request.spanId;
43
-
44
41
  if (!hasBeenTraced) {
45
42
  return undefined;
46
43
  }
47
-
48
44
  return {
49
45
  _dd: {
50
46
  spanId: request.spanId,
@@ -55,7 +51,6 @@ function computeRequestTracingInfo(request) {
55
51
  }
56
52
  };
57
53
  }
58
-
59
54
  function computePerformanceEntryMetrics(timing) {
60
55
  return {
61
56
  resource: extend2Lev({}, {