@cloudcare/browser-rum 3.1.3 → 3.1.5
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/bundle/dataflux-rum.js +1 -1
- package/cjs/boot/buildEnv.js +1 -1
- package/cjs/domain/configuration.js +2 -4
- package/cjs/domain/configuration.js.map +1 -1
- package/cjs/domain/replay/deflate/deflateWorker.js +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js +25 -8
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/viewCollection.js +17 -19
- package/cjs/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
- package/cjs/domain/waitPageActivityEnd.js.map +1 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/domain/configuration.js +3 -5
- package/esm/domain/configuration.js.map +1 -1
- package/esm/domain/replay/deflate/deflateWorker.js +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js +25 -8
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/viewCollection.js +17 -19
- package/esm/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
- package/esm/domain/waitPageActivityEnd.js.map +1 -1
- package/package.json +4 -4
- package/src/domain/configuration.js +4 -6
- package/src/domain/rumEventsCollection/resource/resourceCollection.js +55 -15
- package/src/domain/rumEventsCollection/view/viewCollection.js +43 -19
- package/src/domain/waitPageActivityEnd.js +1 -0
- package/src/.DS_Store +0 -0
- package/src/domain/.DS_Store +0 -0
- package/src/domain/rumEventsCollection/.DS_Store +0 -0
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
display,
|
|
4
4
|
isPercentage,
|
|
5
5
|
validateAndBuildConfiguration,
|
|
6
|
+
validatePostRequestRequireParamsConfiguration,
|
|
6
7
|
isArray,
|
|
7
8
|
TraceType,
|
|
8
9
|
isNullUndefinedDefaultValue,
|
|
@@ -21,12 +22,9 @@ export function validateAndBuildRumConfiguration(initConfiguration) {
|
|
|
21
22
|
)
|
|
22
23
|
return
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
28
|
-
return false
|
|
29
|
-
}
|
|
25
|
+
var requireParamsValidate =
|
|
26
|
+
validatePostRequestRequireParamsConfiguration(initConfiguration)
|
|
27
|
+
if (!requireParamsValidate) return
|
|
30
28
|
// TODO remove fallback in next major
|
|
31
29
|
if (
|
|
32
30
|
initConfiguration.sessionReplaySampleRate !== undefined &&
|
|
@@ -35,10 +35,15 @@ export function startResourceCollection(
|
|
|
35
35
|
pageStateHistory
|
|
36
36
|
) {
|
|
37
37
|
lifeCycle.subscribe(LifeCycleEventType.REQUEST_COMPLETED, function (request) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
var rawEvent = processRequest(
|
|
39
|
+
request,
|
|
40
|
+
configuration,
|
|
41
|
+
sessionManager,
|
|
42
|
+
pageStateHistory
|
|
41
43
|
)
|
|
44
|
+
if (rawEvent) {
|
|
45
|
+
lifeCycle.notify(LifeCycleEventType.RAW_RUM_EVENT_COLLECTED, rawEvent)
|
|
46
|
+
}
|
|
42
47
|
})
|
|
43
48
|
|
|
44
49
|
lifeCycle.subscribe(
|
|
@@ -51,27 +56,48 @@ export function startResourceCollection(
|
|
|
51
56
|
!isRequestKind(entry) &&
|
|
52
57
|
!isResourceUrlLimit(entry.name, configuration.resourceUrlLimit)
|
|
53
58
|
) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
var rawEvent = processResourceEntry(
|
|
60
|
+
entry,
|
|
61
|
+
configuration,
|
|
62
|
+
sessionManager,
|
|
63
|
+
pageStateHistory
|
|
57
64
|
)
|
|
65
|
+
if (rawEvent) {
|
|
66
|
+
lifeCycle.notify(
|
|
67
|
+
LifeCycleEventType.RAW_RUM_EVENT_COLLECTED,
|
|
68
|
+
rawEvent
|
|
69
|
+
)
|
|
70
|
+
}
|
|
58
71
|
}
|
|
59
72
|
}
|
|
60
73
|
}
|
|
61
74
|
)
|
|
62
75
|
}
|
|
63
76
|
|
|
64
|
-
function processRequest(
|
|
65
|
-
|
|
66
|
-
|
|
77
|
+
function processRequest(
|
|
78
|
+
request,
|
|
79
|
+
configuration,
|
|
80
|
+
sessionManager,
|
|
81
|
+
pageStateHistory
|
|
82
|
+
) {
|
|
67
83
|
var matchingTiming = matchRequestTiming(request)
|
|
68
84
|
var startClocks = matchingTiming
|
|
69
85
|
? relativeToClocks(matchingTiming.startTime)
|
|
70
86
|
: request.startClocks
|
|
87
|
+
var shouldIndex = shouldIndexResource(
|
|
88
|
+
configuration,
|
|
89
|
+
sessionManager,
|
|
90
|
+
startClocks
|
|
91
|
+
)
|
|
92
|
+
var tracingInfo = computeRequestTracingInfo(request)
|
|
93
|
+
if (!shouldIndex && !tracingInfo) {
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
var type =
|
|
97
|
+
request.type === RequestType.XHR ? ResourceType.XHR : ResourceType.FETCH
|
|
71
98
|
var correspondingTimingOverrides = matchingTiming
|
|
72
99
|
? computePerformanceEntryMetrics(matchingTiming)
|
|
73
100
|
: undefined
|
|
74
|
-
var tracingInfo = computeRequestTracingInfo(request)
|
|
75
101
|
|
|
76
102
|
var duration = computeRequestDuration(
|
|
77
103
|
pageStateHistory,
|
|
@@ -123,12 +149,24 @@ function processRequest(request, sessionManager, pageStateHistory) {
|
|
|
123
149
|
}
|
|
124
150
|
}
|
|
125
151
|
|
|
126
|
-
function processResourceEntry(
|
|
127
|
-
|
|
128
|
-
|
|
152
|
+
function processResourceEntry(
|
|
153
|
+
entry,
|
|
154
|
+
configuration,
|
|
155
|
+
sessionManager,
|
|
156
|
+
pageStateHistory
|
|
157
|
+
) {
|
|
129
158
|
var startClocks = relativeToClocks(entry.startTime)
|
|
130
|
-
|
|
159
|
+
var shouldIndex = shouldIndexResource(
|
|
160
|
+
configuration,
|
|
161
|
+
sessionManager,
|
|
162
|
+
startClocks
|
|
163
|
+
)
|
|
131
164
|
var tracingInfo = computeEntryTracingInfo(entry)
|
|
165
|
+
if (!shouldIndex && !tracingInfo) {
|
|
166
|
+
return
|
|
167
|
+
}
|
|
168
|
+
var type = computeResourceKind(entry)
|
|
169
|
+
var entryMetrics = computePerformanceEntryMetrics(entry)
|
|
132
170
|
var urlObj = urlParse(entry.name).getParse()
|
|
133
171
|
var statusCode = ''
|
|
134
172
|
if (is304(entry)) {
|
|
@@ -136,7 +174,6 @@ function processResourceEntry(entry, sessionManager, pageStateHistory) {
|
|
|
136
174
|
} else if (isCacheHit(entry)) {
|
|
137
175
|
statusCode = 200
|
|
138
176
|
}
|
|
139
|
-
|
|
140
177
|
var pageStateInfo = computePageStateInfo(
|
|
141
178
|
pageStateHistory,
|
|
142
179
|
startClocks,
|
|
@@ -172,6 +209,9 @@ function processResourceEntry(entry, sessionManager, pageStateHistory) {
|
|
|
172
209
|
}
|
|
173
210
|
}
|
|
174
211
|
}
|
|
212
|
+
function shouldIndexResource(configuration, sessionManager, resourceStart) {
|
|
213
|
+
return sessionManager.findTrackedSession(resourceStart.relative)
|
|
214
|
+
}
|
|
175
215
|
|
|
176
216
|
function computePerformanceEntryMetrics(timing) {
|
|
177
217
|
return {
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
findByPath
|
|
10
10
|
} from '@cloudcare/browser-core'
|
|
11
11
|
import { trackViews } from './trackViews'
|
|
12
|
-
import { toValidEntry } from '../resource/resourceUtils'
|
|
13
12
|
export function startViewCollection(
|
|
14
13
|
lifeCycle,
|
|
15
14
|
configuration,
|
|
@@ -37,41 +36,64 @@ export function startViewCollection(
|
|
|
37
36
|
initialViewOptions
|
|
38
37
|
)
|
|
39
38
|
}
|
|
40
|
-
function computePerformanceViewDetails(
|
|
41
|
-
|
|
42
|
-
if (!validEntry) {
|
|
39
|
+
function computePerformanceViewDetails(navigationTimings) {
|
|
40
|
+
if (!navigationTimings) {
|
|
43
41
|
return undefined
|
|
44
42
|
}
|
|
45
|
-
var fetchStart =
|
|
46
|
-
responseEnd =
|
|
47
|
-
domInteractive =
|
|
48
|
-
domContentLoaded =
|
|
49
|
-
domComplete =
|
|
50
|
-
loadEventEnd =
|
|
51
|
-
loadEventStart =
|
|
52
|
-
domContentLoadedEventEnd =
|
|
43
|
+
var fetchStart = navigationTimings.fetchStart,
|
|
44
|
+
responseEnd = navigationTimings.responseEnd,
|
|
45
|
+
domInteractive = navigationTimings.domInteractive,
|
|
46
|
+
domContentLoaded = navigationTimings.domContentLoaded,
|
|
47
|
+
domComplete = navigationTimings.domComplete,
|
|
48
|
+
loadEventEnd = navigationTimings.loadEventEnd,
|
|
49
|
+
loadEventStart = navigationTimings.loadEventStart,
|
|
50
|
+
domContentLoadedEventEnd = navigationTimings.domContentLoadedEventEnd
|
|
53
51
|
var details = {}
|
|
54
|
-
if (
|
|
52
|
+
if (
|
|
53
|
+
isNumber(responseEnd) &&
|
|
54
|
+
isNumber(fetchStart) &&
|
|
55
|
+
responseEnd !== fetchStart
|
|
56
|
+
) {
|
|
55
57
|
details.fpt = toServerDuration(responseEnd - fetchStart)
|
|
56
58
|
var apdexLevel = parseInt((responseEnd - fetchStart) / 1000) // 秒数取整
|
|
57
59
|
details.apdexLevel = apdexLevel > 9 ? 9 : apdexLevel
|
|
58
60
|
}
|
|
59
|
-
if (
|
|
61
|
+
if (
|
|
62
|
+
isNumber(domInteractive) &&
|
|
63
|
+
isNumber(fetchStart) &&
|
|
64
|
+
domInteractive !== fetchStart
|
|
65
|
+
) {
|
|
60
66
|
details.tti = toServerDuration(domInteractive - fetchStart)
|
|
61
67
|
}
|
|
62
|
-
if (
|
|
68
|
+
if (
|
|
69
|
+
isNumber(domContentLoaded) &&
|
|
70
|
+
isNumber(fetchStart) &&
|
|
71
|
+
domContentLoaded !== fetchStart
|
|
72
|
+
) {
|
|
63
73
|
details.dom_ready = toServerDuration(domContentLoaded - fetchStart)
|
|
64
74
|
}
|
|
65
75
|
// Make sure a connection occurred
|
|
66
|
-
if (
|
|
76
|
+
if (
|
|
77
|
+
isNumber(loadEventEnd) &&
|
|
78
|
+
isNumber(fetchStart) &&
|
|
79
|
+
loadEventEnd !== fetchStart
|
|
80
|
+
) {
|
|
67
81
|
details.load = toServerDuration(loadEventEnd - fetchStart)
|
|
68
82
|
}
|
|
69
|
-
if (
|
|
83
|
+
if (
|
|
84
|
+
isNumber(loadEventStart) &&
|
|
85
|
+
isNumber(domContentLoadedEventEnd) &&
|
|
86
|
+
loadEventStart !== domContentLoadedEventEnd
|
|
87
|
+
) {
|
|
70
88
|
details.resource_load_time = toServerDuration(
|
|
71
89
|
loadEventStart - domContentLoadedEventEnd
|
|
72
90
|
)
|
|
73
91
|
}
|
|
74
|
-
if (
|
|
92
|
+
if (
|
|
93
|
+
isNumber(domComplete) &&
|
|
94
|
+
isNumber(domInteractive) &&
|
|
95
|
+
domComplete !== domInteractive
|
|
96
|
+
) {
|
|
75
97
|
details.dom = toServerDuration(domComplete - domInteractive)
|
|
76
98
|
}
|
|
77
99
|
return details
|
|
@@ -196,7 +218,9 @@ function processViewUpdate(view, configuration, recorderApi, pageStateHistory) {
|
|
|
196
218
|
)
|
|
197
219
|
}
|
|
198
220
|
viewEvent = extend2Lev(viewEvent, {
|
|
199
|
-
view: computePerformanceViewDetails(
|
|
221
|
+
view: computePerformanceViewDetails(
|
|
222
|
+
view.initialViewMetrics.navigationTimings
|
|
223
|
+
)
|
|
200
224
|
})
|
|
201
225
|
return {
|
|
202
226
|
rawRumEvent: viewEvent,
|
package/src/.DS_Store
DELETED
|
Binary file
|
package/src/domain/.DS_Store
DELETED
|
Binary file
|
|
Binary file
|