@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,170 +0,0 @@
1
- import { hasTag } from '../app/guards.js';
2
- import { isURL, getTimeOrigin } from '../utils.js';
3
- import { ResourceTiming, PageLoadTiming, PageRenderTiming } from '../app/messages.gen.js';
4
- function getPaintBlocks(resources) {
5
- const paintBlocks = [];
6
- const elements = document.getElementsByTagName('*');
7
- const styleURL = /url\(("[^"]*"|'[^']*'|[^)]*)\)/i;
8
- for (let i = 0; i < elements.length; i++) {
9
- const element = elements[i];
10
- let src = '';
11
- if (hasTag(element, 'img')) {
12
- src = element.currentSrc || element.src;
13
- }
14
- if (!src) {
15
- const backgroundImage = getComputedStyle(element).getPropertyValue('background-image');
16
- if (backgroundImage) {
17
- const matches = styleURL.exec(backgroundImage);
18
- if (matches !== null) {
19
- src = matches[1];
20
- if (src.startsWith('"') || src.startsWith("'")) {
21
- src = src.substr(1, src.length - 2);
22
- }
23
- }
24
- }
25
- }
26
- if (!src)
27
- continue;
28
- const time = src.substr(0, 10) === 'data:image' ? 0 : resources[src];
29
- if (time === undefined)
30
- continue;
31
- const rect = element.getBoundingClientRect();
32
- const top = Math.max(rect.top, 0);
33
- const left = Math.max(rect.left, 0);
34
- const bottom = Math.min(rect.bottom, window.innerHeight ||
35
- (document.documentElement && document.documentElement.clientHeight) ||
36
- 0);
37
- const right = Math.min(rect.right, window.innerWidth || (document.documentElement && document.documentElement.clientWidth) || 0);
38
- if (bottom <= top || right <= left)
39
- continue;
40
- const area = (bottom - top) * (right - left);
41
- paintBlocks.push({ time, area });
42
- }
43
- return paintBlocks;
44
- }
45
- function calculateSpeedIndex(firstContentfulPaint, paintBlocks) {
46
- let a = (Math.max((document.documentElement && document.documentElement.clientWidth) || 0, window.innerWidth || 0) *
47
- Math.max((document.documentElement && document.documentElement.clientHeight) || 0, window.innerHeight || 0)) /
48
- 10;
49
- let s = a * firstContentfulPaint;
50
- for (let i = 0; i < paintBlocks.length; i++) {
51
- const { time, area } = paintBlocks[i];
52
- a += area;
53
- s += area * (time > firstContentfulPaint ? time : firstContentfulPaint);
54
- }
55
- return a === 0 ? 0 : s / a;
56
- }
57
- export default function (app, opts) {
58
- const options = Object.assign({
59
- captureResourceTimings: true,
60
- capturePageLoadTimings: true,
61
- capturePageRenderTimings: true,
62
- excludedResourceUrls: [],
63
- }, opts);
64
- if (!('PerformanceObserver' in window)) {
65
- options.captureResourceTimings = false;
66
- }
67
- if (!options.captureResourceTimings) {
68
- return;
69
- } // Resources are necessary for all timings
70
- let resources = {};
71
- function resourceTiming(entry) {
72
- if (entry.duration < 0 || !isURL(entry.name) || app.isServiceURL(entry.name))
73
- return;
74
- if (resources !== null) {
75
- resources[entry.name] = entry.startTime + entry.duration;
76
- }
77
- let shouldSkip = false;
78
- options.excludedResourceUrls?.forEach((url) => {
79
- if (entry.name.startsWith(url)) {
80
- shouldSkip = true;
81
- return;
82
- }
83
- });
84
- if (shouldSkip) {
85
- return;
86
- }
87
- app.send(ResourceTiming(entry.startTime + 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,
88
- // @ts-ignore
89
- (entry.responseStatus && entry.responseStatus === 304) || entry.transferSize === 0));
90
- }
91
- const observer = new PerformanceObserver((list) => list.getEntries().forEach(resourceTiming));
92
- let prevSessionID;
93
- app.attachStartCallback(function ({ sessionID }) {
94
- if (sessionID !== prevSessionID) {
95
- // Send past page resources on a newly started session
96
- performance.getEntriesByType('resource').forEach(resourceTiming);
97
- prevSessionID = sessionID;
98
- }
99
- observer.observe({ entryTypes: ['resource'] });
100
- });
101
- app.attachStopCallback(function () {
102
- observer.disconnect();
103
- });
104
- let firstPaint = 0, firstContentfulPaint = 0;
105
- if (options.capturePageLoadTimings) {
106
- let pageLoadTimingSent = false;
107
- app.ticker.attach(() => {
108
- if (pageLoadTimingSent) {
109
- return;
110
- }
111
- if (firstPaint === 0 || firstContentfulPaint === 0) {
112
- performance.getEntriesByType('paint').forEach((entry) => {
113
- const { name, startTime } = entry;
114
- switch (name) {
115
- case 'first-paint':
116
- firstPaint = startTime;
117
- break;
118
- case 'first-contentful-paint':
119
- firstContentfulPaint = startTime;
120
- break;
121
- }
122
- });
123
- }
124
- if (performance.timing.loadEventEnd || performance.now() > 30000) {
125
- pageLoadTimingSent = true;
126
- const {
127
- // should be ok to use here, (https://github.com/mdn/content/issues/4713)
128
- // since it is compared with the values obtained on the page load (before any possible sleep state)
129
- // deprecated though
130
- navigationStart, requestStart, responseStart, responseEnd, domContentLoadedEventStart, domContentLoadedEventEnd, loadEventStart, loadEventEnd, } = performance.timing;
131
- app.send(PageLoadTiming(requestStart - navigationStart || 0, responseStart - navigationStart || 0, responseEnd - navigationStart || 0, domContentLoadedEventStart - navigationStart || 0, domContentLoadedEventEnd - navigationStart || 0, loadEventStart - navigationStart || 0, loadEventEnd - navigationStart || 0, firstPaint, firstContentfulPaint));
132
- }
133
- }, 30);
134
- }
135
- if (options.capturePageRenderTimings) {
136
- let visuallyComplete = 0, interactiveWindowStartTime = 0, interactiveWindowTickTime = 0, paintBlocks = null;
137
- let pageRenderTimingSent = false;
138
- app.ticker.attach(() => {
139
- if (pageRenderTimingSent) {
140
- return;
141
- }
142
- const time = performance.now();
143
- if (resources !== null) {
144
- visuallyComplete = Math.max.apply(null, Object.keys(resources).map((k) => resources[k]));
145
- if (time - visuallyComplete > 1000) {
146
- paintBlocks = getPaintBlocks(resources);
147
- resources = null;
148
- }
149
- }
150
- if (interactiveWindowTickTime !== null) {
151
- if (time - interactiveWindowTickTime > 50) {
152
- interactiveWindowStartTime = time;
153
- }
154
- interactiveWindowTickTime = time - interactiveWindowStartTime > 5000 ? null : time;
155
- }
156
- if ((paintBlocks !== null && interactiveWindowTickTime === null) || time > 30000) {
157
- pageRenderTimingSent = true;
158
- resources = null;
159
- const speedIndex = paintBlocks === null
160
- ? 0
161
- : calculateSpeedIndex(firstContentfulPaint || firstPaint, paintBlocks);
162
- const { domContentLoadedEventEnd, navigationStart } = performance.timing;
163
- const timeToInteractive = interactiveWindowTickTime === null
164
- ? Math.max(interactiveWindowStartTime, firstContentfulPaint, domContentLoadedEventEnd - navigationStart || 0)
165
- : 0;
166
- app.send(PageRenderTiming(speedIndex, firstContentfulPaint > visuallyComplete ? firstContentfulPaint : visuallyComplete, timeToInteractive));
167
- }
168
- });
169
- }
170
- }
@@ -1,80 +0,0 @@
1
- import { TEST_START, TASK_IND, SESSION_ID } from './utils.js';
2
- export default class SignalManager {
3
- constructor(ingestPoint, getTimestamp, token, testId, storageKey, setStorageKey, removeStorageKey, getStorageKey, getSessionId) {
4
- this.ingestPoint = ingestPoint;
5
- this.getTimestamp = getTimestamp;
6
- this.token = token;
7
- this.testId = testId;
8
- this.storageKey = storageKey;
9
- this.setStorageKey = setStorageKey;
10
- this.removeStorageKey = removeStorageKey;
11
- this.getStorageKey = getStorageKey;
12
- this.getSessionId = getSessionId;
13
- this.durations = {
14
- testStart: 0,
15
- tasks: [],
16
- };
17
- this.getDurations = () => {
18
- return this.durations;
19
- };
20
- this.setDurations = (durations) => {
21
- this.durations.testStart = durations.testStart;
22
- this.durations.tasks = durations.tasks;
23
- };
24
- this.signalTask = (taskId, status, taskAnswer) => {
25
- if (!taskId)
26
- return console.error('User Testing: No Task ID Given');
27
- const taskStart = this.durations.tasks.find((t) => t.taskId === taskId);
28
- const timestamp = this.getTimestamp();
29
- const duration = taskStart ? timestamp - taskStart.started : 0;
30
- return fetch(`${this.ingestPoint}/v1/web/uxt/signals/task`, {
31
- method: 'POST',
32
- headers: {
33
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
34
- Authorization: `Bearer ${this.token}`,
35
- },
36
- body: JSON.stringify({
37
- testId: this.testId,
38
- taskId,
39
- status,
40
- duration,
41
- timestamp,
42
- taskAnswer,
43
- }),
44
- });
45
- };
46
- this.signalTest = (status) => {
47
- const timestamp = this.getTimestamp();
48
- if (status === 'begin' && this.testId) {
49
- const sessionId = this.getSessionId();
50
- this.setStorageKey(SESSION_ID, sessionId);
51
- this.setStorageKey(this.storageKey, this.testId.toString());
52
- this.setStorageKey(TEST_START, timestamp.toString());
53
- }
54
- else {
55
- this.removeStorageKey(this.storageKey);
56
- this.removeStorageKey(TASK_IND);
57
- this.removeStorageKey(TEST_START);
58
- }
59
- const start = this.durations.testStart || timestamp;
60
- const duration = timestamp - start;
61
- return fetch(`${this.ingestPoint}/v1/web/uxt/signals/test`, {
62
- method: 'POST',
63
- headers: {
64
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
65
- Authorization: `Bearer ${this.token}`,
66
- },
67
- body: JSON.stringify({
68
- testId: this.testId,
69
- status,
70
- duration,
71
- timestamp,
72
- }),
73
- });
74
- };
75
- const possibleStart = this.getStorageKey(TEST_START);
76
- if (possibleStart) {
77
- this.durations.testStart = parseInt(possibleStart, 10);
78
- }
79
- }
80
- }
@@ -1,37 +0,0 @@
1
- // @ts-nocheck
2
- export default function attachDND(element, dragTarget) {
3
- dragTarget.onmousedown = function (event) {
4
- const clientRect = element.getBoundingClientRect();
5
- const shiftX = event.clientX - clientRect.left;
6
- const shiftY = event.clientY - clientRect.top;
7
- element.style.position = 'fixed';
8
- element.style.zIndex = 99999999999999;
9
- moveAt(event.pageX, event.pageY);
10
- function moveAt(pageX, pageY) {
11
- let leftC = pageX - shiftX;
12
- let topC = pageY - shiftY;
13
- if (leftC <= 5)
14
- leftC = 5;
15
- if (topC <= 5)
16
- topC = 5;
17
- if (leftC >= window.innerWidth - clientRect.width)
18
- leftC = window.innerWidth - clientRect.width;
19
- if (topC >= window.innerHeight - clientRect.height)
20
- topC = window.innerHeight - clientRect.height;
21
- element.style.left = `${leftC}px`;
22
- element.style.top = `${topC}px`;
23
- }
24
- function onMouseMove(event) {
25
- moveAt(event.pageX, event.pageY);
26
- }
27
- document.addEventListener('mousemove', onMouseMove);
28
- const clearAll = () => {
29
- document.removeEventListener('mousemove', onMouseMove);
30
- document.removeEventListener('mouseup', clearAll);
31
- };
32
- document.addEventListener('mouseup', clearAll);
33
- };
34
- dragTarget.ondragstart = function () {
35
- return false;
36
- };
37
- }