@cloudcare/browser-rum 3.3.24 → 3.3.25
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/README.md +33 -0
- package/README.zh.md +30 -0
- package/bundle/dataflux-rum.js +1 -1
- package/cjs/boot/buildEnv.js +1 -1
- package/cjs/boot/disabledRumPublicApi.js +5 -0
- package/cjs/boot/disabledRumPublicApi.js.map +1 -1
- package/cjs/boot/initCallbacks.js +25 -0
- package/cjs/boot/initCallbacks.js.map +1 -0
- package/cjs/boot/perStartRum.js +99 -50
- package/cjs/boot/perStartRum.js.map +1 -1
- package/cjs/boot/rum.js +7 -4
- package/cjs/boot/rum.js.map +1 -1
- package/cjs/boot/rumPublicApi.js +6 -7
- package/cjs/boot/rumPublicApi.js.map +1 -1
- package/cjs/boot/startRecording.js +2 -0
- package/cjs/boot/startRecording.js.map +1 -1
- package/cjs/domain/configuration.js +15 -2
- package/cjs/domain/configuration.js.map +1 -1
- package/cjs/domain/contexts/urlContexts.js +32 -21
- package/cjs/domain/contexts/urlContexts.js.map +1 -1
- package/cjs/domain/contexts/viewContexts.js +1 -1
- package/cjs/domain/contexts/viewContexts.js.map +1 -1
- package/cjs/domain/deflate/deflateWorker.js +39 -27
- package/cjs/domain/deflate/deflateWorker.js.map +1 -1
- package/cjs/domain/privacy.js +9 -6
- package/cjs/domain/privacy.js.map +1 -1
- package/cjs/domain/replay/record/canvasCommandCapture.js +91 -179
- package/cjs/domain/replay/record/canvasCommandCapture.js.map +1 -1
- package/cjs/domain/replay/record/canvasCommandObserverStub.js +24 -0
- package/cjs/domain/replay/record/canvasCommandObserverStub.js.map +1 -0
- package/cjs/domain/replay/record/canvasCommandSerializeArgs.js +3 -2
- package/cjs/domain/replay/record/canvasCommandSerializeArgs.js.map +1 -1
- package/cjs/domain/replay/record/canvasContext.js +25 -0
- package/cjs/domain/replay/record/canvasContext.js.map +1 -1
- package/cjs/domain/replay/record/canvasEncodeWorker.js +1 -1
- package/cjs/domain/replay/record/canvasObserver.js +3 -0
- package/cjs/domain/replay/record/canvasObserver.js.map +1 -1
- package/cjs/domain/replay/record/mutationObserver.js +3 -12
- package/cjs/domain/replay/record/mutationObserver.js.map +1 -1
- package/cjs/domain/replay/record/record.js +1 -1
- package/cjs/domain/replay/record/record.js.map +1 -1
- package/cjs/domain/replay/record/serialize.js +15 -13
- package/cjs/domain/replay/record/serialize.js.map +1 -1
- package/cjs/domain/replay/segmentCollection/buildReplayPayload.js +21 -6
- package/cjs/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -1
- package/cjs/domain/replay/segmentCollection/segmentCollection.js +91 -143
- package/cjs/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
- package/cjs/domain/replayCanvasSupported.js +8 -0
- package/cjs/domain/replayCanvasSupported.js.map +1 -0
- package/cjs/domain/requestCollection.js +38 -39
- package/cjs/domain/requestCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/listenActionEvents.js +1 -1
- package/cjs/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/fetchTimingRegistry.js +143 -0
- package/cjs/domain/rumEventsCollection/resource/fetchTimingRegistry.js.map +1 -0
- package/cjs/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +2 -2
- package/cjs/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js +77 -45
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceTrackerManager.js +11 -9
- package/cjs/domain/rumEventsCollection/resource/resourceTrackerManager.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js +30 -40
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +7 -1
- package/cjs/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackViews.js +3 -0
- package/cjs/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/cjs/domain/tracing/skywalkingTracer.js +4 -50
- package/cjs/domain/tracing/skywalkingTracer.js.map +1 -1
- package/cjs/domain/tracing/tracer.js +26 -3
- package/cjs/domain/tracing/tracer.js.map +1 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/disabledRumPublicApi.js +1 -1
- package/esm/boot/disabledRumPublicApi.js.map +1 -1
- package/esm/boot/initCallbacks.js +2 -0
- package/esm/boot/initCallbacks.js.map +1 -0
- package/esm/boot/perStartRum.js +1 -1
- package/esm/boot/perStartRum.js.map +1 -1
- package/esm/boot/rum.js +1 -1
- package/esm/boot/rum.js.map +1 -1
- package/esm/boot/rumPublicApi.js +1 -1
- package/esm/boot/rumPublicApi.js.map +1 -1
- package/esm/boot/startRecording.js +1 -1
- package/esm/boot/startRecording.js.map +1 -1
- package/esm/domain/configuration.js +1 -1
- package/esm/domain/configuration.js.map +1 -1
- package/esm/domain/contexts/urlContexts.js +1 -1
- package/esm/domain/contexts/urlContexts.js.map +1 -1
- package/esm/domain/contexts/viewContexts.js +1 -1
- package/esm/domain/contexts/viewContexts.js.map +1 -1
- package/esm/domain/deflate/deflateWorker.js +1 -1
- package/esm/domain/deflate/deflateWorker.js.map +1 -1
- package/esm/domain/privacy.js +1 -1
- package/esm/domain/privacy.js.map +1 -1
- package/esm/domain/replay/record/canvasCommandCapture.js +1 -1
- package/esm/domain/replay/record/canvasCommandCapture.js.map +1 -1
- package/esm/domain/replay/record/canvasCommandObserverStub.js +2 -0
- package/esm/domain/replay/record/canvasCommandObserverStub.js.map +1 -0
- package/esm/domain/replay/record/canvasCommandSerializeArgs.js +1 -1
- package/esm/domain/replay/record/canvasCommandSerializeArgs.js.map +1 -1
- package/esm/domain/replay/record/canvasContext.js +1 -1
- package/esm/domain/replay/record/canvasContext.js.map +1 -1
- package/esm/domain/replay/record/canvasEncodeWorker.js +1 -1
- package/esm/domain/replay/record/canvasObserver.js +1 -1
- package/esm/domain/replay/record/canvasObserver.js.map +1 -1
- package/esm/domain/replay/record/mutationObserver.js +1 -1
- package/esm/domain/replay/record/mutationObserver.js.map +1 -1
- package/esm/domain/replay/record/record.js +1 -1
- package/esm/domain/replay/record/record.js.map +1 -1
- package/esm/domain/replay/record/serialize.js +1 -1
- package/esm/domain/replay/record/serialize.js.map +1 -1
- package/esm/domain/replay/segmentCollection/buildReplayPayload.js +1 -1
- package/esm/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -1
- package/esm/domain/replay/segmentCollection/segmentCollection.js +1 -1
- package/esm/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
- package/esm/domain/replayCanvasSupported.js +2 -0
- package/esm/domain/replayCanvasSupported.js.map +1 -0
- package/esm/domain/requestCollection.js +1 -1
- package/esm/domain/requestCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/listenActionEvents.js +1 -1
- package/esm/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/fetchTimingRegistry.js +2 -0
- package/esm/domain/rumEventsCollection/resource/fetchTimingRegistry.js.map +1 -0
- package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +1 -1
- package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceTrackerManager.js +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceTrackerManager.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +1 -1
- package/esm/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackViews.js +1 -1
- package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/esm/domain/tracing/skywalkingTracer.js +1 -1
- package/esm/domain/tracing/skywalkingTracer.js.map +1 -1
- package/esm/domain/tracing/tracer.js +1 -1
- package/esm/domain/tracing/tracer.js.map +1 -1
- package/package.json +7 -7
- package/src/boot/disabledRumPublicApi.js +5 -0
- package/src/boot/initCallbacks.js +16 -0
- package/src/boot/perStartRum.js +102 -59
- package/src/boot/rum.js +7 -4
- package/src/boot/rumPublicApi.js +6 -8
- package/src/boot/startRecording.js +2 -0
- package/src/domain/configuration.js +13 -2
- package/src/domain/contexts/urlContexts.js +34 -27
- package/src/domain/contexts/viewContexts.js +2 -2
- package/src/domain/deflate/deflateWorker.js +35 -21
- package/src/domain/privacy.js +13 -13
- package/src/domain/replay/record/canvasCommandCapture.js +105 -239
- package/src/domain/replay/record/canvasCommandObserverStub.js +11 -0
- package/src/domain/replay/record/canvasCommandSerializeArgs.js +2 -2
- package/src/domain/replay/record/canvasContext.js +32 -0
- package/src/domain/replay/record/canvasObserver.js +5 -1
- package/src/domain/replay/record/mutationObserver.js +6 -22
- package/src/domain/replay/record/record.js +1 -1
- package/src/domain/replay/record/serialize.js +24 -11
- package/src/domain/replay/segmentCollection/buildReplayPayload.js +24 -14
- package/src/domain/replay/segmentCollection/segmentCollection.js +97 -227
- package/src/domain/replayCanvasSupported.js +1 -0
- package/src/domain/requestCollection.js +39 -51
- package/src/domain/rumEventsCollection/actions/listenActionEvents.js +8 -2
- package/src/domain/rumEventsCollection/resource/fetchTimingRegistry.js +138 -0
- package/src/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +2 -2
- package/src/domain/rumEventsCollection/resource/resourceCollection.js +87 -64
- package/src/domain/rumEventsCollection/resource/resourceTrackerManager.js +10 -10
- package/src/domain/rumEventsCollection/resource/resourceUtils.js +36 -59
- package/src/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +8 -2
- package/src/domain/rumEventsCollection/view/trackViews.js +3 -0
- package/src/domain/tracing/skywalkingTracer.js +14 -91
- package/src/domain/tracing/tracer.js +28 -4
- package/types/index.d.ts +9 -0
|
@@ -173,69 +173,51 @@ export function isCacheHit(entry) {
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
export function computePerformanceResourceDetails(entry) {
|
|
176
|
-
|
|
177
|
-
|
|
176
|
+
const {
|
|
177
|
+
startTime, fetchStart, domainLookupStart, domainLookupEnd,
|
|
178
|
+
connectStart, connectEnd, secureConnectionStart,
|
|
179
|
+
requestStart, responseStart, responseEnd, redirectStart, redirectEnd
|
|
180
|
+
} = entry
|
|
181
|
+
const details = {}
|
|
182
|
+
// The browser exposes each phase independently. A zero or unavailable
|
|
183
|
+
// timestamp must not erase valid measurements from a different phase.
|
|
184
|
+
if (validPhase(startTime, requestStart, responseStart)) {
|
|
185
|
+
details.firstByteTime = formatTiming(startTime, requestStart, responseStart)
|
|
186
|
+
details.firstbyte = details.firstByteTime.duration
|
|
187
|
+
if (responseStart <= preferredNow()) details.ttfb = details.firstbyte
|
|
178
188
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
redirectStart = entry.redirectStart,
|
|
183
|
-
redirectEnd = entry.redirectEnd,
|
|
184
|
-
domainLookupStart = entry.domainLookupStart,
|
|
185
|
-
domainLookupEnd = entry.domainLookupEnd,
|
|
186
|
-
connectStart = entry.connectStart,
|
|
187
|
-
secureConnectionStart = entry.secureConnectionStart,
|
|
188
|
-
connectEnd = entry.connectEnd,
|
|
189
|
-
requestStart = entry.requestStart,
|
|
190
|
-
responseStart = entry.responseStart,
|
|
191
|
-
responseEnd = entry.responseEnd
|
|
192
|
-
var details = {
|
|
193
|
-
firstbyte: msToNs(responseStart - requestStart),
|
|
194
|
-
trans: msToNs(responseEnd - responseStart),
|
|
195
|
-
downloadTime: formatTiming(startTime, responseStart, responseEnd),
|
|
196
|
-
firstByteTime: formatTiming(startTime, requestStart, responseStart)
|
|
197
|
-
}
|
|
198
|
-
if (responseStart > 0 && responseStart <= preferredNow()) {
|
|
199
|
-
details.ttfb = msToNs(responseStart - requestStart)
|
|
189
|
+
if (validPhase(startTime, responseStart, responseEnd)) {
|
|
190
|
+
details.downloadTime = formatTiming(startTime, responseStart, responseEnd)
|
|
191
|
+
details.trans = details.downloadTime.duration
|
|
200
192
|
}
|
|
201
|
-
|
|
202
|
-
if (connectEnd !== fetchStart) {
|
|
203
|
-
details.tcp = msToNs(connectEnd - connectStart)
|
|
193
|
+
if (connectEnd !== fetchStart && validPhase(startTime, connectStart, connectEnd)) {
|
|
204
194
|
details.connectTime = formatTiming(startTime, connectStart, connectEnd)
|
|
205
|
-
|
|
206
|
-
if (
|
|
207
|
-
details.
|
|
208
|
-
details.
|
|
209
|
-
startTime,
|
|
210
|
-
secureConnectionStart,
|
|
211
|
-
connectEnd
|
|
212
|
-
)
|
|
195
|
+
details.tcp = details.connectTime.duration
|
|
196
|
+
if (validPhase(connectStart, secureConnectionStart, connectEnd)) {
|
|
197
|
+
details.sslTime = formatTiming(startTime, secureConnectionStart, connectEnd)
|
|
198
|
+
details.ssl = details.sslTime.duration
|
|
213
199
|
}
|
|
214
200
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
details.dns = msToNs(domainLookupEnd - domainLookupStart)
|
|
219
|
-
details.dnsTime = formatTiming(
|
|
220
|
-
startTime,
|
|
221
|
-
domainLookupStart,
|
|
222
|
-
domainLookupEnd
|
|
223
|
-
)
|
|
201
|
+
if (domainLookupEnd !== fetchStart && validPhase(startTime, domainLookupStart, domainLookupEnd)) {
|
|
202
|
+
details.dnsTime = formatTiming(startTime, domainLookupStart, domainLookupEnd)
|
|
203
|
+
details.dns = details.dnsTime.duration
|
|
224
204
|
}
|
|
225
|
-
|
|
226
|
-
if (hasRedirection(entry)) {
|
|
227
|
-
details.redirect = msToNs(redirectEnd - redirectStart)
|
|
205
|
+
if (hasRedirection(entry) && startTime <= redirectStart && redirectStart <= redirectEnd) {
|
|
228
206
|
details.redirectTime = formatTiming(startTime, redirectStart, redirectEnd)
|
|
207
|
+
details.redirect = details.redirectTime.duration
|
|
229
208
|
}
|
|
230
|
-
|
|
231
|
-
if (entry.renderBlockingStatus) {
|
|
232
|
-
details.renderBlockingStatus = entry.renderBlockingStatus
|
|
233
|
-
}
|
|
209
|
+
if (entry.renderBlockingStatus) details.renderBlockingStatus = entry.renderBlockingStatus
|
|
234
210
|
return details
|
|
235
211
|
}
|
|
212
|
+
|
|
213
|
+
function validPhase(origin, start, end) {
|
|
214
|
+
return start > 0 && origin <= start && start <= end && end < Infinity
|
|
215
|
+
}
|
|
216
|
+
|
|
236
217
|
export function hasValidResourceEntryDuration(entry) {
|
|
237
218
|
return entry.duration >= 0
|
|
238
219
|
}
|
|
220
|
+
|
|
239
221
|
export function hasValidResourceEntryTimings(entry) {
|
|
240
222
|
var areCommonTimingsInOrder = areInOrder(
|
|
241
223
|
entry.startTime,
|
|
@@ -271,21 +253,16 @@ function formatTiming(origin, start, end) {
|
|
|
271
253
|
}
|
|
272
254
|
|
|
273
255
|
export function computeResourceEntrySize(entry) {
|
|
274
|
-
//
|
|
275
|
-
|
|
256
|
+
// A cached response may have identical timestamps. Positive byte counts
|
|
257
|
+
// are independently exposed even when detailed timings are restricted.
|
|
258
|
+
if ((entry.responseStart > 0 && entry.startTime <= entry.responseStart) ||
|
|
259
|
+
entry.transferSize > 0 || entry.encodedBodySize > 0 || entry.decodedBodySize > 0) {
|
|
276
260
|
return {
|
|
277
261
|
size: entry.decodedBodySize,
|
|
278
262
|
encodedBodySize: entry.encodedBodySize,
|
|
279
263
|
decodedBodySize: entry.decodedBodySize,
|
|
280
264
|
transferSize: entry.transferSize
|
|
281
265
|
}
|
|
282
|
-
// return {
|
|
283
|
-
// size: entry.decodedBodySize,
|
|
284
|
-
// encodeSize:
|
|
285
|
-
// Number.MAX_SAFE_INTEGER < entry.encodedBodySize
|
|
286
|
-
// ? 0
|
|
287
|
-
// : entry.encodedBodySize // max safe interger
|
|
288
|
-
// }
|
|
289
266
|
}
|
|
290
267
|
return {
|
|
291
268
|
size: undefined,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { runOnReadyState, assign } from '@cloudcare/browser-core'
|
|
1
|
+
import { runOnReadyState, assign, buildUrl } from '@cloudcare/browser-core'
|
|
2
2
|
import { RumPerformanceEntryType } from '../../performanceObservable'
|
|
3
3
|
import { FAKE_INITIAL_DOCUMENT } from './resourceUtils'
|
|
4
4
|
import { getNavigationEntry } from '../../performanceUtils'
|
|
5
|
-
export function retrieveInitialDocumentResourceTiming(configuration, callback) {
|
|
5
|
+
export function retrieveInitialDocumentResourceTiming(configuration, callback, excludeDocumentQuery) {
|
|
6
6
|
runOnReadyState('interactive', function () {
|
|
7
7
|
var entry = assign(getNavigationEntry().toJSON(), {
|
|
8
8
|
entryType: RumPerformanceEntryType.RESOURCE,
|
|
@@ -11,6 +11,12 @@ export function retrieveInitialDocumentResourceTiming(configuration, callback) {
|
|
|
11
11
|
return assign({}, entry, { toJSON: undefined })
|
|
12
12
|
}
|
|
13
13
|
})
|
|
14
|
+
if (excludeDocumentQuery) {
|
|
15
|
+
var url = buildUrl(entry.name)
|
|
16
|
+
url.search = ''
|
|
17
|
+
url.hash = ''
|
|
18
|
+
entry.name = url.href
|
|
19
|
+
}
|
|
14
20
|
callback(entry)
|
|
15
21
|
})
|
|
16
22
|
}
|
|
@@ -124,6 +124,7 @@ export function trackViews(
|
|
|
124
124
|
name: currentView.name,
|
|
125
125
|
service: currentView.service,
|
|
126
126
|
version: currentView.version,
|
|
127
|
+
excludeHashRouteOuterQuery: currentView.excludeHashRouteOuterQuery,
|
|
127
128
|
context: currentView.contextManager.getContext()
|
|
128
129
|
})
|
|
129
130
|
}
|
|
@@ -270,6 +271,7 @@ function newView(
|
|
|
270
271
|
startClocks: startClocks,
|
|
271
272
|
service: service,
|
|
272
273
|
version: version,
|
|
274
|
+
excludeHashRouteOuterQuery: viewOptions && viewOptions.excludeHashRouteOuterQuery,
|
|
273
275
|
url: viewOptions && viewOptions.url
|
|
274
276
|
}
|
|
275
277
|
lifeCycle.notify(LifeCycleEventType.BEFORE_VIEW_CREATED, viewCreatedEvent)
|
|
@@ -484,6 +486,7 @@ function newView(
|
|
|
484
486
|
service: service,
|
|
485
487
|
version: version,
|
|
486
488
|
contextManager: contextManager,
|
|
489
|
+
excludeHashRouteOuterQuery: viewCreatedEvent.excludeHashRouteOuterQuery,
|
|
487
490
|
startClocks: startClocks,
|
|
488
491
|
stopObservable: stopObservable,
|
|
489
492
|
end: function (options) {
|
|
@@ -1,72 +1,12 @@
|
|
|
1
|
-
import { base64Encode,
|
|
2
|
-
// start SkyWalking
|
|
3
|
-
function uuid() {
|
|
4
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
5
|
-
/* tslint:disable */
|
|
6
|
-
var r = (Math.random() * 16) | 0
|
|
7
|
-
/* tslint:disable */
|
|
8
|
-
var v = c === 'x' ? r : (r & 0x3) | 0x8
|
|
1
|
+
import { base64Encode, getUrlParts, getType, UUID } from '@cloudcare/browser-core'
|
|
9
2
|
|
|
10
|
-
return v.toString(16)
|
|
11
|
-
})
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* @param {*} traceId
|
|
16
|
-
* @param {*} traceSegmentId
|
|
17
|
-
* @param {*} applicationId
|
|
18
|
-
* @param {*} version
|
|
19
|
-
* @param {*} requestUrlHost
|
|
20
|
-
*/
|
|
21
|
-
function getSkyWalkingSw8(
|
|
22
|
-
traceId,
|
|
23
|
-
traceSegmentId,
|
|
24
|
-
applicationId,
|
|
25
|
-
env,
|
|
26
|
-
version,
|
|
27
|
-
requestUrlHost
|
|
28
|
-
) {
|
|
29
|
-
try {
|
|
30
|
-
var traceIdStr = String(base64Encode(traceId))
|
|
31
|
-
var segmentId = String(base64Encode(traceSegmentId))
|
|
32
|
-
var service = String(base64Encode(applicationId + '_rum_' + env))
|
|
33
|
-
var instance = String(base64Encode(version))
|
|
34
|
-
var endpoint = String(base64Encode(window.location.href))
|
|
35
|
-
var peer = String(base64Encode(requestUrlHost))
|
|
36
|
-
var index = '0'
|
|
37
|
-
// var values = `${1}-${traceIdStr}-${segmentId}-${index}-${service}-${instance}-${endpoint}-${peer}`;
|
|
38
|
-
return (
|
|
39
|
-
'1-' +
|
|
40
|
-
traceIdStr +
|
|
41
|
-
'-' +
|
|
42
|
-
segmentId +
|
|
43
|
-
'-' +
|
|
44
|
-
index +
|
|
45
|
-
'-' +
|
|
46
|
-
service +
|
|
47
|
-
'-' +
|
|
48
|
-
instance +
|
|
49
|
-
'-' +
|
|
50
|
-
endpoint +
|
|
51
|
-
'-' +
|
|
52
|
-
peer
|
|
53
|
-
)
|
|
54
|
-
} catch (err) {
|
|
55
|
-
return ''
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
*
|
|
60
|
-
* @param {*} configuration
|
|
61
|
-
* @param {*} requestUrl
|
|
62
|
-
*/
|
|
63
3
|
export function SkyWalkingTracer(configuration, requestUrl, traceSampled) {
|
|
64
|
-
this._spanId =
|
|
65
|
-
this._traceId =
|
|
4
|
+
this._spanId = UUID()
|
|
5
|
+
this._traceId = UUID()
|
|
66
6
|
this._applicationId = configuration.applicationId
|
|
67
7
|
this._env = configuration.env
|
|
68
8
|
this._version = configuration.version
|
|
69
|
-
this._urlParse =
|
|
9
|
+
this._urlParse = getUrlParts(requestUrl)
|
|
70
10
|
this._traceSampled = traceSampled
|
|
71
11
|
if (
|
|
72
12
|
configuration.generateTraceId &&
|
|
@@ -94,33 +34,16 @@ SkyWalkingTracer.prototype = {
|
|
|
94
34
|
},
|
|
95
35
|
getSkyWalkingSw8: function () {
|
|
96
36
|
try {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
base64Encode(this.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return (
|
|
108
|
-
(this._traceSampled ? '1' : '0') +
|
|
109
|
-
'-' +
|
|
110
|
-
traceIdStr +
|
|
111
|
-
'-' +
|
|
112
|
-
segmentId +
|
|
113
|
-
'-' +
|
|
114
|
-
index +
|
|
115
|
-
'-' +
|
|
116
|
-
service +
|
|
117
|
-
'-' +
|
|
118
|
-
instance +
|
|
119
|
-
'-' +
|
|
120
|
-
endpoint +
|
|
121
|
-
'-' +
|
|
122
|
-
peer
|
|
123
|
-
)
|
|
37
|
+
return [
|
|
38
|
+
this._traceSampled ? '1' : '0',
|
|
39
|
+
base64Encode(this.getTraceId()),
|
|
40
|
+
base64Encode(this.getSpanId()),
|
|
41
|
+
'0',
|
|
42
|
+
base64Encode(this._applicationId + '_rum_' + this._env),
|
|
43
|
+
base64Encode(this._version),
|
|
44
|
+
base64Encode(window.location.pathname),
|
|
45
|
+
base64Encode(this._urlParse.Host)
|
|
46
|
+
].join('-')
|
|
124
47
|
} catch (err) {
|
|
125
48
|
return ''
|
|
126
49
|
}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
performDraw,
|
|
8
8
|
isNumber,
|
|
9
9
|
getType,
|
|
10
|
+
buildUrl,
|
|
10
11
|
find,
|
|
11
12
|
isMatchOption,
|
|
12
13
|
matchList,
|
|
@@ -37,7 +38,27 @@ export function clearTracingIfNeeded(context) {
|
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
function buildTracingOptions(options) {
|
|
42
|
+
return (options || []).reduce(function (result, option) {
|
|
43
|
+
if (typeof option.match !== 'string') {
|
|
44
|
+
result.push(option)
|
|
45
|
+
} else {
|
|
46
|
+
try {
|
|
47
|
+
// The serialized authority ends with a slash even for bare origins.
|
|
48
|
+
var url = buildUrl(option.match)
|
|
49
|
+
if (/^https?:$/.test(url.protocol) && !url.username && !url.password) {
|
|
50
|
+
result.push({ match: url.href, traceType: option.traceType })
|
|
51
|
+
}
|
|
52
|
+
} catch (_) {
|
|
53
|
+
// An invalid URL grants no tracing access.
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return result
|
|
57
|
+
}, [])
|
|
58
|
+
}
|
|
59
|
+
|
|
40
60
|
export function startTracer(configuration, sessionManager) {
|
|
61
|
+
var tracingOptions = buildTracingOptions(configuration.allowedTracingUrls)
|
|
41
62
|
return {
|
|
42
63
|
clearTracingIfNeeded: clearTracingIfNeeded,
|
|
43
64
|
traceFetch: function (context) {
|
|
@@ -80,7 +101,8 @@ export function startTracer(configuration, sessionManager) {
|
|
|
80
101
|
)
|
|
81
102
|
context.init.headers = headersMap
|
|
82
103
|
}
|
|
83
|
-
}
|
|
104
|
+
},
|
|
105
|
+
tracingOptions
|
|
84
106
|
)
|
|
85
107
|
},
|
|
86
108
|
traceXhr: function (context, xhr) {
|
|
@@ -92,7 +114,8 @@ export function startTracer(configuration, sessionManager) {
|
|
|
92
114
|
each(tracingHeaders, function (value, name) {
|
|
93
115
|
xhr.setRequestHeader(name, value)
|
|
94
116
|
})
|
|
95
|
-
}
|
|
117
|
+
},
|
|
118
|
+
tracingOptions
|
|
96
119
|
)
|
|
97
120
|
}
|
|
98
121
|
}
|
|
@@ -102,14 +125,15 @@ export function injectHeadersIfTracingAllowed(
|
|
|
102
125
|
configuration,
|
|
103
126
|
context,
|
|
104
127
|
sessionManager,
|
|
105
|
-
inject
|
|
128
|
+
inject,
|
|
129
|
+
tracingOptions = buildTracingOptions(configuration.allowedTracingUrls)
|
|
106
130
|
) {
|
|
107
131
|
const session = sessionManager.findTrackedSession()
|
|
108
132
|
if (!session && !configuration.allowTraceHeaderWithoutSession) {
|
|
109
133
|
return
|
|
110
134
|
}
|
|
111
135
|
var tracingOption = find(
|
|
112
|
-
|
|
136
|
+
tracingOptions,
|
|
113
137
|
function (tracingOption) {
|
|
114
138
|
return matchList([tracingOption.match], context.url, true)
|
|
115
139
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -10,7 +10,11 @@ export type {
|
|
|
10
10
|
Context,
|
|
11
11
|
User,
|
|
12
12
|
RumEvent,
|
|
13
|
+
RumFetchResourceEvent,
|
|
13
14
|
RumSyntheticsContext,
|
|
15
|
+
RumInitResult,
|
|
16
|
+
RumInitError,
|
|
17
|
+
RumRemoteConfigurationError,
|
|
14
18
|
RumInitConfiguration,
|
|
15
19
|
RumLegacyInitConfiguration,
|
|
16
20
|
RumSiteInitConfiguration,
|
|
@@ -187,6 +191,8 @@ export interface ResourceTrackerSnapshot {
|
|
|
187
191
|
}
|
|
188
192
|
|
|
189
193
|
export interface ViewOptions {
|
|
194
|
+
/** @internal The Angular router plugin excludes the document query from hash routes. */
|
|
195
|
+
excludeHashRouteOuterQuery?: boolean
|
|
190
196
|
name?: string | undefined
|
|
191
197
|
service?: string | undefined
|
|
192
198
|
version?: string | undefined
|
|
@@ -215,6 +221,8 @@ export interface RumPluginContext {
|
|
|
215
221
|
addError: (error: RumPluginError) => void
|
|
216
222
|
publicApi: RumPluginApi
|
|
217
223
|
rum: RumPluginApi
|
|
224
|
+
/** Register during onInit to run after configuration validation and before the initial View. */
|
|
225
|
+
onConfigurationReady?: (callback: () => void) => void
|
|
218
226
|
initConfiguration: RumPluginInitConfiguration
|
|
219
227
|
}
|
|
220
228
|
|
|
@@ -273,6 +281,7 @@ export declare const datafluxRum: {
|
|
|
273
281
|
getInternalContext: (
|
|
274
282
|
startTime?: number | undefined
|
|
275
283
|
) => InternalContext | undefined
|
|
284
|
+
/** Returns a clone of the accepted configuration, including resolved overrides. Available before the first manual view; does not prove initialization succeeded. */
|
|
276
285
|
getInitConfiguration: () =>
|
|
277
286
|
| RumPluginInitConfiguration
|
|
278
287
|
| undefined
|