@cloudcare/browser-rum 3.3.4 → 3.3.6

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 (79) hide show
  1. package/bundle/dataflux-rum.js +1 -1
  2. package/cjs/boot/buildEnv.js +1 -1
  3. package/cjs/boot/perStartRum.js +42 -6
  4. package/cjs/boot/perStartRum.js.map +1 -1
  5. package/cjs/boot/recorderApi.js +35 -10
  6. package/cjs/boot/recorderApi.js.map +1 -1
  7. package/cjs/boot/rum.js +8 -0
  8. package/cjs/boot/rum.js.map +1 -1
  9. package/cjs/boot/rumPublicApi.js +36 -3
  10. package/cjs/boot/rumPublicApi.js.map +1 -1
  11. package/cjs/domain/configuration.js +7 -0
  12. package/cjs/domain/configuration.js.map +1 -1
  13. package/cjs/domain/contexts/urlContexts.js +11 -2
  14. package/cjs/domain/contexts/urlContexts.js.map +1 -1
  15. package/cjs/domain/contexts/viewContexts.js +2 -2
  16. package/cjs/domain/contexts/viewContexts.js.map +1 -1
  17. package/cjs/domain/deflate/deflateWorker.js +1 -1
  18. package/cjs/domain/plugins.js +67 -0
  19. package/cjs/domain/plugins.js.map +1 -0
  20. package/cjs/domain/replay/record/canvasEncodeWorker.js +1 -1
  21. package/cjs/domain/rumEventsCollection/error/errorCollection.js +17 -5
  22. package/cjs/domain/rumEventsCollection/error/errorCollection.js.map +1 -1
  23. package/cjs/domain/rumEventsCollection/resource/resourceCollection.js +56 -0
  24. package/cjs/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
  25. package/cjs/domain/rumEventsCollection/resource/webSocketCollection.js +196 -0
  26. package/cjs/domain/rumEventsCollection/resource/webSocketCollection.js.map +1 -0
  27. package/cjs/domain/rumEventsCollection/view/trackLoadingTime.js +8 -3
  28. package/cjs/domain/rumEventsCollection/view/trackLoadingTime.js.map +1 -1
  29. package/cjs/domain/rumEventsCollection/view/trackViews.js +2 -1
  30. package/cjs/domain/rumEventsCollection/view/trackViews.js.map +1 -1
  31. package/cjs/domain/rumSessionManager.js +23 -3
  32. package/cjs/domain/rumSessionManager.js.map +1 -1
  33. package/esm/boot/buildEnv.js +1 -1
  34. package/esm/boot/perStartRum.js +42 -6
  35. package/esm/boot/perStartRum.js.map +1 -1
  36. package/esm/boot/recorderApi.js +35 -10
  37. package/esm/boot/recorderApi.js.map +1 -1
  38. package/esm/boot/rum.js +8 -0
  39. package/esm/boot/rum.js.map +1 -1
  40. package/esm/boot/rumPublicApi.js +36 -3
  41. package/esm/boot/rumPublicApi.js.map +1 -1
  42. package/esm/domain/configuration.js +8 -1
  43. package/esm/domain/configuration.js.map +1 -1
  44. package/esm/domain/contexts/urlContexts.js +12 -3
  45. package/esm/domain/contexts/urlContexts.js.map +1 -1
  46. package/esm/domain/contexts/viewContexts.js +2 -2
  47. package/esm/domain/contexts/viewContexts.js.map +1 -1
  48. package/esm/domain/deflate/deflateWorker.js +1 -1
  49. package/esm/domain/plugins.js +59 -0
  50. package/esm/domain/plugins.js.map +1 -0
  51. package/esm/domain/replay/record/canvasEncodeWorker.js +1 -1
  52. package/esm/domain/rumEventsCollection/error/errorCollection.js +17 -5
  53. package/esm/domain/rumEventsCollection/error/errorCollection.js.map +1 -1
  54. package/esm/domain/rumEventsCollection/resource/resourceCollection.js +55 -0
  55. package/esm/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
  56. package/esm/domain/rumEventsCollection/resource/webSocketCollection.js +189 -0
  57. package/esm/domain/rumEventsCollection/resource/webSocketCollection.js.map +1 -0
  58. package/esm/domain/rumEventsCollection/view/trackLoadingTime.js +8 -3
  59. package/esm/domain/rumEventsCollection/view/trackLoadingTime.js.map +1 -1
  60. package/esm/domain/rumEventsCollection/view/trackViews.js +2 -1
  61. package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -1
  62. package/esm/domain/rumSessionManager.js +24 -4
  63. package/esm/domain/rumSessionManager.js.map +1 -1
  64. package/package.json +4 -4
  65. package/src/boot/perStartRum.js +47 -7
  66. package/src/boot/recorderApi.js +36 -12
  67. package/src/boot/rum.js +11 -0
  68. package/src/boot/rumPublicApi.js +38 -3
  69. package/src/domain/configuration.js +13 -1
  70. package/src/domain/contexts/urlContexts.js +17 -3
  71. package/src/domain/contexts/viewContexts.js +2 -2
  72. package/src/domain/plugins.js +94 -0
  73. package/src/domain/rumEventsCollection/error/errorCollection.js +22 -6
  74. package/src/domain/rumEventsCollection/resource/resourceCollection.js +70 -0
  75. package/src/domain/rumEventsCollection/resource/webSocketCollection.js +271 -0
  76. package/src/domain/rumEventsCollection/view/trackLoadingTime.js +12 -3
  77. package/src/domain/rumEventsCollection/view/trackViews.js +2 -1
  78. package/src/domain/rumSessionManager.js +33 -2
  79. package/types/index.d.ts +85 -6
@@ -178,7 +178,8 @@ function newView(
178
178
  name: name,
179
179
  startClocks: startClocks,
180
180
  service: service,
181
- version: version
181
+ version: version,
182
+ url: viewOptions && viewOptions.url
182
183
  }
183
184
  lifeCycle.notify(LifeCycleEventType.BEFORE_VIEW_CREATED, viewCreatedEvent)
184
185
  lifeCycle.notify(LifeCycleEventType.VIEW_CREATED, viewCreatedEvent)
@@ -7,7 +7,9 @@ import {
7
7
  timeStampNow,
8
8
  bridgeSupports,
9
9
  BridgeCapability,
10
- SESSION_NOT_TRACKED
10
+ SESSION_NOT_TRACKED,
11
+ display,
12
+ isPercentage
11
13
  } from '@cloudcare/browser-core'
12
14
 
13
15
  export var RUM_SESSION_KEY = 'rum'
@@ -60,6 +62,7 @@ export function startRumSessionManager(configuration, lifeCycle) {
60
62
  if (!previousState.forcedSession && newState.forcedSession) {
61
63
  const sessionEntity = sessionManager.findSession()
62
64
  if (sessionEntity) {
65
+ sessionEntity.id = newState.id
63
66
  sessionEntity.isSessionForced = true
64
67
  }
65
68
  }
@@ -116,12 +119,18 @@ export function startRumSessionManager(configuration, lifeCycle) {
116
119
  },
117
120
  expire: sessionManager.expire,
118
121
  keepSessionAlive: sessionManager.expandOrRenewSession,
122
+ startSession: function (options) {
123
+ if (!applyStartSessionOptions(configuration, options)) {
124
+ return
125
+ }
126
+ sessionManager.renewSession()
127
+ },
119
128
  expireObservable: sessionManager.expireObservable,
120
129
  sessionStateUpdateObservable: sessionManager.sessionStateUpdateObservable,
121
130
  setErrorForSession: () =>
122
131
  sessionManager.updateSessionState({ hasError: '1', ets: timeStampNow() }),
123
132
  setForcedSession: () => {
124
- sessionManager.updateSessionState({ forcedSession: '1' })
133
+ sessionManager.forceSession()
125
134
  }
126
135
  }
127
136
  }
@@ -148,6 +157,7 @@ export function startRumSessionManagerStub() {
148
157
  },
149
158
  expire: noop,
150
159
  keepSessionAlive: noop,
160
+ startSession: noop,
151
161
  expireObservable: new Observable(),
152
162
  setErrorForSession: function () {
153
163
  session.sessionErrorTimestamp = timeStampNow()
@@ -159,6 +169,27 @@ export function startRumSessionManagerStub() {
159
169
  }
160
170
  }
161
171
 
172
+ function applyStartSessionOptions(configuration, options) {
173
+ if (options === undefined) {
174
+ return true
175
+ }
176
+ if (
177
+ !options ||
178
+ typeof options !== 'object' ||
179
+ (options.sessionSampleRate !== undefined &&
180
+ !isPercentage(options.sessionSampleRate))
181
+ ) {
182
+ display.error(
183
+ 'startSession options should contain a sessionSampleRate between 0 and 100'
184
+ )
185
+ return false
186
+ }
187
+ if (options.sessionSampleRate !== undefined) {
188
+ configuration.sessionSampleRate = options.sessionSampleRate
189
+ }
190
+ return true
191
+ }
192
+
162
193
  function computeSessionState(configuration, rawTrackingType) {
163
194
  const {
164
195
  sessionSampleRate,
package/types/index.d.ts CHANGED
@@ -28,6 +28,22 @@ export interface InternalContext {
28
28
  }
29
29
  }
30
30
 
31
+ export interface StartSessionOptions {
32
+ /**
33
+ * Overrides the runtime RUM session sample rate for the new session and
34
+ * subsequent automatic session renewals.
35
+ */
36
+ sessionSampleRate?: number
37
+ }
38
+
39
+ export interface StartSessionReplayRecordingOptions {
40
+ /**
41
+ * Forces the current session to be tracked, assigns a session ID when
42
+ * necessary, and enables Session Replay recording.
43
+ */
44
+ force?: boolean
45
+ }
46
+
31
47
  export interface CanvasSnapshotResult {
32
48
  ok: boolean
33
49
  reason?: string
@@ -141,10 +157,71 @@ export interface ResourceTrackerSnapshot {
141
157
  rawRumEvent?: object | undefined
142
158
  }
143
159
 
144
- export declare const datafluxRum: {
145
- init: (
146
- initConfiguration: RumInitConfiguration | RumSiteInitConfiguration
160
+ export interface ViewOptions {
161
+ name?: string | undefined
162
+ service?: string | undefined
163
+ version?: string | undefined
164
+ url?: string | undefined
165
+ context?: Context | undefined
166
+ }
167
+
168
+ export interface RumPluginApi {
169
+ startView: (options?: string | ViewOptions) => void
170
+ setViewName: (name: string) => void
171
+ setViewContext: (context: Context) => void
172
+ setViewContextProperty: (key: string, value: any) => void
173
+ addAction: (name: string, context?: object | undefined) => void
174
+ addTypeAction: (
175
+ name: string,
176
+ type?: string,
177
+ context?: object | undefined
147
178
  ) => void
179
+ addError: (error: unknown, context?: object | undefined) => void
180
+ getInternalContext: (
181
+ startTime?: number | undefined
182
+ ) => InternalContext | undefined
183
+ }
184
+
185
+ export interface RumPluginContext {
186
+ addError: (error: RumPluginError) => void
187
+ publicApi: RumPluginApi
188
+ rum: RumPluginApi
189
+ initConfiguration: RumPluginInitConfiguration
190
+ }
191
+
192
+ export interface RumPluginStartContext {
193
+ addError: (error: RumPluginError) => void
194
+ publicApi: RumPluginApi
195
+ rum: RumPluginApi
196
+ }
197
+
198
+ export interface RumPluginError {
199
+ error: unknown
200
+ handlingStack?: string | undefined
201
+ context?: Context | undefined
202
+ startClocks: {
203
+ relative: number
204
+ timeStamp: number
205
+ }
206
+ }
207
+
208
+ export interface RumPlugin {
209
+ name: string
210
+ onInit?: (context: RumPluginContext) => void
211
+ onRumStart?: (context: RumPluginStartContext) => void
212
+ getConfigurationTelemetry?: () => Record<string, unknown>
213
+ }
214
+
215
+ export type RumPluginInitConfiguration = (
216
+ | RumInitConfiguration
217
+ | RumSiteInitConfiguration
218
+ ) & {
219
+ plugins?: RumPlugin[] | undefined
220
+ }
221
+
222
+ export declare const datafluxRum: {
223
+ init: (initConfiguration: RumPluginInitConfiguration) => void
224
+ startView: (options?: string | ViewOptions) => void
148
225
  setViewName: (name: string) => void
149
226
  setViewContext: (context: Context) => void
150
227
  setViewContextProperty: (key: string, value: any) => void
@@ -160,8 +237,7 @@ export declare const datafluxRum: {
160
237
  startTime?: number | undefined
161
238
  ) => InternalContext | undefined
162
239
  getInitConfiguration: () =>
163
- | RumInitConfiguration
164
- | RumSiteInitConfiguration
240
+ | RumPluginInitConfiguration
165
241
  | undefined
166
242
  getRemoteConfiguration: (
167
243
  callback: (remoteConfiguration: object) => void
@@ -181,8 +257,11 @@ export declare const datafluxRum: {
181
257
  removeUserProperty: (key: any) => void
182
258
  clearUser: () => void
183
259
  stopSession: () => void
260
+ startSession: (options?: StartSessionOptions) => void
184
261
  setForcedSession: () => void
185
- startSessionReplayRecording: (options?: { force?: boolean }) => void
262
+ startSessionReplayRecording: (
263
+ options?: StartSessionReplayRecordingOptions
264
+ ) => void
186
265
  isRecording: () => boolean
187
266
  stopSessionReplayRecording: () => void
188
267
  takeSubsequentFullSnapshot: () => void