@cloudcare/browser-rum 3.3.0 → 3.3.3

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 (109) hide show
  1. package/bundle/dataflux-rum.js +1 -1
  2. package/cjs/boot/buildEnv.js +1 -1
  3. package/cjs/boot/perStartRum.js +11 -7
  4. package/cjs/boot/perStartRum.js.map +1 -1
  5. package/cjs/boot/recorderApi.js +39 -43
  6. package/cjs/boot/recorderApi.js.map +1 -1
  7. package/cjs/boot/recorderApiStub.js +53 -0
  8. package/cjs/boot/recorderApiStub.js.map +1 -0
  9. package/cjs/boot/rum.entry.js +6 -7
  10. package/cjs/boot/rum.entry.js.map +1 -1
  11. package/cjs/boot/rum.slim.entry.js +13 -0
  12. package/cjs/boot/rum.slim.entry.js.map +1 -0
  13. package/cjs/boot/rumEntryFactory.js +15 -0
  14. package/cjs/boot/rumEntryFactory.js.map +1 -0
  15. package/cjs/boot/rumPublicApi.js +8 -46
  16. package/cjs/boot/rumPublicApi.js.map +1 -1
  17. package/cjs/boot/rumRecorderApiStub.js +19 -0
  18. package/cjs/boot/rumRecorderApiStub.js.map +1 -0
  19. package/cjs/boot/rumSlimConfiguration.js +16 -0
  20. package/cjs/boot/rumSlimConfiguration.js.map +1 -0
  21. package/cjs/boot/sessionReplayPublicApi.js +62 -0
  22. package/cjs/boot/sessionReplayPublicApi.js.map +1 -0
  23. package/cjs/boot/startRecording.js +6 -1
  24. package/cjs/boot/startRecording.js.map +1 -1
  25. package/cjs/domain/deflate/deflateEncoder.js +2 -4
  26. package/cjs/domain/deflate/deflateEncoder.js.map +1 -1
  27. package/cjs/domain/deflate/deflateWorker.js +1 -1
  28. package/cjs/domain/encoderStreamId.js +11 -0
  29. package/cjs/domain/encoderStreamId.js.map +1 -0
  30. package/cjs/domain/replay/record/canvasEncodeWorker.js +1 -1
  31. package/cjs/domain/replay/record/mutationObserver.js +14 -1
  32. package/cjs/domain/replay/record/mutationObserver.js.map +1 -1
  33. package/cjs/domain/replay/record/record.js +39 -0
  34. package/cjs/domain/replay/record/record.js.map +1 -1
  35. package/cjs/domain/tracing/jaegerTracer.js +6 -6
  36. package/cjs/domain/tracing/jaegerTracer.js.map +1 -1
  37. package/cjs/domain/tracing/traceIdentifier.js +22 -0
  38. package/cjs/domain/tracing/traceIdentifier.js.map +1 -1
  39. package/cjs/domain/tracing/zipkinMultiTracer.js +6 -6
  40. package/cjs/domain/tracing/zipkinMultiTracer.js.map +1 -1
  41. package/cjs/domain/tracing/zipkinSingleTracer.js +6 -6
  42. package/cjs/domain/tracing/zipkinSingleTracer.js.map +1 -1
  43. package/cjs/transport/startRumBatch.js +2 -2
  44. package/cjs/transport/startRumBatch.js.map +1 -1
  45. package/esm/boot/buildEnv.js +1 -1
  46. package/esm/boot/perStartRum.js +11 -7
  47. package/esm/boot/perStartRum.js.map +1 -1
  48. package/esm/boot/recorderApi.js +39 -43
  49. package/esm/boot/recorderApi.js.map +1 -1
  50. package/esm/boot/recorderApiStub.js +47 -0
  51. package/esm/boot/recorderApiStub.js.map +1 -0
  52. package/esm/boot/rum.entry.js +6 -7
  53. package/esm/boot/rum.entry.js.map +1 -1
  54. package/esm/boot/rum.slim.entry.js +7 -0
  55. package/esm/boot/rum.slim.entry.js.map +1 -0
  56. package/esm/boot/rumEntryFactory.js +9 -0
  57. package/esm/boot/rumEntryFactory.js.map +1 -0
  58. package/esm/boot/rumPublicApi.js +8 -46
  59. package/esm/boot/rumPublicApi.js.map +1 -1
  60. package/esm/boot/rumRecorderApiStub.js +13 -0
  61. package/esm/boot/rumRecorderApiStub.js.map +1 -0
  62. package/esm/boot/rumSlimConfiguration.js +10 -0
  63. package/esm/boot/rumSlimConfiguration.js.map +1 -0
  64. package/esm/boot/sessionReplayPublicApi.js +56 -0
  65. package/esm/boot/sessionReplayPublicApi.js.map +1 -0
  66. package/esm/boot/startRecording.js +6 -1
  67. package/esm/boot/startRecording.js.map +1 -1
  68. package/esm/domain/deflate/deflateEncoder.js +2 -4
  69. package/esm/domain/deflate/deflateEncoder.js.map +1 -1
  70. package/esm/domain/deflate/deflateWorker.js +1 -1
  71. package/esm/domain/encoderStreamId.js +5 -0
  72. package/esm/domain/encoderStreamId.js.map +1 -0
  73. package/esm/domain/replay/record/canvasEncodeWorker.js +1 -1
  74. package/esm/domain/replay/record/mutationObserver.js +14 -1
  75. package/esm/domain/replay/record/mutationObserver.js.map +1 -1
  76. package/esm/domain/replay/record/record.js +39 -0
  77. package/esm/domain/replay/record/record.js.map +1 -1
  78. package/esm/domain/tracing/jaegerTracer.js +7 -7
  79. package/esm/domain/tracing/jaegerTracer.js.map +1 -1
  80. package/esm/domain/tracing/traceIdentifier.js +20 -0
  81. package/esm/domain/tracing/traceIdentifier.js.map +1 -1
  82. package/esm/domain/tracing/zipkinMultiTracer.js +7 -7
  83. package/esm/domain/tracing/zipkinMultiTracer.js.map +1 -1
  84. package/esm/domain/tracing/zipkinSingleTracer.js +7 -7
  85. package/esm/domain/tracing/zipkinSingleTracer.js.map +1 -1
  86. package/esm/transport/startRumBatch.js +2 -2
  87. package/esm/transport/startRumBatch.js.map +1 -1
  88. package/package.json +2 -2
  89. package/src/boot/perStartRum.js +11 -7
  90. package/src/boot/recorderApi.js +42 -43
  91. package/src/boot/recorderApiStub.js +47 -0
  92. package/src/boot/rum.entry.js +6 -8
  93. package/src/boot/rum.slim.entry.js +7 -0
  94. package/src/boot/rumEntryFactory.js +10 -0
  95. package/src/boot/rumPublicApi.js +14 -46
  96. package/src/boot/rumRecorderApiStub.js +14 -0
  97. package/src/boot/rumSlimConfiguration.js +11 -0
  98. package/src/boot/sessionReplayPublicApi.js +57 -0
  99. package/src/boot/startRecording.js +6 -1
  100. package/src/domain/deflate/deflateEncoder.js +2 -4
  101. package/src/domain/encoderStreamId.js +5 -0
  102. package/src/domain/replay/record/mutationObserver.js +14 -1
  103. package/src/domain/replay/record/record.js +46 -0
  104. package/src/domain/tracing/jaegerTracer.js +16 -9
  105. package/src/domain/tracing/traceIdentifier.js +24 -0
  106. package/src/domain/tracing/zipkinMultiTracer.js +16 -9
  107. package/src/domain/tracing/zipkinSingleTracer.js +14 -7
  108. package/src/transport/startRumBatch.js +2 -2
  109. package/types/index.d.ts +15 -0
@@ -1,20 +1,29 @@
1
- import { TraceIdentifier, getCrypto } from './traceIdentifier'
1
+ import {
2
+ createRandomHexIdentifier,
3
+ getCrypto,
4
+ normalizeHexIdentifier
5
+ } from './traceIdentifier'
2
6
  import { getType } from '@cloudcare/browser-core'
3
7
  /**
4
8
  *
5
9
  * @param {*} configuration
6
10
  */
7
11
  export function JaegerTracer(configuration, traceSampled) {
8
- this._traceId = new TraceIdentifier()
9
- this._spanId = new TraceIdentifier()
12
+ this._traceId = configuration.traceId128Bit
13
+ ? createRandomHexIdentifier(16)
14
+ : createRandomHexIdentifier(8)
15
+ this._spanId = createRandomHexIdentifier(8)
10
16
  this._traceSampled = traceSampled
11
17
  this.is128Bit = configuration.traceId128Bit
12
18
  if (
13
19
  configuration.generateTraceId &&
14
20
  getType(configuration.generateTraceId) === 'function'
15
21
  ) {
16
- const customTraceId = configuration.generateTraceId()
17
- if (getType(customTraceId) === 'string') {
22
+ const customTraceId = normalizeHexIdentifier(
23
+ configuration.generateTraceId(),
24
+ [16, 32]
25
+ )
26
+ if (customTraceId) {
18
27
  this.customTraceId = customTraceId
19
28
  }
20
29
  }
@@ -24,15 +33,13 @@ JaegerTracer.prototype = {
24
33
  return getCrypto() !== undefined
25
34
  },
26
35
  getSpanId: function () {
27
- return this._spanId.toPaddedHexadecimalString()
36
+ return this._spanId
28
37
  },
29
38
  getTraceId: function () {
30
39
  if (this.customTraceId) {
31
40
  return this.customTraceId
32
41
  }
33
- return this.is128Bit
34
- ? '0000000000000000' + this._traceId.toPaddedHexadecimalString()
35
- : this._traceId.toPaddedHexadecimalString()
42
+ return this._traceId
36
43
  },
37
44
  getUberTraceId: function () {
38
45
  //{trace-id}:{span-id}:{parent-span-id}:{flags}
@@ -41,3 +41,27 @@ TraceIdentifier.prototype = {
41
41
  export function getCrypto() {
42
42
  return window.crypto || window.msCrypto
43
43
  }
44
+
45
+ export function createRandomHexIdentifier(byteLength) {
46
+ var buffer = new Uint8Array(byteLength)
47
+ getCrypto().getRandomValues(buffer)
48
+ var parts = []
49
+ for (var i = 0; i < buffer.length; i += 1) {
50
+ var hex = buffer[i].toString(16)
51
+ parts.push(hex.length === 1 ? '0' + hex : hex)
52
+ }
53
+ return parts.join('')
54
+ }
55
+
56
+ export function normalizeHexIdentifier(value, allowedLengths) {
57
+ if (typeof value !== 'string') {
58
+ return undefined
59
+ }
60
+
61
+ var normalized = value.toLowerCase()
62
+ if (allowedLengths.indexOf(normalized.length) === -1) {
63
+ return undefined
64
+ }
65
+
66
+ return /^[0-9a-f]+$/.test(normalized) ? normalized : undefined
67
+ }
@@ -1,20 +1,29 @@
1
- import { TraceIdentifier, getCrypto } from './traceIdentifier'
1
+ import {
2
+ createRandomHexIdentifier,
3
+ getCrypto,
4
+ normalizeHexIdentifier
5
+ } from './traceIdentifier'
2
6
  import { getType } from '@cloudcare/browser-core'
3
7
  /**
4
8
  *
5
9
  * @param {*} configuration
6
10
  */
7
11
  export function ZipkinMultiTracer(configuration, traceSampled) {
8
- this._traceId = new TraceIdentifier()
9
- this._spanId = new TraceIdentifier()
12
+ this._traceId = configuration.traceId128Bit
13
+ ? createRandomHexIdentifier(16)
14
+ : createRandomHexIdentifier(8)
15
+ this._spanId = createRandomHexIdentifier(8)
10
16
  this._traceSampled = traceSampled
11
17
  this.is128Bit = configuration.traceId128Bit
12
18
  if (
13
19
  configuration.generateTraceId &&
14
20
  getType(configuration.generateTraceId) === 'function'
15
21
  ) {
16
- const customTraceId = configuration.generateTraceId()
17
- if (getType(customTraceId) === 'string') {
22
+ const customTraceId = normalizeHexIdentifier(
23
+ configuration.generateTraceId(),
24
+ [16, 32]
25
+ )
26
+ if (customTraceId) {
18
27
  this.customTraceId = customTraceId
19
28
  }
20
29
  }
@@ -24,15 +33,13 @@ ZipkinMultiTracer.prototype = {
24
33
  return getCrypto() !== undefined
25
34
  },
26
35
  getSpanId: function () {
27
- return this._spanId.toPaddedHexadecimalString()
36
+ return this._spanId
28
37
  },
29
38
  getTraceId: function () {
30
39
  if (this.customTraceId) {
31
40
  return this.customTraceId
32
41
  }
33
- return this.is128Bit
34
- ? '0000000000000000' + this._traceId.toPaddedHexadecimalString()
35
- : this._traceId.toPaddedHexadecimalString()
42
+ return this._traceId
36
43
  },
37
44
 
38
45
  makeTracingHeaders: function () {
@@ -1,19 +1,26 @@
1
- import { TraceIdentifier, getCrypto } from './traceIdentifier'
1
+ import {
2
+ createRandomHexIdentifier,
3
+ getCrypto,
4
+ normalizeHexIdentifier
5
+ } from './traceIdentifier'
2
6
  import { getType } from '@cloudcare/browser-core'
3
7
  /**
4
8
  *
5
9
  * @param {*} configuration
6
10
  */
7
11
  export function ZipkinSingleTracer(configuration, traceSampled) {
8
- this._traceId = new TraceIdentifier()
9
- this._spanId = new TraceIdentifier()
12
+ this._traceId = createRandomHexIdentifier(8)
13
+ this._spanId = createRandomHexIdentifier(8)
10
14
  this._traceSampled = traceSampled
11
15
  if (
12
16
  configuration.generateTraceId &&
13
17
  getType(configuration.generateTraceId) === 'function'
14
18
  ) {
15
- const customTraceId = configuration.generateTraceId()
16
- if (getType(customTraceId) === 'string') {
19
+ const customTraceId = normalizeHexIdentifier(
20
+ configuration.generateTraceId(),
21
+ [16, 32]
22
+ )
23
+ if (customTraceId) {
17
24
  this.customTraceId = customTraceId
18
25
  }
19
26
  }
@@ -23,13 +30,13 @@ ZipkinSingleTracer.prototype = {
23
30
  return getCrypto() !== undefined
24
31
  },
25
32
  getSpanId: function () {
26
- return this._spanId.toPaddedHexadecimalString()
33
+ return this._spanId
27
34
  },
28
35
  getTraceId: function () {
29
36
  if (this.customTraceId) {
30
37
  return this.customTraceId
31
38
  }
32
- return this._traceId.toPaddedHexadecimalString()
39
+ return this._traceId
33
40
  },
34
41
  getB3Str: function () {
35
42
  //{TraceId}-{SpanId}-{SamplingState}-{ParentSpanId}
@@ -3,7 +3,7 @@ import {
3
3
  RumEventType,
4
4
  startBatchWithReplica
5
5
  } from '@cloudcare/browser-core'
6
- import { DeflateEncoderStreamId } from '../domain/deflate'
6
+ import { EncoderStreamId } from '../domain/encoderStreamId'
7
7
  export function startRumBatch(
8
8
  configuration,
9
9
  lifeCycle,
@@ -17,7 +17,7 @@ export function startRumBatch(
17
17
  configuration,
18
18
  {
19
19
  endpoint: configuration.rumEndpoint,
20
- encoder: createEncoder(DeflateEncoderStreamId.RUM)
20
+ encoder: createEncoder(EncoderStreamId.RUM)
21
21
  },
22
22
  reportError,
23
23
  pageExitObservable,
package/types/index.d.ts CHANGED
@@ -84,6 +84,18 @@ export interface CanvasMutationDebugResult {
84
84
  export interface CanvasMutationDebugHistoryResult
85
85
  extends CanvasMutationDebugResult {}
86
86
 
87
+ export interface DomMutationDebugResult {
88
+ timestamp: number
89
+ adds: object[]
90
+ removes: object[]
91
+ texts: object[]
92
+ attributes: object[]
93
+ addsCount: number
94
+ removesCount: number
95
+ textsCount: number
96
+ attributesCount: number
97
+ }
98
+
87
99
  export interface ReplaySegmentFlushDebugResult {
88
100
  sequence: number
89
101
  creationReason: string
@@ -189,6 +201,8 @@ export declare const datafluxRum: {
189
201
  getCanvasMutationHistoryForDebug: () =>
190
202
  | CanvasMutationDebugHistoryResult[]
191
203
  | undefined
204
+ getLastDomMutationForDebug: () => DomMutationDebugResult | undefined
205
+ getDomMutationHistoryForDebug: () => DomMutationDebugResult[] | undefined
192
206
  getLastReplaySegmentFlushForDebug: () =>
193
207
  | ReplaySegmentFlushDebugResult
194
208
  | undefined
@@ -198,6 +212,7 @@ export declare const datafluxRum: {
198
212
  getReplayPerformanceForDebug: () =>
199
213
  | ReplayPerformanceDebugResult
200
214
  | undefined
215
+ flushReplayMutationsForDebug: () => void
201
216
  createResourceTrackerId: () => string
202
217
  setResourceContext: (trackerId: string, context: Context) => void
203
218
  appendResourceContext: (trackerId: string, context: Context) => void