@openreplay/tracker 14.0.10-beta.1 → 14.0.10

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 +27 -49
  2. package/dist/cjs/index.js.map +1 -0
  3. package/{cjs → dist/cjs/main}/app/index.d.ts +38 -6
  4. package/{lib → dist/cjs/main}/app/messages.gen.d.ts +2 -2
  5. package/{lib/app/nodes.d.ts → dist/cjs/main/app/nodes/index.d.ts} +15 -7
  6. package/dist/cjs/main/app/nodes/maintainer.d.ts +28 -0
  7. package/{cjs → dist/cjs/main}/app/observer/iframe_observer.d.ts +1 -1
  8. package/{lib → dist/cjs/main}/app/observer/iframe_offsets.d.ts +1 -1
  9. package/{lib → dist/cjs/main}/app/observer/observer.d.ts +6 -0
  10. package/{lib → dist/cjs/main}/app/observer/top_observer.d.ts +6 -2
  11. package/{cjs → dist/cjs/main}/app/sanitizer.d.ts +5 -2
  12. package/{cjs → dist/cjs/main}/app/session.d.ts +6 -3
  13. package/{lib → dist/cjs/main}/index.d.ts +2 -2
  14. package/{lib → dist/cjs/main}/modules/attributeSender.d.ts +5 -2
  15. package/{cjs → dist/cjs/main}/modules/conditionsManager.d.ts +1 -1
  16. package/{cjs → dist/cjs/main}/modules/tagWatcher.d.ts +8 -4
  17. package/{lib → dist/cjs/main}/modules/userTesting/SignalManager.d.ts +2 -2
  18. package/{lib → dist/cjs/main}/utils.d.ts +4 -3
  19. package/dist/lib/index.js +9323 -0
  20. package/dist/lib/index.js.map +1 -0
  21. package/{lib → dist/lib/main}/app/index.d.ts +38 -6
  22. package/{cjs → dist/lib/main}/app/messages.gen.d.ts +2 -2
  23. package/{cjs/app/nodes.d.ts → dist/lib/main/app/nodes/index.d.ts} +15 -7
  24. package/dist/lib/main/app/nodes/maintainer.d.ts +28 -0
  25. package/{lib → dist/lib/main}/app/observer/iframe_observer.d.ts +1 -1
  26. package/{cjs → dist/lib/main}/app/observer/iframe_offsets.d.ts +1 -1
  27. package/{cjs → dist/lib/main}/app/observer/observer.d.ts +6 -0
  28. package/{cjs → dist/lib/main}/app/observer/top_observer.d.ts +6 -2
  29. package/{lib → dist/lib/main}/app/sanitizer.d.ts +5 -2
  30. package/{lib → dist/lib/main}/app/session.d.ts +6 -3
  31. package/{cjs → dist/lib/main}/index.d.ts +2 -2
  32. package/{cjs → dist/lib/main}/modules/attributeSender.d.ts +5 -2
  33. package/{lib → dist/lib/main}/modules/conditionsManager.d.ts +1 -1
  34. package/{lib → dist/lib/main}/modules/tagWatcher.d.ts +8 -4
  35. package/{cjs → dist/lib/main}/modules/userTesting/SignalManager.d.ts +2 -2
  36. package/{cjs → dist/lib/main}/utils.d.ts +4 -3
  37. package/package.json +29 -10
  38. package/.eslintignore +0 -11
  39. package/.nvmrc +0 -1
  40. package/.prettierignore +0 -1
  41. package/CHANGELOG.md +0 -297
  42. package/bun.lockb +0 -0
  43. package/cjs/app/canvas.js +0 -204
  44. package/cjs/app/guards.js +0 -37
  45. package/cjs/app/index.js +0 -1366
  46. package/cjs/app/logger.js +0 -37
  47. package/cjs/app/messages.gen.js +0 -702
  48. package/cjs/app/nodes.js +0 -110
  49. package/cjs/app/observer/iframe_observer.js +0 -35
  50. package/cjs/app/observer/iframe_offsets.js +0 -56
  51. package/cjs/app/observer/observer.js +0 -352
  52. package/cjs/app/observer/shadow_root_observer.js +0 -24
  53. package/cjs/app/observer/top_observer.js +0 -134
  54. package/cjs/app/sanitizer.js +0 -82
  55. package/cjs/app/session.js +0 -140
  56. package/cjs/app/ticker.js +0 -48
  57. package/cjs/common/interaction.js +0 -2
  58. package/cjs/common/messages.gen.js +0 -4
  59. package/cjs/modules/attributeSender.js +0 -51
  60. package/cjs/modules/axiosSpy.js +0 -122
  61. package/cjs/modules/conditionsManager.js +0 -343
  62. package/cjs/modules/connection.js +0 -15
  63. package/cjs/modules/console.js +0 -127
  64. package/cjs/modules/constructedStyleSheets.js +0 -138
  65. package/cjs/modules/cssrules.js +0 -99
  66. package/cjs/modules/exception.js +0 -85
  67. package/cjs/modules/featureFlags.js +0 -89
  68. package/cjs/modules/focus.js +0 -45
  69. package/cjs/modules/fonts.js +0 -57
  70. package/cjs/modules/img.js +0 -110
  71. package/cjs/modules/input.js +0 -203
  72. package/cjs/modules/mouse.js +0 -195
  73. package/cjs/modules/network.js +0 -244
  74. package/cjs/modules/performance.js +0 -53
  75. package/cjs/modules/scroll.js +0 -84
  76. package/cjs/modules/selection.js +0 -37
  77. package/cjs/modules/tabs.js +0 -13
  78. package/cjs/modules/tagWatcher.js +0 -76
  79. package/cjs/modules/timing.js +0 -173
  80. package/cjs/modules/userTesting/SignalManager.js +0 -83
  81. package/cjs/modules/userTesting/dnd.js +0 -40
  82. package/cjs/modules/userTesting/index.js +0 -464
  83. package/cjs/modules/userTesting/recorder.js +0 -101
  84. package/cjs/modules/userTesting/styles.js +0 -266
  85. package/cjs/modules/userTesting/utils.js +0 -87
  86. package/cjs/modules/viewport.js +0 -43
  87. package/cjs/package.json +0 -1
  88. package/cjs/utils.js +0 -230
  89. package/coverage/clover.xml +0 -4304
  90. package/coverage/coverage-final.json +0 -55
  91. package/coverage/lcov-report/base.css +0 -224
  92. package/coverage/lcov-report/block-navigation.js +0 -87
  93. package/coverage/lcov-report/favicon.png +0 -0
  94. package/coverage/lcov-report/index.html +0 -206
  95. package/coverage/lcov-report/main/app/canvas.ts.html +0 -712
  96. package/coverage/lcov-report/main/app/guards.ts.html +0 -232
  97. package/coverage/lcov-report/main/app/index.html +0 -236
  98. package/coverage/lcov-report/main/app/index.ts.html +0 -3955
  99. package/coverage/lcov-report/main/app/logger.ts.html +0 -211
  100. package/coverage/lcov-report/main/app/messages.gen.ts.html +0 -3034
  101. package/coverage/lcov-report/main/app/nodes.ts.html +0 -406
  102. package/coverage/lcov-report/main/app/observer/iframe_observer.ts.html +0 -148
  103. package/coverage/lcov-report/main/app/observer/iframe_offsets.ts.html +0 -289
  104. package/coverage/lcov-report/main/app/observer/index.html +0 -161
  105. package/coverage/lcov-report/main/app/observer/shadow_root_observer.ts.html +0 -142
  106. package/coverage/lcov-report/main/app/observer/top_observer.ts.html +0 -541
  107. package/coverage/lcov-report/main/app/sanitizer.ts.html +0 -403
  108. package/coverage/lcov-report/main/app/session.ts.html +0 -622
  109. package/coverage/lcov-report/main/app/ticker.ts.html +0 -250
  110. package/coverage/lcov-report/main/index.html +0 -131
  111. package/coverage/lcov-report/main/index.ts.html +0 -1597
  112. package/coverage/lcov-report/main/modules/Network/beaconProxy.ts.html +0 -400
  113. package/coverage/lcov-report/main/modules/Network/fetchProxy.ts.html +0 -1075
  114. package/coverage/lcov-report/main/modules/Network/index.html +0 -191
  115. package/coverage/lcov-report/main/modules/Network/index.ts.html +0 -244
  116. package/coverage/lcov-report/main/modules/Network/networkMessage.ts.html +0 -400
  117. package/coverage/lcov-report/main/modules/Network/utils.ts.html +0 -709
  118. package/coverage/lcov-report/main/modules/Network/xhrProxy.ts.html +0 -877
  119. package/coverage/lcov-report/main/modules/attributeSender.ts.html +0 -241
  120. package/coverage/lcov-report/main/modules/axiosSpy.ts.html +0 -709
  121. package/coverage/lcov-report/main/modules/conditionsManager.ts.html +0 -1381
  122. package/coverage/lcov-report/main/modules/connection.ts.html +0 -160
  123. package/coverage/lcov-report/main/modules/console.ts.html +0 -541
  124. package/coverage/lcov-report/main/modules/constructedStyleSheets.ts.html +0 -571
  125. package/coverage/lcov-report/main/modules/cssrules.ts.html +0 -418
  126. package/coverage/lcov-report/main/modules/exception.ts.html +0 -385
  127. package/coverage/lcov-report/main/modules/featureFlags.ts.html +0 -415
  128. package/coverage/lcov-report/main/modules/focus.ts.html +0 -220
  129. package/coverage/lcov-report/main/modules/fonts.ts.html +0 -289
  130. package/coverage/lcov-report/main/modules/img.ts.html +0 -436
  131. package/coverage/lcov-report/main/modules/index.html +0 -431
  132. package/coverage/lcov-report/main/modules/input.ts.html +0 -826
  133. package/coverage/lcov-report/main/modules/mouse.ts.html +0 -826
  134. package/coverage/lcov-report/main/modules/network.ts.html +0 -1123
  135. package/coverage/lcov-report/main/modules/performance.ts.html +0 -367
  136. package/coverage/lcov-report/main/modules/scroll.ts.html +0 -364
  137. package/coverage/lcov-report/main/modules/selection.ts.html +0 -202
  138. package/coverage/lcov-report/main/modules/tabs.ts.html +0 -124
  139. package/coverage/lcov-report/main/modules/tagWatcher.ts.html +0 -337
  140. package/coverage/lcov-report/main/modules/timing.ts.html +0 -877
  141. package/coverage/lcov-report/main/modules/userTesting/SignalManager.ts.html +0 -370
  142. package/coverage/lcov-report/main/modules/userTesting/dnd.ts.html +0 -220
  143. package/coverage/lcov-report/main/modules/userTesting/index.html +0 -191
  144. package/coverage/lcov-report/main/modules/userTesting/index.ts.html +0 -1909
  145. package/coverage/lcov-report/main/modules/userTesting/recorder.ts.html +0 -430
  146. package/coverage/lcov-report/main/modules/userTesting/styles.ts.html +0 -937
  147. package/coverage/lcov-report/main/modules/userTesting/utils.ts.html +0 -364
  148. package/coverage/lcov-report/main/modules/viewport.ts.html +0 -250
  149. package/coverage/lcov-report/main/utils.ts.html +0 -814
  150. package/coverage/lcov-report/prettify.css +0 -1
  151. package/coverage/lcov-report/prettify.js +0 -2
  152. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  153. package/coverage/lcov-report/sorter.js +0 -196
  154. package/coverage/lcov-report/webworker/BatchWriter.ts.html +0 -499
  155. package/coverage/lcov-report/webworker/MessageEncoder.gen.ts.html +0 -1021
  156. package/coverage/lcov-report/webworker/PrimitiveEncoder.ts.html +0 -436
  157. package/coverage/lcov-report/webworker/QueueSender.ts.html +0 -547
  158. package/coverage/lcov-report/webworker/index.html +0 -176
  159. package/coverage/lcov-report/webworker/index.ts.html +0 -667
  160. package/coverage/lcov.info +0 -8425
  161. package/jest.config.js +0 -13
  162. package/lib/app/canvas.js +0 -202
  163. package/lib/app/guards.js +0 -26
  164. package/lib/app/index.js +0 -1336
  165. package/lib/app/logger.js +0 -33
  166. package/lib/app/messages.gen.js +0 -622
  167. package/lib/app/nodes.js +0 -107
  168. package/lib/app/observer/iframe_observer.js +0 -29
  169. package/lib/app/observer/iframe_offsets.js +0 -53
  170. package/lib/app/observer/observer.js +0 -349
  171. package/lib/app/observer/shadow_root_observer.js +0 -18
  172. package/lib/app/observer/top_observer.js +0 -128
  173. package/lib/app/sanitizer.js +0 -77
  174. package/lib/app/session.js +0 -137
  175. package/lib/app/ticker.js +0 -45
  176. package/lib/common/interaction.js +0 -1
  177. package/lib/common/messages.gen.js +0 -3
  178. package/lib/common/tsconfig.tsbuildinfo +0 -1
  179. package/lib/index.js +0 -423
  180. package/lib/modules/attributeSender.js +0 -46
  181. package/lib/modules/axiosSpy.js +0 -119
  182. package/lib/modules/conditionsManager.js +0 -340
  183. package/lib/modules/connection.js +0 -12
  184. package/lib/modules/console.js +0 -124
  185. package/lib/modules/constructedStyleSheets.js +0 -133
  186. package/lib/modules/cssrules.js +0 -97
  187. package/lib/modules/exception.js +0 -76
  188. package/lib/modules/featureFlags.js +0 -86
  189. package/lib/modules/focus.js +0 -42
  190. package/lib/modules/fonts.js +0 -54
  191. package/lib/modules/img.js +0 -107
  192. package/lib/modules/input.js +0 -198
  193. package/lib/modules/mouse.js +0 -192
  194. package/lib/modules/network.js +0 -238
  195. package/lib/modules/performance.js +0 -49
  196. package/lib/modules/scroll.js +0 -81
  197. package/lib/modules/selection.js +0 -35
  198. package/lib/modules/tabs.js +0 -10
  199. package/lib/modules/tagWatcher.js +0 -73
  200. package/lib/modules/timing.js +0 -170
  201. package/lib/modules/userTesting/SignalManager.js +0 -80
  202. package/lib/modules/userTesting/dnd.js +0 -37
  203. package/lib/modules/userTesting/index.js +0 -435
  204. package/lib/modules/userTesting/recorder.js +0 -97
  205. package/lib/modules/userTesting/styles.js +0 -263
  206. package/lib/modules/userTesting/utils.js +0 -79
  207. package/lib/modules/viewport.js +0 -40
  208. package/lib/utils.js +0 -211
  209. package/rollup.config.js +0 -12
  210. package/scripts/checkver.cjs +0 -7
  211. package/tsconfig-base.json +0 -16
  212. /package/{cjs → dist/cjs}/common/interaction.d.ts +0 -0
  213. /package/{cjs → dist/cjs}/common/messages.gen.d.ts +0 -0
  214. /package/{cjs → dist/cjs/main}/app/canvas.d.ts +0 -0
  215. /package/{cjs → dist/cjs/main}/app/guards.d.ts +0 -0
  216. /package/{cjs → dist/cjs/main}/app/logger.d.ts +0 -0
  217. /package/{cjs → dist/cjs/main}/app/observer/shadow_root_observer.d.ts +0 -0
  218. /package/{cjs → dist/cjs/main}/app/ticker.d.ts +0 -0
  219. /package/{cjs → dist/cjs/main}/modules/axiosSpy.d.ts +0 -0
  220. /package/{cjs → dist/cjs/main}/modules/connection.d.ts +0 -0
  221. /package/{cjs → dist/cjs/main}/modules/console.d.ts +0 -0
  222. /package/{cjs → dist/cjs/main}/modules/constructedStyleSheets.d.ts +0 -0
  223. /package/{cjs → dist/cjs/main}/modules/cssrules.d.ts +0 -0
  224. /package/{cjs → dist/cjs/main}/modules/exception.d.ts +0 -0
  225. /package/{cjs → dist/cjs/main}/modules/featureFlags.d.ts +0 -0
  226. /package/{cjs → dist/cjs/main}/modules/focus.d.ts +0 -0
  227. /package/{cjs → dist/cjs/main}/modules/fonts.d.ts +0 -0
  228. /package/{cjs → dist/cjs/main}/modules/img.d.ts +0 -0
  229. /package/{cjs → dist/cjs/main}/modules/input.d.ts +0 -0
  230. /package/{cjs → dist/cjs/main}/modules/mouse.d.ts +0 -0
  231. /package/{cjs → dist/cjs/main}/modules/network.d.ts +0 -0
  232. /package/{cjs → dist/cjs/main}/modules/performance.d.ts +0 -0
  233. /package/{cjs → dist/cjs/main}/modules/scroll.d.ts +0 -0
  234. /package/{cjs → dist/cjs/main}/modules/selection.d.ts +0 -0
  235. /package/{cjs → dist/cjs/main}/modules/tabs.d.ts +0 -0
  236. /package/{cjs → dist/cjs/main}/modules/timing.d.ts +0 -0
  237. /package/{cjs → dist/cjs/main}/modules/userTesting/dnd.d.ts +0 -0
  238. /package/{cjs → dist/cjs/main}/modules/userTesting/index.d.ts +0 -0
  239. /package/{cjs → dist/cjs/main}/modules/userTesting/recorder.d.ts +0 -0
  240. /package/{cjs → dist/cjs/main}/modules/userTesting/styles.d.ts +0 -0
  241. /package/{cjs → dist/cjs/main}/modules/userTesting/utils.d.ts +0 -0
  242. /package/{cjs → dist/cjs/main}/modules/viewport.d.ts +0 -0
  243. /package/{lib → dist/lib}/common/interaction.d.ts +0 -0
  244. /package/{lib → dist/lib}/common/messages.gen.d.ts +0 -0
  245. /package/{lib → dist/lib/main}/app/canvas.d.ts +0 -0
  246. /package/{lib → dist/lib/main}/app/guards.d.ts +0 -0
  247. /package/{lib → dist/lib/main}/app/logger.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,134 +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 observer_js_1 = __importDefault(require("./observer.js"));
7
- const guards_js_1 = require("../guards.js");
8
- const iframe_observer_js_1 = __importDefault(require("./iframe_observer.js"));
9
- const shadow_root_observer_js_1 = __importDefault(require("./shadow_root_observer.js"));
10
- const iframe_offsets_js_1 = __importDefault(require("./iframe_offsets.js"));
11
- const messages_gen_js_1 = require("../messages.gen.js");
12
- const utils_js_1 = require("../../utils.js");
13
- const attachShadowNativeFn = utils_js_1.IN_BROWSER ? Element.prototype.attachShadow : () => new ShadowRoot();
14
- class TopObserver extends observer_js_1.default {
15
- constructor(app, options) {
16
- super(app, true);
17
- this.iframeOffsets = new iframe_offsets_js_1.default();
18
- this.contextCallbacks = [];
19
- // Attached once per Tracker instance
20
- this.contextsSet = new Set();
21
- this.iframeObservers = [];
22
- this.shadowRootObservers = [];
23
- this.options = Object.assign({
24
- captureIFrames: true,
25
- }, options);
26
- // IFrames
27
- this.app.nodes.attachNodeCallback((node) => {
28
- if ((0, guards_js_1.hasTag)(node, 'iframe') &&
29
- ((this.options.captureIFrames && !(0, utils_js_1.hasOpenreplayAttribute)(node, 'obscured')) ||
30
- (0, utils_js_1.hasOpenreplayAttribute)(node, 'capture'))) {
31
- this.handleIframe(node);
32
- }
33
- });
34
- // ShadowDOM
35
- this.app.nodes.attachNodeCallback((node) => {
36
- if ((0, guards_js_1.isElementNode)(node) && node.shadowRoot !== null) {
37
- this.handleShadowRoot(node.shadowRoot);
38
- }
39
- });
40
- }
41
- attachContextCallback(cb) {
42
- this.contextCallbacks.push(cb);
43
- }
44
- getDocumentOffset(doc) {
45
- return this.iframeOffsets.getDocumentOffset(doc);
46
- }
47
- handleIframe(iframe) {
48
- let doc = null;
49
- // setTimeout is required. Otherwise some event listeners (scroll, mousemove) applied in modules
50
- // do not work on the iframe document when it 've been loaded dynamically ((why?))
51
- const handle = this.app.safe(() => setTimeout(() => {
52
- const id = this.app.nodes.getID(iframe);
53
- if (id === undefined) {
54
- //log
55
- return;
56
- }
57
- if (!(0, utils_js_1.canAccessIframe)(iframe))
58
- return;
59
- const currentWin = iframe.contentWindow;
60
- const currentDoc = iframe.contentDocument;
61
- if (currentDoc && currentDoc !== doc) {
62
- const observer = new iframe_observer_js_1.default(this.app);
63
- this.iframeObservers.push(observer);
64
- observer.observe(iframe); // TODO: call unregisterNode for the previous doc if present (incapsulate: one iframe - one observer)
65
- doc = currentDoc;
66
- this.iframeOffsets.observe(iframe);
67
- }
68
- if (currentWin &&
69
- // Sometimes currentWin.window is null (not in specification). Such window object is not functional
70
- currentWin === currentWin.window &&
71
- !this.contextsSet.has(currentWin) // for each context callbacks called once per Tracker (TopObserver) instance
72
- //TODO: more explicit logic
73
- ) {
74
- this.contextsSet.add(currentWin);
75
- //@ts-ignore https://github.com/microsoft/TypeScript/issues/41684
76
- this.contextCallbacks.forEach((cb) => cb(currentWin));
77
- }
78
- // we need this delay because few iframes stacked one in another with rapid updates will break the player (or browser engine rather?)
79
- }, 100));
80
- iframe.addEventListener('load', handle); // why app.attachEventListener not working?
81
- handle();
82
- }
83
- handleShadowRoot(shRoot) {
84
- const observer = new shadow_root_observer_js_1.default(this.app);
85
- this.shadowRootObservers.push(observer);
86
- observer.observe(shRoot.host);
87
- }
88
- observe() {
89
- // Protection from several subsequent calls?
90
- const observer = this;
91
- Element.prototype.attachShadow = function () {
92
- // eslint-disable-next-line
93
- const shadow = attachShadowNativeFn.apply(this, arguments);
94
- observer.handleShadowRoot(shadow);
95
- return shadow;
96
- };
97
- this.app.nodes.clear();
98
- // Can observe documentElement (<html>) here, because it is not supposed to be changing.
99
- // However, it is possible in some exotic cases and may cause an ignorance of the newly created <html>
100
- // In this case context.document have to be observed, but this will cause
101
- // the change in the re-player behaviour caused by CreateDocument message:
102
- // the 0-node ("fRoot") will become #document rather than documentElement as it is now.
103
- // Alternatively - observe(#document) then bindNode(documentElement)
104
- this.observeRoot(window.document, () => {
105
- this.app.send((0, messages_gen_js_1.CreateDocument)());
106
- // it has no node_id here
107
- this.app.nodes.callNodeCallbacks(document, true);
108
- }, window.document.documentElement);
109
- }
110
- crossdomainObserve(selfId, frameOder) {
111
- const observer = this;
112
- Element.prototype.attachShadow = function () {
113
- // eslint-disable-next-line
114
- const shadow = attachShadowNativeFn.apply(this, arguments);
115
- observer.handleShadowRoot(shadow);
116
- return shadow;
117
- };
118
- this.app.nodes.clear();
119
- this.app.nodes.syntheticMode(frameOder);
120
- const iframeObserver = new iframe_observer_js_1.default(this.app);
121
- this.iframeObservers.push(iframeObserver);
122
- iframeObserver.syntheticObserve(selfId, window.document);
123
- }
124
- disconnect() {
125
- this.iframeOffsets.clear();
126
- Element.prototype.attachShadow = attachShadowNativeFn;
127
- this.iframeObservers.forEach((o) => o.disconnect());
128
- this.iframeObservers = [];
129
- this.shadowRootObservers.forEach((o) => o.disconnect());
130
- this.shadowRootObservers = [];
131
- super.disconnect();
132
- }
133
- }
134
- exports.default = TopObserver;
@@ -1,82 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.stringWiper = exports.SanitizeLevel = void 0;
4
- const utils_js_1 = require("../utils.js");
5
- const guards_js_1 = require("./guards.js");
6
- var SanitizeLevel;
7
- (function (SanitizeLevel) {
8
- SanitizeLevel[SanitizeLevel["Plain"] = 0] = "Plain";
9
- SanitizeLevel[SanitizeLevel["Obscured"] = 1] = "Obscured";
10
- SanitizeLevel[SanitizeLevel["Hidden"] = 2] = "Hidden";
11
- })(SanitizeLevel = exports.SanitizeLevel || (exports.SanitizeLevel = {}));
12
- const stringWiper = (input) => input
13
- .trim()
14
- .replace(/[^\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/g, '█');
15
- exports.stringWiper = stringWiper;
16
- class Sanitizer {
17
- constructor(app, options) {
18
- this.app = app;
19
- this.obscured = new Set();
20
- this.hidden = new Set();
21
- this.options = Object.assign({
22
- obscureTextEmails: true,
23
- obscureTextNumbers: false,
24
- }, options);
25
- }
26
- handleNode(id, parentID, node) {
27
- if (this.obscured.has(parentID) ||
28
- ((0, guards_js_1.isElementNode)(node) &&
29
- ((0, utils_js_1.hasOpenreplayAttribute)(node, 'masked') || (0, utils_js_1.hasOpenreplayAttribute)(node, 'obscured')))) {
30
- this.obscured.add(id);
31
- }
32
- if (this.hidden.has(parentID) ||
33
- ((0, guards_js_1.isElementNode)(node) &&
34
- ((0, utils_js_1.hasOpenreplayAttribute)(node, 'htmlmasked') || (0, utils_js_1.hasOpenreplayAttribute)(node, 'hidden')))) {
35
- this.hidden.add(id);
36
- }
37
- if (this.options.domSanitizer !== undefined && (0, guards_js_1.isElementNode)(node)) {
38
- const sanitizeLevel = this.options.domSanitizer(node);
39
- if (sanitizeLevel === SanitizeLevel.Obscured) {
40
- this.obscured.add(id);
41
- }
42
- if (sanitizeLevel === SanitizeLevel.Hidden) {
43
- this.hidden.add(id);
44
- }
45
- }
46
- }
47
- sanitize(id, data) {
48
- if (this.obscured.has(id)) {
49
- // TODO: is it the best place to put trim() ? Might trimmed spaces be considered in layout in certain cases?
50
- return (0, exports.stringWiper)(data);
51
- }
52
- if (this.options.obscureTextNumbers) {
53
- data = data.replace(/\d/g, '0');
54
- }
55
- if (this.options.obscureTextEmails) {
56
- data = data.replace(/^\w+([+.-]\w+)*@\w+([.-]\w+)*\.\w{2,3}$/g, (email) => {
57
- const [name, domain] = email.split('@');
58
- const [domainName, host] = domain.split('.');
59
- return `${(0, utils_js_1.stars)(name)}@${(0, utils_js_1.stars)(domainName)}.${(0, utils_js_1.stars)(host)}`;
60
- });
61
- }
62
- return data;
63
- }
64
- isObscured(id) {
65
- return this.obscured.has(id);
66
- }
67
- isHidden(id) {
68
- return this.hidden.has(id);
69
- }
70
- getInnerTextSecure(el) {
71
- const id = this.app.nodes.getID(el);
72
- if (!id) {
73
- return '';
74
- }
75
- return this.sanitize(id, el.innerText);
76
- }
77
- clear() {
78
- this.obscured.clear();
79
- this.hidden.clear();
80
- }
81
- }
82
- exports.default = Sanitizer;
@@ -1,140 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_js_1 = require("../utils.js");
4
- class Session {
5
- constructor(app, options) {
6
- this.app = app;
7
- this.options = options;
8
- this.metadata = {};
9
- this.userID = null;
10
- this.callbacks = [];
11
- this.timestamp = 0;
12
- this.createTabId();
13
- }
14
- attachUpdateCallback(cb) {
15
- this.callbacks.push(cb);
16
- }
17
- handleUpdate(newInfo) {
18
- if (newInfo.userID == null) {
19
- delete newInfo.userID;
20
- }
21
- if (newInfo.sessionID == null) {
22
- delete newInfo.sessionID;
23
- }
24
- this.callbacks.forEach((cb) => cb(newInfo));
25
- }
26
- assign(newInfo) {
27
- if (newInfo.userID !== undefined) {
28
- // TODO clear nullable/undefinable types
29
- this.userID = newInfo.userID;
30
- }
31
- if (newInfo.metadata !== undefined) {
32
- Object.entries(newInfo.metadata).forEach(([k, v]) => (this.metadata[k] = v));
33
- }
34
- if (newInfo.sessionID !== undefined) {
35
- this.sessionID = newInfo.sessionID;
36
- }
37
- if (newInfo.timestamp !== undefined) {
38
- this.timestamp = newInfo.timestamp;
39
- }
40
- if (newInfo.projectID !== undefined) {
41
- this.projectID = newInfo.projectID;
42
- }
43
- this.handleUpdate(newInfo);
44
- }
45
- setMetadata(key, value) {
46
- this.metadata[key] = value;
47
- this.handleUpdate({ metadata: { [key]: value } });
48
- }
49
- setUserID(userID) {
50
- this.userID = userID;
51
- this.handleUpdate({ userID });
52
- }
53
- setUserInfo(userInfo) {
54
- this.userInfo = userInfo;
55
- }
56
- getPageNumber() {
57
- const pageNoStr = this.app.sessionStorage.getItem(this.options.session_pageno_key);
58
- if (pageNoStr == null) {
59
- return undefined;
60
- }
61
- return parseInt(pageNoStr);
62
- }
63
- incPageNo() {
64
- let pageNo = this.getPageNumber();
65
- if (pageNo === undefined) {
66
- pageNo = 0;
67
- }
68
- else {
69
- pageNo++;
70
- }
71
- this.app.sessionStorage.setItem(this.options.session_pageno_key, pageNo.toString());
72
- return pageNo;
73
- }
74
- getSessionToken() {
75
- const token = this.token || this.app.sessionStorage.getItem(this.options.session_token_key);
76
- return token || undefined;
77
- }
78
- setSessionToken(token) {
79
- this.token = token;
80
- this.app.sessionStorage.setItem(this.options.session_token_key, token);
81
- }
82
- applySessionHash(hash) {
83
- const hashParts = decodeURI(hash).split('&');
84
- let token = hash;
85
- let pageNoStr = '100500'; // back-compat for sessionToken
86
- if (hashParts.length == 2) {
87
- ;
88
- [pageNoStr, token] = hashParts;
89
- }
90
- if (!pageNoStr || !token) {
91
- return;
92
- }
93
- this.app.sessionStorage.setItem(this.options.session_token_key, token);
94
- this.app.sessionStorage.setItem(this.options.session_pageno_key, pageNoStr);
95
- }
96
- getSessionHash() {
97
- const pageNo = this.getPageNumber();
98
- const token = this.getSessionToken();
99
- if (pageNo === undefined || token === undefined) {
100
- return;
101
- }
102
- return encodeURI(String(pageNo) + '&' + token);
103
- }
104
- getTabId() {
105
- if (!this.tabId)
106
- this.createTabId();
107
- return this.tabId;
108
- }
109
- regenerateTabId() {
110
- const randomId = (0, utils_js_1.generateRandomId)(12);
111
- this.app.sessionStorage.setItem(this.options.session_tabid_key, randomId);
112
- this.tabId = randomId;
113
- }
114
- createTabId() {
115
- const localId = this.app.sessionStorage.getItem(this.options.session_tabid_key);
116
- if (localId) {
117
- this.tabId = localId;
118
- }
119
- else {
120
- this.regenerateTabId();
121
- }
122
- }
123
- getInfo() {
124
- return {
125
- sessionID: this.sessionID,
126
- metadata: this.metadata,
127
- userID: this.userID,
128
- timestamp: this.timestamp,
129
- projectID: this.projectID,
130
- };
131
- }
132
- reset() {
133
- this.app.sessionStorage.removeItem(this.options.session_token_key);
134
- this.metadata = {};
135
- this.userID = null;
136
- this.sessionID = undefined;
137
- this.timestamp = 0;
138
- }
139
- }
140
- exports.default = Session;
package/cjs/app/ticker.js DELETED
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function wrap(callback, n) {
4
- let t = 0;
5
- return () => {
6
- if (t++ >= n) {
7
- t = 0;
8
- callback();
9
- }
10
- };
11
- }
12
- class Ticker {
13
- constructor(app) {
14
- this.app = app;
15
- this.timer = null;
16
- this.callbacks = [];
17
- }
18
- /**
19
- * @param {Callback} callback - repeated cb
20
- * @param {number} n - number of turn skips; ticker have a 30 ms cycle
21
- * @param {boolean} useSafe - using safe wrapper to check if app is active
22
- * @param {object} thisArg - link to <this>
23
- * */
24
- attach(callback, n = 0, useSafe = true, thisArg) {
25
- if (thisArg) {
26
- callback = callback.bind(thisArg);
27
- }
28
- if (useSafe) {
29
- callback = this.app.safe(callback);
30
- }
31
- this.callbacks.unshift(n ? wrap(callback, n) : callback) - 1;
32
- }
33
- start() {
34
- if (this.timer === null) {
35
- this.timer = setInterval(() => this.callbacks.forEach((cb) => {
36
- if (cb)
37
- cb();
38
- }), 30);
39
- }
40
- }
41
- stop() {
42
- if (this.timer !== null) {
43
- clearInterval(this.timer);
44
- this.timer = null;
45
- }
46
- }
47
- }
48
- exports.default = Ticker;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +0,0 @@
1
- "use strict";
2
- // Auto-generated, do not edit
3
- /* eslint-disable */
4
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StringDictionary = void 0;
4
- class StringDictionary {
5
- constructor() {
6
- this.idx = 1;
7
- this.backDict = {};
8
- }
9
- getKey(str) {
10
- let isNew = false;
11
- if (!this.backDict[str]) {
12
- isNew = true;
13
- this.backDict[str] = this.idx++;
14
- }
15
- return [this.backDict[str], isNew];
16
- }
17
- }
18
- exports.StringDictionary = StringDictionary;
19
- class AttributeSender {
20
- constructor(app, isDictDisabled) {
21
- this.app = app;
22
- this.isDictDisabled = isDictDisabled;
23
- this.dict = new StringDictionary();
24
- }
25
- sendSetAttribute(id, name, value) {
26
- if (this.isDictDisabled) {
27
- const msg = [12 /* Type.SetNodeAttribute */, id, name, value];
28
- return this.app.send(msg);
29
- }
30
- else {
31
- const message = [
32
- 51 /* Type.SetNodeAttributeDict */,
33
- id,
34
- this.applyDict(name),
35
- this.applyDict(value),
36
- ];
37
- return this.app.send(message);
38
- }
39
- }
40
- applyDict(str) {
41
- const [key, isNew] = this.dict.getKey(str);
42
- if (isNew) {
43
- this.app.send([50 /* Type.StringDict */, key, str]);
44
- }
45
- return key;
46
- }
47
- clear() {
48
- this.dict = new StringDictionary();
49
- }
50
- }
51
- exports.default = AttributeSender;
@@ -1,122 +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 utils_js_1 = require("../utils.js");
5
- const exception_js_1 = require("./exception.js");
6
- function default_1(app, instance, opts, sanitize, stringify) {
7
- app.debug.log('Openreplay: attaching axios spy to instance', instance);
8
- function captureResponseData(axiosResponseObj) {
9
- app.debug.log('Openreplay: capturing axios response data', axiosResponseObj);
10
- const { headers: reqHs, data: reqData, method, url, baseURL } = axiosResponseObj.config;
11
- const { data: rData, headers: rHs, status: globStatus, response } = axiosResponseObj;
12
- const { data: resData, headers: resHs, status: resStatus } = response || {};
13
- const ihOpt = opts.ignoreHeaders;
14
- const isHIgnoring = Array.isArray(ihOpt) ? (name) => ihOpt.includes(name) : () => ihOpt;
15
- function writeHeader(hsObj, header) {
16
- if (!isHIgnoring(header[0])) {
17
- hsObj[header[0]] = header[1];
18
- }
19
- }
20
- let requestHs = {};
21
- let responseHs = {};
22
- if (reqHs.toJSON) {
23
- requestHs = reqHs.toJSON();
24
- }
25
- else if (reqHs instanceof Headers) {
26
- reqHs.forEach((v, n) => writeHeader(requestHs, [n, v]));
27
- }
28
- else if (Array.isArray(reqHs)) {
29
- reqHs.forEach((h) => writeHeader(requestHs, h));
30
- }
31
- else if (typeof reqHs === 'object') {
32
- Object.entries(reqHs).forEach((h) => writeHeader(requestHs, h));
33
- }
34
- const usedResHeader = resHs ? resHs : rHs;
35
- if (usedResHeader.toJSON) {
36
- responseHs = usedResHeader.toJSON();
37
- }
38
- else if (usedResHeader instanceof Headers) {
39
- usedResHeader.forEach((v, n) => writeHeader(responseHs, [n, v]));
40
- }
41
- else if (Array.isArray(usedResHeader)) {
42
- usedResHeader.forEach((h) => writeHeader(responseHs, h));
43
- }
44
- else if (typeof usedResHeader === 'object') {
45
- Object.entries(usedResHeader).forEach(([n, v]) => {
46
- if (!isHIgnoring(n))
47
- responseHs[n] = v;
48
- });
49
- }
50
- const reqResInfo = sanitize({
51
- url,
52
- method: method || '',
53
- status: globStatus || resStatus || 0,
54
- request: {
55
- headers: requestHs,
56
- body: reqData,
57
- },
58
- response: {
59
- headers: responseHs,
60
- body: resData || rData,
61
- },
62
- });
63
- if (!reqResInfo) {
64
- app.debug.log('Openreplay: empty request/response info, skipping');
65
- return;
66
- }
67
- const requestStart = axiosResponseObj.config.__openreplay_timing;
68
- const duration = performance.now() - requestStart;
69
- app.debug.log('Openreplay: final req object', reqResInfo);
70
- app.send((0, messages_gen_js_1.NetworkRequest)('xhr', String(method), String(reqResInfo.url), stringify(reqResInfo.request), stringify(reqResInfo.response), reqResInfo.status, requestStart + (0, utils_js_1.getTimeOrigin)(), duration, 0));
71
- }
72
- function getStartTime(config) {
73
- app.debug.log('Openreplay: capturing API request', config);
74
- config.__openreplay_timing = performance.now();
75
- if (opts.sessionTokenHeader) {
76
- const header = typeof opts.sessionTokenHeader === 'string'
77
- ? opts.sessionTokenHeader
78
- : 'X-OpenReplay-Session-Token';
79
- const headerValue = app.getSessionToken();
80
- if (headerValue) {
81
- config.headers.set(header, headerValue);
82
- }
83
- }
84
- return config;
85
- }
86
- function captureNetworkRequest(response) {
87
- if (opts.failuresOnly)
88
- return response;
89
- captureResponseData(response);
90
- return response;
91
- }
92
- function captureNetworkError(error) {
93
- app.debug.log('Openreplay: capturing API request error', error);
94
- if (isAxiosError(error) && Boolean(error.response)) {
95
- captureResponseData(error.response);
96
- }
97
- else if (error instanceof Error) {
98
- app.send((0, exception_js_1.getExceptionMessage)(error, []));
99
- }
100
- return Promise.reject(error);
101
- }
102
- function logRequestError(ev) {
103
- app.debug.log('Openreplay: failed API request, skipping', ev);
104
- }
105
- const reqInt = instance.interceptors.request.use(getStartTime, logRequestError, {
106
- synchronous: true,
107
- });
108
- const resInt = instance.interceptors.response.use(captureNetworkRequest, captureNetworkError, {
109
- synchronous: true,
110
- });
111
- app.attachStopCallback(() => {
112
- instance.interceptors.request.eject?.(reqInt);
113
- instance.interceptors.response.eject?.(resInt);
114
- });
115
- }
116
- exports.default = default_1;
117
- function isAxiosError(payload) {
118
- return isObject(payload) && payload.isAxiosError === true;
119
- }
120
- function isObject(thing) {
121
- return thing !== null && typeof thing === 'object';
122
- }