@multiplayer-app/session-recorder-react-native 1.0.1-beta.4 → 1.0.1-beta.5

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 (165) hide show
  1. package/android/src/main/java/com/multiplayer/sessionrecordernative/SessionRecorderNativeModule.kt +2 -2
  2. package/lib/module/components/SessionRecorderWidget/ErrorBanner.js.map +1 -1
  3. package/lib/module/components/SessionRecorderWidget/ModalHeader.js.map +1 -1
  4. package/lib/module/components/SessionRecorderWidget/SessionRecorderWidget.js.map +1 -1
  5. package/lib/module/components/SessionRecorderWidget/icons.js.map +1 -1
  6. package/lib/module/components/SessionRecorderWidget/styles.js.map +1 -1
  7. package/lib/module/config/constants.js.map +1 -1
  8. package/lib/module/config/defaults.js.map +1 -1
  9. package/lib/module/config/masking.js.map +1 -1
  10. package/lib/module/config/session-recorder.js.map +1 -1
  11. package/lib/module/config/validators.js.map +1 -1
  12. package/lib/module/config/widget.js.map +1 -1
  13. package/lib/module/context/SessionRecorderStore.js.map +1 -1
  14. package/lib/module/context/useSessionRecorderStore.js.map +1 -1
  15. package/lib/module/context/useStoreSelector.js.map +1 -1
  16. package/lib/module/native/SessionRecorderNative.js.map +1 -1
  17. package/lib/module/native/index.js.map +1 -1
  18. package/lib/module/otel/helpers.js +1 -1
  19. package/lib/module/otel/helpers.js.map +1 -1
  20. package/lib/module/otel/index.js.map +1 -1
  21. package/lib/module/otel/instrumentations/index.js.map +1 -1
  22. package/lib/module/patch/xhr.js.map +1 -1
  23. package/lib/module/recorder/eventExporter.js.map +1 -1
  24. package/lib/module/recorder/gestureRecorder.js.map +1 -1
  25. package/lib/module/recorder/index.js.map +1 -1
  26. package/lib/module/recorder/navigationTracker.js.map +1 -1
  27. package/lib/module/recorder/screenRecorder.js.map +1 -1
  28. package/lib/module/services/api.service.js.map +1 -1
  29. package/lib/module/services/network.service.js.map +1 -1
  30. package/lib/module/services/screenMaskingService.js.map +1 -1
  31. package/lib/module/services/storage.service.js.map +1 -1
  32. package/lib/module/session-recorder.js.map +1 -1
  33. package/lib/module/types/index.js.map +1 -1
  34. package/lib/module/types/session-recorder.js.map +1 -1
  35. package/lib/module/utils/app-metadata.js +2 -2
  36. package/lib/module/utils/constants.optional.js.map +1 -1
  37. package/lib/module/utils/createStore.js.map +1 -1
  38. package/lib/module/utils/logger.js +0 -8
  39. package/lib/module/utils/logger.js.map +1 -1
  40. package/lib/module/utils/platform.js +1 -1
  41. package/lib/module/utils/platform.js.map +1 -1
  42. package/lib/module/utils/rrweb-events.js.map +1 -1
  43. package/lib/module/utils/session.js.map +1 -1
  44. package/lib/module/utils/shallowEqual.js.map +1 -1
  45. package/lib/module/utils/time.js.map +1 -1
  46. package/lib/module/version.js +1 -1
  47. package/lib/typescript/src/components/ScreenRecorderView/index.d.ts +1 -1
  48. package/lib/typescript/src/components/SessionRecorderWidget/ErrorBanner.d.ts.map +1 -1
  49. package/lib/typescript/src/components/SessionRecorderWidget/ModalHeader.d.ts.map +1 -1
  50. package/lib/typescript/src/components/SessionRecorderWidget/SessionRecorderWidget.d.ts.map +1 -1
  51. package/lib/typescript/src/components/SessionRecorderWidget/icons.d.ts.map +1 -1
  52. package/lib/typescript/src/components/SessionRecorderWidget/index.d.ts +1 -1
  53. package/lib/typescript/src/components/SessionRecorderWidget/styles.d.ts.map +1 -1
  54. package/lib/typescript/src/components/index.d.ts.map +1 -1
  55. package/lib/typescript/src/config/constants.d.ts.map +1 -1
  56. package/lib/typescript/src/config/defaults.d.ts.map +1 -1
  57. package/lib/typescript/src/config/index.d.ts.map +1 -1
  58. package/lib/typescript/src/config/masking.d.ts.map +1 -1
  59. package/lib/typescript/src/config/session-recorder.d.ts.map +1 -1
  60. package/lib/typescript/src/config/validators.d.ts.map +1 -1
  61. package/lib/typescript/src/config/widget.d.ts +1 -1
  62. package/lib/typescript/src/config/widget.d.ts.map +1 -1
  63. package/lib/typescript/src/context/SessionRecorderStore.d.ts.map +1 -1
  64. package/lib/typescript/src/context/useSessionRecorderStore.d.ts +3 -3
  65. package/lib/typescript/src/context/useSessionRecorderStore.d.ts.map +1 -1
  66. package/lib/typescript/src/context/useStoreSelector.d.ts.map +1 -1
  67. package/lib/typescript/src/index.d.ts.map +1 -1
  68. package/lib/typescript/src/native/SessionRecorderNative.d.ts.map +1 -1
  69. package/lib/typescript/src/native/index.d.ts +1 -1
  70. package/lib/typescript/src/native/index.d.ts.map +1 -1
  71. package/lib/typescript/src/otel/helpers.d.ts.map +1 -1
  72. package/lib/typescript/src/otel/index.d.ts.map +1 -1
  73. package/lib/typescript/src/otel/instrumentations/index.d.ts.map +1 -1
  74. package/lib/typescript/src/patch/index.d.ts.map +1 -1
  75. package/lib/typescript/src/patch/xhr.d.ts.map +1 -1
  76. package/lib/typescript/src/recorder/eventExporter.d.ts.map +1 -1
  77. package/lib/typescript/src/recorder/gestureRecorder.d.ts.map +1 -1
  78. package/lib/typescript/src/recorder/index.d.ts.map +1 -1
  79. package/lib/typescript/src/recorder/navigationTracker.d.ts.map +1 -1
  80. package/lib/typescript/src/recorder/screenRecorder.d.ts.map +1 -1
  81. package/lib/typescript/src/services/api.service.d.ts.map +1 -1
  82. package/lib/typescript/src/services/network.service.d.ts.map +1 -1
  83. package/lib/typescript/src/services/screenMaskingService.d.ts.map +1 -1
  84. package/lib/typescript/src/services/storage.service.d.ts.map +1 -1
  85. package/lib/typescript/src/session-recorder.d.ts.map +1 -1
  86. package/lib/typescript/src/types/configs.d.ts.map +1 -1
  87. package/lib/typescript/src/types/index.d.ts.map +1 -1
  88. package/lib/typescript/src/types/session-recorder.d.ts +4 -4
  89. package/lib/typescript/src/types/session-recorder.d.ts.map +1 -1
  90. package/lib/typescript/src/types/session.d.ts.map +1 -1
  91. package/lib/typescript/src/utils/app-metadata.d.ts.map +1 -1
  92. package/lib/typescript/src/utils/constants.optional.d.ts.map +1 -1
  93. package/lib/typescript/src/utils/constants.optional.expo.d.ts.map +1 -1
  94. package/lib/typescript/src/utils/createStore.d.ts.map +1 -1
  95. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  96. package/lib/typescript/src/utils/logger.d.ts +1 -1
  97. package/lib/typescript/src/utils/logger.d.ts.map +1 -1
  98. package/lib/typescript/src/utils/platform.d.ts.map +1 -1
  99. package/lib/typescript/src/utils/request-utils.d.ts.map +1 -1
  100. package/lib/typescript/src/utils/rrweb-events.d.ts.map +1 -1
  101. package/lib/typescript/src/utils/session.d.ts.map +1 -1
  102. package/lib/typescript/src/utils/shallowEqual.d.ts.map +1 -1
  103. package/lib/typescript/src/utils/time.d.ts.map +1 -1
  104. package/lib/typescript/src/utils/type-utils.d.ts.map +1 -1
  105. package/lib/typescript/src/version.d.ts.map +1 -1
  106. package/package.json +1 -1
  107. package/src/components/ScreenRecorderView/index.ts +1 -1
  108. package/src/components/SessionRecorderWidget/ErrorBanner.tsx +14 -14
  109. package/src/components/SessionRecorderWidget/ModalHeader.tsx +11 -9
  110. package/src/components/SessionRecorderWidget/SessionRecorderWidget.tsx +70 -56
  111. package/src/components/SessionRecorderWidget/icons.tsx +58 -30
  112. package/src/components/SessionRecorderWidget/index.ts +1 -1
  113. package/src/components/SessionRecorderWidget/styles.ts +17 -18
  114. package/src/components/index.ts +2 -2
  115. package/src/config/constants.ts +19 -20
  116. package/src/config/defaults.ts +35 -31
  117. package/src/config/index.ts +5 -5
  118. package/src/config/masking.ts +44 -18
  119. package/src/config/session-recorder.ts +54 -26
  120. package/src/config/validators.ts +43 -20
  121. package/src/config/widget.ts +24 -15
  122. package/src/context/SessionRecorderStore.ts +19 -18
  123. package/src/context/useSessionRecorderStore.ts +17 -10
  124. package/src/context/useStoreSelector.ts +20 -18
  125. package/src/index.ts +7 -7
  126. package/src/native/SessionRecorderNative.ts +83 -67
  127. package/src/native/index.ts +5 -1
  128. package/src/otel/helpers.ts +109 -93
  129. package/src/otel/index.ts +46 -49
  130. package/src/otel/instrumentations/index.ts +44 -41
  131. package/src/patch/index.ts +1 -1
  132. package/src/patch/xhr.ts +77 -78
  133. package/src/recorder/eventExporter.ts +63 -68
  134. package/src/recorder/gestureRecorder.ts +359 -212
  135. package/src/recorder/index.ts +75 -62
  136. package/src/recorder/navigationTracker.ts +120 -97
  137. package/src/recorder/screenRecorder.ts +214 -163
  138. package/src/services/api.service.ts +49 -48
  139. package/src/services/network.service.ts +67 -58
  140. package/src/services/screenMaskingService.ts +81 -50
  141. package/src/services/storage.service.ts +99 -70
  142. package/src/session-recorder.ts +270 -214
  143. package/src/types/configs.ts +53 -31
  144. package/src/types/expo-constants.d.ts +2 -2
  145. package/src/types/index.ts +16 -18
  146. package/src/types/session-recorder.ts +106 -111
  147. package/src/types/session.ts +45 -45
  148. package/src/utils/app-metadata.ts +9 -9
  149. package/src/utils/constants.optional.expo.ts +3 -3
  150. package/src/utils/constants.optional.ts +14 -12
  151. package/src/utils/createStore.ts +23 -20
  152. package/src/utils/index.ts +7 -7
  153. package/src/utils/logger.ts +87 -58
  154. package/src/utils/platform.ts +149 -118
  155. package/src/utils/request-utils.ts +15 -15
  156. package/src/utils/rrweb-events.ts +47 -34
  157. package/src/utils/session.ts +15 -12
  158. package/src/utils/shallowEqual.ts +16 -10
  159. package/src/utils/time.ts +7 -4
  160. package/src/utils/type-utils.ts +36 -36
  161. package/src/version.ts +1 -1
  162. package/android/src/main/java/com/multiplayer/sessionrecordernative/SessionRecorderNativeModuleSpec.kt +0 -51
  163. package/android/src/main/java/com/xxx/XxxModule.kt +0 -23
  164. package/ios/Xxx.h +0 -5
  165. package/ios/Xxx.mm +0 -21
@@ -1,7 +1,7 @@
1
- import io, { Socket } from 'socket.io-client'
1
+ import io, { Socket } from 'socket.io-client';
2
2
 
3
- import { type ISession } from '../types'
4
- import { logger } from '../utils'
3
+ import { type ISession } from '../types';
4
+ import { logger } from '../utils';
5
5
 
6
6
  import {
7
7
  SESSION_ADD_EVENT,
@@ -9,30 +9,30 @@ import {
9
9
  SESSION_STOPPED_EVENT,
10
10
  SESSION_SUBSCRIBE_EVENT,
11
11
  SESSION_UNSUBSCRIBE_EVENT,
12
- } from '../config'
12
+ } from '../config';
13
13
 
14
- const MAX_RECONNECTION_ATTEMPTS = 2
14
+ const MAX_RECONNECTION_ATTEMPTS = 2;
15
15
 
16
16
  export class EventExporter {
17
- private socket: Socket | null = null
18
- private queue: any[] = []
19
- private isConnecting: boolean = false
20
- private isConnected: boolean = false
21
- private attempts: number = 0
22
- private sessionId: string | null = null
23
-
24
- private socketUrl: string
25
- private apiKey: string
26
-
27
- constructor(options: { socketUrl: string, apiKey: string }) {
28
- this.socketUrl = options.socketUrl
29
- this.apiKey = options.apiKey
17
+ private socket: Socket | null = null;
18
+ private queue: any[] = [];
19
+ private isConnecting: boolean = false;
20
+ private isConnected: boolean = false;
21
+ private attempts: number = 0;
22
+ private sessionId: string | null = null;
23
+
24
+ private socketUrl: string;
25
+ private apiKey: string;
26
+
27
+ constructor(options: { socketUrl: string; apiKey: string }) {
28
+ this.socketUrl = options.socketUrl;
29
+ this.apiKey = options.apiKey;
30
30
  }
31
31
 
32
32
  private init(): void {
33
- if (this.isConnecting || this.isConnected) return
34
- this.attempts++
35
- this.isConnecting = true
33
+ if (this.isConnecting || this.isConnected) return;
34
+ this.attempts++;
35
+ this.isConnecting = true;
36
36
  this.socket = io(this.socketUrl, {
37
37
  path: '/v0/radar/ws',
38
38
  auth: {
@@ -40,7 +40,7 @@ export class EventExporter {
40
40
  },
41
41
  reconnectionAttempts: 2,
42
42
  transports: ['websocket'],
43
- })
43
+ });
44
44
 
45
45
  // this.socket.on('connect', () => {
46
46
  // this.isConnecting = false
@@ -50,58 +50,53 @@ export class EventExporter {
50
50
  // })
51
51
 
52
52
  this.socket.on('ready', () => {
53
- this.isConnecting = false
54
- this.isConnected = true
55
- logger.info('EventExporter', 'Connected to server')
56
- this.flushQueue()
57
- })
53
+ this.isConnecting = false;
54
+ this.isConnected = true;
55
+ logger.info('EventExporter', 'Connected to server');
56
+ this.flushQueue();
57
+ });
58
58
 
59
59
  this.socket.on('disconnect', (_err: any) => {
60
- this.isConnecting = false
61
- this.isConnected = false
62
- logger.info('EventExporter', 'Disconnected from server')
63
- })
60
+ this.isConnecting = false;
61
+ this.isConnected = false;
62
+ logger.info('EventExporter', 'Disconnected from server');
63
+ });
64
64
 
65
65
  this.socket.on('connect_error', (err: any) => {
66
- this.isConnecting = false
67
- this.isConnected = false
68
- this.checkReconnectionAttempts()
69
- logger.error('EventExporter', 'Error connecting to server', err)
70
- })
66
+ this.isConnecting = false;
67
+ this.isConnected = false;
68
+ this.checkReconnectionAttempts();
69
+ logger.error('EventExporter', 'Error connecting to server', err);
70
+ });
71
71
 
72
72
  this.socket.on(SESSION_STOPPED_EVENT, (_: any) => {
73
+ this.unsubscribeFromSession();
74
+ });
73
75
 
74
- this.unsubscribeFromSession()
75
- })
76
-
77
- this.socket.on(SESSION_AUTO_CREATED, (_: any) => {
78
-
79
- })
76
+ this.socket.on(SESSION_AUTO_CREATED, (_: any) => {});
80
77
  }
81
78
 
82
79
  setApiKey(apiKey: string): void {
83
- this.apiKey = apiKey
80
+ this.apiKey = apiKey;
84
81
  }
85
82
 
86
83
  setSocketUrl(socketUrl: string): void {
87
- this.socketUrl = socketUrl
84
+ this.socketUrl = socketUrl;
88
85
  }
89
86
 
90
87
  private checkReconnectionAttempts(): void {
91
88
  if (this.attempts >= MAX_RECONNECTION_ATTEMPTS) {
92
-
93
- this.flushQueue()
89
+ this.flushQueue();
94
90
  }
95
91
  }
96
92
 
97
-
98
93
  private flushQueue(): void {
99
- while (this.queue.length > 0 && (this.socket?.connected)) {
100
- const event = this.queue.shift()
101
- if (!event) continue
94
+ while (this.queue.length > 0 && this.socket?.connected) {
95
+ const event = this.queue.shift();
96
+ if (!event) continue;
102
97
 
103
98
  if (this.socket?.connected) {
104
- this.socket.emit(event.name, event.data)
99
+ this.socket.emit(event.name, event.data);
105
100
  }
106
101
  }
107
102
  }
@@ -109,47 +104,47 @@ export class EventExporter {
109
104
  private unsubscribeFromSession() {
110
105
  const payload = {
111
106
  debugSessionId: this.sessionId,
112
- }
107
+ };
113
108
  if (this.socket?.connected) {
114
- this.socket.emit(SESSION_UNSUBSCRIBE_EVENT, payload)
109
+ this.socket.emit(SESSION_UNSUBSCRIBE_EVENT, payload);
115
110
  }
116
111
  }
117
112
 
118
113
  public send(event: any): void {
119
114
  if (this.socket?.connected) {
120
- this.socket.emit(SESSION_ADD_EVENT, event)
115
+ this.socket.emit(SESSION_ADD_EVENT, event);
121
116
  } else {
122
- this.queue.push({ data: event, name: SESSION_ADD_EVENT })
123
- this.init()
117
+ this.queue.push({ data: event, name: SESSION_ADD_EVENT });
118
+ this.init();
124
119
  }
125
120
  }
126
121
 
127
122
  public subscribeToSession(session: ISession): void {
128
- this.sessionId = session.shortId || session._id
123
+ this.sessionId = session.shortId || session._id;
129
124
  const payload = {
130
125
  projectId: session.project,
131
126
  workspaceId: session.workspace,
132
127
  debugSessionId: this.sessionId,
133
128
  sessionType: session.creationType,
134
- }
129
+ };
135
130
  if (this.socket?.connected) {
136
- this.socket.emit(SESSION_SUBSCRIBE_EVENT, payload)
131
+ this.socket.emit(SESSION_SUBSCRIBE_EVENT, payload);
137
132
  } else {
138
- this.queue.push({ data: payload, name: SESSION_SUBSCRIBE_EVENT })
139
- this.init()
133
+ this.queue.push({ data: payload, name: SESSION_SUBSCRIBE_EVENT });
134
+ this.init();
140
135
  }
141
136
  }
142
137
 
143
138
  public close(): void {
144
139
  if (this.socket?.connected) {
145
140
  setTimeout(() => {
146
- this.unsubscribeFromSession()
147
- this.attempts = 0
148
- this.isConnected = false
149
- this.isConnecting = false
150
- this.socket?.disconnect()
151
- this.socket = null
152
- }, 500)
141
+ this.unsubscribeFromSession();
142
+ this.attempts = 0;
143
+ this.isConnected = false;
144
+ this.isConnecting = false;
145
+ this.socket?.disconnect();
146
+ this.socket = null;
147
+ }, 500);
153
148
  }
154
149
  }
155
150
  }