@cloudcare/browser-rum 3.3.24 → 3.3.26

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 (209) hide show
  1. package/README.md +33 -0
  2. package/README.zh.md +30 -0
  3. package/bundle/dataflux-rum.js +1 -1
  4. package/cjs/boot/buildEnv.js +1 -1
  5. package/cjs/boot/disabledRumPublicApi.js +5 -0
  6. package/cjs/boot/disabledRumPublicApi.js.map +1 -1
  7. package/cjs/boot/initCallbacks.js +25 -0
  8. package/cjs/boot/initCallbacks.js.map +1 -0
  9. package/cjs/boot/perStartRum.js +99 -50
  10. package/cjs/boot/perStartRum.js.map +1 -1
  11. package/cjs/boot/recorderApi.js +36 -1
  12. package/cjs/boot/recorderApi.js.map +1 -1
  13. package/cjs/boot/rum.js +8 -9
  14. package/cjs/boot/rum.js.map +1 -1
  15. package/cjs/boot/rumPublicApi.js +6 -7
  16. package/cjs/boot/rumPublicApi.js.map +1 -1
  17. package/cjs/boot/startRecording.js +2 -0
  18. package/cjs/boot/startRecording.js.map +1 -1
  19. package/cjs/domain/configuration.js +15 -2
  20. package/cjs/domain/configuration.js.map +1 -1
  21. package/cjs/domain/contexts/urlContexts.js +32 -21
  22. package/cjs/domain/contexts/urlContexts.js.map +1 -1
  23. package/cjs/domain/contexts/viewContexts.js +1 -1
  24. package/cjs/domain/contexts/viewContexts.js.map +1 -1
  25. package/cjs/domain/deflate/deflateWorker.js +39 -27
  26. package/cjs/domain/deflate/deflateWorker.js.map +1 -1
  27. package/cjs/domain/privacy.js +79 -107
  28. package/cjs/domain/privacy.js.map +1 -1
  29. package/cjs/domain/replay/record/canvasCommandCapture.js +87 -179
  30. package/cjs/domain/replay/record/canvasCommandCapture.js.map +1 -1
  31. package/cjs/domain/replay/record/canvasCommandObserver.js +10 -6
  32. package/cjs/domain/replay/record/canvasCommandObserver.js.map +1 -1
  33. package/cjs/domain/replay/record/canvasCommandObserverStub.js +24 -0
  34. package/cjs/domain/replay/record/canvasCommandObserverStub.js.map +1 -0
  35. package/cjs/domain/replay/record/canvasCommandSerializeArgs.js +3 -2
  36. package/cjs/domain/replay/record/canvasCommandSerializeArgs.js.map +1 -1
  37. package/cjs/domain/replay/record/canvasContext.js +15 -0
  38. package/cjs/domain/replay/record/canvasContext.js.map +1 -1
  39. package/cjs/domain/replay/record/canvasEncodeWorker.js +1 -1
  40. package/cjs/domain/replay/record/canvasObserver.js +3 -0
  41. package/cjs/domain/replay/record/canvasObserver.js.map +1 -1
  42. package/cjs/domain/replay/record/canvasWebGLPluginHost.js +5 -1
  43. package/cjs/domain/replay/record/canvasWebGLPluginHost.js.map +1 -1
  44. package/cjs/domain/replay/record/mutationObserver.js +3 -12
  45. package/cjs/domain/replay/record/mutationObserver.js.map +1 -1
  46. package/cjs/domain/replay/record/observers.js +3 -7
  47. package/cjs/domain/replay/record/observers.js.map +1 -1
  48. package/cjs/domain/replay/record/record.js +15 -2
  49. package/cjs/domain/replay/record/record.js.map +1 -1
  50. package/cjs/domain/replay/record/serializationUtils.js +8 -23
  51. package/cjs/domain/replay/record/serializationUtils.js.map +1 -1
  52. package/cjs/domain/replay/record/serialize.js +19 -33
  53. package/cjs/domain/replay/record/serialize.js.map +1 -1
  54. package/cjs/domain/replay/segmentCollection/buildReplayPayload.js +21 -6
  55. package/cjs/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -1
  56. package/cjs/domain/replay/segmentCollection/segmentCollection.js +91 -143
  57. package/cjs/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
  58. package/cjs/domain/replayCanvasSupported.js +8 -0
  59. package/cjs/domain/replayCanvasSupported.js.map +1 -0
  60. package/cjs/domain/requestCollection.js +38 -39
  61. package/cjs/domain/requestCollection.js.map +1 -1
  62. package/cjs/domain/rumEventsCollection/actions/listenActionEvents.js +1 -1
  63. package/cjs/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -1
  64. package/cjs/domain/rumEventsCollection/resource/fetchTimingRegistry.js +143 -0
  65. package/cjs/domain/rumEventsCollection/resource/fetchTimingRegistry.js.map +1 -0
  66. package/cjs/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +2 -2
  67. package/cjs/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
  68. package/cjs/domain/rumEventsCollection/resource/resourceCollection.js +91 -66
  69. package/cjs/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
  70. package/cjs/domain/rumEventsCollection/resource/resourceTrackerManager.js +11 -9
  71. package/cjs/domain/rumEventsCollection/resource/resourceTrackerManager.js.map +1 -1
  72. package/cjs/domain/rumEventsCollection/resource/resourceUtils.js +35 -50
  73. package/cjs/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
  74. package/cjs/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +7 -1
  75. package/cjs/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -1
  76. package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +1 -1
  77. package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
  78. package/cjs/domain/rumEventsCollection/view/trackViews.js +3 -0
  79. package/cjs/domain/rumEventsCollection/view/trackViews.js.map +1 -1
  80. package/cjs/domain/rumEventsCollection/view/viewCollection.js +1 -1
  81. package/cjs/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
  82. package/cjs/domain/tracing/skywalkingTracer.js +4 -50
  83. package/cjs/domain/tracing/skywalkingTracer.js.map +1 -1
  84. package/cjs/domain/tracing/tracer.js +26 -3
  85. package/cjs/domain/tracing/tracer.js.map +1 -1
  86. package/esm/boot/buildEnv.js +1 -1
  87. package/esm/boot/disabledRumPublicApi.js +1 -1
  88. package/esm/boot/disabledRumPublicApi.js.map +1 -1
  89. package/esm/boot/initCallbacks.js +2 -0
  90. package/esm/boot/initCallbacks.js.map +1 -0
  91. package/esm/boot/perStartRum.js +1 -1
  92. package/esm/boot/perStartRum.js.map +1 -1
  93. package/esm/boot/recorderApi.js +1 -1
  94. package/esm/boot/recorderApi.js.map +1 -1
  95. package/esm/boot/rum.js +1 -1
  96. package/esm/boot/rum.js.map +1 -1
  97. package/esm/boot/rumPublicApi.js +1 -1
  98. package/esm/boot/rumPublicApi.js.map +1 -1
  99. package/esm/boot/startRecording.js +1 -1
  100. package/esm/boot/startRecording.js.map +1 -1
  101. package/esm/domain/configuration.js +1 -1
  102. package/esm/domain/configuration.js.map +1 -1
  103. package/esm/domain/contexts/urlContexts.js +1 -1
  104. package/esm/domain/contexts/urlContexts.js.map +1 -1
  105. package/esm/domain/contexts/viewContexts.js +1 -1
  106. package/esm/domain/contexts/viewContexts.js.map +1 -1
  107. package/esm/domain/deflate/deflateWorker.js +1 -1
  108. package/esm/domain/deflate/deflateWorker.js.map +1 -1
  109. package/esm/domain/privacy.js +1 -1
  110. package/esm/domain/privacy.js.map +1 -1
  111. package/esm/domain/replay/record/canvasCommandCapture.js +1 -1
  112. package/esm/domain/replay/record/canvasCommandCapture.js.map +1 -1
  113. package/esm/domain/replay/record/canvasCommandObserver.js +1 -1
  114. package/esm/domain/replay/record/canvasCommandObserver.js.map +1 -1
  115. package/esm/domain/replay/record/canvasCommandObserverStub.js +2 -0
  116. package/esm/domain/replay/record/canvasCommandObserverStub.js.map +1 -0
  117. package/esm/domain/replay/record/canvasCommandSerializeArgs.js +1 -1
  118. package/esm/domain/replay/record/canvasCommandSerializeArgs.js.map +1 -1
  119. package/esm/domain/replay/record/canvasContext.js +1 -1
  120. package/esm/domain/replay/record/canvasContext.js.map +1 -1
  121. package/esm/domain/replay/record/canvasEncodeWorker.js +1 -1
  122. package/esm/domain/replay/record/canvasObserver.js +1 -1
  123. package/esm/domain/replay/record/canvasObserver.js.map +1 -1
  124. package/esm/domain/replay/record/canvasWebGLPluginHost.js +1 -1
  125. package/esm/domain/replay/record/canvasWebGLPluginHost.js.map +1 -1
  126. package/esm/domain/replay/record/mutationObserver.js +1 -1
  127. package/esm/domain/replay/record/mutationObserver.js.map +1 -1
  128. package/esm/domain/replay/record/observers.js +1 -1
  129. package/esm/domain/replay/record/observers.js.map +1 -1
  130. package/esm/domain/replay/record/record.js +1 -1
  131. package/esm/domain/replay/record/record.js.map +1 -1
  132. package/esm/domain/replay/record/serializationUtils.js +1 -1
  133. package/esm/domain/replay/record/serializationUtils.js.map +1 -1
  134. package/esm/domain/replay/record/serialize.js +1 -1
  135. package/esm/domain/replay/record/serialize.js.map +1 -1
  136. package/esm/domain/replay/segmentCollection/buildReplayPayload.js +1 -1
  137. package/esm/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -1
  138. package/esm/domain/replay/segmentCollection/segmentCollection.js +1 -1
  139. package/esm/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
  140. package/esm/domain/replayCanvasSupported.js +2 -0
  141. package/esm/domain/replayCanvasSupported.js.map +1 -0
  142. package/esm/domain/requestCollection.js +1 -1
  143. package/esm/domain/requestCollection.js.map +1 -1
  144. package/esm/domain/rumEventsCollection/actions/listenActionEvents.js +1 -1
  145. package/esm/domain/rumEventsCollection/actions/listenActionEvents.js.map +1 -1
  146. package/esm/domain/rumEventsCollection/resource/fetchTimingRegistry.js +2 -0
  147. package/esm/domain/rumEventsCollection/resource/fetchTimingRegistry.js.map +1 -0
  148. package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +1 -1
  149. package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
  150. package/esm/domain/rumEventsCollection/resource/resourceCollection.js +1 -1
  151. package/esm/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
  152. package/esm/domain/rumEventsCollection/resource/resourceTrackerManager.js +1 -1
  153. package/esm/domain/rumEventsCollection/resource/resourceTrackerManager.js.map +1 -1
  154. package/esm/domain/rumEventsCollection/resource/resourceUtils.js +1 -1
  155. package/esm/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
  156. package/esm/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +1 -1
  157. package/esm/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js.map +1 -1
  158. package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +1 -1
  159. package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
  160. package/esm/domain/rumEventsCollection/view/trackViews.js +1 -1
  161. package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -1
  162. package/esm/domain/rumEventsCollection/view/viewCollection.js +1 -1
  163. package/esm/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
  164. package/esm/domain/tracing/skywalkingTracer.js +1 -1
  165. package/esm/domain/tracing/skywalkingTracer.js.map +1 -1
  166. package/esm/domain/tracing/tracer.js +1 -1
  167. package/esm/domain/tracing/tracer.js.map +1 -1
  168. package/package.json +7 -7
  169. package/src/boot/disabledRumPublicApi.js +5 -0
  170. package/src/boot/initCallbacks.js +16 -0
  171. package/src/boot/perStartRum.js +102 -59
  172. package/src/boot/recorderApi.js +51 -2
  173. package/src/boot/rum.js +12 -18
  174. package/src/boot/rumPublicApi.js +6 -8
  175. package/src/boot/startRecording.js +2 -0
  176. package/src/domain/configuration.js +13 -2
  177. package/src/domain/contexts/urlContexts.js +34 -27
  178. package/src/domain/contexts/viewContexts.js +2 -2
  179. package/src/domain/deflate/deflateWorker.js +35 -21
  180. package/src/domain/privacy.js +93 -157
  181. package/src/domain/replay/record/canvasCommandCapture.js +102 -239
  182. package/src/domain/replay/record/canvasCommandObserver.js +11 -18
  183. package/src/domain/replay/record/canvasCommandObserverStub.js +11 -0
  184. package/src/domain/replay/record/canvasCommandSerializeArgs.js +2 -2
  185. package/src/domain/replay/record/canvasContext.js +18 -0
  186. package/src/domain/replay/record/canvasObserver.js +5 -1
  187. package/src/domain/replay/record/canvasWebGLPluginHost.js +4 -1
  188. package/src/domain/replay/record/mutationObserver.js +6 -22
  189. package/src/domain/replay/record/observers.js +4 -8
  190. package/src/domain/replay/record/record.js +20 -5
  191. package/src/domain/replay/record/serializationUtils.js +10 -33
  192. package/src/domain/replay/record/serialize.js +30 -38
  193. package/src/domain/replay/segmentCollection/buildReplayPayload.js +24 -14
  194. package/src/domain/replay/segmentCollection/segmentCollection.js +97 -227
  195. package/src/domain/replayCanvasSupported.js +1 -0
  196. package/src/domain/requestCollection.js +39 -51
  197. package/src/domain/rumEventsCollection/actions/listenActionEvents.js +8 -2
  198. package/src/domain/rumEventsCollection/resource/fetchTimingRegistry.js +138 -0
  199. package/src/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +2 -2
  200. package/src/domain/rumEventsCollection/resource/resourceCollection.js +103 -88
  201. package/src/domain/rumEventsCollection/resource/resourceTrackerManager.js +10 -10
  202. package/src/domain/rumEventsCollection/resource/resourceUtils.js +41 -69
  203. package/src/domain/rumEventsCollection/resource/retrieveInitialDocumentResourceTiming.js +8 -2
  204. package/src/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +1 -1
  205. package/src/domain/rumEventsCollection/view/trackViews.js +3 -0
  206. package/src/domain/rumEventsCollection/view/viewCollection.js +2 -3
  207. package/src/domain/tracing/skywalkingTracer.js +14 -91
  208. package/src/domain/tracing/tracer.js +28 -4
  209. package/types/index.d.ts +9 -0
@@ -1 +1 @@
1
- {"version":3,"file":"tracer.js","names":["objectEntries","each","shallowClone","isArray","TraceType","performDraw","isNumber","getType","find","isMatchOption","matchList","isString","isRequest","display","DDtraceTracer","SkyWalkingTracer","JaegerTracer","ZipkinSingleTracer","ZipkinMultiTracer","W3cTraceParentTracer","isTraceSampled","isTracingOption","item","expectedItem","match","traceType","clearTracingIfNeeded","context","status","isAborted","traceId","undefined","spanId","traceSampled","startTracer","configuration","sessionManager","traceFetch","injectHeadersIfTracingAllowed","tracingHeaders","input","init","headers","Headers","forEach","value","key","push","header","headersMap","concat","Request","append","traceXhr","xhr","name","setRequestHeader","inject","session","findTrackedSession","allowTraceHeaderWithoutSession","tracingOption","allowedTracingUrls","url","tracer","id","tracingSampleRate","DDTRACE","SKYWALKING_V3","ZIPKIN_MULTI_HEADER","JAEGER","W3C_TRACEPARENT","W3C_TRACEPARENT_64","ZIPKIN_SINGLE_HEADER","isTracingSupported","getTraceId","getSpanId","makeTracingHeaders","injectTraceHeader","result","visitorId","enabled","toLowerCase","warn"],"sources":["../../../src/domain/tracing/tracer.js"],"mappings":"OACEA,cACAC,KACAC,aACAC,QACAC,UACAC,YACAC,SACAC,QACAC,KACAC,cACAC,UACAC,SACAC,UACAC,YACK,iCACEC,kBAAqB,yBACrBC,qBAAwB,4BACxBC,iBAAoB,wBACpBC,uBAA0B,8BAC1BC,sBAAyB,6BACzBC,yBAA4B,gCAC5BC,mBAAsB,mBACxB,SAASC,gBAAgBC,MAC9B,IAAIC,aAAeD,KACnB,MAC4B,WAA1Bf,QAAQgB,eACRd,cAAcc,aAAaC,QAC3Bb,SAASY,aAAaE,UAE1B,QACO,SAASC,qBAAqBC,SACZ,IAAnBA,QAAQC,QAAiBD,QAAQE,YACnCF,QAAQG,aAAUC,EAClBJ,QAAQK,YAASD,EACjBJ,QAAQM,kBAAeF,EAE3B,QAEO,SAASG,YAAYC,cAAeC,gBACzC,MAAO,CACLV,qBAAsBA,qBACtBW,WAAY,SAAZA,WAAsBV,SACpB,OAAOW,8BACLH,cACAR,QACAS,gBACA,SAAUG,gBACR,IACE3B,UAAUe,QAAQa,QAChBb,QAAQc,MAASd,QAAQc,KAAKC,QAM3B,CACLf,QAAQc,KAAOvC,aAAayB,QAAQc,MACpC,IAAIC,QAAU,GACVf,QAAQc,KAAKC,mBAAmBC,QAClChB,QAAQc,KAAKC,QAAQE,SAAQ,SAAUC,MAAOC,KAC5CJ,QAAQK,KAAK,CAACD,IAAKD,OACrB,IACS1C,QAAQwB,QAAQc,KAAKC,SAC9BzC,KAAK0B,QAAQc,KAAKC,SAAS,SAAUM,QACnCN,QAAQK,KAAKC,OACf,IACSrB,QAAQc,KAAKC,SACtBzC,KAAK0B,QAAQc,KAAKC,SAAS,SAAUG,MAAOC,KAC1CJ,QAAQK,KAAK,CAAC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UAAUoE,mBACbR,OAAS,IAAI7C,qBAAqBgB,cAAeF,cAAc,GAC/D,MACF,KAAK7B,UAAUqE,qBACbT,OAAS,IAAI/C,mBAAmBkB,cAAeF,cAKnD,GAAK+B,QAAWA,OAAOU,qBAAvB,CAIA/C,QAAQG,QAAUkC,OAAOW,aACzBhD,QAAQK,OAASgC,OAAOY,YACxBjD,QAAQM,aAAeA,aACvB,IAAIS,QAAUsB,OAAOa,qBACrB,GAAI1C,cAAc2C,kBAAmB,CACnC,IAAIC,OAAS5C,cAAc2C,kBAAkB5E,aAAayB,UAClC,WAApBpB,QAAQwE,SACV9E,KAAK8E,QAAQ,SAAUlC,MAAOC,KAC5B,GAAuB,WAAnBvC,QAAQsC,OAAqB,CAC/B,GACElB,QAAQqD,WACR7C,cAAc6C,WACd7C,cAAc6C,UAAUC,SACxBnC,IAAIoC,gBAAkB/C,cAAc6C,UAAUhC,OAK9C,YAHAnC,QAAQsE,KACN,yEAIJzC,QAAQI,KAAOD,KACjB,CACF,GAEJ,CACAY,OAAOf,QA3BP,CAnCA,CATA,CAwEF","ignoreList":[]}
1
+ {"version":3,"file":"tracer.js","names":["objectEntries","each","shallowClone","isArray","TraceType","performDraw","isNumber","getType","buildUrl","find","isMatchOption","matchList","isString","isRequest","display","DDtraceTracer","SkyWalkingTracer","JaegerTracer","ZipkinSingleTracer","ZipkinMultiTracer","W3cTraceParentTracer","isTraceSampled","isTracingOption","item","expectedItem","match","traceType","clearTracingIfNeeded","context","status","isAborted","traceId","undefined","spanId","traceSampled","buildTracingOptions","options","reduce","result","option","push","url","test","protocol","username","password","href","_","startTracer","configuration","sessionManager","tracingOptions","allowedTracingUrls","traceFetch","injectHeadersIfTracingAllowed","tracingHeaders","input","init","headers","Headers","forEach","value","key","header","headersMap","concat","Request","append","traceXhr","xhr","name","setRequestHeader","inject","arguments","length","session","findTrackedSession","allowTraceHeaderWithoutSession","tracingOption","tracer","id","tracingSampleRate","DDTRACE","SKYWALKING_V3","ZIPKIN_MULTI_HEADER","JAEGER","W3C_TRACEPARENT","W3C_TRACEPARENT_64","ZIPKIN_SINGLE_HEADER","isTracingSupported","getTraceId","getSpanId","makeTracingHeaders","injectTraceHeader","visitorId","enabled","toLowerCase","warn"],"sources":["../../../src/domain/tracing/tracer.js"],"mappings":"OACEA,cACAC,KACAC,aACAC,QACAC,UACAC,YACAC,SACAC,QACAC,SACAC,KACAC,cACAC,UACAC,SACAC,UACAC,YACK,iCACEC,kBAAqB,yBACrBC,qBAAwB,4BACxBC,iBAAoB,wBACpBC,uBAA0B,8BAC1BC,sBAAyB,6BACzBC,yBAA4B,gCAC5BC,mBAAsB,mBACxB,SAASC,gBAAgBC,MAC9B,IAAIC,aAAeD,KACnB,MAC4B,WAA1BhB,QAAQiB,eACRd,cAAcc,aAAaC,QAC3Bb,SAASY,aAAaE,UAE1B,QACO,SAASC,qBAAqBC,SACZ,IAAnBA,QAAQC,QAAiBD,QAAQE,YACnCF,QAAQG,aAAUC,EAClBJ,QAAQK,YAASD,EACjBJ,QAAQM,kBAAeF,EAE3B,CAEA,SAASG,oBAAoBC,SAC3B,OAAQA,SAAW,IAAIC,QAAO,SAAUC,OAAQC,QAC9C,GAA4B,iBAAjBA,OAAOd,MAChBa,OAAOE,KAAKD,aAEZ,IAEE,IAAIE,IAAMjC,SAAS+B,OAAOd,QACtB,YAAYiB,KAAKD,IAAIE,WAAcF,IAAIG,UAAaH,IAAII,UAC1DP,OAAOE,KAAK,CAAEf,MAAOgB,IAAIK,KAAMpB,UAAWa,OAAOb,WAErD,CAAE,MAAOqB,GACP,CAGJ,OAAOT,MACT,GAAG,GACL,QAEO,SAASU,YAAYC,cAAeC,gBACzC,IAAIC,eAAiBhB,oBAAoBc,cAAcG,oBACvD,MAAO,CACLzB,qBAAsBA,qBACtB0B,WAAY,SAAZA,WAAsBzB,SACpB,OAAO0B,8BACLL,cACArB,QACAsB,gBACA,SAAUK,gBACR,IACE1C,UAAUe,QAAQ4B,QAChB5B,QAAQ6B,MAAS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HANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@cloudcare/browser-rum",
3
- "version": "3.3.24",
3
+ "version": "3.3.26",
4
4
  "main": "cjs/index.js",
5
5
  "module": "esm/index.js",
6
6
  "types": "types/index.d.ts",
7
7
  "dependencies": {
8
- "@cloudcare/browser-core": "3.3.24",
9
- "@cloudcare/browser-worker": "3.3.24"
8
+ "@cloudcare/browser-core": "3.3.26",
9
+ "@cloudcare/browser-worker": "3.3.26"
10
10
  },
11
11
  "description": "Guance Browser SDK RUM Package",
12
12
  "browserSdkCapabilities": {
@@ -17,9 +17,9 @@
17
17
  "build": "run-s build:cjs build:esm build:bundle",
18
18
  "build:cjs": "rm -rf cjs && babel --config-file ./babel.cjs.json --out-dir cjs ./src && npm run replace-build-env cjs && node ../../scripts/strip-source-map-sources-content.js cjs",
19
19
  "build:esm": "rm -rf esm && babel --config-file ./babel.esm.json --out-dir esm ./src && npm run replace-build-env esm && node ../../scripts/optimize-esm.js esm && node ../../scripts/strip-source-map-sources-content.js esm",
20
- "build:bundle": "rm -rf bundle && webpack --mode=production && npm run check:bundle-size && npm run check:bundle-contract",
21
- "check:bundle-size": "node ../../scripts/check-bundle-size.js bundle/dataflux-rum.js",
22
- "check:bundle-contract": "node ../../scripts/check-bundle-property-contract.js bundle/dataflux-rum.js rum && node ../../scripts/check-rum-webgl-boundary.js bundle/dataflux-rum.js",
20
+ "build:bundle": "rm -rf bundle && webpack --mode=production && webpack --mode=production --env domOnly && npm run check:bundle-size && npm run check:bundle-contract",
21
+ "check:bundle-size": "node ../../scripts/check-bundle-size.js bundle/dataflux-rum.js && node ../../scripts/check-bundle-size.js bundle/dataflux-rum-dom.js dom",
22
+ "check:bundle-contract": "node ../../scripts/check-bundle-property-contract.js bundle/dataflux-rum.js rum && node ../../scripts/check-bundle-property-contract.js bundle/dataflux-rum-dom.js rum && node ../../scripts/check-rum-webgl-boundary.js bundle/dataflux-rum.js",
23
23
  "replace-build-env": "node ../../scripts/replace-build-env.js",
24
24
  "publish:oss:current": "npm run build:bundle && node ./scripts/publish-oss.js current",
25
25
  "publish:oss:lts": "npm run build:bundle && node ./scripts/publish-oss.js lts",
@@ -41,5 +41,5 @@
41
41
  "author": "dataflux",
42
42
  "license": "MIT",
43
43
  "homepage": "https://github.com/GuanceCloud/datakit-js/README.md",
44
- "gitHead": "07bfd797d5951f2aae259a903b5cbdeafe1c4348"
44
+ "gitHead": "c453c2490d7704f59abe8917de333b9273b06134"
45
45
  }
@@ -1,5 +1,7 @@
1
1
  // A construction failure happens before init(), so its monitor cannot help.
2
2
  // Keep this fallback free of runtime collectors and browser instrumentation.
3
+ import { reportInitError } from './initCallbacks'
4
+
3
5
  export function makeDisabledRumPublicApi(withReplay) {
4
6
  function noop() {}
5
7
  function emptyContext() { return {} }
@@ -31,6 +33,9 @@ export function makeDisabledRumPublicApi(withReplay) {
31
33
  }
32
34
  }
33
35
  methods.forEach(function (name) { api[name] = noop })
36
+ api.init = function (configuration) {
37
+ reportInitError(configuration, 'sdk_disabled', 'RUM is disabled because SDK construction failed.')
38
+ }
34
39
  api.getGlobalContext = api.getRumGlobalContext = api.getViewContext = api.getUser = emptyContext
35
40
  api.createResourceTrackerId = function () { return '' }
36
41
  api.getRemoteConfiguration = noop
@@ -0,0 +1,16 @@
1
+ import { catchUserErrors, displayAlreadyInitializedError, getType } from '@cloudcare/browser-core'
2
+
3
+ export function callInitCallback(configuration, name, result) {
4
+ if (configuration && getType(configuration[name]) === 'function') {
5
+ catchUserErrors(configuration[name], name + ' callback threw an error:')(result)
6
+ }
7
+ }
8
+
9
+ export function reportInitError(configuration, code, message) {
10
+ callInitCallback(configuration, 'onInitError', { code: code, message: message })
11
+ }
12
+
13
+ export function reportAlreadyInitialized(configuration) {
14
+ displayAlreadyInitializedError('DATAFLUX_RUM', configuration)
15
+ reportInitError(configuration, 'already_initialized', 'RUM is already initialized or initialization is in progress.')
16
+ }
@@ -2,7 +2,8 @@ import {
2
2
  createBoundedBuffer,
3
3
  display,
4
4
  canUseEventBridge,
5
- displayAlreadyInitializedError,
5
+ catchUserErrors,
6
+ monitorError,
6
7
  willSyntheticsInjectRum,
7
8
  noop,
8
9
  timeStampNow,
@@ -15,8 +16,9 @@ import {
15
16
  getEventBridge,
16
17
  getType
17
18
  } from '@cloudcare/browser-core'
18
- import { validateAndBuildRumConfiguration } from '../domain/configuration'
19
+ import { prepareReplayCanvasConfiguration, validateAndBuildRumConfiguration } from '../domain/configuration'
19
20
  import { getPluginsTelemetry, validatePlugins } from '../domain/plugins'
21
+ import { callInitCallback, reportInitError, reportAlreadyInitialized } from './initCallbacks'
20
22
 
21
23
  export function createPreStartStrategy(
22
24
  rumPublicApiOptions,
@@ -28,7 +30,7 @@ export function createPreStartStrategy(
28
30
  var startCompressionWorker = rumPublicApiOptions.startCompressionWorker
29
31
  var overrideInitConfiguration = rumPublicApiOptions.overrideInitConfiguration
30
32
  var bufferApiCalls = createBoundedBuffer()
31
- var remoteConfigrationCallbacks = createBoundedBuffer()
33
+ var remoteConfigurationCallbacks = createBoundedBuffer()
32
34
  var firstStartViewCall
33
35
 
34
36
  var compressionWorker
@@ -37,11 +39,11 @@ export function createPreStartStrategy(
37
39
  var cachedConfiguration
38
40
  var cachedRemoteConfiguration
39
41
  var hasStarted
40
- var initializationPending
41
- var pluginsRequireManualViewTracking
42
+ var pendingAttempt
43
+ var workerFailed = false
42
44
  var resourceTrackerManager = rumPublicApiOptions.resourceTrackerManager
43
45
  function tryStartRum() {
44
- if (hasStarted || !cachedInitConfiguration || !cachedConfiguration) {
46
+ if (hasStarted || workerFailed || !cachedInitConfiguration || !cachedConfiguration) {
45
47
  return
46
48
  }
47
49
 
@@ -61,17 +63,35 @@ export function createPreStartStrategy(
61
63
  initialViewOptions = firstStartViewCall.options
62
64
  }
63
65
 
66
+ hasStarted = true
64
67
  var startRumResult = doStartRum(
65
68
  cachedConfiguration,
66
69
  compressionWorker,
67
70
  initialViewOptions
68
71
  )
69
- hasStarted = true
70
72
 
71
73
  bufferApiCalls.drain(startRumResult)
72
74
  }
73
75
 
74
- function doInit(initConfiguration, remoteConfiguration) {
76
+ function fail(attempt, code, message) {
77
+ if (pendingAttempt !== attempt) return
78
+ attempt.$rConfigurationReadyCallbacks = undefined
79
+ pendingAttempt = undefined
80
+ if (code === 'worker_initialization_failed') workerFailed = true
81
+ reportInitError(attempt, code, message)
82
+ }
83
+
84
+ function run(attempt, callback) {
85
+ if (pendingAttempt !== attempt) return
86
+ try {
87
+ callback()
88
+ } catch (error) {
89
+ fail(attempt, 'initialization_failed', 'An error occurred while initializing RUM.')
90
+ monitorError(error)
91
+ }
92
+ }
93
+
94
+ function doInit(attempt, initConfiguration, remoteConfiguration, remoteError) {
75
95
  var eventBridgeAvailable = canUseEventBridge()
76
96
  if (eventBridgeAvailable) {
77
97
  initConfiguration = overrideInitConfigurationForBridge(initConfiguration)
@@ -83,11 +103,7 @@ export function createPreStartStrategy(
83
103
  // Update the exposed initConfiguration to reflect the bridge and remote configuration overrides
84
104
  cachedInitConfiguration = initConfiguration
85
105
  cachedRemoteConfiguration = remoteConfiguration
86
- remoteConfigrationCallbacks.drain(cachedRemoteConfiguration)
87
- if (cachedConfiguration) {
88
- displayAlreadyInitializedError('DATAFLUX_RUM', initConfiguration)
89
- return
90
- }
106
+ remoteConfigurationCallbacks.drain(cachedRemoteConfiguration)
91
107
  var telemetryConfiguration = deepClone(initConfiguration)
92
108
  if (initConfiguration.plugins) {
93
109
  telemetryConfiguration.plugins = getPluginsTelemetry(
@@ -97,7 +113,7 @@ export function createPreStartStrategy(
97
113
  addTelemetryConfiguration(telemetryConfiguration)
98
114
  var configuration = validateAndBuildRumConfiguration(initConfiguration)
99
115
  if (!configuration) {
100
- initializationPending = false
116
+ fail(attempt, 'invalid_configuration', 'Invalid RUM configuration.')
101
117
  return
102
118
  }
103
119
 
@@ -109,48 +125,71 @@ export function createPreStartStrategy(
109
125
  display.warn(
110
126
  'No storage available for session. We will not send any data.'
111
127
  )
112
- initializationPending = false
128
+ fail(attempt, 'storage_unavailable', 'No storage available for the RUM session.')
113
129
  return
114
130
  }
115
131
 
132
+ var prepared = false
133
+ var workerReady = true
134
+ function notifyIfReady() {
135
+ if (!prepared || !workerReady || pendingAttempt !== attempt) return
136
+ pendingAttempt = undefined
137
+ const result = { remoteConfiguration: 'disabled' }
138
+ if (remoteError) {
139
+ result.remoteConfiguration = 'fallback'
140
+ result.remoteConfigurationError = remoteError
141
+ } else if (remoteConfiguration !== undefined) {
142
+ result.remoteConfiguration = 'applied'
143
+ }
144
+ callInitCallback(attempt, 'onInitSuccess', result)
145
+ }
146
+
116
147
  if (
117
148
  configuration.compressIntakeRequests &&
118
149
  !configuration.sendContentTypeByJson &&
119
150
  !eventBridgeAvailable &&
120
151
  startCompressionWorker
121
152
  ) {
122
- compressionWorker = startCompressionWorker(
123
- configuration,
124
- 'RUM',
125
- // Worker initialization can fail asynchronously, especially in Firefox where even CSP
126
- // issues are reported asynchronously. For now, the SDK will continue its execution even if
127
- // data won't be sent to Datadog. We could improve this behavior in the future.
128
- noop
129
- )
130
- if (!compressionWorker) {
131
- // The compression worker starter should have logged an error message explaining the issue
132
- initializationPending = false
153
+ workerReady = false
154
+ function onWorkerError(reason) {
155
+ fail(attempt, 'worker_initialization_failed', reason || 'Unable to create the RUM compression Worker.')
156
+ }
157
+ compressionWorker = startCompressionWorker(configuration, 'RUM', onWorkerError, undefined, function () {
158
+ workerReady = true
159
+ notifyIfReady()
160
+ })
161
+ if (!compressionWorker || workerFailed) {
162
+ onWorkerError()
133
163
  return
134
164
  }
135
165
  }
136
166
 
167
+ // Let plugins queue the initial manual View before collection starts.
168
+ const callbacks = attempt.$rConfigurationReadyCallbacks
169
+ attempt.$rConfigurationReadyCallbacks = undefined
170
+ callbacks.forEach(function (callback) {
171
+ catchUserErrors(callback, 'Plugin configuration callback threw an error:')()
172
+ })
137
173
  cachedConfiguration = configuration
138
- initializationPending = false
139
- // Instrumuent fetch to track network requests
140
- // This is needed in case the consent is not granted and some cutsomer
141
- // library (Apollo Client) is storing uninstrumented fetch to be used later
142
- // The subscrption is needed so that the instrumentation process is completed
174
+ // Instrument fetch before returning so libraries can cache the wrapped function.
143
175
  initFetchObservable().subscribe(noop)
144
176
  tryStartRum()
177
+ // The handshake gates the notification. Collection starts as soon as the Worker exists.
178
+ prepared = true
179
+ notifyIfReady()
145
180
  }
146
181
 
147
182
  return {
148
183
  init: function (initConfiguration, publicApi) {
184
+ if (workerFailed) return
149
185
  if (!initConfiguration) {
150
186
  display.error('Missing configuration')
151
187
  return
152
188
  }
153
- // Set the experimental feature flags as early as possible, so we can use them in most places
189
+ if (pendingAttempt || cachedConfiguration) {
190
+ reportAlreadyInitialized(initConfiguration)
191
+ return
192
+ }
154
193
 
155
194
  // If we are in a Synthetics test configured to automatically inject a RUM instance, we want
156
195
  // to completely discard the customer application RUM instance by ignoring their init() call.
@@ -158,37 +197,40 @@ export function createPreStartStrategy(
158
197
  // internal `ignoreInitIfSyntheticsWillInjectRum` option is here to bypass this condition.
159
198
  if (ignoreInitIfSyntheticsWillInjectRum && willSyntheticsInjectRum()) {
160
199
  cachedInitConfiguration = initConfiguration
161
- return
162
- }
163
- if (initializationPending || cachedConfiguration) {
164
- displayAlreadyInitializedError('DATAFLUX_RUM', initConfiguration)
200
+ reportInitError(initConfiguration, 'initialization_ignored', 'RUM initialization was delegated to Synthetics.')
165
201
  return
166
202
  }
167
203
  // Expose the accepted configuration regardless of initialization success.
204
+ initConfiguration = prepareReplayCanvasConfiguration(initConfiguration)
168
205
  cachedInitConfiguration = initConfiguration
169
- if (!validatePlugins(initConfiguration.plugins)) {
170
- return
171
- }
172
- initializationPending = true
173
- if (rumPublicApiOptions.onInit) {
174
- rumPublicApiOptions.onInit(initConfiguration, publicApi)
175
- }
176
- pluginsRequireManualViewTracking =
177
- !!initConfiguration.plugins &&
178
- initConfiguration.trackViewsManually === true
179
- if (initConfiguration.remoteConfiguration) {
180
- fetchAndApplyRemoteConfiguration(
181
- initConfiguration,
182
- function (remoteInitConfiguration, remoteConfiguration) {
183
- if (pluginsRequireManualViewTracking) {
184
- remoteInitConfiguration.trackViewsManually = true
185
- }
186
- doInit(remoteInitConfiguration, remoteConfiguration)
187
- }
188
- )
189
- } else {
190
- doInit(initConfiguration)
206
+ const attempt = pendingAttempt = {
207
+ onInitSuccess: initConfiguration.onInitSuccess,
208
+ onInitError: initConfiguration.onInitError,
209
+ $rConfigurationReadyCallbacks: []
191
210
  }
211
+ run(attempt, function () {
212
+ if (!validatePlugins(initConfiguration.plugins)) {
213
+ fail(attempt, 'invalid_plugins', 'Invalid RUM plugins configuration.')
214
+ return
215
+ }
216
+ if (rumPublicApiOptions.onInit) {
217
+ rumPublicApiOptions.onInit(initConfiguration, publicApi, function (callback) {
218
+ if (attempt.$rConfigurationReadyCallbacks) attempt.$rConfigurationReadyCallbacks.push(callback)
219
+ })
220
+ }
221
+ const pluginsRequireManualViewTracking =
222
+ !!initConfiguration.plugins && initConfiguration.trackViewsManually === true
223
+ if (initConfiguration.remoteConfiguration) {
224
+ fetchAndApplyRemoteConfiguration(initConfiguration, function (resolved, remote, error) {
225
+ run(attempt, function () {
226
+ if (pluginsRequireManualViewTracking) resolved.trackViewsManually = true
227
+ doInit(attempt, resolved, remote, error)
228
+ })
229
+ })
230
+ } else {
231
+ doInit(attempt, initConfiguration)
232
+ }
233
+ })
192
234
  },
193
235
 
194
236
  getInitConfiguration: function () {
@@ -196,10 +238,11 @@ export function createPreStartStrategy(
196
238
  },
197
239
  getRemoteConfiguration: function (callback) {
198
240
  if (getType(callback) === 'function') {
241
+ callback = catchUserErrors(callback, 'getRemoteConfiguration callback threw an error:')
199
242
  if (cachedRemoteConfiguration) {
200
243
  callback(cachedRemoteConfiguration)
201
244
  } else {
202
- remoteConfigrationCallbacks.add(callback)
245
+ remoteConfigurationCallbacks.add(callback)
203
246
  }
204
247
  }
205
248
  },
@@ -7,7 +7,11 @@ import {
7
7
  BridgeCapability,
8
8
  PageExitReason,
9
9
  monitorError,
10
- Observable
10
+ Observable,
11
+ addEventListener,
12
+ clearTimeout,
13
+ DOM_EVENT,
14
+ setTimeout
11
15
  } from '@cloudcare/browser-core'
12
16
 
13
17
  import { makeRecorderApiStub } from './recorderApiStub'
@@ -19,6 +23,7 @@ import {
19
23
  DeflateEncoderStreamId
20
24
  } from '../domain/deflate'
21
25
  import { createDeflateWorkerController } from '../domain/deflate/deflateWorker'
26
+ var INITIAL_SNAPSHOT_RETRY_DELAY_MS = 1000
22
27
  var RecorderStatus = {
23
28
  // The recorder is stopped.
24
29
  Stopped: 0,
@@ -60,6 +65,7 @@ export function makeRecorderApi(startRecordingImpl, createDeflateWorkerImpl) {
60
65
  $rStatus: RecorderStatus.Stopped
61
66
  }
62
67
  var retryOnView = false
68
+ var initialSnapshotRetryAvailable = true
63
69
  var nextRecordingToken = 0
64
70
  var unloadRecoveryGeneration = 0
65
71
  var replayDeflateWorkerController = createDeflateWorkerController()
@@ -87,6 +93,37 @@ export function makeRecorderApi(startRecordingImpl, createDeflateWorkerImpl) {
87
93
  keepRecordingIntent(options && options.force ? undefined : options, true)
88
94
  }
89
95
 
96
+ function cancelInitialSnapshotRetry() {
97
+ if (state.$rCancelRetry) {
98
+ state.$rCancelRetry()
99
+ state.$rCancelRetry = undefined
100
+ }
101
+ }
102
+
103
+ function scheduleInitialSnapshotRetry(intent) {
104
+ function retryWhenVisible() {
105
+ if (state === intent && document.visibilityState !== 'hidden') {
106
+ initialSnapshotRetryAvailable = false
107
+ startStrategy(intent.$rOptions)
108
+ }
109
+ }
110
+ var timer = setTimeout(function () {
111
+ if (document.visibilityState === 'hidden') {
112
+ // Keep this view's one retry until the user returns to the tab.
113
+ intent.$rCancelRetry = addEventListener(
114
+ document,
115
+ DOM_EVENT.VISIBILITY_CHANGE,
116
+ retryWhenVisible
117
+ ).stop
118
+ } else {
119
+ retryWhenVisible()
120
+ }
121
+ }, INITIAL_SNAPSHOT_RETRY_DELAY_MS)
122
+ intent.$rCancelRetry = function () {
123
+ clearTimeout(timer)
124
+ }
125
+ }
126
+
90
127
  function reconcileStoppedRecordingState() {
91
128
  if (
92
129
  state.$rStatus === RecorderStatus.Started &&
@@ -122,6 +159,7 @@ export function makeRecorderApi(startRecordingImpl, createDeflateWorkerImpl) {
122
159
  compressionWorker
123
160
  ) {
124
161
  lifeCycle.subscribe(LifeCycleEventType.SESSION_EXPIRED, function () {
162
+ cancelInitialSnapshotRetry()
125
163
  if (isRecordingInProgress()) {
126
164
  var options = state.$rOptions
127
165
  stopStrategy()
@@ -156,11 +194,13 @@ export function makeRecorderApi(startRecordingImpl, createDeflateWorkerImpl) {
156
194
  }
157
195
  )
158
196
  lifeCycle.subscribe(LifeCycleEventType.SESSION_RENEWED, function () {
197
+ initialSnapshotRetryAvailable = true
159
198
  if (state.$rStatus === RecorderStatus.IntentToStart) {
160
199
  startStrategy(state.$rOptions)
161
200
  }
162
201
  })
163
202
  lifeCycle.subscribe(LifeCycleEventType.VIEW_CREATED, function () {
203
+ initialSnapshotRetryAvailable = true
164
204
  reconcileStoppedRecordingState()
165
205
  if (state.$rStatus === RecorderStatus.IntentToStart && retryOnView) {
166
206
  startStrategy(state.$rOptions)
@@ -247,6 +287,7 @@ export function makeRecorderApi(startRecordingImpl, createDeflateWorkerImpl) {
247
287
  return replayDeflateWorkerController.getStatus()
248
288
  }
249
289
  startStrategy = function (options) {
290
+ cancelInitialSnapshotRetry()
250
291
  reconcileStoppedRecordingState()
251
292
  if (isRecordingInProgress()) {
252
293
  if (options && options.force) {
@@ -294,12 +335,19 @@ export function makeRecorderApi(startRecordingImpl, createDeflateWorkerImpl) {
294
335
  viewContexts,
295
336
  deflateEncoder,
296
337
  undefined,
297
- function () {
338
+ function (stopReason) {
298
339
  if (
299
340
  isRecordingInProgress() &&
300
341
  state.$rToken === recordingToken
301
342
  ) {
302
343
  keepRecordingIntentAfterFailure(options)
344
+ if (
345
+ stopReason === 'initial_full_snapshot_serialization_timeout' &&
346
+ state.$rStatus === RecorderStatus.IntentToStart &&
347
+ initialSnapshotRetryAvailable
348
+ ) {
349
+ scheduleInitialSnapshotRetry(state)
350
+ }
303
351
  }
304
352
  }
305
353
  )
@@ -369,6 +417,7 @@ export function makeRecorderApi(startRecordingImpl, createDeflateWorkerImpl) {
369
417
  }
370
418
 
371
419
  stopStrategy = function (flushReason) {
420
+ cancelInitialSnapshotRetry()
372
421
  unloadRecoveryGeneration += 1
373
422
  if (state.$rStatus === RecorderStatus.Stopped) {
374
423
  return
package/src/boot/rum.js CHANGED
@@ -6,6 +6,7 @@ import { startCacheUsrCache } from '../domain/usr'
6
6
  import {
7
7
  LifeCycle,
8
8
  LifeCycleEventType,
9
+ assign,
9
10
  createPageExitObservable,
10
11
  canUseEventBridge,
11
12
  startTelemetry,
@@ -16,7 +17,7 @@ import { createDOMMutationObservable } from '../domain/domMutationObservable.js'
16
17
  import { createLocationChangeObservable } from '../domain/locationChangeObservable'
17
18
  import { startLongTaskCollection } from '../domain/rumEventsCollection/longTask/longTaskCollection'
18
19
  import { startLongAnimationFrameCollection } from '../domain/rumEventsCollection/longTask/longAnimationFrameCollection'
19
- import { RumPerformanceEntryType } from '../domain/performanceObservable'
20
+ import { RumPerformanceEntryType, supportPerformanceTimingEvent } from '../domain/performanceObservable'
20
21
  import { startActionCollection } from '../domain/rumEventsCollection/actions/actionCollection'
21
22
  import { startRumBatch } from '../transport/startRumBatch'
22
23
  import { startRumEventBridge } from '../transport/startRumEventBridge'
@@ -41,6 +42,7 @@ export function startRum(
41
42
  createEncoder,
42
43
  resourceTrackerManager
43
44
  ) {
45
+ var excludeDocumentQuery = initialViewOptions?.excludeHashRouteOuterQuery && location.hash.indexOf('#/') === 0
44
46
  var cleanupTasks = []
45
47
  var lifeCycle = new LifeCycle()
46
48
  var telemetry = startRumTelemetry(configuration)
@@ -143,7 +145,8 @@ export function startRum(
143
145
  pageStateHistory,
144
146
  undefined,
145
147
  undefined,
146
- resourceTrackerManager
148
+ resourceTrackerManager,
149
+ excludeDocumentQuery
147
150
  )
148
151
  var addResource = _startResourceCollection.addResource
149
152
  cleanupTasks.push(_startResourceCollection.stop)
@@ -154,20 +157,11 @@ export function startRum(
154
157
  )
155
158
  cleanupTasks.unshift(webSocketCollection.stop)
156
159
  }
157
- if (
158
- PerformanceObserver.supportedEntryTypes &&
159
- PerformanceObserver.supportedEntryTypes.includes(
160
- RumPerformanceEntryType.LONG_ANIMATION_FRAME
161
- )
162
- ) {
163
- var longAnimationFrameCollection = startLongAnimationFrameCollection(
164
- lifeCycle,
165
- configuration
166
- )
167
- cleanupTasks.push(longAnimationFrameCollection.stop)
168
- } else {
169
- startLongTaskCollection(lifeCycle, configuration)
170
- }
160
+ var startTaskCollection = configuration.enableLongAnimationFrame &&
161
+ supportPerformanceTimingEvent(RumPerformanceEntryType.LONG_ANIMATION_FRAME)
162
+ ? startLongAnimationFrameCollection
163
+ : startLongTaskCollection
164
+ cleanupTasks.push(startTaskCollection(lifeCycle, configuration).stop)
171
165
 
172
166
  var _startErrorCollection = startErrorCollection(
173
167
  lifeCycle,
@@ -176,7 +170,7 @@ export function startRum(
176
170
  pageStateHistory
177
171
  )
178
172
  var addError = _startErrorCollection.addError
179
- startRequestCollection(lifeCycle, configuration, session)
173
+ cleanupTasks.push(startRequestCollection(lifeCycle, configuration, session).stop)
180
174
 
181
175
  var internalContext = startInternalContext(
182
176
  configuration.applicationId,
@@ -197,7 +191,7 @@ export function startRum(
197
191
  getViewContext,
198
192
  setViewName,
199
193
  lifeCycle: lifeCycle,
200
- viewContexts: viewContexts,
194
+ viewContexts: assign({}, viewContexts, { $rGetDocumentUrl: urlContexts.$rGetDocumentUrl }),
201
195
  session: session,
202
196
  setForcedSession: function () {
203
197
  session.setForcedSession({ refreshView: true })
@@ -18,7 +18,6 @@ import {
18
18
  sanitize,
19
19
  createCustomerDataTrackerManager,
20
20
  CustomerDataCompressionStatus,
21
- displayAlreadyInitializedError,
22
21
  getType,
23
22
  noop
24
23
  } from '@cloudcare/browser-core'
@@ -98,12 +97,13 @@ export function makeRumPublicApi(startRumImpl, recorderApi, options) {
98
97
  strategy = createPreStartStrategy(
99
98
  assign({}, options, {
100
99
  resourceTrackerManager: resourceTrackerManager,
101
- onInit: function (initConfiguration, publicApi) {
100
+ onInit: function (initConfiguration, publicApi, onConfigurationReady) {
102
101
  callPluginsMethod(initConfiguration.plugins, 'onInit', {
103
102
  addError: addPluginError,
104
103
  publicApi: publicApi,
105
104
  rum: publicApi,
106
- initConfiguration: initConfiguration
105
+ initConfiguration: initConfiguration,
106
+ onConfigurationReady: onConfigurationReady
107
107
  })
108
108
  },
109
109
  onConfigurationReady: function (configuration) {
@@ -252,7 +252,7 @@ export function makeRumPublicApi(startRumImpl, recorderApi, options) {
252
252
  }),
253
253
 
254
254
  getInitConfiguration: monitor(function () {
255
- return deepClone(strategy.initConfiguration)
255
+ return deepClone(strategy.getInitConfiguration())
256
256
  }),
257
257
  getRemoteConfiguration: monitor(function (callback) {
258
258
  return strategy.getRemoteConfiguration(callback)
@@ -389,10 +389,8 @@ export function makeRumPublicApi(startRumImpl, recorderApi, options) {
389
389
  function createPostStartStrategy(preStartStrategy, startRumResult) {
390
390
  return assign(
391
391
  {
392
- init: function (initConfiguration) {
393
- displayAlreadyInitializedError('DATAFLUX_RUM', initConfiguration)
394
- },
395
- initConfiguration: preStartStrategy.getInitConfiguration(),
392
+ init: preStartStrategy.init,
393
+ getInitConfiguration: preStartStrategy.getInitConfiguration,
396
394
  getRemoteConfiguration: function (callback) {
397
395
  preStartStrategy.getRemoteConfiguration(callback)
398
396
  }
@@ -288,6 +288,7 @@ export function startRecording(
288
288
  emit: wrappedEmit,
289
289
  $rEmitBaseline: wrappedEmitBaseline,
290
290
  configuration: configuration,
291
+ $rGetDocumentUrl: viewContexts.$rGetDocumentUrl,
291
292
  lifeCycle: lifeCycle,
292
293
  sessionManager: sessionManager,
293
294
  $rWasLastEmitBackpressured: wasLastEmitBackpressured,
@@ -306,6 +307,7 @@ export function startRecording(
306
307
  _record = recordImpl({
307
308
  emit: addRecord,
308
309
  configuration: configuration,
310
+ $rGetDocumentUrl: viewContexts.$rGetDocumentUrl,
309
311
  lifeCycle: lifeCycle,
310
312
  sessionManager: sessionManager,
311
313
  $rWasLastEmitBackpressured: wasLastEmitBackpressured,