@cloudcare/browser-core 3.2.51 → 3.3.4

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 (57) hide show
  1. package/cjs/browser/asyncClocks.js +2 -2
  2. package/cjs/browser/asyncClocks.js.map +1 -1
  3. package/cjs/configuration/remoteConfiguration.js +1 -0
  4. package/cjs/configuration/remoteConfiguration.js.map +1 -1
  5. package/cjs/helper/deviceInfo.js +91 -44
  6. package/cjs/helper/deviceInfo.js.map +1 -1
  7. package/cjs/helper/polyfills.js +1 -1
  8. package/cjs/helper/polyfills.js.map +1 -1
  9. package/cjs/helper/tools.js +4 -4
  10. package/cjs/helper/tools.js.map +1 -1
  11. package/cjs/helper/valueHistory.js +1 -1
  12. package/cjs/helper/valueHistory.js.map +1 -1
  13. package/cjs/report/reportObservable.js +2 -2
  14. package/cjs/report/reportObservable.js.map +1 -1
  15. package/cjs/session/sessionManagement.js +1 -0
  16. package/cjs/session/sessionManagement.js.map +1 -1
  17. package/cjs/session/sessionStore.js +1 -1
  18. package/cjs/session/sessionStore.js.map +1 -1
  19. package/cjs/synthetics/syntheticsWorkerValues.js +2 -2
  20. package/cjs/synthetics/syntheticsWorkerValues.js.map +1 -1
  21. package/cjs/transport/httpRequest.js +6 -40
  22. package/cjs/transport/httpRequest.js.map +1 -1
  23. package/esm/browser/asyncClocks.js +2 -2
  24. package/esm/browser/asyncClocks.js.map +1 -1
  25. package/esm/configuration/remoteConfiguration.js +1 -0
  26. package/esm/configuration/remoteConfiguration.js.map +1 -1
  27. package/esm/helper/deviceInfo.js +90 -44
  28. package/esm/helper/deviceInfo.js.map +1 -1
  29. package/esm/helper/polyfills.js +1 -1
  30. package/esm/helper/polyfills.js.map +1 -1
  31. package/esm/helper/tools.js +4 -4
  32. package/esm/helper/tools.js.map +1 -1
  33. package/esm/helper/valueHistory.js +1 -1
  34. package/esm/helper/valueHistory.js.map +1 -1
  35. package/esm/report/reportObservable.js +2 -0
  36. package/esm/report/reportObservable.js.map +1 -1
  37. package/esm/session/sessionManagement.js +1 -0
  38. package/esm/session/sessionManagement.js.map +1 -1
  39. package/esm/session/sessionStore.js +1 -1
  40. package/esm/session/sessionStore.js.map +1 -1
  41. package/esm/synthetics/syntheticsWorkerValues.js +2 -2
  42. package/esm/synthetics/syntheticsWorkerValues.js.map +1 -1
  43. package/esm/transport/httpRequest.js +5 -39
  44. package/esm/transport/httpRequest.js.map +1 -1
  45. package/package.json +2 -2
  46. package/src/browser/asyncClocks.js +2 -2
  47. package/src/configuration/remoteConfiguration.js +1 -0
  48. package/src/helper/deviceInfo.js +105 -53
  49. package/src/helper/polyfills.js +1 -1
  50. package/src/helper/tools.js +4 -4
  51. package/src/helper/valueHistory.js +1 -1
  52. package/src/report/reportObservable.js +2 -0
  53. package/src/session/sessionManagement.js +1 -0
  54. package/src/session/sessionStore.js +4 -1
  55. package/src/synthetics/syntheticsWorkerValues.js +6 -4
  56. package/src/transport/httpRequest.js +5 -44
  57. package/types/index.d.ts +74 -0
@@ -764,9 +764,9 @@ export var sessionStorage = {
764
764
  var key = '__sensorsdatasupport__'
765
765
  var val = 'testIsSupportStorage'
766
766
  try {
767
- if (sessionStorage && sessionStorage.setItem) {
768
- sessionStorage.setItem(key, val)
769
- sessionStorage.removeItem(key, val)
767
+ if (window.sessionStorage && window.sessionStorage.setItem) {
768
+ window.sessionStorage.setItem(key, val)
769
+ window.sessionStorage.removeItem(key, val)
770
770
  supported = true
771
771
  } else {
772
772
  supported = false
@@ -958,7 +958,7 @@ export var getHostname = function (url, defaultValue) {
958
958
  }
959
959
  var hostname = null
960
960
  try {
961
- hostname = URL(url).hostname
961
+ hostname = new URL(url).hostname
962
962
  } catch (e) {}
963
963
  return hostname || defaultValue
964
964
  }
@@ -20,7 +20,7 @@ export function createValueHistory(params) {
20
20
  var maxEntries = params.maxEntries
21
21
 
22
22
  var entries = []
23
- if (cleanupHistoriesInterval) {
23
+ if (cleanupHistoriesInterval === null) {
24
24
  cleanupHistoriesInterval = setInterval(function () {
25
25
  return clearExpiredValues()
26
26
  }, CLEAR_OLD_VALUES_INTERVAL)
@@ -11,6 +11,8 @@ import {
11
11
  import { addEventListener } from '../browser/addEventListener'
12
12
  import { DOM_EVENT } from '../helper/enums'
13
13
  import { monitor } from '../helper/monitor'
14
+ import { ErrorSource } from '../helper/errorTools'
15
+ import { ErrorHandling } from '../helper/enums'
14
16
  export var RawReportType = {
15
17
  intervention: 'intervention',
16
18
  deprecation: 'deprecation',
@@ -83,6 +83,7 @@ export function startSessionManager(
83
83
  findSession: function (startTime, options) {
84
84
  return sessionContextHistory.find(startTime, options)
85
85
  },
86
+ expandOrRenewSession: sessionStore.expandOrRenewSession,
86
87
  renewObservable,
87
88
  expireObservable,
88
89
  sessionStateUpdateObservable: sessionStore.sessionStateUpdateObservable,
@@ -160,7 +160,10 @@ export function startSessionStore(
160
160
  processSessionStoreOperations(
161
161
  {
162
162
  process: function (sessionState) {
163
- if (isSessionInNotStartedState(sessionState)) {
163
+ if (
164
+ isSessionInNotStartedState(sessionState) ||
165
+ isSessionInExpiredState(sessionState)
166
+ ) {
164
167
  return getExpiredSessionState()
165
168
  }
166
169
  },
@@ -13,14 +13,16 @@ export function willSyntheticsInjectRum() {
13
13
 
14
14
  export function getSyntheticsTestId() {
15
15
  var value =
16
- window._GUANCE_SYNTHETICS_PUBLIC_ID ||
17
- getCookie(SYNTHETICS_TEST_ID_COOKIE_NAME)
16
+ typeof window._GUANCE_SYNTHETICS_PUBLIC_ID === 'string'
17
+ ? window._GUANCE_SYNTHETICS_PUBLIC_ID
18
+ : getCookie(SYNTHETICS_TEST_ID_COOKIE_NAME)
18
19
  return typeof value === 'string' ? value : undefined
19
20
  }
20
21
 
21
22
  export function getSyntheticsResultId() {
22
23
  var value =
23
- window._GUANCE_SYNTHETICS_RESULT_ID ||
24
- getCookie(SYNTHETICS_RESULT_ID_COOKIE_NAME)
24
+ typeof window._GUANCE_SYNTHETICS_RESULT_ID === 'string'
25
+ ? window._GUANCE_SYNTHETICS_RESULT_ID
26
+ : getCookie(SYNTHETICS_RESULT_ID_COOKIE_NAME)
25
27
  return typeof value === 'string' ? value : undefined
26
28
  }
@@ -29,7 +29,7 @@ export function createHttpRequest(
29
29
  }
30
30
  var retryState = newRetryState(retryMaxSize)
31
31
  var sendStrategyForRetry = function (payload, onResponse) {
32
- return fetchKeepAliveStrategy(endpointUrl, bytesLimit, payload, onResponse)
32
+ return fetchStrategyWithFallback(endpointUrl, payload, onResponse)
33
33
  }
34
34
 
35
35
  return {
@@ -87,57 +87,19 @@ function reportBeaconError(e) {
87
87
  addTelemetryError(e)
88
88
  }
89
89
  }
90
- export function fetchKeepAliveStrategy(
90
+ export function fetchStrategyWithFallback(
91
91
  endpointUrl,
92
- bytesLimit,
93
92
  payload,
94
93
  onResponse
95
94
  ) {
96
- var data = payload.data
97
- var bytesCount = payload.bytesCount
98
95
  var url = addBatchPrecision(endpointUrl, payload.encoding)
99
- var canUseKeepAlive = isKeepAliveSupported() && bytesCount < bytesLimit
100
- if (canUseKeepAlive) {
101
- var fetchOption = {
102
- method: 'POST',
103
- body: data,
104
- keepalive: true,
105
- mode: 'cors'
106
- }
107
- const headers = {
108
- 'x-client-timestamp': Date.now().toString()
109
- }
110
- if (payload.type) {
111
- headers['Content-Type'] = payload.type
112
- }
113
- fetchOption.headers = headers
114
- fetch(url, fetchOption)
115
- .then(
116
- monitor(function (response) {
117
- if (typeof onResponse === 'function') {
118
- onResponse({ status: response.status, type: response.type })
119
- }
120
- })
121
- )
122
- .catch(
123
- monitor(function () {
124
- fetchStrategy(url, payload, onResponse)
125
- })
126
- )
96
+ if (typeof fetch === 'function') {
97
+ sendFetch(url, payload, onResponse)
127
98
  } else {
128
99
  sendXHR(url, payload, onResponse)
129
100
  }
130
101
  }
131
102
 
132
- function isKeepAliveSupported() {
133
- // Request can throw, cf https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#errors
134
- try {
135
- return window.Request && 'keepalive' in new Request('http://a')
136
- } catch {
137
- return false
138
- }
139
- }
140
-
141
103
  function sendXHR(url, payload, onResponse) {
142
104
  const data = payload.data
143
105
  const request = new XMLHttpRequest()
@@ -162,11 +124,10 @@ function sendXHR(url, payload, onResponse) {
162
124
  )
163
125
  request.send(data)
164
126
  }
165
- function fetchStrategy(url, payload, onResponse) {
127
+ function sendFetch(url, payload, onResponse) {
166
128
  const fetchOption = {
167
129
  method: 'POST',
168
130
  body: payload.data,
169
- keepalive: true,
170
131
  mode: 'cors'
171
132
  }
172
133
  const headers = {
package/types/index.d.ts CHANGED
@@ -199,6 +199,12 @@ export interface RumBaseInitConfiguration extends InitConfiguration {
199
199
  * sessionReplay and compressIntakeRequests data compression are both done in the web worker thread, so by default, you need to allow worker-src blob: under CSP security access, or use workerUrl to host the worker address yourself
200
200
  */
201
201
  workerUrl?: string
202
+ /**
203
+ * Canvas snapshot encoding is done in a dedicated canvas worker thread. By
204
+ * default it uses an inlined blob worker, or you can host a separate
205
+ * canvas-worker bundle yourself for stricter CSP/security environments.
206
+ */
207
+ replayCanvasWorkerUrl?: string
202
208
  /**
203
209
  * Compress RUM data request content to reduce bandwidth usage when sending large amounts of data. Compression is done in the Worker thread.
204
210
  */
@@ -241,6 +247,74 @@ export interface RumBaseInitConfiguration extends InitConfiguration {
241
247
  * @returns true means mask the node, false means do not mask and continue privacyLevel logic
242
248
  */
243
249
  shouldMaskNode?: (node: Node, privacyLevel: NodePrivacyLevel) => boolean
250
+ /**
251
+ * Whether to enable canvas recording for session replay.
252
+ */
253
+ replayCanvasEnabled?: boolean | undefined
254
+ /**
255
+ * Canvas replay recording mode. Defaults to `auto`.
256
+ * `manual` records only when `snapshotCanvas()` is called.
257
+ * `auto` performs automatic canvas recording.
258
+ */
259
+ replayCanvasMode?: 'manual' | 'auto' | undefined
260
+ /**
261
+ * Canvas replay sampling strategy. A number means snapshot sampling at the configured rate.
262
+ * `'all'` enables 2D command capture, with automatic snapshot fallback for
263
+ * unsupported replay-fidelity cases. Defaults to a numeric sampling mode.
264
+ */
265
+ replayCanvasSampling?: 'all' | number | undefined
266
+ /**
267
+ * Encoded image mime type used for canvas snapshots.
268
+ */
269
+ replayCanvasMimeType?: string | undefined
270
+ /**
271
+ * Encoded image quality for canvas snapshots. Supports `low`, `medium`, `high`,
272
+ * or a number from 0 to 1 for advanced overrides.
273
+ */
274
+ replayCanvasQuality?: 'low' | 'medium' | 'high' | number | undefined
275
+ /**
276
+ * Maximum canvas edge size before downscaling for encoding.
277
+ */
278
+ replayCanvasMaxCanvasSize?: number | undefined
279
+ /**
280
+ * Maximum encoded bytes allowed for a single canvas snapshot.
281
+ */
282
+ replayCanvasMaxEncodedBytes?: number | undefined
283
+ /**
284
+ * Maximum number of concurrent canvas encoding tasks.
285
+ */
286
+ replayCanvasMaxConcurrentEncodes?: number | undefined
287
+ /**
288
+ * Whether canvas mutations should be flushed into a replay segment immediately.
289
+ */
290
+ replayCanvasFlushImmediately?: boolean | undefined
291
+ /**
292
+ * Auto snapshot interval in milliseconds when `replayCanvasMode` is `auto`.
293
+ */
294
+ replayCanvasAutoInterval?: number | undefined
295
+ /**
296
+ * Minimum cooldown in milliseconds after a successful auto snapshot.
297
+ */
298
+ replayCanvasAutoCooldown?: number | undefined
299
+ /**
300
+ * Backoff in milliseconds after an auto snapshot is skipped as unchanged.
301
+ */
302
+ replayCanvasAutoUnchangedBackoff?: number | undefined
303
+ /**
304
+ * Backoff in milliseconds after an auto snapshot fails.
305
+ */
306
+ replayCanvasAutoFailureBackoff?: number | undefined
307
+ /**
308
+ * Maximum number of canvases processed in a single auto snapshot run.
309
+ */
310
+ replayCanvasAutoMaxPerRun?: number | undefined
311
+ /**
312
+ * Controls whether a canvas should be recorded. Returning `false` skips the canvas.
313
+ * Returning a number assigns auto mode priority, where higher values are processed first.
314
+ */
315
+ shouldRecordCanvas?:
316
+ | ((canvas: HTMLCanvasElement) => boolean | number | undefined)
317
+ | undefined
244
318
  }
245
319
  export type RumInitConfiguration = RumBaseInitConfiguration &
246
320
  DatakitInitConfiguration