@openreplay/tracker 14.0.10-beta.2 → 14.0.11

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 (273) hide show
  1. package/{cjs → dist/cjs}/index.js +29 -49
  2. package/dist/cjs/index.js.map +1 -0
  3. package/{cjs → dist/cjs/main}/app/index.d.ts +17 -5
  4. package/{lib → dist/cjs/main}/app/logger.d.ts +1 -0
  5. package/{lib → dist/cjs/main}/app/messages.gen.d.ts +2 -2
  6. package/{lib/app/nodes.d.ts → dist/cjs/main/app/nodes/index.d.ts} +14 -7
  7. package/dist/cjs/main/app/nodes/maintainer.d.ts +28 -0
  8. package/{lib → dist/cjs/main}/app/observer/iframe_observer.d.ts +2 -0
  9. package/{lib → dist/cjs/main}/app/observer/iframe_offsets.d.ts +1 -1
  10. package/{lib → dist/cjs/main}/app/observer/observer.d.ts +3 -1
  11. package/{lib → dist/cjs/main}/app/observer/top_observer.d.ts +7 -1
  12. package/{cjs → dist/cjs/main}/app/sanitizer.d.ts +5 -2
  13. package/{cjs → dist/cjs/main}/app/session.d.ts +6 -3
  14. package/{cjs → dist/cjs/main}/index.d.ts +2 -2
  15. package/{cjs → dist/cjs/main}/modules/attributeSender.d.ts +5 -2
  16. package/{cjs → dist/cjs/main}/modules/conditionsManager.d.ts +1 -1
  17. package/{cjs → dist/cjs/main}/modules/tagWatcher.d.ts +8 -4
  18. package/{lib → dist/cjs/main}/modules/userTesting/SignalManager.d.ts +2 -2
  19. package/{lib → dist/cjs/main}/utils.d.ts +4 -3
  20. package/dist/lib/index.js +9358 -0
  21. package/dist/lib/index.js.map +1 -0
  22. package/{lib → dist/lib/main}/app/index.d.ts +17 -5
  23. package/{cjs → dist/lib/main}/app/logger.d.ts +1 -0
  24. package/{cjs → dist/lib/main}/app/messages.gen.d.ts +2 -2
  25. package/{cjs/app/nodes.d.ts → dist/lib/main/app/nodes/index.d.ts} +14 -7
  26. package/dist/lib/main/app/nodes/maintainer.d.ts +28 -0
  27. package/{cjs → dist/lib/main}/app/observer/iframe_observer.d.ts +2 -0
  28. package/{cjs → dist/lib/main}/app/observer/iframe_offsets.d.ts +1 -1
  29. package/{cjs → dist/lib/main}/app/observer/observer.d.ts +3 -1
  30. package/{cjs → dist/lib/main}/app/observer/top_observer.d.ts +7 -1
  31. package/{lib → dist/lib/main}/app/sanitizer.d.ts +5 -2
  32. package/{lib → dist/lib/main}/app/session.d.ts +6 -3
  33. package/{lib → dist/lib/main}/index.d.ts +2 -2
  34. package/{lib → dist/lib/main}/modules/attributeSender.d.ts +5 -2
  35. package/{lib → dist/lib/main}/modules/conditionsManager.d.ts +1 -1
  36. package/{lib → dist/lib/main}/modules/tagWatcher.d.ts +8 -4
  37. package/{cjs → dist/lib/main}/modules/userTesting/SignalManager.d.ts +2 -2
  38. package/{cjs → dist/lib/main}/utils.d.ts +4 -3
  39. package/package.json +31 -20
  40. package/.eslintignore +0 -11
  41. package/.nvmrc +0 -1
  42. package/.prettierignore +0 -1
  43. package/CHANGELOG.md +0 -297
  44. package/bun.lockb +0 -0
  45. package/cjs/app/canvas.js +0 -204
  46. package/cjs/app/guards.js +0 -37
  47. package/cjs/app/index.js +0 -1397
  48. package/cjs/app/logger.js +0 -37
  49. package/cjs/app/messages.gen.js +0 -702
  50. package/cjs/app/nodes.js +0 -111
  51. package/cjs/app/observer/iframe_observer.js +0 -35
  52. package/cjs/app/observer/iframe_offsets.js +0 -56
  53. package/cjs/app/observer/observer.js +0 -383
  54. package/cjs/app/observer/shadow_root_observer.js +0 -24
  55. package/cjs/app/observer/top_observer.js +0 -134
  56. package/cjs/app/sanitizer.js +0 -82
  57. package/cjs/app/session.js +0 -140
  58. package/cjs/app/ticker.js +0 -48
  59. package/cjs/common/interaction.js +0 -2
  60. package/cjs/common/messages.gen.js +0 -4
  61. package/cjs/modules/attributeSender.js +0 -51
  62. package/cjs/modules/axiosSpy.js +0 -122
  63. package/cjs/modules/conditionsManager.js +0 -343
  64. package/cjs/modules/connection.js +0 -15
  65. package/cjs/modules/console.js +0 -127
  66. package/cjs/modules/constructedStyleSheets.js +0 -138
  67. package/cjs/modules/cssrules.js +0 -99
  68. package/cjs/modules/exception.js +0 -85
  69. package/cjs/modules/featureFlags.js +0 -89
  70. package/cjs/modules/focus.js +0 -45
  71. package/cjs/modules/fonts.js +0 -57
  72. package/cjs/modules/img.js +0 -110
  73. package/cjs/modules/input.js +0 -203
  74. package/cjs/modules/mouse.js +0 -195
  75. package/cjs/modules/network.js +0 -244
  76. package/cjs/modules/performance.js +0 -53
  77. package/cjs/modules/scroll.js +0 -84
  78. package/cjs/modules/selection.js +0 -37
  79. package/cjs/modules/tabs.js +0 -13
  80. package/cjs/modules/tagWatcher.js +0 -76
  81. package/cjs/modules/timing.js +0 -173
  82. package/cjs/modules/userTesting/SignalManager.js +0 -83
  83. package/cjs/modules/userTesting/dnd.js +0 -40
  84. package/cjs/modules/userTesting/index.js +0 -464
  85. package/cjs/modules/userTesting/recorder.js +0 -101
  86. package/cjs/modules/userTesting/styles.js +0 -266
  87. package/cjs/modules/userTesting/utils.js +0 -87
  88. package/cjs/modules/viewport.js +0 -43
  89. package/cjs/package.json +0 -1
  90. package/cjs/utils.js +0 -249
  91. package/coverage/clover.xml +0 -4304
  92. package/coverage/coverage-final.json +0 -55
  93. package/coverage/lcov-report/base.css +0 -224
  94. package/coverage/lcov-report/block-navigation.js +0 -87
  95. package/coverage/lcov-report/favicon.png +0 -0
  96. package/coverage/lcov-report/index.html +0 -206
  97. package/coverage/lcov-report/main/app/canvas.ts.html +0 -712
  98. package/coverage/lcov-report/main/app/guards.ts.html +0 -232
  99. package/coverage/lcov-report/main/app/index.html +0 -236
  100. package/coverage/lcov-report/main/app/index.ts.html +0 -3955
  101. package/coverage/lcov-report/main/app/logger.ts.html +0 -211
  102. package/coverage/lcov-report/main/app/messages.gen.ts.html +0 -3034
  103. package/coverage/lcov-report/main/app/nodes.ts.html +0 -406
  104. package/coverage/lcov-report/main/app/observer/iframe_observer.ts.html +0 -148
  105. package/coverage/lcov-report/main/app/observer/iframe_offsets.ts.html +0 -289
  106. package/coverage/lcov-report/main/app/observer/index.html +0 -161
  107. package/coverage/lcov-report/main/app/observer/shadow_root_observer.ts.html +0 -142
  108. package/coverage/lcov-report/main/app/observer/top_observer.ts.html +0 -541
  109. package/coverage/lcov-report/main/app/sanitizer.ts.html +0 -403
  110. package/coverage/lcov-report/main/app/session.ts.html +0 -622
  111. package/coverage/lcov-report/main/app/ticker.ts.html +0 -250
  112. package/coverage/lcov-report/main/index.html +0 -131
  113. package/coverage/lcov-report/main/index.ts.html +0 -1597
  114. package/coverage/lcov-report/main/modules/Network/beaconProxy.ts.html +0 -400
  115. package/coverage/lcov-report/main/modules/Network/fetchProxy.ts.html +0 -1075
  116. package/coverage/lcov-report/main/modules/Network/index.html +0 -191
  117. package/coverage/lcov-report/main/modules/Network/index.ts.html +0 -244
  118. package/coverage/lcov-report/main/modules/Network/networkMessage.ts.html +0 -400
  119. package/coverage/lcov-report/main/modules/Network/utils.ts.html +0 -709
  120. package/coverage/lcov-report/main/modules/Network/xhrProxy.ts.html +0 -877
  121. package/coverage/lcov-report/main/modules/attributeSender.ts.html +0 -241
  122. package/coverage/lcov-report/main/modules/axiosSpy.ts.html +0 -709
  123. package/coverage/lcov-report/main/modules/conditionsManager.ts.html +0 -1381
  124. package/coverage/lcov-report/main/modules/connection.ts.html +0 -160
  125. package/coverage/lcov-report/main/modules/console.ts.html +0 -541
  126. package/coverage/lcov-report/main/modules/constructedStyleSheets.ts.html +0 -571
  127. package/coverage/lcov-report/main/modules/cssrules.ts.html +0 -418
  128. package/coverage/lcov-report/main/modules/exception.ts.html +0 -385
  129. package/coverage/lcov-report/main/modules/featureFlags.ts.html +0 -415
  130. package/coverage/lcov-report/main/modules/focus.ts.html +0 -220
  131. package/coverage/lcov-report/main/modules/fonts.ts.html +0 -289
  132. package/coverage/lcov-report/main/modules/img.ts.html +0 -436
  133. package/coverage/lcov-report/main/modules/index.html +0 -431
  134. package/coverage/lcov-report/main/modules/input.ts.html +0 -826
  135. package/coverage/lcov-report/main/modules/mouse.ts.html +0 -826
  136. package/coverage/lcov-report/main/modules/network.ts.html +0 -1123
  137. package/coverage/lcov-report/main/modules/performance.ts.html +0 -367
  138. package/coverage/lcov-report/main/modules/scroll.ts.html +0 -364
  139. package/coverage/lcov-report/main/modules/selection.ts.html +0 -202
  140. package/coverage/lcov-report/main/modules/tabs.ts.html +0 -124
  141. package/coverage/lcov-report/main/modules/tagWatcher.ts.html +0 -337
  142. package/coverage/lcov-report/main/modules/timing.ts.html +0 -877
  143. package/coverage/lcov-report/main/modules/userTesting/SignalManager.ts.html +0 -370
  144. package/coverage/lcov-report/main/modules/userTesting/dnd.ts.html +0 -220
  145. package/coverage/lcov-report/main/modules/userTesting/index.html +0 -191
  146. package/coverage/lcov-report/main/modules/userTesting/index.ts.html +0 -1909
  147. package/coverage/lcov-report/main/modules/userTesting/recorder.ts.html +0 -430
  148. package/coverage/lcov-report/main/modules/userTesting/styles.ts.html +0 -937
  149. package/coverage/lcov-report/main/modules/userTesting/utils.ts.html +0 -364
  150. package/coverage/lcov-report/main/modules/viewport.ts.html +0 -250
  151. package/coverage/lcov-report/main/utils.ts.html +0 -814
  152. package/coverage/lcov-report/prettify.css +0 -1
  153. package/coverage/lcov-report/prettify.js +0 -2
  154. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  155. package/coverage/lcov-report/sorter.js +0 -196
  156. package/coverage/lcov-report/webworker/BatchWriter.ts.html +0 -499
  157. package/coverage/lcov-report/webworker/MessageEncoder.gen.ts.html +0 -1021
  158. package/coverage/lcov-report/webworker/PrimitiveEncoder.ts.html +0 -436
  159. package/coverage/lcov-report/webworker/QueueSender.ts.html +0 -547
  160. package/coverage/lcov-report/webworker/index.html +0 -176
  161. package/coverage/lcov-report/webworker/index.ts.html +0 -667
  162. package/coverage/lcov.info +0 -8425
  163. package/jest.config.js +0 -13
  164. package/lib/app/canvas.js +0 -202
  165. package/lib/app/guards.js +0 -26
  166. package/lib/app/index.js +0 -1367
  167. package/lib/app/logger.js +0 -33
  168. package/lib/app/messages.gen.js +0 -622
  169. package/lib/app/nodes.js +0 -108
  170. package/lib/app/observer/iframe_observer.js +0 -29
  171. package/lib/app/observer/iframe_offsets.js +0 -53
  172. package/lib/app/observer/observer.js +0 -380
  173. package/lib/app/observer/shadow_root_observer.js +0 -18
  174. package/lib/app/observer/top_observer.js +0 -128
  175. package/lib/app/sanitizer.js +0 -77
  176. package/lib/app/session.js +0 -137
  177. package/lib/app/ticker.js +0 -45
  178. package/lib/common/interaction.js +0 -1
  179. package/lib/common/messages.gen.js +0 -3
  180. package/lib/common/tsconfig.tsbuildinfo +0 -1
  181. package/lib/index.js +0 -423
  182. package/lib/modules/attributeSender.js +0 -46
  183. package/lib/modules/axiosSpy.js +0 -119
  184. package/lib/modules/conditionsManager.js +0 -340
  185. package/lib/modules/connection.js +0 -12
  186. package/lib/modules/console.js +0 -124
  187. package/lib/modules/constructedStyleSheets.js +0 -133
  188. package/lib/modules/cssrules.js +0 -97
  189. package/lib/modules/exception.js +0 -76
  190. package/lib/modules/featureFlags.js +0 -86
  191. package/lib/modules/focus.js +0 -42
  192. package/lib/modules/fonts.js +0 -54
  193. package/lib/modules/img.js +0 -107
  194. package/lib/modules/input.js +0 -198
  195. package/lib/modules/mouse.js +0 -192
  196. package/lib/modules/network.js +0 -238
  197. package/lib/modules/performance.js +0 -49
  198. package/lib/modules/scroll.js +0 -81
  199. package/lib/modules/selection.js +0 -35
  200. package/lib/modules/tabs.js +0 -10
  201. package/lib/modules/tagWatcher.js +0 -73
  202. package/lib/modules/timing.js +0 -170
  203. package/lib/modules/userTesting/SignalManager.js +0 -80
  204. package/lib/modules/userTesting/dnd.js +0 -37
  205. package/lib/modules/userTesting/index.js +0 -435
  206. package/lib/modules/userTesting/recorder.js +0 -97
  207. package/lib/modules/userTesting/styles.js +0 -263
  208. package/lib/modules/userTesting/utils.js +0 -79
  209. package/lib/modules/viewport.js +0 -40
  210. package/lib/utils.js +0 -230
  211. package/rollup.config.js +0 -12
  212. package/scripts/checkver.cjs +0 -7
  213. package/tsconfig-base.json +0 -16
  214. /package/{cjs → dist/cjs}/common/interaction.d.ts +0 -0
  215. /package/{cjs → dist/cjs}/common/messages.gen.d.ts +0 -0
  216. /package/{cjs → dist/cjs/main}/app/canvas.d.ts +0 -0
  217. /package/{cjs → dist/cjs/main}/app/guards.d.ts +0 -0
  218. /package/{cjs → dist/cjs/main}/app/observer/shadow_root_observer.d.ts +0 -0
  219. /package/{cjs → dist/cjs/main}/app/ticker.d.ts +0 -0
  220. /package/{cjs → dist/cjs/main}/modules/axiosSpy.d.ts +0 -0
  221. /package/{cjs → dist/cjs/main}/modules/connection.d.ts +0 -0
  222. /package/{cjs → dist/cjs/main}/modules/console.d.ts +0 -0
  223. /package/{cjs → dist/cjs/main}/modules/constructedStyleSheets.d.ts +0 -0
  224. /package/{cjs → dist/cjs/main}/modules/cssrules.d.ts +0 -0
  225. /package/{cjs → dist/cjs/main}/modules/exception.d.ts +0 -0
  226. /package/{cjs → dist/cjs/main}/modules/featureFlags.d.ts +0 -0
  227. /package/{cjs → dist/cjs/main}/modules/focus.d.ts +0 -0
  228. /package/{cjs → dist/cjs/main}/modules/fonts.d.ts +0 -0
  229. /package/{cjs → dist/cjs/main}/modules/img.d.ts +0 -0
  230. /package/{cjs → dist/cjs/main}/modules/input.d.ts +0 -0
  231. /package/{cjs → dist/cjs/main}/modules/mouse.d.ts +0 -0
  232. /package/{cjs → dist/cjs/main}/modules/network.d.ts +0 -0
  233. /package/{cjs → dist/cjs/main}/modules/performance.d.ts +0 -0
  234. /package/{cjs → dist/cjs/main}/modules/scroll.d.ts +0 -0
  235. /package/{cjs → dist/cjs/main}/modules/selection.d.ts +0 -0
  236. /package/{cjs → dist/cjs/main}/modules/tabs.d.ts +0 -0
  237. /package/{cjs → dist/cjs/main}/modules/timing.d.ts +0 -0
  238. /package/{cjs → dist/cjs/main}/modules/userTesting/dnd.d.ts +0 -0
  239. /package/{cjs → dist/cjs/main}/modules/userTesting/index.d.ts +0 -0
  240. /package/{cjs → dist/cjs/main}/modules/userTesting/recorder.d.ts +0 -0
  241. /package/{cjs → dist/cjs/main}/modules/userTesting/styles.d.ts +0 -0
  242. /package/{cjs → dist/cjs/main}/modules/userTesting/utils.d.ts +0 -0
  243. /package/{cjs → dist/cjs/main}/modules/viewport.d.ts +0 -0
  244. /package/{lib → dist/lib}/common/interaction.d.ts +0 -0
  245. /package/{lib → dist/lib}/common/messages.gen.d.ts +0 -0
  246. /package/{lib → dist/lib/main}/app/canvas.d.ts +0 -0
  247. /package/{lib → dist/lib/main}/app/guards.d.ts +0 -0
  248. /package/{lib → dist/lib/main}/app/observer/shadow_root_observer.d.ts +0 -0
  249. /package/{lib → dist/lib/main}/app/ticker.d.ts +0 -0
  250. /package/{lib → dist/lib/main}/modules/axiosSpy.d.ts +0 -0
  251. /package/{lib → dist/lib/main}/modules/connection.d.ts +0 -0
  252. /package/{lib → dist/lib/main}/modules/console.d.ts +0 -0
  253. /package/{lib → dist/lib/main}/modules/constructedStyleSheets.d.ts +0 -0
  254. /package/{lib → dist/lib/main}/modules/cssrules.d.ts +0 -0
  255. /package/{lib → dist/lib/main}/modules/exception.d.ts +0 -0
  256. /package/{lib → dist/lib/main}/modules/featureFlags.d.ts +0 -0
  257. /package/{lib → dist/lib/main}/modules/focus.d.ts +0 -0
  258. /package/{lib → dist/lib/main}/modules/fonts.d.ts +0 -0
  259. /package/{lib → dist/lib/main}/modules/img.d.ts +0 -0
  260. /package/{lib → dist/lib/main}/modules/input.d.ts +0 -0
  261. /package/{lib → dist/lib/main}/modules/mouse.d.ts +0 -0
  262. /package/{lib → dist/lib/main}/modules/network.d.ts +0 -0
  263. /package/{lib → dist/lib/main}/modules/performance.d.ts +0 -0
  264. /package/{lib → dist/lib/main}/modules/scroll.d.ts +0 -0
  265. /package/{lib → dist/lib/main}/modules/selection.d.ts +0 -0
  266. /package/{lib → dist/lib/main}/modules/tabs.d.ts +0 -0
  267. /package/{lib → dist/lib/main}/modules/timing.d.ts +0 -0
  268. /package/{lib → dist/lib/main}/modules/userTesting/dnd.d.ts +0 -0
  269. /package/{lib → dist/lib/main}/modules/userTesting/index.d.ts +0 -0
  270. /package/{lib → dist/lib/main}/modules/userTesting/recorder.d.ts +0 -0
  271. /package/{lib → dist/lib/main}/modules/userTesting/styles.d.ts +0 -0
  272. /package/{lib → dist/lib/main}/modules/userTesting/utils.d.ts +0 -0
  273. /package/{lib → dist/lib/main}/modules/viewport.d.ts +0 -0
@@ -1,340 +0,0 @@
1
- export default class ConditionsManager {
2
- constructor(app, startParams) {
3
- this.app = app;
4
- this.startParams = startParams;
5
- this.conditions = [];
6
- this.hasStarted = false;
7
- this.createConditionFromFilter = (filter) => {
8
- if (filter.value.length) {
9
- const resultCondition = mapCondition(filter);
10
- if (resultCondition.type) {
11
- return resultCondition;
12
- }
13
- }
14
- return undefined;
15
- };
16
- this.durationInt = null;
17
- }
18
- setConditions(conditions) {
19
- this.conditions = conditions;
20
- }
21
- async fetchConditions(projectId, token) {
22
- try {
23
- const r = await fetch(`${this.app.options.ingestPoint}/v1/web/conditions/${projectId}`, {
24
- method: 'GET',
25
- headers: {
26
- Authorization: `Bearer ${token}`,
27
- },
28
- });
29
- const { conditions } = (await r.json());
30
- const mappedConditions = [];
31
- conditions.forEach((c) => {
32
- const filters = c.filters;
33
- filters.forEach((filter) => {
34
- let cond;
35
- if (filter.type === 'fetch') {
36
- cond = {
37
- type: 'network_request',
38
- subConditions: [],
39
- name: c.name,
40
- };
41
- filter.filters.forEach((f) => {
42
- const subCond = this.createConditionFromFilter(f);
43
- if (subCond) {
44
- ;
45
- cond.subConditions.push(subCond);
46
- }
47
- });
48
- }
49
- else {
50
- cond = this.createConditionFromFilter(filter);
51
- }
52
- if (cond) {
53
- if (cond.type === 'session_duration') {
54
- this.processDuration(cond.value[0], c.name);
55
- }
56
- mappedConditions.push({ ...cond, name: c.name });
57
- }
58
- });
59
- });
60
- this.conditions = mappedConditions;
61
- }
62
- catch (e) {
63
- this.app.debug.error('Critical: cannot fetch start conditions');
64
- }
65
- }
66
- trigger(conditionName) {
67
- if (this.hasStarted)
68
- return;
69
- try {
70
- this.hasStarted = true;
71
- void this.app.start(this.startParams, undefined, conditionName);
72
- }
73
- catch (e) {
74
- this.app.debug.error(e);
75
- }
76
- }
77
- processMessage(message) {
78
- if (this.hasStarted)
79
- return;
80
- switch (message[0]) {
81
- case 78 /* Type.JSException */:
82
- this.jsExceptionEvent(message);
83
- break;
84
- case 27 /* Type.CustomEvent */:
85
- this.customEvent(message);
86
- break;
87
- case 68 /* Type.MouseClick */:
88
- this.clickEvent(message);
89
- break;
90
- case 122 /* Type.SetPageLocation */:
91
- this.pageLocationEvent(message);
92
- break;
93
- case 83 /* Type.NetworkRequest */:
94
- this.networkRequest(message);
95
- break;
96
- default:
97
- break;
98
- }
99
- }
100
- processFlags(flag) {
101
- const flagConds = this.conditions.filter((c) => c.type === 'feature_flag');
102
- if (flagConds.length) {
103
- flagConds.forEach((flagCond) => {
104
- const operator = operators[flagCond.operator];
105
- if (operator && flag.find((f) => operator(f.key, flagCond.value))) {
106
- this.trigger(flagCond.name);
107
- }
108
- });
109
- }
110
- }
111
- processDuration(durationMs, condName) {
112
- this.durationInt = setInterval(() => {
113
- const sessionLength = performance.now();
114
- if (sessionLength > durationMs) {
115
- this.trigger(condName);
116
- }
117
- }, 1000);
118
- this.app.attachStopCallback(() => {
119
- if (this.durationInt) {
120
- clearInterval(this.durationInt);
121
- }
122
- });
123
- }
124
- networkRequest(message) {
125
- // method - 2, url - 3, status - 6, duration - 8
126
- const reqConds = this.conditions.filter((c) => c.type === 'network_request');
127
- if (!reqConds.length)
128
- return;
129
- reqConds.forEach((reqCond) => {
130
- const validSubConditions = reqCond.subConditions.filter((c) => c.operator !== 'isAny');
131
- if (validSubConditions.length) {
132
- const allPass = validSubConditions.every((subCond) => {
133
- let value;
134
- switch (subCond.key) {
135
- case 'url':
136
- value = message[3];
137
- break;
138
- case 'status':
139
- value = message[6];
140
- break;
141
- case 'method':
142
- value = message[2];
143
- break;
144
- case 'duration':
145
- value = message[8];
146
- break;
147
- default:
148
- break;
149
- }
150
- const operator = operators[subCond.operator];
151
- // @ts-ignore
152
- if (operator && operator(value, subCond.value)) {
153
- return true;
154
- }
155
- });
156
- if (allPass) {
157
- this.trigger(reqCond.name);
158
- }
159
- }
160
- else if (validSubConditions.length === 0 && reqCond.subConditions.length) {
161
- this.trigger(reqCond.name);
162
- }
163
- });
164
- }
165
- customEvent(message) {
166
- // name - 1, payload - 2
167
- const evConds = this.conditions.filter((c) => c.type === 'custom_event');
168
- if (evConds.length) {
169
- evConds.forEach((evCond) => {
170
- const operator = operators[evCond.operator];
171
- if (operator &&
172
- (operator(message[1], evCond.value) || operator(message[2], evCond.value))) {
173
- this.trigger(evCond.name);
174
- }
175
- });
176
- }
177
- }
178
- clickEvent(message) {
179
- // label - 3, selector - 4
180
- const clickCond = this.conditions.filter((c) => c.type === 'click');
181
- if (clickCond.length) {
182
- clickCond.forEach((click) => {
183
- const operator = operators[click.operator];
184
- if (operator && (operator(message[3], click.value) || operator(message[4], click.value))) {
185
- this.trigger(click.name);
186
- }
187
- });
188
- }
189
- }
190
- pageLocationEvent(message) {
191
- // url - 1
192
- const urlConds = this.conditions.filter((c) => c.type === 'visited_url');
193
- if (urlConds) {
194
- urlConds.forEach((urlCond) => {
195
- const operator = operators[urlCond.operator];
196
- if (operator && operator(message[1], urlCond.value)) {
197
- this.trigger(urlCond.name);
198
- }
199
- });
200
- }
201
- }
202
- jsExceptionEvent(message) {
203
- // name - 1, message - 2, payload - 3
204
- const testedValues = [message[1], message[2], message[3]];
205
- const exceptionConds = this.conditions.filter((c) => c.type === 'exception');
206
- if (exceptionConds) {
207
- exceptionConds.forEach((exceptionCond) => {
208
- const operator = operators[exceptionCond.operator];
209
- if (operator && testedValues.some((val) => operator(val, exceptionCond.value))) {
210
- this.trigger(exceptionCond.name);
211
- }
212
- });
213
- }
214
- }
215
- }
216
- const operators = {
217
- is: (val, target) => target.some((t) => val.includes(t)),
218
- isAny: () => true,
219
- isNot: (val, target) => !target.some((t) => val.includes(t)),
220
- contains: (val, target) => target.some((t) => val.includes(t)),
221
- notContains: (val, target) => !target.some((t) => val.includes(t)),
222
- startsWith: (val, target) => target.some((t) => val.startsWith(t)),
223
- endsWith: (val, target) => target.some((t) => val.endsWith(t)),
224
- greaterThan: (val, target) => val > target,
225
- greaterOrEqual: (val, target) => val >= target,
226
- lessOrEqual: (val, target) => val <= target,
227
- lessThan: (val, target) => val < target,
228
- };
229
- const mapCondition = (condition) => {
230
- const opMap = {
231
- on: 'is',
232
- notOn: 'isNot',
233
- '\u003e': 'greaterThan',
234
- '\u003c': 'lessThan',
235
- '\u003d': 'is',
236
- '\u003c=': 'lessOrEqual',
237
- '\u003e=': 'greaterOrEqual',
238
- };
239
- const mapOperator = (operator) => {
240
- const keys = Object.keys(opMap);
241
- // @ts-ignore
242
- if (keys.includes(operator))
243
- return opMap[operator];
244
- };
245
- let con = {
246
- type: '',
247
- operator: '',
248
- value: condition.value,
249
- key: '',
250
- };
251
- switch (condition.type) {
252
- case 'click':
253
- con = {
254
- type: 'click',
255
- operator: mapOperator(condition.operator),
256
- value: condition.value,
257
- key: '',
258
- };
259
- break;
260
- case 'location':
261
- con = {
262
- type: 'visited_url',
263
- // @ts-ignore
264
- operator: condition.operator,
265
- value: condition.value,
266
- key: '',
267
- };
268
- break;
269
- case 'custom':
270
- con = {
271
- type: 'custom_event',
272
- // @ts-ignore
273
- operator: condition.operator,
274
- value: condition.value,
275
- key: '',
276
- };
277
- break;
278
- case 'metadata':
279
- con = {
280
- // @ts-ignore
281
- type: condition.source === 'featureFlag' ? 'feature_flag' : condition.type,
282
- // @ts-ignore
283
- operator: condition.operator,
284
- value: condition.value,
285
- key: '',
286
- };
287
- break;
288
- case 'error':
289
- con = {
290
- type: 'exception',
291
- // @ts-ignore
292
- operator: condition.operator,
293
- value: condition.value,
294
- key: '',
295
- };
296
- break;
297
- case 'duration':
298
- con = {
299
- type: 'session_duration',
300
- // @ts-ignore
301
- value: condition.value[0],
302
- key: '',
303
- };
304
- break;
305
- case 'fetchUrl':
306
- con = {
307
- type: 'network_request',
308
- key: 'url',
309
- operator: condition.operator,
310
- value: condition.value,
311
- };
312
- break;
313
- case 'fetchStatusCode':
314
- con = {
315
- type: 'network_request',
316
- key: 'status',
317
- operator: mapOperator(condition.operator),
318
- value: condition.value,
319
- };
320
- break;
321
- case 'fetchMethod':
322
- con = {
323
- type: 'network_request',
324
- key: 'method',
325
- operator: mapOperator(condition.operator),
326
- value: condition.value,
327
- };
328
- break;
329
- case 'fetchDuration':
330
- con = {
331
- type: 'network_request',
332
- key: 'duration',
333
- operator: mapOperator(condition.operator),
334
- value: condition.value,
335
- };
336
- break;
337
- }
338
- // @ts-ignore
339
- return con;
340
- };
@@ -1,12 +0,0 @@
1
- import { ConnectionInformation } from '../app/messages.gen.js';
2
- export default function (app) {
3
- const connection = navigator.connection ||
4
- navigator.mozConnection ||
5
- navigator.webkitConnection;
6
- if (connection === undefined) {
7
- return;
8
- }
9
- const sendConnectionInformation = () => app.send(ConnectionInformation(Math.round(connection.downlink * 1000), connection.type || 'unknown'));
10
- sendConnectionInformation();
11
- connection.addEventListener('change', sendConnectionInformation);
12
- }
@@ -1,124 +0,0 @@
1
- import { IN_BROWSER } from '../utils.js';
2
- import { ConsoleLog } from '../app/messages.gen.js';
3
- const printError = IN_BROWSER && 'InstallTrigger' in window // detect Firefox
4
- ? (e) => e.message + '\n' + e.stack
5
- : (e) => e.stack || e.message;
6
- function printString(arg) {
7
- if (arg === undefined) {
8
- return 'undefined';
9
- }
10
- if (arg === null) {
11
- return 'null';
12
- }
13
- if (arg instanceof Error) {
14
- return printError(arg);
15
- }
16
- if (Array.isArray(arg)) {
17
- return `Array(${arg.length})`;
18
- }
19
- return String(arg);
20
- }
21
- function printFloat(arg) {
22
- if (typeof arg !== 'number')
23
- return 'NaN';
24
- return arg.toString();
25
- }
26
- function printInt(arg) {
27
- if (typeof arg !== 'number')
28
- return 'NaN';
29
- return Math.floor(arg).toString();
30
- }
31
- function printObject(arg) {
32
- if (arg === undefined) {
33
- return 'undefined';
34
- }
35
- if (arg === null) {
36
- return 'null';
37
- }
38
- if (arg instanceof Error) {
39
- return printError(arg);
40
- }
41
- if (Array.isArray(arg)) {
42
- const length = arg.length;
43
- const values = arg.slice(0, 10).map(printString).join(', ');
44
- return `Array(${length})[${values}]`;
45
- }
46
- if (typeof arg === 'object') {
47
- const res = [];
48
- let i = 0;
49
- for (const k in arg) {
50
- if (++i === 10) {
51
- break;
52
- }
53
- const v = arg[k];
54
- res.push(k + ': ' + printString(v));
55
- }
56
- return '{' + res.join(', ') + '}';
57
- }
58
- return arg.toString();
59
- }
60
- function printf(args) {
61
- if (typeof args[0] === 'string') {
62
- args.unshift(args.shift().replace(/%(o|s|f|d|i)/g, (s, t) => {
63
- const arg = args.shift();
64
- if (arg === undefined)
65
- return s;
66
- switch (t) {
67
- case 'o':
68
- return printObject(arg);
69
- case 's':
70
- return printString(arg);
71
- case 'f':
72
- return printFloat(arg);
73
- case 'd':
74
- case 'i':
75
- return printInt(arg);
76
- default:
77
- return s;
78
- }
79
- }));
80
- }
81
- return args.map(printObject).join(' ');
82
- }
83
- const consoleMethods = ['log', 'info', 'warn', 'error', 'debug', 'assert'];
84
- export default function (app, opts) {
85
- const options = Object.assign({
86
- consoleMethods,
87
- consoleThrottling: 30,
88
- }, opts);
89
- if (!Array.isArray(options.consoleMethods) || options.consoleMethods.length === 0) {
90
- return;
91
- }
92
- const sendConsoleLog = app.safe((level, args) => app.send(ConsoleLog(level, printf(args))));
93
- let n = 0;
94
- const reset = () => {
95
- n = 0;
96
- };
97
- app.attachStartCallback(reset);
98
- app.ticker.attach(reset, 33, false);
99
- const patchConsole = (console, ctx) => {
100
- const handler = {
101
- apply: function (target, thisArg, argumentsList) {
102
- Reflect.apply(target, ctx, argumentsList);
103
- n = n + 1;
104
- if (n > options.consoleThrottling) {
105
- return;
106
- }
107
- else {
108
- sendConsoleLog(target.name, argumentsList);
109
- }
110
- },
111
- };
112
- options.consoleMethods.forEach((method) => {
113
- if (consoleMethods.indexOf(method) === -1) {
114
- app.debug.error(`OpenReplay: unsupported console method "${method}"`);
115
- return;
116
- }
117
- const fn = ctx.console[method];
118
- console[method] = new Proxy(fn, handler);
119
- });
120
- };
121
- const patchContext = app.safe((context) => patchConsole(context.console, context));
122
- patchContext(window);
123
- app.observer.attachContextCallback(patchContext);
124
- }
@@ -1,133 +0,0 @@
1
- import { AdoptedSSReplaceURLBased, AdoptedSSInsertRuleURLBased, AdoptedSSAddOwner, AdoptedSSRemoveOwner, } from '../app/messages.gen.js';
2
- import { isRootNode } from '../app/guards.js';
3
- function hasAdoptedSS(node) {
4
- return (isRootNode(node) &&
5
- // @ts-ignore
6
- !!node.adoptedStyleSheets);
7
- }
8
- // TODO: encapsulate to be init-ed on-start and join with cssrules.ts under one folder
9
- let _id = 0xf;
10
- export function nextID() {
11
- return _id++;
12
- }
13
- export const styleSheetIDMap = new Map();
14
- export default function (app) {
15
- if (app === null) {
16
- return;
17
- }
18
- if (!hasAdoptedSS(document)) {
19
- return;
20
- }
21
- const styleSheetIDMap = new Map();
22
- const adoptedStyleSheetsOwnings = new Map();
23
- const sendAdoptedStyleSheetsUpdate = (root) => setTimeout(() => {
24
- let nodeID = app.nodes.getID(root);
25
- if (root === document) {
26
- nodeID = 0; // main document doesn't have nodeID. ID count starts from the documentElement
27
- }
28
- if (nodeID === undefined) {
29
- return;
30
- }
31
- let pastOwning = adoptedStyleSheetsOwnings.get(nodeID);
32
- if (!pastOwning) {
33
- pastOwning = [];
34
- }
35
- const nowOwning = [];
36
- const styleSheets = root.adoptedStyleSheets;
37
- if (styleSheets && Symbol.iterator in styleSheets) {
38
- for (const s of styleSheets) {
39
- let sheetID = styleSheetIDMap.get(s);
40
- const init = !sheetID;
41
- if (!sheetID) {
42
- sheetID = nextID();
43
- styleSheetIDMap.set(s, sheetID);
44
- }
45
- if (!pastOwning.includes(sheetID)) {
46
- app.send(AdoptedSSAddOwner(sheetID, nodeID));
47
- }
48
- if (init) {
49
- const rules = s.cssRules;
50
- for (let i = 0; i < rules.length; i++) {
51
- app.send(AdoptedSSInsertRuleURLBased(sheetID, rules[i].cssText, i, app.getBaseHref()));
52
- }
53
- }
54
- nowOwning.push(sheetID);
55
- }
56
- }
57
- if (Symbol.iterator in pastOwning) {
58
- for (const sheetID of pastOwning) {
59
- if (!nowOwning.includes(sheetID)) {
60
- app.send(AdoptedSSRemoveOwner(sheetID, nodeID));
61
- }
62
- }
63
- }
64
- adoptedStyleSheetsOwnings.set(nodeID, nowOwning);
65
- }, 20); // Mysterious bug:
66
- /* On the page https://explore.fast.design/components/fast-accordion
67
- the only rule inside the only adoptedStyleSheet of the iframe-s document
68
- gets changed during first milliseconds after the load.
69
- However, none of the documented methods (replace, insertRule) is triggered.
70
- The rule is not substituted (remains the same object), however the text gets changed.
71
- */
72
- function patchAdoptedStyleSheets(prototype) {
73
- const nativeAdoptedStyleSheetsDescriptor = Object.getOwnPropertyDescriptor(prototype, 'adoptedStyleSheets');
74
- if (nativeAdoptedStyleSheetsDescriptor) {
75
- Object.defineProperty(prototype, 'adoptedStyleSheets', {
76
- ...nativeAdoptedStyleSheetsDescriptor,
77
- set: function (value) {
78
- // @ts-ignore
79
- const retVal = nativeAdoptedStyleSheetsDescriptor.set.call(this, value);
80
- sendAdoptedStyleSheetsUpdate(this);
81
- return retVal;
82
- },
83
- });
84
- }
85
- }
86
- const patchContext = (context) => {
87
- // @ts-ignore
88
- if (context.__openreplay_adpss_patched__) {
89
- return;
90
- }
91
- else {
92
- // @ts-ignore
93
- context.__openreplay_adpss_patched__ = true;
94
- }
95
- patchAdoptedStyleSheets(context.Document.prototype);
96
- patchAdoptedStyleSheets(context.ShadowRoot.prototype);
97
- //@ts-ignore TODO: upgrade ts to 4.8+
98
- const { replace, replaceSync } = context.CSSStyleSheet.prototype;
99
- //@ts-ignore
100
- context.CSSStyleSheet.prototype.replace = function (text) {
101
- return replace.call(this, text).then((sheet) => {
102
- const sheetID = styleSheetIDMap.get(this);
103
- if (sheetID) {
104
- app.send(AdoptedSSReplaceURLBased(sheetID, text, app.getBaseHref()));
105
- }
106
- return sheet;
107
- });
108
- };
109
- //@ts-ignore
110
- context.CSSStyleSheet.prototype.replaceSync = function (text) {
111
- const sheetID = styleSheetIDMap.get(this);
112
- if (sheetID) {
113
- app.send(AdoptedSSReplaceURLBased(sheetID, text, app.getBaseHref()));
114
- }
115
- return replaceSync.call(this, text);
116
- };
117
- };
118
- patchContext(window);
119
- app.observer.attachContextCallback(app.safe(patchContext));
120
- app.attachStopCallback(() => {
121
- styleSheetIDMap.clear();
122
- adoptedStyleSheetsOwnings.clear();
123
- });
124
- // So far main Document is not triggered with nodeCallbacks
125
- app.attachStartCallback(() => {
126
- sendAdoptedStyleSheetsUpdate(document);
127
- });
128
- app.nodes.attachNodeCallback((node) => {
129
- if (hasAdoptedSS(node)) {
130
- sendAdoptedStyleSheetsUpdate(node);
131
- }
132
- });
133
- }