@openreplay/tracker 14.0.10-beta.2 → 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 +17 -5
  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} +14 -7
  6. package/dist/cjs/main/app/nodes/maintainer.d.ts +28 -0
  7. package/{lib → dist/cjs/main}/app/observer/iframe_offsets.d.ts +1 -1
  8. package/{lib → dist/cjs/main}/app/observer/observer.d.ts +3 -1
  9. package/{lib → dist/cjs/main}/app/observer/top_observer.d.ts +5 -1
  10. package/{cjs → dist/cjs/main}/app/sanitizer.d.ts +5 -2
  11. package/{cjs → dist/cjs/main}/app/session.d.ts +6 -3
  12. package/{cjs → dist/cjs/main}/index.d.ts +2 -2
  13. package/{cjs → dist/cjs/main}/modules/attributeSender.d.ts +5 -2
  14. package/{cjs → dist/cjs/main}/modules/conditionsManager.d.ts +1 -1
  15. package/{cjs → dist/cjs/main}/modules/tagWatcher.d.ts +8 -4
  16. package/{lib → dist/cjs/main}/modules/userTesting/SignalManager.d.ts +2 -2
  17. package/{lib → dist/cjs/main}/utils.d.ts +4 -3
  18. package/dist/lib/index.js +9323 -0
  19. package/dist/lib/index.js.map +1 -0
  20. package/{lib → dist/lib/main}/app/index.d.ts +17 -5
  21. package/{cjs → dist/lib/main}/app/messages.gen.d.ts +2 -2
  22. package/{cjs/app/nodes.d.ts → dist/lib/main/app/nodes/index.d.ts} +14 -7
  23. package/dist/lib/main/app/nodes/maintainer.d.ts +28 -0
  24. package/{cjs → dist/lib/main}/app/observer/iframe_offsets.d.ts +1 -1
  25. package/{cjs → dist/lib/main}/app/observer/observer.d.ts +3 -1
  26. package/{cjs → dist/lib/main}/app/observer/top_observer.d.ts +5 -1
  27. package/{lib → dist/lib/main}/app/sanitizer.d.ts +5 -2
  28. package/{lib → dist/lib/main}/app/session.d.ts +6 -3
  29. package/{lib → dist/lib/main}/index.d.ts +2 -2
  30. package/{lib → dist/lib/main}/modules/attributeSender.d.ts +5 -2
  31. package/{lib → dist/lib/main}/modules/conditionsManager.d.ts +1 -1
  32. package/{lib → dist/lib/main}/modules/tagWatcher.d.ts +8 -4
  33. package/{cjs → dist/lib/main}/modules/userTesting/SignalManager.d.ts +2 -2
  34. package/{cjs → dist/lib/main}/utils.d.ts +4 -3
  35. package/package.json +29 -10
  36. package/.eslintignore +0 -11
  37. package/.nvmrc +0 -1
  38. package/.prettierignore +0 -1
  39. package/CHANGELOG.md +0 -297
  40. package/bun.lockb +0 -0
  41. package/cjs/app/canvas.js +0 -204
  42. package/cjs/app/guards.js +0 -37
  43. package/cjs/app/index.js +0 -1397
  44. package/cjs/app/logger.js +0 -37
  45. package/cjs/app/messages.gen.js +0 -702
  46. package/cjs/app/nodes.js +0 -111
  47. package/cjs/app/observer/iframe_observer.js +0 -35
  48. package/cjs/app/observer/iframe_offsets.js +0 -56
  49. package/cjs/app/observer/observer.js +0 -383
  50. package/cjs/app/observer/shadow_root_observer.js +0 -24
  51. package/cjs/app/observer/top_observer.js +0 -134
  52. package/cjs/app/sanitizer.js +0 -82
  53. package/cjs/app/session.js +0 -140
  54. package/cjs/app/ticker.js +0 -48
  55. package/cjs/common/interaction.js +0 -2
  56. package/cjs/common/messages.gen.js +0 -4
  57. package/cjs/modules/attributeSender.js +0 -51
  58. package/cjs/modules/axiosSpy.js +0 -122
  59. package/cjs/modules/conditionsManager.js +0 -343
  60. package/cjs/modules/connection.js +0 -15
  61. package/cjs/modules/console.js +0 -127
  62. package/cjs/modules/constructedStyleSheets.js +0 -138
  63. package/cjs/modules/cssrules.js +0 -99
  64. package/cjs/modules/exception.js +0 -85
  65. package/cjs/modules/featureFlags.js +0 -89
  66. package/cjs/modules/focus.js +0 -45
  67. package/cjs/modules/fonts.js +0 -57
  68. package/cjs/modules/img.js +0 -110
  69. package/cjs/modules/input.js +0 -203
  70. package/cjs/modules/mouse.js +0 -195
  71. package/cjs/modules/network.js +0 -244
  72. package/cjs/modules/performance.js +0 -53
  73. package/cjs/modules/scroll.js +0 -84
  74. package/cjs/modules/selection.js +0 -37
  75. package/cjs/modules/tabs.js +0 -13
  76. package/cjs/modules/tagWatcher.js +0 -76
  77. package/cjs/modules/timing.js +0 -173
  78. package/cjs/modules/userTesting/SignalManager.js +0 -83
  79. package/cjs/modules/userTesting/dnd.js +0 -40
  80. package/cjs/modules/userTesting/index.js +0 -464
  81. package/cjs/modules/userTesting/recorder.js +0 -101
  82. package/cjs/modules/userTesting/styles.js +0 -266
  83. package/cjs/modules/userTesting/utils.js +0 -87
  84. package/cjs/modules/viewport.js +0 -43
  85. package/cjs/package.json +0 -1
  86. package/cjs/utils.js +0 -249
  87. package/coverage/clover.xml +0 -4304
  88. package/coverage/coverage-final.json +0 -55
  89. package/coverage/lcov-report/base.css +0 -224
  90. package/coverage/lcov-report/block-navigation.js +0 -87
  91. package/coverage/lcov-report/favicon.png +0 -0
  92. package/coverage/lcov-report/index.html +0 -206
  93. package/coverage/lcov-report/main/app/canvas.ts.html +0 -712
  94. package/coverage/lcov-report/main/app/guards.ts.html +0 -232
  95. package/coverage/lcov-report/main/app/index.html +0 -236
  96. package/coverage/lcov-report/main/app/index.ts.html +0 -3955
  97. package/coverage/lcov-report/main/app/logger.ts.html +0 -211
  98. package/coverage/lcov-report/main/app/messages.gen.ts.html +0 -3034
  99. package/coverage/lcov-report/main/app/nodes.ts.html +0 -406
  100. package/coverage/lcov-report/main/app/observer/iframe_observer.ts.html +0 -148
  101. package/coverage/lcov-report/main/app/observer/iframe_offsets.ts.html +0 -289
  102. package/coverage/lcov-report/main/app/observer/index.html +0 -161
  103. package/coverage/lcov-report/main/app/observer/shadow_root_observer.ts.html +0 -142
  104. package/coverage/lcov-report/main/app/observer/top_observer.ts.html +0 -541
  105. package/coverage/lcov-report/main/app/sanitizer.ts.html +0 -403
  106. package/coverage/lcov-report/main/app/session.ts.html +0 -622
  107. package/coverage/lcov-report/main/app/ticker.ts.html +0 -250
  108. package/coverage/lcov-report/main/index.html +0 -131
  109. package/coverage/lcov-report/main/index.ts.html +0 -1597
  110. package/coverage/lcov-report/main/modules/Network/beaconProxy.ts.html +0 -400
  111. package/coverage/lcov-report/main/modules/Network/fetchProxy.ts.html +0 -1075
  112. package/coverage/lcov-report/main/modules/Network/index.html +0 -191
  113. package/coverage/lcov-report/main/modules/Network/index.ts.html +0 -244
  114. package/coverage/lcov-report/main/modules/Network/networkMessage.ts.html +0 -400
  115. package/coverage/lcov-report/main/modules/Network/utils.ts.html +0 -709
  116. package/coverage/lcov-report/main/modules/Network/xhrProxy.ts.html +0 -877
  117. package/coverage/lcov-report/main/modules/attributeSender.ts.html +0 -241
  118. package/coverage/lcov-report/main/modules/axiosSpy.ts.html +0 -709
  119. package/coverage/lcov-report/main/modules/conditionsManager.ts.html +0 -1381
  120. package/coverage/lcov-report/main/modules/connection.ts.html +0 -160
  121. package/coverage/lcov-report/main/modules/console.ts.html +0 -541
  122. package/coverage/lcov-report/main/modules/constructedStyleSheets.ts.html +0 -571
  123. package/coverage/lcov-report/main/modules/cssrules.ts.html +0 -418
  124. package/coverage/lcov-report/main/modules/exception.ts.html +0 -385
  125. package/coverage/lcov-report/main/modules/featureFlags.ts.html +0 -415
  126. package/coverage/lcov-report/main/modules/focus.ts.html +0 -220
  127. package/coverage/lcov-report/main/modules/fonts.ts.html +0 -289
  128. package/coverage/lcov-report/main/modules/img.ts.html +0 -436
  129. package/coverage/lcov-report/main/modules/index.html +0 -431
  130. package/coverage/lcov-report/main/modules/input.ts.html +0 -826
  131. package/coverage/lcov-report/main/modules/mouse.ts.html +0 -826
  132. package/coverage/lcov-report/main/modules/network.ts.html +0 -1123
  133. package/coverage/lcov-report/main/modules/performance.ts.html +0 -367
  134. package/coverage/lcov-report/main/modules/scroll.ts.html +0 -364
  135. package/coverage/lcov-report/main/modules/selection.ts.html +0 -202
  136. package/coverage/lcov-report/main/modules/tabs.ts.html +0 -124
  137. package/coverage/lcov-report/main/modules/tagWatcher.ts.html +0 -337
  138. package/coverage/lcov-report/main/modules/timing.ts.html +0 -877
  139. package/coverage/lcov-report/main/modules/userTesting/SignalManager.ts.html +0 -370
  140. package/coverage/lcov-report/main/modules/userTesting/dnd.ts.html +0 -220
  141. package/coverage/lcov-report/main/modules/userTesting/index.html +0 -191
  142. package/coverage/lcov-report/main/modules/userTesting/index.ts.html +0 -1909
  143. package/coverage/lcov-report/main/modules/userTesting/recorder.ts.html +0 -430
  144. package/coverage/lcov-report/main/modules/userTesting/styles.ts.html +0 -937
  145. package/coverage/lcov-report/main/modules/userTesting/utils.ts.html +0 -364
  146. package/coverage/lcov-report/main/modules/viewport.ts.html +0 -250
  147. package/coverage/lcov-report/main/utils.ts.html +0 -814
  148. package/coverage/lcov-report/prettify.css +0 -1
  149. package/coverage/lcov-report/prettify.js +0 -2
  150. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  151. package/coverage/lcov-report/sorter.js +0 -196
  152. package/coverage/lcov-report/webworker/BatchWriter.ts.html +0 -499
  153. package/coverage/lcov-report/webworker/MessageEncoder.gen.ts.html +0 -1021
  154. package/coverage/lcov-report/webworker/PrimitiveEncoder.ts.html +0 -436
  155. package/coverage/lcov-report/webworker/QueueSender.ts.html +0 -547
  156. package/coverage/lcov-report/webworker/index.html +0 -176
  157. package/coverage/lcov-report/webworker/index.ts.html +0 -667
  158. package/coverage/lcov.info +0 -8425
  159. package/jest.config.js +0 -13
  160. package/lib/app/canvas.js +0 -202
  161. package/lib/app/guards.js +0 -26
  162. package/lib/app/index.js +0 -1367
  163. package/lib/app/logger.js +0 -33
  164. package/lib/app/messages.gen.js +0 -622
  165. package/lib/app/nodes.js +0 -108
  166. package/lib/app/observer/iframe_observer.js +0 -29
  167. package/lib/app/observer/iframe_offsets.js +0 -53
  168. package/lib/app/observer/observer.js +0 -380
  169. package/lib/app/observer/shadow_root_observer.js +0 -18
  170. package/lib/app/observer/top_observer.js +0 -128
  171. package/lib/app/sanitizer.js +0 -77
  172. package/lib/app/session.js +0 -137
  173. package/lib/app/ticker.js +0 -45
  174. package/lib/common/interaction.js +0 -1
  175. package/lib/common/messages.gen.js +0 -3
  176. package/lib/common/tsconfig.tsbuildinfo +0 -1
  177. package/lib/index.js +0 -423
  178. package/lib/modules/attributeSender.js +0 -46
  179. package/lib/modules/axiosSpy.js +0 -119
  180. package/lib/modules/conditionsManager.js +0 -340
  181. package/lib/modules/connection.js +0 -12
  182. package/lib/modules/console.js +0 -124
  183. package/lib/modules/constructedStyleSheets.js +0 -133
  184. package/lib/modules/cssrules.js +0 -97
  185. package/lib/modules/exception.js +0 -76
  186. package/lib/modules/featureFlags.js +0 -86
  187. package/lib/modules/focus.js +0 -42
  188. package/lib/modules/fonts.js +0 -54
  189. package/lib/modules/img.js +0 -107
  190. package/lib/modules/input.js +0 -198
  191. package/lib/modules/mouse.js +0 -192
  192. package/lib/modules/network.js +0 -238
  193. package/lib/modules/performance.js +0 -49
  194. package/lib/modules/scroll.js +0 -81
  195. package/lib/modules/selection.js +0 -35
  196. package/lib/modules/tabs.js +0 -10
  197. package/lib/modules/tagWatcher.js +0 -73
  198. package/lib/modules/timing.js +0 -170
  199. package/lib/modules/userTesting/SignalManager.js +0 -80
  200. package/lib/modules/userTesting/dnd.js +0 -37
  201. package/lib/modules/userTesting/index.js +0 -435
  202. package/lib/modules/userTesting/recorder.js +0 -97
  203. package/lib/modules/userTesting/styles.js +0 -263
  204. package/lib/modules/userTesting/utils.js +0 -79
  205. package/lib/modules/viewport.js +0 -40
  206. package/lib/utils.js +0 -230
  207. package/rollup.config.js +0 -12
  208. package/scripts/checkver.cjs +0 -7
  209. package/tsconfig-base.json +0 -16
  210. /package/{cjs → dist/cjs}/common/interaction.d.ts +0 -0
  211. /package/{cjs → dist/cjs}/common/messages.gen.d.ts +0 -0
  212. /package/{cjs → dist/cjs/main}/app/canvas.d.ts +0 -0
  213. /package/{cjs → dist/cjs/main}/app/guards.d.ts +0 -0
  214. /package/{cjs → dist/cjs/main}/app/logger.d.ts +0 -0
  215. /package/{cjs → dist/cjs/main}/app/observer/iframe_observer.d.ts +0 -0
  216. /package/{cjs → dist/cjs/main}/app/observer/shadow_root_observer.d.ts +0 -0
  217. /package/{cjs → dist/cjs/main}/app/ticker.d.ts +0 -0
  218. /package/{cjs → dist/cjs/main}/modules/axiosSpy.d.ts +0 -0
  219. /package/{cjs → dist/cjs/main}/modules/connection.d.ts +0 -0
  220. /package/{cjs → dist/cjs/main}/modules/console.d.ts +0 -0
  221. /package/{cjs → dist/cjs/main}/modules/constructedStyleSheets.d.ts +0 -0
  222. /package/{cjs → dist/cjs/main}/modules/cssrules.d.ts +0 -0
  223. /package/{cjs → dist/cjs/main}/modules/exception.d.ts +0 -0
  224. /package/{cjs → dist/cjs/main}/modules/featureFlags.d.ts +0 -0
  225. /package/{cjs → dist/cjs/main}/modules/focus.d.ts +0 -0
  226. /package/{cjs → dist/cjs/main}/modules/fonts.d.ts +0 -0
  227. /package/{cjs → dist/cjs/main}/modules/img.d.ts +0 -0
  228. /package/{cjs → dist/cjs/main}/modules/input.d.ts +0 -0
  229. /package/{cjs → dist/cjs/main}/modules/mouse.d.ts +0 -0
  230. /package/{cjs → dist/cjs/main}/modules/network.d.ts +0 -0
  231. /package/{cjs → dist/cjs/main}/modules/performance.d.ts +0 -0
  232. /package/{cjs → dist/cjs/main}/modules/scroll.d.ts +0 -0
  233. /package/{cjs → dist/cjs/main}/modules/selection.d.ts +0 -0
  234. /package/{cjs → dist/cjs/main}/modules/tabs.d.ts +0 -0
  235. /package/{cjs → dist/cjs/main}/modules/timing.d.ts +0 -0
  236. /package/{cjs → dist/cjs/main}/modules/userTesting/dnd.d.ts +0 -0
  237. /package/{cjs → dist/cjs/main}/modules/userTesting/index.d.ts +0 -0
  238. /package/{cjs → dist/cjs/main}/modules/userTesting/recorder.d.ts +0 -0
  239. /package/{cjs → dist/cjs/main}/modules/userTesting/styles.d.ts +0 -0
  240. /package/{cjs → dist/cjs/main}/modules/userTesting/utils.d.ts +0 -0
  241. /package/{cjs → dist/cjs/main}/modules/viewport.d.ts +0 -0
  242. /package/{lib → dist/lib}/common/interaction.d.ts +0 -0
  243. /package/{lib → dist/lib}/common/messages.gen.d.ts +0 -0
  244. /package/{lib → dist/lib/main}/app/canvas.d.ts +0 -0
  245. /package/{lib → dist/lib/main}/app/guards.d.ts +0 -0
  246. /package/{lib → dist/lib/main}/app/logger.d.ts +0 -0
  247. /package/{lib → dist/lib/main}/app/observer/iframe_observer.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,76 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WATCHED_TAGS_KEY = void 0;
4
- exports.WATCHED_TAGS_KEY = '__or__watched_tags__';
5
- class TagWatcher {
6
- constructor(sessionStorage, errLog, onTag) {
7
- this.sessionStorage = sessionStorage;
8
- this.errLog = errLog;
9
- this.onTag = onTag;
10
- this.intervals = {};
11
- this.tags = [];
12
- const tags = JSON.parse(sessionStorage.getItem(exports.WATCHED_TAGS_KEY) ?? '[]');
13
- this.setTags(tags);
14
- this.observer = new IntersectionObserver((entries) => {
15
- entries.forEach((entry) => {
16
- if (entry.isIntersecting) {
17
- if (entry.target) {
18
- // @ts-ignore
19
- const tag = entry.target.__or_watcher_tagname;
20
- if (tag) {
21
- this.onTagRendered(tag);
22
- }
23
- this.observer.unobserve(entry.target);
24
- }
25
- }
26
- });
27
- });
28
- }
29
- async fetchTags(ingest, token) {
30
- return fetch(`${ingest}/v1/web/tags`, {
31
- method: 'GET',
32
- headers: {
33
- Authorization: `Bearer ${token}`,
34
- },
35
- })
36
- .then((r) => r.json())
37
- .then(({ tags }) => {
38
- if (tags && tags.length) {
39
- this.setTags(tags);
40
- const tagString = JSON.stringify(tags);
41
- this.sessionStorage.setItem(exports.WATCHED_TAGS_KEY, tagString || '');
42
- }
43
- })
44
- .catch((e) => this.errLog(e));
45
- }
46
- setTags(tags) {
47
- this.tags = tags;
48
- this.intervals = {};
49
- tags.forEach((tag) => {
50
- this.intervals[tag.id] = setInterval(() => {
51
- const possibleEls = document.querySelectorAll(tag.selector);
52
- if (possibleEls.length > 0) {
53
- const el = possibleEls[0];
54
- // @ts-ignore
55
- el.__or_watcher_tagname = tag.id;
56
- this.observer.observe(el);
57
- }
58
- }, 500);
59
- });
60
- }
61
- onTagRendered(tagId) {
62
- if (this.intervals[tagId]) {
63
- clearInterval(this.intervals[tagId]);
64
- }
65
- this.onTag(tagId);
66
- }
67
- clear() {
68
- this.tags.forEach((tag) => {
69
- clearInterval(this.intervals[tag.id]);
70
- });
71
- this.tags = [];
72
- this.intervals = {};
73
- this.observer.disconnect();
74
- }
75
- }
76
- exports.default = TagWatcher;
@@ -1,173 +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
- function getPaintBlocks(resources) {
7
- const paintBlocks = [];
8
- const elements = document.getElementsByTagName('*');
9
- const styleURL = /url\(("[^"]*"|'[^']*'|[^)]*)\)/i;
10
- for (let i = 0; i < elements.length; i++) {
11
- const element = elements[i];
12
- let src = '';
13
- if ((0, guards_js_1.hasTag)(element, 'img')) {
14
- src = element.currentSrc || element.src;
15
- }
16
- if (!src) {
17
- const backgroundImage = getComputedStyle(element).getPropertyValue('background-image');
18
- if (backgroundImage) {
19
- const matches = styleURL.exec(backgroundImage);
20
- if (matches !== null) {
21
- src = matches[1];
22
- if (src.startsWith('"') || src.startsWith("'")) {
23
- src = src.substr(1, src.length - 2);
24
- }
25
- }
26
- }
27
- }
28
- if (!src)
29
- continue;
30
- const time = src.substr(0, 10) === 'data:image' ? 0 : resources[src];
31
- if (time === undefined)
32
- continue;
33
- const rect = element.getBoundingClientRect();
34
- const top = Math.max(rect.top, 0);
35
- const left = Math.max(rect.left, 0);
36
- const bottom = Math.min(rect.bottom, window.innerHeight ||
37
- (document.documentElement && document.documentElement.clientHeight) ||
38
- 0);
39
- const right = Math.min(rect.right, window.innerWidth || (document.documentElement && document.documentElement.clientWidth) || 0);
40
- if (bottom <= top || right <= left)
41
- continue;
42
- const area = (bottom - top) * (right - left);
43
- paintBlocks.push({ time, area });
44
- }
45
- return paintBlocks;
46
- }
47
- function calculateSpeedIndex(firstContentfulPaint, paintBlocks) {
48
- let a = (Math.max((document.documentElement && document.documentElement.clientWidth) || 0, window.innerWidth || 0) *
49
- Math.max((document.documentElement && document.documentElement.clientHeight) || 0, window.innerHeight || 0)) /
50
- 10;
51
- let s = a * firstContentfulPaint;
52
- for (let i = 0; i < paintBlocks.length; i++) {
53
- const { time, area } = paintBlocks[i];
54
- a += area;
55
- s += area * (time > firstContentfulPaint ? time : firstContentfulPaint);
56
- }
57
- return a === 0 ? 0 : s / a;
58
- }
59
- function default_1(app, opts) {
60
- const options = Object.assign({
61
- captureResourceTimings: true,
62
- capturePageLoadTimings: true,
63
- capturePageRenderTimings: true,
64
- excludedResourceUrls: [],
65
- }, opts);
66
- if (!('PerformanceObserver' in window)) {
67
- options.captureResourceTimings = false;
68
- }
69
- if (!options.captureResourceTimings) {
70
- return;
71
- } // Resources are necessary for all timings
72
- let resources = {};
73
- function resourceTiming(entry) {
74
- if (entry.duration < 0 || !(0, utils_js_1.isURL)(entry.name) || app.isServiceURL(entry.name))
75
- return;
76
- if (resources !== null) {
77
- resources[entry.name] = entry.startTime + entry.duration;
78
- }
79
- let shouldSkip = false;
80
- options.excludedResourceUrls?.forEach((url) => {
81
- if (entry.name.startsWith(url)) {
82
- shouldSkip = true;
83
- return;
84
- }
85
- });
86
- if (shouldSkip) {
87
- return;
88
- }
89
- app.send((0, messages_gen_js_1.ResourceTiming)(entry.startTime + (0, utils_js_1.getTimeOrigin)(), entry.duration, entry.responseStart && entry.startTime ? entry.responseStart - entry.startTime : 0, entry.transferSize > entry.encodedBodySize ? entry.transferSize - entry.encodedBodySize : 0, entry.encodedBodySize || 0, entry.decodedBodySize || 0, entry.name, entry.initiatorType, entry.transferSize,
90
- // @ts-ignore
91
- (entry.responseStatus && entry.responseStatus === 304) || entry.transferSize === 0));
92
- }
93
- const observer = new PerformanceObserver((list) => list.getEntries().forEach(resourceTiming));
94
- let prevSessionID;
95
- app.attachStartCallback(function ({ sessionID }) {
96
- if (sessionID !== prevSessionID) {
97
- // Send past page resources on a newly started session
98
- performance.getEntriesByType('resource').forEach(resourceTiming);
99
- prevSessionID = sessionID;
100
- }
101
- observer.observe({ entryTypes: ['resource'] });
102
- });
103
- app.attachStopCallback(function () {
104
- observer.disconnect();
105
- });
106
- let firstPaint = 0, firstContentfulPaint = 0;
107
- if (options.capturePageLoadTimings) {
108
- let pageLoadTimingSent = false;
109
- app.ticker.attach(() => {
110
- if (pageLoadTimingSent) {
111
- return;
112
- }
113
- if (firstPaint === 0 || firstContentfulPaint === 0) {
114
- performance.getEntriesByType('paint').forEach((entry) => {
115
- const { name, startTime } = entry;
116
- switch (name) {
117
- case 'first-paint':
118
- firstPaint = startTime;
119
- break;
120
- case 'first-contentful-paint':
121
- firstContentfulPaint = startTime;
122
- break;
123
- }
124
- });
125
- }
126
- if (performance.timing.loadEventEnd || performance.now() > 30000) {
127
- pageLoadTimingSent = true;
128
- const {
129
- // should be ok to use here, (https://github.com/mdn/content/issues/4713)
130
- // since it is compared with the values obtained on the page load (before any possible sleep state)
131
- // deprecated though
132
- navigationStart, requestStart, responseStart, responseEnd, domContentLoadedEventStart, domContentLoadedEventEnd, loadEventStart, loadEventEnd, } = performance.timing;
133
- app.send((0, messages_gen_js_1.PageLoadTiming)(requestStart - navigationStart || 0, responseStart - navigationStart || 0, responseEnd - navigationStart || 0, domContentLoadedEventStart - navigationStart || 0, domContentLoadedEventEnd - navigationStart || 0, loadEventStart - navigationStart || 0, loadEventEnd - navigationStart || 0, firstPaint, firstContentfulPaint));
134
- }
135
- }, 30);
136
- }
137
- if (options.capturePageRenderTimings) {
138
- let visuallyComplete = 0, interactiveWindowStartTime = 0, interactiveWindowTickTime = 0, paintBlocks = null;
139
- let pageRenderTimingSent = false;
140
- app.ticker.attach(() => {
141
- if (pageRenderTimingSent) {
142
- return;
143
- }
144
- const time = performance.now();
145
- if (resources !== null) {
146
- visuallyComplete = Math.max.apply(null, Object.keys(resources).map((k) => resources[k]));
147
- if (time - visuallyComplete > 1000) {
148
- paintBlocks = getPaintBlocks(resources);
149
- resources = null;
150
- }
151
- }
152
- if (interactiveWindowTickTime !== null) {
153
- if (time - interactiveWindowTickTime > 50) {
154
- interactiveWindowStartTime = time;
155
- }
156
- interactiveWindowTickTime = time - interactiveWindowStartTime > 5000 ? null : time;
157
- }
158
- if ((paintBlocks !== null && interactiveWindowTickTime === null) || time > 30000) {
159
- pageRenderTimingSent = true;
160
- resources = null;
161
- const speedIndex = paintBlocks === null
162
- ? 0
163
- : calculateSpeedIndex(firstContentfulPaint || firstPaint, paintBlocks);
164
- const { domContentLoadedEventEnd, navigationStart } = performance.timing;
165
- const timeToInteractive = interactiveWindowTickTime === null
166
- ? Math.max(interactiveWindowStartTime, firstContentfulPaint, domContentLoadedEventEnd - navigationStart || 0)
167
- : 0;
168
- app.send((0, messages_gen_js_1.PageRenderTiming)(speedIndex, firstContentfulPaint > visuallyComplete ? firstContentfulPaint : visuallyComplete, timeToInteractive));
169
- }
170
- });
171
- }
172
- }
173
- exports.default = default_1;
@@ -1,83 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_js_1 = require("./utils.js");
4
- class SignalManager {
5
- constructor(ingestPoint, getTimestamp, token, testId, storageKey, setStorageKey, removeStorageKey, getStorageKey, getSessionId) {
6
- this.ingestPoint = ingestPoint;
7
- this.getTimestamp = getTimestamp;
8
- this.token = token;
9
- this.testId = testId;
10
- this.storageKey = storageKey;
11
- this.setStorageKey = setStorageKey;
12
- this.removeStorageKey = removeStorageKey;
13
- this.getStorageKey = getStorageKey;
14
- this.getSessionId = getSessionId;
15
- this.durations = {
16
- testStart: 0,
17
- tasks: [],
18
- };
19
- this.getDurations = () => {
20
- return this.durations;
21
- };
22
- this.setDurations = (durations) => {
23
- this.durations.testStart = durations.testStart;
24
- this.durations.tasks = durations.tasks;
25
- };
26
- this.signalTask = (taskId, status, taskAnswer) => {
27
- if (!taskId)
28
- return console.error('User Testing: No Task ID Given');
29
- const taskStart = this.durations.tasks.find((t) => t.taskId === taskId);
30
- const timestamp = this.getTimestamp();
31
- const duration = taskStart ? timestamp - taskStart.started : 0;
32
- return fetch(`${this.ingestPoint}/v1/web/uxt/signals/task`, {
33
- method: 'POST',
34
- headers: {
35
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
36
- Authorization: `Bearer ${this.token}`,
37
- },
38
- body: JSON.stringify({
39
- testId: this.testId,
40
- taskId,
41
- status,
42
- duration,
43
- timestamp,
44
- taskAnswer,
45
- }),
46
- });
47
- };
48
- this.signalTest = (status) => {
49
- const timestamp = this.getTimestamp();
50
- if (status === 'begin' && this.testId) {
51
- const sessionId = this.getSessionId();
52
- this.setStorageKey(utils_js_1.SESSION_ID, sessionId);
53
- this.setStorageKey(this.storageKey, this.testId.toString());
54
- this.setStorageKey(utils_js_1.TEST_START, timestamp.toString());
55
- }
56
- else {
57
- this.removeStorageKey(this.storageKey);
58
- this.removeStorageKey(utils_js_1.TASK_IND);
59
- this.removeStorageKey(utils_js_1.TEST_START);
60
- }
61
- const start = this.durations.testStart || timestamp;
62
- const duration = timestamp - start;
63
- return fetch(`${this.ingestPoint}/v1/web/uxt/signals/test`, {
64
- method: 'POST',
65
- headers: {
66
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
67
- Authorization: `Bearer ${this.token}`,
68
- },
69
- body: JSON.stringify({
70
- testId: this.testId,
71
- status,
72
- duration,
73
- timestamp,
74
- }),
75
- });
76
- };
77
- const possibleStart = this.getStorageKey(utils_js_1.TEST_START);
78
- if (possibleStart) {
79
- this.durations.testStart = parseInt(possibleStart, 10);
80
- }
81
- }
82
- }
83
- exports.default = SignalManager;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- // @ts-nocheck
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- function attachDND(element, dragTarget) {
5
- dragTarget.onmousedown = function (event) {
6
- const clientRect = element.getBoundingClientRect();
7
- const shiftX = event.clientX - clientRect.left;
8
- const shiftY = event.clientY - clientRect.top;
9
- element.style.position = 'fixed';
10
- element.style.zIndex = 99999999999999;
11
- moveAt(event.pageX, event.pageY);
12
- function moveAt(pageX, pageY) {
13
- let leftC = pageX - shiftX;
14
- let topC = pageY - shiftY;
15
- if (leftC <= 5)
16
- leftC = 5;
17
- if (topC <= 5)
18
- topC = 5;
19
- if (leftC >= window.innerWidth - clientRect.width)
20
- leftC = window.innerWidth - clientRect.width;
21
- if (topC >= window.innerHeight - clientRect.height)
22
- topC = window.innerHeight - clientRect.height;
23
- element.style.left = `${leftC}px`;
24
- element.style.top = `${topC}px`;
25
- }
26
- function onMouseMove(event) {
27
- moveAt(event.pageX, event.pageY);
28
- }
29
- document.addEventListener('mousemove', onMouseMove);
30
- const clearAll = () => {
31
- document.removeEventListener('mousemove', onMouseMove);
32
- document.removeEventListener('mouseup', clearAll);
33
- };
34
- document.addEventListener('mouseup', clearAll);
35
- };
36
- dragTarget.ondragstart = function () {
37
- return false;
38
- };
39
- }
40
- exports.default = attachDND;