@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,195 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const guards_js_1 = require("../app/guards.js");
4
- const utils_js_1 = require("../utils.js");
5
- const messages_gen_js_1 = require("../app/messages.gen.js");
6
- const input_js_1 = require("./input.js");
7
- const finder_1 = require("@medv/finder");
8
- function _getSelector(target, document, options) {
9
- const selector = (0, finder_1.finder)(target, {
10
- root: document.body,
11
- seedMinLength: 3,
12
- optimizedMinLength: options?.minSelectorDepth || 2,
13
- threshold: options?.nthThreshold || 1000,
14
- maxNumberOfTries: options?.maxOptimiseTries || 10000,
15
- });
16
- return selector;
17
- }
18
- function isClickable(element) {
19
- const tag = element.tagName.toUpperCase();
20
- return (tag === 'BUTTON' ||
21
- tag === 'A' ||
22
- tag === 'LI' ||
23
- tag === 'SELECT' ||
24
- tag === 'TR' ||
25
- tag === 'TH' ||
26
- element.onclick != null ||
27
- element.getAttribute('role') === 'button');
28
- //|| element.className.includes("btn")
29
- // MBTODO: intercept addEventListener
30
- }
31
- //TODO: fix (typescript is not sure about target variable after assignation of svg)
32
- function getTarget(target, document) {
33
- if (target instanceof Element) {
34
- return _getTarget(target, document);
35
- }
36
- return null;
37
- }
38
- function _getTarget(target, document) {
39
- let element = target;
40
- while (element !== null && element !== document.documentElement) {
41
- if ((0, utils_js_1.hasOpenreplayAttribute)(element, 'masked')) {
42
- return null;
43
- }
44
- element = element.parentElement;
45
- }
46
- if ((0, guards_js_1.isSVGElement)(target)) {
47
- let owner = target.ownerSVGElement;
48
- while (owner !== null) {
49
- target = owner;
50
- owner = owner.ownerSVGElement;
51
- }
52
- }
53
- element = target;
54
- while (element !== null && element !== document.documentElement) {
55
- const tag = element.tagName.toUpperCase();
56
- if (tag === 'LABEL') {
57
- return null;
58
- }
59
- if (tag === 'INPUT') {
60
- return element;
61
- }
62
- if (isClickable(element) || (0, utils_js_1.getLabelAttribute)(element) !== null) {
63
- return element;
64
- }
65
- element = element.parentElement;
66
- }
67
- return target === document.documentElement ? null : target;
68
- }
69
- function default_1(app, options) {
70
- const { disableClickmaps = false } = options || {};
71
- function getTargetLabel(target) {
72
- const dl = (0, utils_js_1.getLabelAttribute)(target);
73
- if (dl !== null) {
74
- return dl;
75
- }
76
- if ((0, guards_js_1.hasTag)(target, 'input')) {
77
- return (0, input_js_1.getInputLabel)(target);
78
- }
79
- if (isClickable(target)) {
80
- let label = '';
81
- if (target instanceof HTMLElement) {
82
- label = app.sanitizer.getInnerTextSecure(target);
83
- }
84
- label = label || target.id || target.className;
85
- return (0, utils_js_1.normSpaces)(label).slice(0, 100);
86
- }
87
- return '';
88
- }
89
- let mousePositionX = -1;
90
- let mousePositionY = -1;
91
- let mousePositionChanged = false;
92
- let mouseTarget = null;
93
- let mouseTargetTime = 0;
94
- let selectorMap = {};
95
- let velocity = 0;
96
- let direction = 0;
97
- let directionChangeCount = 0;
98
- let distance = 0;
99
- let checkIntervalId;
100
- const shakeThreshold = 0.008;
101
- const shakeCheckInterval = 225;
102
- function checkMouseShaking() {
103
- const nextVelocity = distance / shakeCheckInterval;
104
- if (!velocity) {
105
- velocity = nextVelocity;
106
- return;
107
- }
108
- const acceleration = (nextVelocity - velocity) / shakeCheckInterval;
109
- if (directionChangeCount > 4 && acceleration > shakeThreshold) {
110
- app.send((0, messages_gen_js_1.MouseThrashing)((0, utils_js_1.now)()));
111
- }
112
- distance = 0;
113
- directionChangeCount = 0;
114
- velocity = nextVelocity;
115
- }
116
- app.attachStartCallback(() => {
117
- checkIntervalId = setInterval(() => checkMouseShaking(), shakeCheckInterval);
118
- });
119
- app.attachStopCallback(() => {
120
- mousePositionX = -1;
121
- mousePositionY = -1;
122
- mousePositionChanged = false;
123
- mouseTarget = null;
124
- selectorMap = {};
125
- if (checkIntervalId) {
126
- clearInterval(checkIntervalId);
127
- }
128
- });
129
- const sendMouseMove = () => {
130
- if (mousePositionChanged) {
131
- app.send((0, messages_gen_js_1.MouseMove)(mousePositionX, mousePositionY));
132
- mousePositionChanged = false;
133
- }
134
- };
135
- const patchDocument = (document, topframe = false) => {
136
- function getSelector(id, target, options) {
137
- return (selectorMap[id] = selectorMap[id] || _getSelector(target, document, options));
138
- }
139
- const attachListener = topframe
140
- ? app.attachEventListener.bind(app) // attached/removed on start/stop
141
- : app.nodes.attachNodeListener.bind(app.nodes); // attached/removed on node register/unregister
142
- attachListener(document.documentElement, 'mouseover', (e) => {
143
- const target = getTarget(e.target, document);
144
- if (target !== mouseTarget) {
145
- mouseTarget = target;
146
- mouseTargetTime = performance.now();
147
- }
148
- });
149
- attachListener(document, 'mousemove', (e) => {
150
- const [left, top] = app.observer.getDocumentOffset(document); // MBTODO?: document-id related message
151
- mousePositionX = e.clientX + left;
152
- mousePositionY = e.clientY + top;
153
- mousePositionChanged = true;
154
- const nextDirection = Math.sign(e.movementX);
155
- distance += Math.abs(e.movementX) + Math.abs(e.movementY);
156
- if (nextDirection !== direction) {
157
- direction = nextDirection;
158
- directionChangeCount++;
159
- }
160
- }, false);
161
- attachListener(document, 'click', (e) => {
162
- const target = getTarget(e.target, document);
163
- if ((!e.clientX && !e.clientY) || target === null) {
164
- return;
165
- }
166
- const id = app.nodes.getID(target);
167
- if (id !== undefined) {
168
- const clickX = e.pageX;
169
- const clickY = e.pageY;
170
- const contentWidth = document.documentElement.scrollWidth;
171
- const contentHeight = document.documentElement.scrollHeight;
172
- const normalizedX = roundNumber(clickX / contentWidth);
173
- const normalizedY = roundNumber(clickY / contentHeight);
174
- sendMouseMove();
175
- app.send((0, messages_gen_js_1.MouseClick)(id, mouseTarget === target ? Math.round(performance.now() - mouseTargetTime) : 0, getTargetLabel(target), isClickable(target) && !disableClickmaps ? getSelector(id, target, options) : '', normalizedX, normalizedY), true);
176
- }
177
- mouseTarget = null;
178
- });
179
- };
180
- app.nodes.attachNodeCallback((node) => {
181
- if ((0, guards_js_1.isDocument)(node)) {
182
- patchDocument(node);
183
- }
184
- });
185
- patchDocument(document, true);
186
- app.ticker.attach(sendMouseMove, options?.trackingOffset || 7);
187
- }
188
- exports.default = default_1;
189
- /**
190
- * we get 0 to 1 decimal number, convert and round it, then turn to %
191
- * 0.39643 => 396.43 => 396 => 39.6%
192
- * */
193
- function roundNumber(num) {
194
- return Math.round(num * 1e4);
195
- }
@@ -1,244 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const messages_gen_js_1 = require("../app/messages.gen.js");
7
- const utils_js_1 = require("../utils.js");
8
- const axiosSpy_js_1 = __importDefault(require("./axiosSpy.js"));
9
- const network_proxy_1 = __importDefault(require("@openreplay/network-proxy"));
10
- function getXHRRequestDataObject(xhr) {
11
- // @ts-ignore this is 3x faster than using Map<XHR, XHRRequestData>
12
- if (!xhr.__or_req_data__) {
13
- // @ts-ignore
14
- xhr.__or_req_data__ = { body: undefined, headers: {} };
15
- }
16
- // @ts-ignore
17
- return xhr.__or_req_data__;
18
- }
19
- function strMethod(method) {
20
- return typeof method === 'string' ? method.toUpperCase() : 'GET';
21
- }
22
- function default_1(app, opts = {}) {
23
- const options = Object.assign({
24
- failuresOnly: false,
25
- ignoreHeaders: ['cookie', 'set-cookie', 'authorization'],
26
- capturePayload: false,
27
- sessionTokenHeader: false,
28
- captureInIframes: true,
29
- axiosInstances: undefined,
30
- useProxy: true,
31
- }, opts);
32
- if (options.useProxy === false) {
33
- app.debug.warn('Network module is migrating to proxy api, to gradually migrate and test it set useProxy to true');
34
- }
35
- const ignoreHeaders = options.ignoreHeaders;
36
- const isHIgnored = Array.isArray(ignoreHeaders)
37
- ? (name) => ignoreHeaders.includes(name)
38
- : () => ignoreHeaders;
39
- const stHeader = options.sessionTokenHeader === true ? 'X-OpenReplay-SessionToken' : options.sessionTokenHeader;
40
- function setSessionTokenHeader(setRequestHeader) {
41
- if (stHeader) {
42
- const sessionToken = app.getSessionToken();
43
- if (sessionToken) {
44
- app.safe(setRequestHeader)(stHeader, sessionToken);
45
- }
46
- }
47
- }
48
- function sanitize(reqResInfo) {
49
- if (!options.capturePayload) {
50
- // @ts-ignore
51
- delete reqResInfo.request.body;
52
- delete reqResInfo.response.body;
53
- }
54
- if (options.sanitizer) {
55
- const resBody = reqResInfo.response.body;
56
- if (typeof resBody === 'string') {
57
- // Parse response in order to have handy view in sanitization function
58
- try {
59
- reqResInfo.response.body = JSON.parse(resBody);
60
- }
61
- catch { }
62
- }
63
- return options.sanitizer(reqResInfo);
64
- }
65
- return reqResInfo;
66
- }
67
- function stringify(r) {
68
- if (r && typeof r.body !== 'string') {
69
- try {
70
- r.body = JSON.stringify(r.body);
71
- }
72
- catch {
73
- r.body = '<unable to stringify>';
74
- app.notify.warn("Openreplay fetch couldn't stringify body:", r.body);
75
- }
76
- }
77
- return JSON.stringify(r);
78
- }
79
- const patchWindow = (context) => {
80
- /* ====== modern way ====== */
81
- if (options.useProxy) {
82
- return (0, network_proxy_1.default)(context, options.ignoreHeaders, setSessionTokenHeader, sanitize, (message) => {
83
- app.send((0, messages_gen_js_1.NetworkRequest)(message.requestType, message.method, message.url, message.request, message.response, message.status, message.startTime + (0, utils_js_1.getTimeOrigin)(), message.duration, message.responseSize));
84
- }, (url) => app.isServiceURL(url), { xhr: true, fetch: true, beacon: true }, options.tokenUrlMatcher);
85
- }
86
- /* ====== Fetch ====== */
87
- const origFetch = context.fetch.bind(context);
88
- const trackFetch = (input, init = {}) => {
89
- if (!(typeof input === 'string' || input instanceof URL) || app.isServiceURL(String(input))) {
90
- return origFetch(input, init);
91
- }
92
- setSessionTokenHeader(function (name, value) {
93
- if (init.headers === undefined) {
94
- init.headers = {};
95
- }
96
- if (init.headers instanceof Headers) {
97
- init.headers.append(name, value);
98
- }
99
- else if (Array.isArray(init.headers)) {
100
- init.headers.push([name, value]);
101
- }
102
- else {
103
- init.headers[name] = value;
104
- }
105
- });
106
- const startTime = performance.now();
107
- return origFetch(input, init).then((response) => {
108
- const duration = performance.now() - startTime;
109
- if (options.failuresOnly && response.status < 400) {
110
- return response;
111
- }
112
- const r = response.clone();
113
- r.text()
114
- .then((text) => {
115
- const reqHs = {};
116
- const resHs = {};
117
- if (ignoreHeaders !== true) {
118
- // request headers
119
- const writeReqHeader = ([n, v]) => {
120
- if (!isHIgnored(n)) {
121
- reqHs[n] = v;
122
- }
123
- };
124
- if (init.headers instanceof Headers) {
125
- init.headers.forEach((v, n) => writeReqHeader([n, v]));
126
- }
127
- else if (Array.isArray(init.headers)) {
128
- init.headers.forEach(writeReqHeader);
129
- }
130
- else if (typeof init.headers === 'object') {
131
- Object.entries(init.headers).forEach(writeReqHeader);
132
- }
133
- // response headers
134
- r.headers.forEach((v, n) => {
135
- if (!isHIgnored(n))
136
- resHs[n] = v;
137
- });
138
- }
139
- const method = strMethod(init.method);
140
- const reqResInfo = sanitize({
141
- url: String(input),
142
- method,
143
- status: r.status,
144
- request: {
145
- headers: reqHs,
146
- // @ts-ignore
147
- body: init.body || null,
148
- },
149
- response: {
150
- headers: resHs,
151
- body: text,
152
- },
153
- });
154
- if (!reqResInfo) {
155
- return;
156
- }
157
- app.send((0, messages_gen_js_1.NetworkRequest)('fetch', method, String(reqResInfo.url), stringify(reqResInfo.request), stringify(reqResInfo.response), r.status, startTime + (0, utils_js_1.getTimeOrigin)(), duration, 0));
158
- })
159
- .catch((e) => app.debug.error('Could not process Fetch response:', e));
160
- return response;
161
- });
162
- };
163
- // @ts-ignore
164
- context.fetch = trackFetch;
165
- /* ====== <> ====== */
166
- /* ====== XHR ====== */
167
- const nativeOpen = context.XMLHttpRequest.prototype.open;
168
- const nativeSetRequestHeader = context.XMLHttpRequest.prototype.setRequestHeader;
169
- const nativeSend = context.XMLHttpRequest.prototype.send;
170
- function trackXMLHttpReqOpen(initMethod, url) {
171
- const xhr = this;
172
- setSessionTokenHeader((name, value) => xhr.setRequestHeader(name, value));
173
- let startTime = 0;
174
- xhr.addEventListener('loadstart', (e) => {
175
- startTime = e.timeStamp;
176
- });
177
- xhr.addEventListener('load', app.safe((e) => {
178
- const { headers: reqHs, body: reqBody } = getXHRRequestDataObject(xhr);
179
- const duration = startTime > 0 ? e.timeStamp - startTime : 0;
180
- const hString = xhr.getAllResponseHeaders() || ''; // might be null (only if no response received though)
181
- const headersArr = hString.trim().split(/[\r\n]+/);
182
- const headerMap = {};
183
- headersArr.forEach(function (line) {
184
- const parts = line.split(': ');
185
- const header = parts.shift();
186
- if (!isHIgnored(header)) {
187
- headerMap[header] = parts.join(': ');
188
- }
189
- });
190
- const method = strMethod(initMethod);
191
- const reqResInfo = sanitize({
192
- url: String(url),
193
- method,
194
- status: xhr.status,
195
- request: {
196
- headers: reqHs,
197
- // @ts-ignore
198
- body: reqBody || null,
199
- },
200
- response: {
201
- headers: headerMap,
202
- body: xhr.response,
203
- },
204
- });
205
- if (!reqResInfo) {
206
- return;
207
- }
208
- app.send((0, messages_gen_js_1.NetworkRequest)('xhr', method, String(reqResInfo.url), stringify(reqResInfo.request), stringify(reqResInfo.response), xhr.status, startTime + (0, utils_js_1.getTimeOrigin)(), duration, 0));
209
- }));
210
- //TODO: handle error (though it has no Error API nor any useful information)
211
- //xhr.addEventListener('error', (e) => {})
212
- return nativeOpen.apply(this, arguments);
213
- }
214
- function trackXHRSend(body) {
215
- const rdo = getXHRRequestDataObject(this);
216
- rdo.body = body;
217
- // @ts-ignore ??? this -> XMLHttpRequest
218
- return nativeSend.apply(this, arguments);
219
- }
220
- function trackSetReqHeader(name, value) {
221
- if (!isHIgnored(name)) {
222
- const rdo = getXHRRequestDataObject(this);
223
- rdo.headers[name] = value;
224
- }
225
- return nativeSetRequestHeader.apply(this, arguments);
226
- }
227
- if (!options.axiosInstances) {
228
- context.XMLHttpRequest.prototype.open = trackXMLHttpReqOpen;
229
- context.XMLHttpRequest.prototype.send = trackXHRSend;
230
- context.XMLHttpRequest.prototype.setRequestHeader = trackSetReqHeader;
231
- }
232
- /* ====== <> ====== */
233
- };
234
- patchWindow(window);
235
- if (options.axiosInstances) {
236
- options.axiosInstances.forEach((axiosInstance) => {
237
- (0, axiosSpy_js_1.default)(app, axiosInstance, options, sanitize, stringify);
238
- });
239
- }
240
- if (options.captureInIframes) {
241
- app.observer.attachContextCallback(app.safe(patchWindow));
242
- }
243
- }
244
- exports.default = default_1;
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jsHeapSizeLimit = exports.deviceMemory = void 0;
4
- const utils_js_1 = require("../utils.js");
5
- const messages_gen_js_1 = require("../app/messages.gen.js");
6
- const perf = utils_js_1.IN_BROWSER && 'performance' in window && 'memory' in performance // works in Chrome only
7
- ? performance
8
- : { memory: {} };
9
- exports.deviceMemory = utils_js_1.IN_BROWSER ? (navigator.deviceMemory || 0) * 1024 : 0;
10
- exports.jsHeapSizeLimit = perf.memory.jsHeapSizeLimit || 0;
11
- function default_1(app, opts) {
12
- const options = Object.assign({
13
- capturePerformance: true,
14
- }, opts);
15
- if (!options.capturePerformance) {
16
- return;
17
- }
18
- let frames;
19
- let ticks;
20
- const nextFrame = () => {
21
- if (frames === undefined || frames === -1) {
22
- return;
23
- }
24
- frames++;
25
- requestAnimationFrame(nextFrame);
26
- };
27
- app.ticker.attach(() => {
28
- if (ticks === undefined || ticks === -1) {
29
- return;
30
- }
31
- ticks++;
32
- }, 0, false);
33
- const sendPerformanceTrack = () => {
34
- if (frames === undefined || ticks === undefined) {
35
- return;
36
- }
37
- app.send((0, messages_gen_js_1.PerformanceTrack)(frames, ticks, perf.memory.totalJSHeapSize || 0, perf.memory.usedJSHeapSize || 0));
38
- ticks = frames = document.hidden ? -1 : 0;
39
- };
40
- app.attachStartCallback(() => {
41
- ticks = frames = -1;
42
- sendPerformanceTrack();
43
- nextFrame();
44
- });
45
- app.attachStopCallback(() => {
46
- ticks = frames = undefined;
47
- });
48
- app.ticker.attach(sendPerformanceTrack, 40, false);
49
- if (document.hidden !== undefined) {
50
- app.attachEventListener(document, 'visibilitychange', sendPerformanceTrack, false, false);
51
- }
52
- }
53
- exports.default = default_1;
@@ -1,84 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const messages_gen_js_1 = require("../app/messages.gen.js");
4
- const guards_js_1 = require("../app/guards.js");
5
- function getDocumentScroll(doc) {
6
- const win = doc.defaultView;
7
- return [
8
- (win && win.scrollX) ||
9
- (doc.documentElement && doc.documentElement.scrollLeft) ||
10
- (doc.body && doc.body.scrollLeft) ||
11
- 0,
12
- (win && win.scrollY) ||
13
- (doc.documentElement && doc.documentElement.scrollTop) ||
14
- (doc.body && doc.body.scrollTop) ||
15
- 0,
16
- ];
17
- }
18
- function default_1(app, insideIframe) {
19
- let documentScroll = false;
20
- const nodeScroll = new Map();
21
- function setNodeScroll(target) {
22
- if (!(0, guards_js_1.isNode)(target)) {
23
- return;
24
- }
25
- if ((0, guards_js_1.isElementNode)(target)) {
26
- nodeScroll.set(target, [target.scrollLeft, target.scrollTop]);
27
- }
28
- if ((0, guards_js_1.isDocument)(target)) {
29
- nodeScroll.set(target, getDocumentScroll(target));
30
- }
31
- }
32
- const sendSetViewportScroll = app.safe(() => {
33
- if (insideIframe) {
34
- return;
35
- }
36
- app.send((0, messages_gen_js_1.SetViewportScroll)(...getDocumentScroll(document)));
37
- });
38
- const sendSetNodeScroll = app.safe((s, node) => {
39
- const id = app.nodes.getID(node);
40
- if (id !== undefined) {
41
- app.send((0, messages_gen_js_1.SetNodeScroll)(id, s[0], s[1]));
42
- }
43
- });
44
- app.attachStartCallback(sendSetViewportScroll);
45
- app.attachStopCallback(() => {
46
- documentScroll = false;
47
- nodeScroll.clear();
48
- });
49
- app.nodes.attachNodeCallback((node, isStart) => {
50
- // MBTODO: iterate over all the nodes on start instead of using isStart hack
51
- if (isStart) {
52
- if ((0, guards_js_1.isElementNode)(node) && node.scrollLeft + node.scrollTop > 0) {
53
- nodeScroll.set(node, [node.scrollLeft, node.scrollTop]);
54
- }
55
- else if ((0, guards_js_1.isDocument)(node)) {
56
- // DRY somehow?
57
- nodeScroll.set(node, getDocumentScroll(node));
58
- }
59
- }
60
- if ((0, guards_js_1.isRootNode)(node)) {
61
- // scroll is not-composed event (https://javascript.info/shadow-dom-events)
62
- app.nodes.attachNodeListener(node, 'scroll', (e) => {
63
- setNodeScroll(e.target);
64
- });
65
- }
66
- });
67
- app.attachEventListener(document, 'scroll', (e) => {
68
- const target = e.target;
69
- if (target === document) {
70
- documentScroll = true;
71
- return;
72
- }
73
- setNodeScroll(target);
74
- });
75
- app.ticker.attach(() => {
76
- if (documentScroll) {
77
- sendSetViewportScroll();
78
- documentScroll = false;
79
- }
80
- nodeScroll.forEach(sendSetNodeScroll);
81
- nodeScroll.clear();
82
- }, 5, false);
83
- }
84
- exports.default = default_1;
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const messages_gen_js_1 = require("../app/messages.gen.js");
4
- function selection(app) {
5
- app.attachEventListener(document, 'selectionchange', () => {
6
- const selection = document.getSelection();
7
- if (selection !== null && !selection.isCollapsed) {
8
- const selectionStart = app.nodes.getID(selection.anchorNode);
9
- const selectionEnd = app.nodes.getID(selection.focusNode);
10
- const selectedText = selection.toString().replace(/\s+/g, ' ');
11
- if (selectionStart && selectionEnd) {
12
- app.send((0, messages_gen_js_1.SelectionChange)(selectionStart, selectionEnd, selectedText));
13
- }
14
- }
15
- else {
16
- app.send((0, messages_gen_js_1.SelectionChange)(-1, -1, ''));
17
- }
18
- });
19
- }
20
- exports.default = selection;
21
- /** TODO: research how to get all in-between nodes inside selection range
22
- * including nodes between anchor and focus nodes and their children
23
- * without recursively searching the dom tree
24
- */
25
- // if (selection.rangeCount) {
26
- // const nodes = [];
27
- // for (let i = 0; i < selection.rangeCount; i++) {
28
- // const range = selection.getRangeAt(i);
29
- // let node: Node | null = range.startContainer;
30
- // while (node) {
31
- // nodes.push(node);
32
- // if (node === range.endContainer) break;
33
- // node = node.nextSibling;
34
- // }
35
- // }
36
- // // send selected nodes
37
- // }
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const messages_gen_js_1 = require("../app/messages.gen.js");
4
- function default_1(app) {
5
- function changeTab() {
6
- if (!document.hidden) {
7
- app.debug.log('Openreplay: tab change to' + app.session.getTabId());
8
- app.send((0, messages_gen_js_1.TabChange)(app.session.getTabId()));
9
- }
10
- }
11
- app.attachEventListener(window, 'focus', changeTab, false, false);
12
- }
13
- exports.default = default_1;