@cloudcare/browser-rum 3.2.13 → 3.2.15
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/boot/perStartRum.js +16 -0
- package/cjs/boot/perStartRum.js.map +1 -1
- package/cjs/boot/rum.js +14 -6
- package/cjs/boot/rum.js.map +1 -1
- package/cjs/boot/rumPublicApi.js +51 -7
- package/cjs/boot/rumPublicApi.js.map +1 -1
- package/cjs/domain/assembly.js +16 -6
- package/cjs/domain/assembly.js.map +1 -1
- package/cjs/domain/contexts/internalContext.js +1 -1
- package/cjs/domain/contexts/internalContext.js.map +1 -1
- package/cjs/domain/contexts/viewContexts.js +7 -2
- package/cjs/domain/contexts/viewContexts.js.map +1 -1
- package/cjs/domain/deflate/deflateWorker.js +1 -1
- package/cjs/domain/rumEventsCollection/actions/getSelectorsFromElement.js +61 -14
- package/cjs/domain/rumEventsCollection/actions/getSelectorsFromElement.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +17 -3
- package/cjs/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js +0 -17
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackViews.js +42 -2
- package/cjs/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/perStartRum.js +16 -0
- package/esm/boot/perStartRum.js.map +1 -1
- package/esm/boot/rum.js +14 -6
- package/esm/boot/rum.js.map +1 -1
- package/esm/boot/rumPublicApi.js +52 -8
- package/esm/boot/rumPublicApi.js.map +1 -1
- package/esm/domain/assembly.js +16 -6
- package/esm/domain/assembly.js.map +1 -1
- package/esm/domain/contexts/internalContext.js +1 -1
- package/esm/domain/contexts/internalContext.js.map +1 -1
- package/esm/domain/contexts/viewContexts.js +7 -2
- package/esm/domain/contexts/viewContexts.js.map +1 -1
- package/esm/domain/deflate/deflateWorker.js +1 -1
- package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js +61 -14
- package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +17 -3
- package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js +0 -17
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackViews.js +43 -3
- package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/package.json +4 -4
- package/src/boot/perStartRum.js +16 -0
- package/src/boot/rum.js +16 -5
- package/src/boot/rumPublicApi.js +53 -9
- package/src/domain/assembly.js +21 -7
- package/src/domain/contexts/internalContext.js +1 -1
- package/src/domain/contexts/viewContexts.js +8 -3
- package/src/domain/rumEventsCollection/actions/getSelectorsFromElement.js +75 -22
- package/src/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +21 -3
- package/src/domain/rumEventsCollection/resource/resourceUtils.js +0 -17
- package/src/domain/rumEventsCollection/view/trackViews.js +43 -5
- package/types/index.d.ts +4 -0
package/src/domain/assembly.js
CHANGED
|
@@ -26,7 +26,10 @@ var VIEW_MODIFIABLE_FIELD_PATHS = {
|
|
|
26
26
|
var USER_CUSTOMIZABLE_FIELD_PATHS = {
|
|
27
27
|
context: 'object'
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
const ROOT_MODIFIABLE_FIELD_PATHS = {
|
|
30
|
+
service: 'string',
|
|
31
|
+
version: 'string'
|
|
32
|
+
}
|
|
30
33
|
var modifiableFieldPathsByEvent = {}
|
|
31
34
|
export function startRumAssembly(
|
|
32
35
|
configuration,
|
|
@@ -40,7 +43,10 @@ export function startRumAssembly(
|
|
|
40
43
|
getCommonContext,
|
|
41
44
|
reportError
|
|
42
45
|
) {
|
|
43
|
-
modifiableFieldPathsByEvent[RumEventType.VIEW] =
|
|
46
|
+
modifiableFieldPathsByEvent[RumEventType.VIEW] = {
|
|
47
|
+
...USER_CUSTOMIZABLE_FIELD_PATHS,
|
|
48
|
+
...VIEW_MODIFIABLE_FIELD_PATHS
|
|
49
|
+
}
|
|
44
50
|
modifiableFieldPathsByEvent[RumEventType.ERROR] = assign(
|
|
45
51
|
{
|
|
46
52
|
'error.message': 'string',
|
|
@@ -48,21 +54,24 @@ export function startRumAssembly(
|
|
|
48
54
|
'error.resource.url': 'string'
|
|
49
55
|
},
|
|
50
56
|
USER_CUSTOMIZABLE_FIELD_PATHS,
|
|
51
|
-
VIEW_MODIFIABLE_FIELD_PATHS
|
|
57
|
+
VIEW_MODIFIABLE_FIELD_PATHS,
|
|
58
|
+
ROOT_MODIFIABLE_FIELD_PATHS
|
|
52
59
|
)
|
|
53
60
|
modifiableFieldPathsByEvent[RumEventType.RESOURCE] = assign(
|
|
54
61
|
{
|
|
55
62
|
'resource.url': 'string'
|
|
56
63
|
},
|
|
57
64
|
USER_CUSTOMIZABLE_FIELD_PATHS,
|
|
58
|
-
VIEW_MODIFIABLE_FIELD_PATHS
|
|
65
|
+
VIEW_MODIFIABLE_FIELD_PATHS,
|
|
66
|
+
ROOT_MODIFIABLE_FIELD_PATHS
|
|
59
67
|
)
|
|
60
68
|
modifiableFieldPathsByEvent[RumEventType.ACTION] = assign(
|
|
61
69
|
{
|
|
62
70
|
'action.target.name': 'string'
|
|
63
71
|
},
|
|
64
72
|
USER_CUSTOMIZABLE_FIELD_PATHS,
|
|
65
|
-
VIEW_MODIFIABLE_FIELD_PATHS
|
|
73
|
+
VIEW_MODIFIABLE_FIELD_PATHS,
|
|
74
|
+
ROOT_MODIFIABLE_FIELD_PATHS
|
|
66
75
|
)
|
|
67
76
|
modifiableFieldPathsByEvent[RumEventType.LONG_TASK] = assign(
|
|
68
77
|
{},
|
|
@@ -134,7 +143,7 @@ export function startRumAssembly(
|
|
|
134
143
|
},
|
|
135
144
|
view: {
|
|
136
145
|
id: viewContext.id,
|
|
137
|
-
name: viewContext.name,
|
|
146
|
+
name: viewContext.name || viewContext.path,
|
|
138
147
|
url: urlContext.url,
|
|
139
148
|
referrer: urlContext.referrer,
|
|
140
149
|
host: urlContext.host,
|
|
@@ -150,7 +159,12 @@ export function startRumAssembly(
|
|
|
150
159
|
}
|
|
151
160
|
var rumEvent = extend2Lev(rumContext, viewContext, rawRumEvent)
|
|
152
161
|
var serverRumEvent = withSnakeCaseKeys(rumEvent)
|
|
153
|
-
var context = extend2Lev(
|
|
162
|
+
var context = extend2Lev(
|
|
163
|
+
{},
|
|
164
|
+
commonContext.context,
|
|
165
|
+
viewContext.context,
|
|
166
|
+
customerContext
|
|
167
|
+
)
|
|
154
168
|
if (!isEmptyObject(context)) {
|
|
155
169
|
serverRumEvent.context = context
|
|
156
170
|
}
|
|
@@ -18,11 +18,14 @@ export function startViewContexts(lifeCycle) {
|
|
|
18
18
|
lifeCycle.subscribe(LifeCycleEventType.AFTER_VIEW_ENDED, function (data) {
|
|
19
19
|
viewContextHistory.closeActive(data.endClocks.relative)
|
|
20
20
|
})
|
|
21
|
-
lifeCycle.subscribe(LifeCycleEventType.
|
|
22
|
-
|
|
21
|
+
lifeCycle.subscribe(LifeCycleEventType.BEFORE_VIEW_UPDATED, (viewUpdate) => {
|
|
22
|
+
const currentView = viewContextHistory.find(viewUpdate.startClocks.relative)
|
|
23
23
|
if (currentView && viewUpdate.name) {
|
|
24
24
|
currentView.name = viewUpdate.name
|
|
25
25
|
}
|
|
26
|
+
if (currentView && viewUpdate.context) {
|
|
27
|
+
currentView.context = viewUpdate.context
|
|
28
|
+
}
|
|
26
29
|
})
|
|
27
30
|
lifeCycle.subscribe(LifeCycleEventType.SESSION_RENEWED, function () {
|
|
28
31
|
viewContextHistory.reset()
|
|
@@ -32,8 +35,10 @@ export function startViewContexts(lifeCycle) {
|
|
|
32
35
|
return {
|
|
33
36
|
service: view.service,
|
|
34
37
|
version: view.version,
|
|
38
|
+
context: view.context,
|
|
35
39
|
id: view.id,
|
|
36
|
-
name: view.name
|
|
40
|
+
name: view.name,
|
|
41
|
+
startClocks: view.startClocks
|
|
37
42
|
}
|
|
38
43
|
}
|
|
39
44
|
|
|
@@ -43,12 +43,11 @@ export function getSelectorFromElement(targetElement, actionNameAttribute) {
|
|
|
43
43
|
// parents, and we cannot determine if it's unique in the document.
|
|
44
44
|
return
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
element,
|
|
46
|
+
let targetElementSelector
|
|
47
|
+
let currentElement = targetElement
|
|
48
|
+
while (currentElement && currentElement.nodeName !== 'HTML') {
|
|
49
|
+
const globallyUniqueSelector = findSelector(
|
|
50
|
+
currentElement,
|
|
52
51
|
GLOBALLY_UNIQUE_SELECTOR_GETTERS,
|
|
53
52
|
isSelectorUniqueGlobally,
|
|
54
53
|
actionNameAttribute,
|
|
@@ -57,9 +56,8 @@ export function getSelectorFromElement(targetElement, actionNameAttribute) {
|
|
|
57
56
|
if (globallyUniqueSelector) {
|
|
58
57
|
return globallyUniqueSelector
|
|
59
58
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
element,
|
|
59
|
+
const uniqueSelectorAmongChildren = findSelector(
|
|
60
|
+
currentElement,
|
|
63
61
|
UNIQUE_AMONG_CHILDREN_SELECTOR_GETTERS,
|
|
64
62
|
isSelectorUniqueAmongSiblings,
|
|
65
63
|
actionNameAttribute,
|
|
@@ -67,10 +65,38 @@ export function getSelectorFromElement(targetElement, actionNameAttribute) {
|
|
|
67
65
|
)
|
|
68
66
|
targetElementSelector =
|
|
69
67
|
uniqueSelectorAmongChildren ||
|
|
70
|
-
combineSelector(
|
|
68
|
+
combineSelector(
|
|
69
|
+
getPositionSelector(currentElement),
|
|
70
|
+
targetElementSelector
|
|
71
|
+
)
|
|
71
72
|
|
|
72
|
-
|
|
73
|
+
currentElement = currentElement.parentElement
|
|
73
74
|
}
|
|
75
|
+
// while (element && element.nodeName !== 'HTML') {
|
|
76
|
+
// var globallyUniqueSelector = findSelector(
|
|
77
|
+
// element,
|
|
78
|
+
// GLOBALLY_UNIQUE_SELECTOR_GETTERS,
|
|
79
|
+
// isSelectorUniqueGlobally,
|
|
80
|
+
// actionNameAttribute,
|
|
81
|
+
// targetElementSelector
|
|
82
|
+
// )
|
|
83
|
+
// if (globallyUniqueSelector) {
|
|
84
|
+
// return globallyUniqueSelector
|
|
85
|
+
// }
|
|
86
|
+
|
|
87
|
+
// var uniqueSelectorAmongChildren = findSelector(
|
|
88
|
+
// element,
|
|
89
|
+
// UNIQUE_AMONG_CHILDREN_SELECTOR_GETTERS,
|
|
90
|
+
// isSelectorUniqueAmongSiblings,
|
|
91
|
+
// actionNameAttribute,
|
|
92
|
+
// targetElementSelector
|
|
93
|
+
// )
|
|
94
|
+
// targetElementSelector =
|
|
95
|
+
// uniqueSelectorAmongChildren ||
|
|
96
|
+
// combineSelector(getPositionSelector(element), targetElementSelector)
|
|
97
|
+
|
|
98
|
+
// element = element.parentElement
|
|
99
|
+
// }
|
|
74
100
|
|
|
75
101
|
return targetElementSelector
|
|
76
102
|
}
|
|
@@ -170,15 +196,18 @@ function findSelector(
|
|
|
170
196
|
if (!elementSelector) {
|
|
171
197
|
continue
|
|
172
198
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
return fullSelector
|
|
199
|
+
if (predicate(element, elementSelector, childSelector)) {
|
|
200
|
+
return combineSelector(elementSelector, childSelector)
|
|
176
201
|
}
|
|
177
202
|
}
|
|
178
203
|
}
|
|
179
204
|
|
|
180
|
-
function isSelectorUniqueGlobally(element,
|
|
181
|
-
return
|
|
205
|
+
function isSelectorUniqueGlobally(element, elementSelector, childSelector) {
|
|
206
|
+
return (
|
|
207
|
+
element.ownerDocument.querySelectorAll(
|
|
208
|
+
combineSelector(elementSelector, childSelector)
|
|
209
|
+
).length === 1
|
|
210
|
+
)
|
|
182
211
|
}
|
|
183
212
|
/**
|
|
184
213
|
* Check whether the selector is unique among the element siblings. In other words, it returns true
|
|
@@ -190,12 +219,36 @@ function isSelectorUniqueGlobally(element, selector) {
|
|
|
190
219
|
* direct descendent of the element parent. This should not impact results too much: if it
|
|
191
220
|
* inaccurately returns false, we'll just fall back to another strategy.
|
|
192
221
|
*/
|
|
193
|
-
function isSelectorUniqueAmongSiblings(
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
222
|
+
function isSelectorUniqueAmongSiblings(
|
|
223
|
+
currentElement,
|
|
224
|
+
currentElementSelector,
|
|
225
|
+
childSelector
|
|
226
|
+
) {
|
|
227
|
+
let isSiblingMatching
|
|
228
|
+
|
|
229
|
+
if (childSelector === undefined) {
|
|
230
|
+
// If the child selector is undefined (meaning `currentElement` is the target element, not one
|
|
231
|
+
// of its ancestor), we need to use `matches` to check if the sibling is matching the selector,
|
|
232
|
+
// as `querySelector` only returns a descendant of the element.
|
|
233
|
+
isSiblingMatching = (sibling) => sibling.matches(currentElementSelector)
|
|
234
|
+
} else {
|
|
235
|
+
const scopedSelector = supportScopeSelector()
|
|
236
|
+
? combineSelector(`${currentElementSelector}:scope`, childSelector)
|
|
237
|
+
: combineSelector(currentElementSelector, childSelector)
|
|
238
|
+
isSiblingMatching = (sibling) =>
|
|
239
|
+
sibling.querySelector(scopedSelector) !== null
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const parent = currentElement.parentElement
|
|
243
|
+
let sibling = parent.firstElementChild
|
|
244
|
+
while (sibling) {
|
|
245
|
+
if (sibling !== currentElement && isSiblingMatching(sibling)) {
|
|
246
|
+
return false
|
|
247
|
+
}
|
|
248
|
+
sibling = sibling.nextElementSibling
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return true
|
|
199
252
|
}
|
|
200
253
|
function combineSelector(parent, child) {
|
|
201
254
|
return child ? parent + '>' + child : parent
|
|
@@ -27,6 +27,7 @@ export function matchRequestResourceEntry(request) {
|
|
|
27
27
|
if (!sameNameEntries.length || !('toJSON' in sameNameEntries[0])) {
|
|
28
28
|
return
|
|
29
29
|
}
|
|
30
|
+
|
|
30
31
|
var candidates = filter(sameNameEntries, function (entry) {
|
|
31
32
|
return !alreadyMatchedEntries.has(entry)
|
|
32
33
|
})
|
|
@@ -46,11 +47,28 @@ export function matchRequestResourceEntry(request) {
|
|
|
46
47
|
})
|
|
47
48
|
)
|
|
48
49
|
})
|
|
50
|
+
let lastEntry = undefined
|
|
51
|
+
if (candidates.length > 1) {
|
|
52
|
+
// 取值和 request startTime 间隔更接近的
|
|
53
|
+
let startTimeDuration = Number.MAX_SAFE_INTEGER
|
|
54
|
+
candidates.forEach((entry) => {
|
|
55
|
+
const _startTimeDuration = Math.abs(
|
|
56
|
+
entry.startTime - request.startClocks.relative
|
|
57
|
+
)
|
|
58
|
+
if (_startTimeDuration < startTimeDuration) {
|
|
59
|
+
startTimeDuration = _startTimeDuration
|
|
60
|
+
lastEntry = entry
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
} else if (candidates.length === 1) {
|
|
64
|
+
lastEntry = candidates[0]
|
|
65
|
+
}
|
|
49
66
|
|
|
50
|
-
if (
|
|
51
|
-
alreadyMatchedEntries.add(
|
|
52
|
-
return
|
|
67
|
+
if (lastEntry) {
|
|
68
|
+
alreadyMatchedEntries.add(lastEntry)
|
|
69
|
+
return lastEntry.toJSON()
|
|
53
70
|
}
|
|
71
|
+
|
|
54
72
|
return
|
|
55
73
|
}
|
|
56
74
|
|
|
@@ -300,23 +300,6 @@ export function hasValidResourceEntryDuration(entry) {
|
|
|
300
300
|
return entry.duration >= 0
|
|
301
301
|
}
|
|
302
302
|
export function hasValidResourceEntryTimings(entry) {
|
|
303
|
-
// Ensure timings are in the right order. On top of filtering out potential invalid
|
|
304
|
-
// RumPerformanceResourceTiming, it will ignore entries from requests where timings cannot be
|
|
305
|
-
// collected, for example cross origin requests without a "Timing-Allow-Origin" header allowing
|
|
306
|
-
// it.
|
|
307
|
-
// page_fmp float 首屏时间(用于衡量用户什么时候看到页面的主要内容),跟FCP的时长非常接近,这里我们就用FCP的时间作为首屏时间 firstPaintContentEnd - firstPaintContentStart
|
|
308
|
-
// page_fpt float 首次渲染时间,即白屏时间(从请求开始到浏览器开始解析第一批HTML文档字节的时间差。) responseEnd - fetchStart
|
|
309
|
-
// page_tti float 首次可交互时间(浏览器完成所有HTML解析并且完成DOM构建,此时浏览器开始加载资源。) domInteractive - fetchStart
|
|
310
|
-
// page_firstbyte float 首包时间 responseStart - domainLookupStart
|
|
311
|
-
// page_dom_ready float DOM Ready时间(如果页面有同步执行的JS,则同步JS执行时间=ready-tti。) domContentLoadEventEnd - fetchStart
|
|
312
|
-
// page_load float 页面完全加载时间(load=首次渲染时间+DOM解析耗时+同步JS执行+资源加载耗时。) loadEventStart - fetchStart
|
|
313
|
-
// page_dns float dns解析时间 domainLookupEnd - domainLookupStart
|
|
314
|
-
// page_tcp float tcp连接时间 connectEnd - connectStart
|
|
315
|
-
// page_ssl float ssl安全连接时间(仅适用于https) connectEnd - secureConnectionStart
|
|
316
|
-
// page_ttfb float 请求响应耗时 responseStart - requestStart
|
|
317
|
-
// page_trans float 内容传输时间 responseEnd - responseStart
|
|
318
|
-
// page_dom float DOM解析耗时 domInteractive - responseEnd
|
|
319
|
-
// page_resource_load_time float 资源加载时间 loadEventStart - domContentLoadedEventEnd
|
|
320
303
|
var areCommonTimingsInOrder = areInOrder(
|
|
321
304
|
entry.startTime,
|
|
322
305
|
entry.fetchStart,
|
|
@@ -18,7 +18,8 @@ import {
|
|
|
18
18
|
Observable,
|
|
19
19
|
clearInterval,
|
|
20
20
|
setTimeout,
|
|
21
|
-
isNullUndefinedDefaultValue
|
|
21
|
+
isNullUndefinedDefaultValue,
|
|
22
|
+
createContextManager
|
|
22
23
|
} from '@cloudcare/browser-core'
|
|
23
24
|
|
|
24
25
|
import { trackInitialViewMetrics } from './trackInitialViewTimings'
|
|
@@ -70,7 +71,8 @@ export function trackViews(
|
|
|
70
71
|
currentView = startNewView(ViewLoadingType.ROUTE_CHANGE, undefined, {
|
|
71
72
|
name: currentView.name,
|
|
72
73
|
service: currentView.service,
|
|
73
|
-
version: currentView.version
|
|
74
|
+
version: currentView.version,
|
|
75
|
+
context: currentView.contextManager.getContext()
|
|
74
76
|
})
|
|
75
77
|
})
|
|
76
78
|
|
|
@@ -115,6 +117,16 @@ export function trackViews(
|
|
|
115
117
|
options
|
|
116
118
|
)
|
|
117
119
|
},
|
|
120
|
+
setViewContext: (context) => {
|
|
121
|
+
currentView.contextManager.setContext(context)
|
|
122
|
+
},
|
|
123
|
+
setViewContextProperty: (key, value) => {
|
|
124
|
+
currentView.contextManager.setContextProperty(key, value)
|
|
125
|
+
},
|
|
126
|
+
setViewName: (name) => {
|
|
127
|
+
currentView.setViewName(name)
|
|
128
|
+
},
|
|
129
|
+
getViewContext: () => currentView.contextManager.getContext(),
|
|
118
130
|
stop: function () {
|
|
119
131
|
if (locationChangeSubscription) {
|
|
120
132
|
locationChangeSubscription.unsubscribe()
|
|
@@ -146,15 +158,20 @@ function newView(
|
|
|
146
158
|
var documentVersion = 0
|
|
147
159
|
var endClocks
|
|
148
160
|
var location = shallowClone(initialLocation)
|
|
149
|
-
|
|
161
|
+
const contextManager = createContextManager()
|
|
150
162
|
var sessionIsActive = true
|
|
151
163
|
var name
|
|
152
164
|
var service
|
|
153
165
|
var version
|
|
166
|
+
var context
|
|
154
167
|
if (viewOptions) {
|
|
155
168
|
name = viewOptions.name
|
|
156
169
|
service = viewOptions.service
|
|
157
170
|
version = viewOptions.version
|
|
171
|
+
context = viewOptions.context
|
|
172
|
+
}
|
|
173
|
+
if (context) {
|
|
174
|
+
contextManager.setContext(context)
|
|
158
175
|
}
|
|
159
176
|
var viewCreatedEvent = {
|
|
160
177
|
id: id,
|
|
@@ -174,7 +191,7 @@ function newView(
|
|
|
174
191
|
leading: false
|
|
175
192
|
}
|
|
176
193
|
)
|
|
177
|
-
var
|
|
194
|
+
var throttled = _scheduleViewUpdate.throttled
|
|
178
195
|
var cancelScheduleViewUpdate = _scheduleViewUpdate.cancel
|
|
179
196
|
|
|
180
197
|
var _trackCommonViewMetrics = trackCommonViewMetrics(
|
|
@@ -213,10 +230,25 @@ function newView(
|
|
|
213
230
|
SESSION_KEEP_ALIVE_INTERVAL
|
|
214
231
|
)
|
|
215
232
|
triggerViewUpdate()
|
|
233
|
+
// View context update should always be throttled
|
|
234
|
+
contextManager.changeObservable.subscribe(scheduleViewUpdate)
|
|
235
|
+
|
|
236
|
+
function triggerBeforeViewUpdate() {
|
|
237
|
+
lifeCycle.notify(LifeCycleEventType.BEFORE_VIEW_UPDATED, {
|
|
238
|
+
id,
|
|
239
|
+
name,
|
|
240
|
+
context: contextManager.getContext(),
|
|
241
|
+
startClocks
|
|
242
|
+
})
|
|
243
|
+
}
|
|
244
|
+
function scheduleViewUpdate() {
|
|
245
|
+
triggerBeforeViewUpdate()
|
|
246
|
+
throttled()
|
|
247
|
+
}
|
|
216
248
|
|
|
217
249
|
function triggerViewUpdate() {
|
|
218
250
|
cancelScheduleViewUpdate()
|
|
219
|
-
|
|
251
|
+
triggerBeforeViewUpdate()
|
|
220
252
|
documentVersion += 1
|
|
221
253
|
var currentEnd =
|
|
222
254
|
endClocks === undefined ? timeStampNow() : endClocks.timeStamp
|
|
@@ -227,6 +259,7 @@ function newView(
|
|
|
227
259
|
name: name,
|
|
228
260
|
service: service,
|
|
229
261
|
version: version,
|
|
262
|
+
context: contextManager.getContext(),
|
|
230
263
|
loadingType: loadingType,
|
|
231
264
|
location: location,
|
|
232
265
|
startClocks: startClocks,
|
|
@@ -242,6 +275,7 @@ function newView(
|
|
|
242
275
|
name: name,
|
|
243
276
|
service: service,
|
|
244
277
|
version: version,
|
|
278
|
+
contextManager: contextManager,
|
|
245
279
|
stopObservable: stopObservable,
|
|
246
280
|
end: function (options) {
|
|
247
281
|
if (endClocks) {
|
|
@@ -283,6 +317,10 @@ function newView(
|
|
|
283
317
|
: elapsed(startClocks.timeStamp, time)
|
|
284
318
|
customTimings[sanitizeTiming(name)] = relativeTime
|
|
285
319
|
scheduleViewUpdate()
|
|
320
|
+
},
|
|
321
|
+
setViewName(updatedName) {
|
|
322
|
+
name = updatedName
|
|
323
|
+
triggerViewUpdate()
|
|
286
324
|
}
|
|
287
325
|
}
|
|
288
326
|
return result
|
package/types/index.d.ts
CHANGED
|
@@ -30,6 +30,10 @@ export declare const datafluxRum: {
|
|
|
30
30
|
init: (
|
|
31
31
|
initConfiguration: RumInitConfiguration | RumSiteInitConfiguration
|
|
32
32
|
) => void
|
|
33
|
+
setViewName: (name: string) => void
|
|
34
|
+
setViewContext: (context: Context) => void
|
|
35
|
+
setViewContextProperty: (key: string, value: any) => void
|
|
36
|
+
getViewContext: () => Context
|
|
33
37
|
setGlobalContextProperty: (key: any, value: any) => void
|
|
34
38
|
addRumGlobalContext: (key: any, value: any) => void
|
|
35
39
|
removeGlobalContextProperty: (key: any) => void
|