@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.
- package/{cjs → dist/cjs}/index.js +27 -49
- package/dist/cjs/index.js.map +1 -0
- package/{cjs → dist/cjs/main}/app/index.d.ts +38 -6
- package/{lib → dist/cjs/main}/app/messages.gen.d.ts +2 -2
- package/{lib/app/nodes.d.ts → dist/cjs/main/app/nodes/index.d.ts} +15 -7
- package/dist/cjs/main/app/nodes/maintainer.d.ts +28 -0
- package/{cjs → dist/cjs/main}/app/observer/iframe_observer.d.ts +1 -1
- package/{lib → dist/cjs/main}/app/observer/iframe_offsets.d.ts +1 -1
- package/{lib → dist/cjs/main}/app/observer/observer.d.ts +6 -0
- package/{lib → dist/cjs/main}/app/observer/top_observer.d.ts +6 -2
- package/{cjs → dist/cjs/main}/app/sanitizer.d.ts +5 -2
- package/{cjs → dist/cjs/main}/app/session.d.ts +6 -3
- package/{lib → dist/cjs/main}/index.d.ts +2 -2
- package/{lib → dist/cjs/main}/modules/attributeSender.d.ts +5 -2
- package/{cjs → dist/cjs/main}/modules/conditionsManager.d.ts +1 -1
- package/{cjs → dist/cjs/main}/modules/tagWatcher.d.ts +8 -4
- package/{lib → dist/cjs/main}/modules/userTesting/SignalManager.d.ts +2 -2
- package/{lib → dist/cjs/main}/utils.d.ts +4 -3
- package/dist/lib/index.js +9323 -0
- package/dist/lib/index.js.map +1 -0
- package/{lib → dist/lib/main}/app/index.d.ts +38 -6
- package/{cjs → dist/lib/main}/app/messages.gen.d.ts +2 -2
- package/{cjs/app/nodes.d.ts → dist/lib/main/app/nodes/index.d.ts} +15 -7
- package/dist/lib/main/app/nodes/maintainer.d.ts +28 -0
- package/{lib → dist/lib/main}/app/observer/iframe_observer.d.ts +1 -1
- package/{cjs → dist/lib/main}/app/observer/iframe_offsets.d.ts +1 -1
- package/{cjs → dist/lib/main}/app/observer/observer.d.ts +6 -0
- package/{cjs → dist/lib/main}/app/observer/top_observer.d.ts +6 -2
- package/{lib → dist/lib/main}/app/sanitizer.d.ts +5 -2
- package/{lib → dist/lib/main}/app/session.d.ts +6 -3
- package/{cjs → dist/lib/main}/index.d.ts +2 -2
- package/{cjs → dist/lib/main}/modules/attributeSender.d.ts +5 -2
- package/{lib → dist/lib/main}/modules/conditionsManager.d.ts +1 -1
- package/{lib → dist/lib/main}/modules/tagWatcher.d.ts +8 -4
- package/{cjs → dist/lib/main}/modules/userTesting/SignalManager.d.ts +2 -2
- package/{cjs → dist/lib/main}/utils.d.ts +4 -3
- package/package.json +29 -10
- package/.eslintignore +0 -11
- package/.nvmrc +0 -1
- package/.prettierignore +0 -1
- package/CHANGELOG.md +0 -297
- package/bun.lockb +0 -0
- package/cjs/app/canvas.js +0 -204
- package/cjs/app/guards.js +0 -37
- package/cjs/app/index.js +0 -1366
- package/cjs/app/logger.js +0 -37
- package/cjs/app/messages.gen.js +0 -702
- package/cjs/app/nodes.js +0 -110
- package/cjs/app/observer/iframe_observer.js +0 -35
- package/cjs/app/observer/iframe_offsets.js +0 -56
- package/cjs/app/observer/observer.js +0 -352
- package/cjs/app/observer/shadow_root_observer.js +0 -24
- package/cjs/app/observer/top_observer.js +0 -134
- package/cjs/app/sanitizer.js +0 -82
- package/cjs/app/session.js +0 -140
- package/cjs/app/ticker.js +0 -48
- package/cjs/common/interaction.js +0 -2
- package/cjs/common/messages.gen.js +0 -4
- package/cjs/modules/attributeSender.js +0 -51
- package/cjs/modules/axiosSpy.js +0 -122
- package/cjs/modules/conditionsManager.js +0 -343
- package/cjs/modules/connection.js +0 -15
- package/cjs/modules/console.js +0 -127
- package/cjs/modules/constructedStyleSheets.js +0 -138
- package/cjs/modules/cssrules.js +0 -99
- package/cjs/modules/exception.js +0 -85
- package/cjs/modules/featureFlags.js +0 -89
- package/cjs/modules/focus.js +0 -45
- package/cjs/modules/fonts.js +0 -57
- package/cjs/modules/img.js +0 -110
- package/cjs/modules/input.js +0 -203
- package/cjs/modules/mouse.js +0 -195
- package/cjs/modules/network.js +0 -244
- package/cjs/modules/performance.js +0 -53
- package/cjs/modules/scroll.js +0 -84
- package/cjs/modules/selection.js +0 -37
- package/cjs/modules/tabs.js +0 -13
- package/cjs/modules/tagWatcher.js +0 -76
- package/cjs/modules/timing.js +0 -173
- package/cjs/modules/userTesting/SignalManager.js +0 -83
- package/cjs/modules/userTesting/dnd.js +0 -40
- package/cjs/modules/userTesting/index.js +0 -464
- package/cjs/modules/userTesting/recorder.js +0 -101
- package/cjs/modules/userTesting/styles.js +0 -266
- package/cjs/modules/userTesting/utils.js +0 -87
- package/cjs/modules/viewport.js +0 -43
- package/cjs/package.json +0 -1
- package/cjs/utils.js +0 -230
- package/coverage/clover.xml +0 -4304
- package/coverage/coverage-final.json +0 -55
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -206
- package/coverage/lcov-report/main/app/canvas.ts.html +0 -712
- package/coverage/lcov-report/main/app/guards.ts.html +0 -232
- package/coverage/lcov-report/main/app/index.html +0 -236
- package/coverage/lcov-report/main/app/index.ts.html +0 -3955
- package/coverage/lcov-report/main/app/logger.ts.html +0 -211
- package/coverage/lcov-report/main/app/messages.gen.ts.html +0 -3034
- package/coverage/lcov-report/main/app/nodes.ts.html +0 -406
- package/coverage/lcov-report/main/app/observer/iframe_observer.ts.html +0 -148
- package/coverage/lcov-report/main/app/observer/iframe_offsets.ts.html +0 -289
- package/coverage/lcov-report/main/app/observer/index.html +0 -161
- package/coverage/lcov-report/main/app/observer/shadow_root_observer.ts.html +0 -142
- package/coverage/lcov-report/main/app/observer/top_observer.ts.html +0 -541
- package/coverage/lcov-report/main/app/sanitizer.ts.html +0 -403
- package/coverage/lcov-report/main/app/session.ts.html +0 -622
- package/coverage/lcov-report/main/app/ticker.ts.html +0 -250
- package/coverage/lcov-report/main/index.html +0 -131
- package/coverage/lcov-report/main/index.ts.html +0 -1597
- package/coverage/lcov-report/main/modules/Network/beaconProxy.ts.html +0 -400
- package/coverage/lcov-report/main/modules/Network/fetchProxy.ts.html +0 -1075
- package/coverage/lcov-report/main/modules/Network/index.html +0 -191
- package/coverage/lcov-report/main/modules/Network/index.ts.html +0 -244
- package/coverage/lcov-report/main/modules/Network/networkMessage.ts.html +0 -400
- package/coverage/lcov-report/main/modules/Network/utils.ts.html +0 -709
- package/coverage/lcov-report/main/modules/Network/xhrProxy.ts.html +0 -877
- package/coverage/lcov-report/main/modules/attributeSender.ts.html +0 -241
- package/coverage/lcov-report/main/modules/axiosSpy.ts.html +0 -709
- package/coverage/lcov-report/main/modules/conditionsManager.ts.html +0 -1381
- package/coverage/lcov-report/main/modules/connection.ts.html +0 -160
- package/coverage/lcov-report/main/modules/console.ts.html +0 -541
- package/coverage/lcov-report/main/modules/constructedStyleSheets.ts.html +0 -571
- package/coverage/lcov-report/main/modules/cssrules.ts.html +0 -418
- package/coverage/lcov-report/main/modules/exception.ts.html +0 -385
- package/coverage/lcov-report/main/modules/featureFlags.ts.html +0 -415
- package/coverage/lcov-report/main/modules/focus.ts.html +0 -220
- package/coverage/lcov-report/main/modules/fonts.ts.html +0 -289
- package/coverage/lcov-report/main/modules/img.ts.html +0 -436
- package/coverage/lcov-report/main/modules/index.html +0 -431
- package/coverage/lcov-report/main/modules/input.ts.html +0 -826
- package/coverage/lcov-report/main/modules/mouse.ts.html +0 -826
- package/coverage/lcov-report/main/modules/network.ts.html +0 -1123
- package/coverage/lcov-report/main/modules/performance.ts.html +0 -367
- package/coverage/lcov-report/main/modules/scroll.ts.html +0 -364
- package/coverage/lcov-report/main/modules/selection.ts.html +0 -202
- package/coverage/lcov-report/main/modules/tabs.ts.html +0 -124
- package/coverage/lcov-report/main/modules/tagWatcher.ts.html +0 -337
- package/coverage/lcov-report/main/modules/timing.ts.html +0 -877
- package/coverage/lcov-report/main/modules/userTesting/SignalManager.ts.html +0 -370
- package/coverage/lcov-report/main/modules/userTesting/dnd.ts.html +0 -220
- package/coverage/lcov-report/main/modules/userTesting/index.html +0 -191
- package/coverage/lcov-report/main/modules/userTesting/index.ts.html +0 -1909
- package/coverage/lcov-report/main/modules/userTesting/recorder.ts.html +0 -430
- package/coverage/lcov-report/main/modules/userTesting/styles.ts.html +0 -937
- package/coverage/lcov-report/main/modules/userTesting/utils.ts.html +0 -364
- package/coverage/lcov-report/main/modules/viewport.ts.html +0 -250
- package/coverage/lcov-report/main/utils.ts.html +0 -814
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/webworker/BatchWriter.ts.html +0 -499
- package/coverage/lcov-report/webworker/MessageEncoder.gen.ts.html +0 -1021
- package/coverage/lcov-report/webworker/PrimitiveEncoder.ts.html +0 -436
- package/coverage/lcov-report/webworker/QueueSender.ts.html +0 -547
- package/coverage/lcov-report/webworker/index.html +0 -176
- package/coverage/lcov-report/webworker/index.ts.html +0 -667
- package/coverage/lcov.info +0 -8425
- package/jest.config.js +0 -13
- package/lib/app/canvas.js +0 -202
- package/lib/app/guards.js +0 -26
- package/lib/app/index.js +0 -1336
- package/lib/app/logger.js +0 -33
- package/lib/app/messages.gen.js +0 -622
- package/lib/app/nodes.js +0 -107
- package/lib/app/observer/iframe_observer.js +0 -29
- package/lib/app/observer/iframe_offsets.js +0 -53
- package/lib/app/observer/observer.js +0 -349
- package/lib/app/observer/shadow_root_observer.js +0 -18
- package/lib/app/observer/top_observer.js +0 -128
- package/lib/app/sanitizer.js +0 -77
- package/lib/app/session.js +0 -137
- package/lib/app/ticker.js +0 -45
- package/lib/common/interaction.js +0 -1
- package/lib/common/messages.gen.js +0 -3
- package/lib/common/tsconfig.tsbuildinfo +0 -1
- package/lib/index.js +0 -423
- package/lib/modules/attributeSender.js +0 -46
- package/lib/modules/axiosSpy.js +0 -119
- package/lib/modules/conditionsManager.js +0 -340
- package/lib/modules/connection.js +0 -12
- package/lib/modules/console.js +0 -124
- package/lib/modules/constructedStyleSheets.js +0 -133
- package/lib/modules/cssrules.js +0 -97
- package/lib/modules/exception.js +0 -76
- package/lib/modules/featureFlags.js +0 -86
- package/lib/modules/focus.js +0 -42
- package/lib/modules/fonts.js +0 -54
- package/lib/modules/img.js +0 -107
- package/lib/modules/input.js +0 -198
- package/lib/modules/mouse.js +0 -192
- package/lib/modules/network.js +0 -238
- package/lib/modules/performance.js +0 -49
- package/lib/modules/scroll.js +0 -81
- package/lib/modules/selection.js +0 -35
- package/lib/modules/tabs.js +0 -10
- package/lib/modules/tagWatcher.js +0 -73
- package/lib/modules/timing.js +0 -170
- package/lib/modules/userTesting/SignalManager.js +0 -80
- package/lib/modules/userTesting/dnd.js +0 -37
- package/lib/modules/userTesting/index.js +0 -435
- package/lib/modules/userTesting/recorder.js +0 -97
- package/lib/modules/userTesting/styles.js +0 -263
- package/lib/modules/userTesting/utils.js +0 -79
- package/lib/modules/viewport.js +0 -40
- package/lib/utils.js +0 -211
- package/rollup.config.js +0 -12
- package/scripts/checkver.cjs +0 -7
- package/tsconfig-base.json +0 -16
- /package/{cjs → dist/cjs}/common/interaction.d.ts +0 -0
- /package/{cjs → dist/cjs}/common/messages.gen.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/app/canvas.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/app/guards.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/app/logger.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/app/observer/shadow_root_observer.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/app/ticker.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/axiosSpy.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/connection.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/console.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/constructedStyleSheets.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/cssrules.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/exception.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/featureFlags.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/focus.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/fonts.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/img.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/input.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/mouse.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/network.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/performance.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/scroll.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/selection.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/tabs.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/timing.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/userTesting/dnd.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/userTesting/index.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/userTesting/recorder.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/userTesting/styles.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/userTesting/utils.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/viewport.d.ts +0 -0
- /package/{lib → dist/lib}/common/interaction.d.ts +0 -0
- /package/{lib → dist/lib}/common/messages.gen.d.ts +0 -0
- /package/{lib → dist/lib/main}/app/canvas.d.ts +0 -0
- /package/{lib → dist/lib/main}/app/guards.d.ts +0 -0
- /package/{lib → dist/lib/main}/app/logger.d.ts +0 -0
- /package/{lib → dist/lib/main}/app/observer/shadow_root_observer.d.ts +0 -0
- /package/{lib → dist/lib/main}/app/ticker.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/axiosSpy.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/connection.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/console.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/constructedStyleSheets.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/cssrules.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/exception.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/featureFlags.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/focus.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/fonts.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/img.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/input.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/mouse.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/network.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/performance.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/scroll.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/selection.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/tabs.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/timing.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/userTesting/dnd.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/userTesting/index.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/userTesting/recorder.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/userTesting/styles.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/userTesting/utils.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/viewport.d.ts +0 -0
|
@@ -1,435 +0,0 @@
|
|
|
1
|
-
import * as styles from './styles.js';
|
|
2
|
-
import Recorder, { Quality } from './recorder.js';
|
|
3
|
-
import attachDND from './dnd.js';
|
|
4
|
-
import { generateGrid, generateChevron, createSpinner, createElement, TEST_START, TASK_IND, SESSION_ID, TEST_ID, } from './utils.js';
|
|
5
|
-
import SignalManager from './SignalManager.js';
|
|
6
|
-
export default class UserTestManager {
|
|
7
|
-
constructor(app, storageKey) {
|
|
8
|
-
this.app = app;
|
|
9
|
-
this.storageKey = storageKey;
|
|
10
|
-
this.bg = createElement('div', 'bg', styles.bgStyle, undefined, '__or_ut_bg');
|
|
11
|
-
this.container = createElement('div', 'container', styles.containerStyle, undefined, '__or_ut_ct');
|
|
12
|
-
this.widgetGuidelinesVisible = true;
|
|
13
|
-
this.widgetTasksVisible = false;
|
|
14
|
-
this.widgetVisible = true;
|
|
15
|
-
this.isActive = false;
|
|
16
|
-
this.descriptionSection = null;
|
|
17
|
-
this.taskSection = null;
|
|
18
|
-
this.endSection = null;
|
|
19
|
-
this.stopButton = null;
|
|
20
|
-
this.stopButtonContainer = null;
|
|
21
|
-
this.test = null;
|
|
22
|
-
this.testId = null;
|
|
23
|
-
this.signalManager = null;
|
|
24
|
-
this.getTest = (id, token, inProgress) => {
|
|
25
|
-
this.testId = id;
|
|
26
|
-
const ingest = this.app.options.ingestPoint;
|
|
27
|
-
return fetch(`${ingest}/v1/web/uxt/test/${id}`, {
|
|
28
|
-
headers: {
|
|
29
|
-
Authorization: `Bearer ${token}`,
|
|
30
|
-
},
|
|
31
|
-
})
|
|
32
|
-
.then((res) => res.json())
|
|
33
|
-
.then(({ test }) => {
|
|
34
|
-
this.isActive = true;
|
|
35
|
-
this.test = test;
|
|
36
|
-
this.signalManager = new SignalManager(this.app.options.ingestPoint, () => this.app.timestamp(), token, id, this.storageKey, (k, v) => this.app.localStorage.setItem(k, v), (k) => this.app.localStorage.removeItem(k), (k) => this.app.localStorage.getItem(k), () => this.app.getSessionID());
|
|
37
|
-
this.createGreeting(test.title, test.reqMic, test.reqCamera);
|
|
38
|
-
if (inProgress) {
|
|
39
|
-
if (test.reqMic || test.reqCamera) {
|
|
40
|
-
void this.userRecorder.startRecording(30, Quality.Standard, test.reqMic, test.reqCamera);
|
|
41
|
-
}
|
|
42
|
-
this.showWidget(test.description, test.tasks, true);
|
|
43
|
-
this.showTaskSection();
|
|
44
|
-
}
|
|
45
|
-
})
|
|
46
|
-
.then(() => id)
|
|
47
|
-
.catch((err) => {
|
|
48
|
-
console.log('OR: Error fetching test', err);
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
this.hideTaskSection = () => false;
|
|
52
|
-
this.showTaskSection = () => true;
|
|
53
|
-
this.collapseWidget = () => false;
|
|
54
|
-
this.removeGreeting = () => false;
|
|
55
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
56
|
-
this.toggleDescriptionVisibility = () => { };
|
|
57
|
-
this.currentTaskIndex = 0;
|
|
58
|
-
this.userRecorder = new Recorder(app);
|
|
59
|
-
const sessionId = this.app.getSessionID();
|
|
60
|
-
const savedSessionId = this.app.localStorage.getItem(SESSION_ID);
|
|
61
|
-
if (sessionId !== savedSessionId) {
|
|
62
|
-
this.app.localStorage.removeItem(this.storageKey);
|
|
63
|
-
this.app.localStorage.removeItem(SESSION_ID);
|
|
64
|
-
this.app.localStorage.removeItem(TEST_ID);
|
|
65
|
-
this.app.localStorage.removeItem(TASK_IND);
|
|
66
|
-
this.app.localStorage.removeItem(TEST_START);
|
|
67
|
-
}
|
|
68
|
-
const taskIndex = this.app.localStorage.getItem(TASK_IND);
|
|
69
|
-
if (taskIndex) {
|
|
70
|
-
this.currentTaskIndex = parseInt(taskIndex, 10);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
getTestId() {
|
|
74
|
-
return this.testId;
|
|
75
|
-
}
|
|
76
|
-
createGreeting(title, micRequired, cameraRequired) {
|
|
77
|
-
const titleElement = createElement('div', 'title', styles.titleStyle, title);
|
|
78
|
-
const descriptionElement = createElement('div', 'description', styles.descriptionStyle, `Welcome, you're here to help us improve, not to be judged. Your insights matter!\n
|
|
79
|
-
📹 We're recording this browser tab to learn from your experience.
|
|
80
|
-
🎤 Please enable mic and camera if asked, to give us a complete picture.`);
|
|
81
|
-
const buttonElement = createElement('div', 'button', styles.buttonStyle, 'Read guidelines to begin');
|
|
82
|
-
this.removeGreeting = () => {
|
|
83
|
-
// this.container.innerHTML = ''
|
|
84
|
-
if (micRequired || cameraRequired) {
|
|
85
|
-
void this.userRecorder.startRecording(30, Quality.Standard, micRequired, cameraRequired);
|
|
86
|
-
}
|
|
87
|
-
this.container.removeChild(buttonElement);
|
|
88
|
-
this.container.removeChild(descriptionElement);
|
|
89
|
-
this.container.removeChild(titleElement);
|
|
90
|
-
return false;
|
|
91
|
-
};
|
|
92
|
-
buttonElement.onclick = () => {
|
|
93
|
-
this.removeGreeting();
|
|
94
|
-
const durations = this.signalManager?.getDurations();
|
|
95
|
-
if (durations && this.signalManager) {
|
|
96
|
-
durations.testStart = this.app.timestamp();
|
|
97
|
-
this.signalManager.setDurations(durations);
|
|
98
|
-
}
|
|
99
|
-
void this.signalManager?.signalTest('begin');
|
|
100
|
-
this.container.style.fontFamily = `-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"`;
|
|
101
|
-
Object.assign(this.container.style, styles.containerWidgetStyle);
|
|
102
|
-
this.showWidget(this.test?.guidelines || '', this.test?.tasks || []);
|
|
103
|
-
};
|
|
104
|
-
this.container.append(titleElement, descriptionElement, buttonElement);
|
|
105
|
-
this.bg.appendChild(this.container);
|
|
106
|
-
document.body.appendChild(this.bg);
|
|
107
|
-
}
|
|
108
|
-
showWidget(guidelines, tasks, inProgress) {
|
|
109
|
-
this.container.innerHTML = '';
|
|
110
|
-
Object.assign(this.bg.style, {
|
|
111
|
-
position: 'fixed',
|
|
112
|
-
zIndex: 99999999999999,
|
|
113
|
-
right: '8px',
|
|
114
|
-
left: 'unset',
|
|
115
|
-
width: 'fit-content',
|
|
116
|
-
top: '8px',
|
|
117
|
-
height: 'fit-content',
|
|
118
|
-
background: 'unset',
|
|
119
|
-
display: 'unset',
|
|
120
|
-
alignItems: 'unset',
|
|
121
|
-
justifyContent: 'unset',
|
|
122
|
-
});
|
|
123
|
-
// Create title section
|
|
124
|
-
const titleSection = this.createTitleSection();
|
|
125
|
-
this.container.style.fontFamily = `-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"`;
|
|
126
|
-
Object.assign(this.container.style, styles.containerWidgetStyle);
|
|
127
|
-
const descriptionSection = this.createDescriptionSection(guidelines);
|
|
128
|
-
const tasksSection = this.createTasksSection(tasks);
|
|
129
|
-
const stopButton = createElement('div', 'stop_bn_or', styles.stopWidgetStyle, 'Abort Session');
|
|
130
|
-
const stopContainer = createElement('div', 'stop_ct_or', { fontSize: '13px!important' });
|
|
131
|
-
stopContainer.style.fontSize = '13px';
|
|
132
|
-
stopContainer.append(stopButton);
|
|
133
|
-
this.container.append(titleSection, descriptionSection, tasksSection, stopContainer);
|
|
134
|
-
this.taskSection = tasksSection;
|
|
135
|
-
this.descriptionSection = descriptionSection;
|
|
136
|
-
this.stopButton = stopButton;
|
|
137
|
-
this.stopButtonContainer = stopContainer;
|
|
138
|
-
stopButton.onclick = () => {
|
|
139
|
-
this.userRecorder.discard();
|
|
140
|
-
void this.signalManager?.signalTest('skipped');
|
|
141
|
-
document.body.removeChild(this.bg);
|
|
142
|
-
window.close();
|
|
143
|
-
};
|
|
144
|
-
if (!inProgress) {
|
|
145
|
-
this.hideTaskSection();
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
this.toggleDescriptionVisibility();
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
createTitleSection() {
|
|
152
|
-
const title = createElement('div', 'title', styles.titleWidgetStyle);
|
|
153
|
-
const leftIcon = generateGrid();
|
|
154
|
-
const titleText = createElement('div', 'title_text', {
|
|
155
|
-
maxWidth: '19rem',
|
|
156
|
-
overflow: 'hidden',
|
|
157
|
-
textOverflow: 'ellipsis',
|
|
158
|
-
width: '100%',
|
|
159
|
-
fontSize: 16,
|
|
160
|
-
lineHeight: 'auto',
|
|
161
|
-
cursor: 'pointer',
|
|
162
|
-
}, this.test?.title);
|
|
163
|
-
const rightIcon = generateChevron();
|
|
164
|
-
title.append(leftIcon, titleText, rightIcon);
|
|
165
|
-
const toggleWidget = (isVisible) => {
|
|
166
|
-
this.widgetVisible = isVisible;
|
|
167
|
-
this.container.style.fontFamily = `-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"`;
|
|
168
|
-
Object.assign(this.container.style, this.widgetVisible
|
|
169
|
-
? styles.containerWidgetStyle
|
|
170
|
-
: { border: 'none', background: 'none', padding: 0 });
|
|
171
|
-
if (this.taskSection) {
|
|
172
|
-
Object.assign(this.taskSection.style, this.widgetVisible ? styles.descriptionWidgetStyle : { display: 'none' });
|
|
173
|
-
}
|
|
174
|
-
if (this.descriptionSection) {
|
|
175
|
-
Object.assign(this.descriptionSection.style, this.widgetVisible ? styles.descriptionWidgetStyle : { display: 'none' });
|
|
176
|
-
}
|
|
177
|
-
if (this.endSection) {
|
|
178
|
-
Object.assign(this.endSection.style, this.widgetVisible ? styles.descriptionWidgetStyle : { display: 'none' });
|
|
179
|
-
}
|
|
180
|
-
if (this.stopButton) {
|
|
181
|
-
Object.assign(this.stopButton.style, this.widgetVisible ? styles.stopWidgetStyle : { display: 'none' });
|
|
182
|
-
}
|
|
183
|
-
return isVisible;
|
|
184
|
-
};
|
|
185
|
-
const collapseWidget = () => {
|
|
186
|
-
Object.assign(rightIcon.style, {
|
|
187
|
-
transform: this.widgetVisible ? 'rotate(0deg)' : 'rotate(180deg)',
|
|
188
|
-
});
|
|
189
|
-
toggleWidget(!this.widgetVisible);
|
|
190
|
-
};
|
|
191
|
-
titleText.onclick = collapseWidget;
|
|
192
|
-
rightIcon.onclick = collapseWidget;
|
|
193
|
-
attachDND(this.bg, leftIcon);
|
|
194
|
-
this.collapseWidget = () => toggleWidget(false);
|
|
195
|
-
return title;
|
|
196
|
-
}
|
|
197
|
-
createDescriptionSection(guidelines) {
|
|
198
|
-
const section = createElement('div', 'description_section_or', styles.descriptionWidgetStyle);
|
|
199
|
-
const titleContainer = createElement('div', 'description_s_title_or', styles.sectionTitleStyle);
|
|
200
|
-
const title = createElement('div', 'title', {
|
|
201
|
-
fontSize: 13,
|
|
202
|
-
fontWeight: 500,
|
|
203
|
-
lineHeight: 'auto',
|
|
204
|
-
}, 'Introduction & Guidelines');
|
|
205
|
-
const icon = createElement('div', 'icon', styles.symbolIcon, '-');
|
|
206
|
-
const content = createElement('div', 'content', styles.contentStyle);
|
|
207
|
-
const descriptionC = createElement('div', 'text_description', {
|
|
208
|
-
maxHeight: '250px',
|
|
209
|
-
overflowY: 'auto',
|
|
210
|
-
whiteSpace: 'pre-wrap',
|
|
211
|
-
fontSize: 13,
|
|
212
|
-
color: '#454545',
|
|
213
|
-
lineHeight: 'auto',
|
|
214
|
-
});
|
|
215
|
-
descriptionC.innerHTML = guidelines;
|
|
216
|
-
const button = createElement('div', 'button_begin_or', styles.buttonWidgetStyle, 'Begin Test');
|
|
217
|
-
titleContainer.append(title, icon);
|
|
218
|
-
content.append(descriptionC, button);
|
|
219
|
-
section.append(titleContainer, content);
|
|
220
|
-
const toggleDescriptionVisibility = () => {
|
|
221
|
-
this.widgetGuidelinesVisible = !this.widgetGuidelinesVisible;
|
|
222
|
-
icon.textContent = this.widgetGuidelinesVisible ? '-' : '+';
|
|
223
|
-
Object.assign(content.style, this.widgetGuidelinesVisible ? styles.contentStyle : { display: 'none' });
|
|
224
|
-
};
|
|
225
|
-
titleContainer.onclick = toggleDescriptionVisibility;
|
|
226
|
-
this.toggleDescriptionVisibility = () => {
|
|
227
|
-
this.widgetGuidelinesVisible = false;
|
|
228
|
-
icon.textContent = this.widgetGuidelinesVisible ? '-' : '+';
|
|
229
|
-
Object.assign(content.style, this.widgetGuidelinesVisible ? styles.contentStyle : { display: 'none' });
|
|
230
|
-
content.removeChild(button);
|
|
231
|
-
};
|
|
232
|
-
button.onclick = () => {
|
|
233
|
-
toggleDescriptionVisibility();
|
|
234
|
-
if (this.test) {
|
|
235
|
-
const durations = this.signalManager?.getDurations();
|
|
236
|
-
const taskDurationInd = durations
|
|
237
|
-
? durations.tasks.findIndex((t) => this.test && t.taskId === this.test.tasks[0].task_id)
|
|
238
|
-
: null;
|
|
239
|
-
if (durations && taskDurationInd === -1) {
|
|
240
|
-
durations.tasks.push({
|
|
241
|
-
taskId: this.test.tasks[0].task_id,
|
|
242
|
-
started: this.app.timestamp(),
|
|
243
|
-
});
|
|
244
|
-
this.signalManager?.setDurations(durations);
|
|
245
|
-
}
|
|
246
|
-
void this.signalManager?.signalTask(this.test.tasks[0].task_id, 'begin');
|
|
247
|
-
}
|
|
248
|
-
this.showTaskSection();
|
|
249
|
-
content.removeChild(button);
|
|
250
|
-
};
|
|
251
|
-
return section;
|
|
252
|
-
}
|
|
253
|
-
createTasksSection(tasks) {
|
|
254
|
-
this.container.style.fontFamily = `-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"`;
|
|
255
|
-
Object.assign(this.container.style, styles.containerWidgetStyle);
|
|
256
|
-
const section = createElement('div', 'task_section_or', styles.descriptionWidgetStyle);
|
|
257
|
-
const titleContainer = createElement('div', 'description_t_title_or', styles.sectionTitleStyle);
|
|
258
|
-
const title = createElement('div', 'title', {
|
|
259
|
-
fontSize: '13px',
|
|
260
|
-
fontWeight: '500',
|
|
261
|
-
lineHeight: 'auto',
|
|
262
|
-
}, 'Tasks');
|
|
263
|
-
const icon = createElement('div', 'icon', styles.symbolIcon, '-');
|
|
264
|
-
const content = createElement('div', 'content', styles.contentStyle);
|
|
265
|
-
const pagination = createElement('div', 'pagination', styles.paginationStyle);
|
|
266
|
-
// const leftArrow = createElement('span', 'leftArrow', {}, '<')
|
|
267
|
-
// const rightArrow = createElement('span', 'rightArrow', {}, '>')
|
|
268
|
-
const taskCard = createElement('div', 'taskCard', styles.taskDescriptionCard);
|
|
269
|
-
const taskText = createElement('div', 'taskText', styles.taskTextStyle);
|
|
270
|
-
const taskDescription = createElement('div', 'taskDescription', styles.taskDescriptionStyle);
|
|
271
|
-
const taskButtons = createElement('div', 'taskButtons', styles.taskButtonsRow);
|
|
272
|
-
const inputTitle = createElement('div', 'taskText', styles.taskTextStyle);
|
|
273
|
-
inputTitle.textContent = 'Your answer';
|
|
274
|
-
const inputArea = createElement('textarea', 'taskDescription', {
|
|
275
|
-
resize: 'vertical',
|
|
276
|
-
});
|
|
277
|
-
const inputContainer = createElement('div', 'inputArea', styles.taskDescriptionCard);
|
|
278
|
-
inputContainer.append(inputTitle, inputArea);
|
|
279
|
-
const closePanelButton = createElement('div', 'closePanelButton', styles.taskButtonStyle, 'Collapse Panel');
|
|
280
|
-
const nextButton = createElement('div', 'nextButton', styles.taskButtonBorderedStyle, 'Done, Next');
|
|
281
|
-
titleContainer.append(title, icon);
|
|
282
|
-
taskCard.append(taskText, taskDescription);
|
|
283
|
-
taskButtons.append(closePanelButton, nextButton);
|
|
284
|
-
content.append(pagination, taskCard, inputContainer, taskButtons);
|
|
285
|
-
section.append(titleContainer, content);
|
|
286
|
-
const updateTaskContent = () => {
|
|
287
|
-
const task = tasks[this.currentTaskIndex];
|
|
288
|
-
taskText.textContent = task.title;
|
|
289
|
-
taskDescription.textContent = task.description;
|
|
290
|
-
if (task.allow_typing) {
|
|
291
|
-
inputContainer.style.display = 'flex';
|
|
292
|
-
}
|
|
293
|
-
else {
|
|
294
|
-
inputContainer.style.display = 'none';
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
// pagination.appendChild(leftArrow)
|
|
298
|
-
tasks.forEach((_, index) => {
|
|
299
|
-
const pageNumber = createElement('span', `or_task_${index}`, {
|
|
300
|
-
outline: '1px solid #efefef',
|
|
301
|
-
fontSize: '13px',
|
|
302
|
-
height: '24px',
|
|
303
|
-
width: '24px',
|
|
304
|
-
display: 'flex',
|
|
305
|
-
flexDirection: 'column',
|
|
306
|
-
alignItems: 'center',
|
|
307
|
-
justifyContent: 'center',
|
|
308
|
-
borderRadius: '6.25em',
|
|
309
|
-
}, (index + 1).toString());
|
|
310
|
-
pageNumber.id = `or_task_${index}`;
|
|
311
|
-
pagination.append(pageNumber);
|
|
312
|
-
});
|
|
313
|
-
// pagination.appendChild(rightArrow)
|
|
314
|
-
const toggleTasksVisibility = () => {
|
|
315
|
-
this.widgetTasksVisible = !this.widgetTasksVisible;
|
|
316
|
-
icon.textContent = this.widgetTasksVisible ? '-' : '+';
|
|
317
|
-
Object.assign(content.style, this.widgetTasksVisible ? styles.contentStyle : { display: 'none' });
|
|
318
|
-
};
|
|
319
|
-
this.hideTaskSection = () => {
|
|
320
|
-
icon.textContent = '+';
|
|
321
|
-
Object.assign(content.style, {
|
|
322
|
-
display: 'none',
|
|
323
|
-
});
|
|
324
|
-
this.widgetTasksVisible = false;
|
|
325
|
-
return false;
|
|
326
|
-
};
|
|
327
|
-
this.showTaskSection = () => {
|
|
328
|
-
icon.textContent = '-';
|
|
329
|
-
Object.assign(content.style, styles.contentStyle);
|
|
330
|
-
this.widgetTasksVisible = true;
|
|
331
|
-
return true;
|
|
332
|
-
};
|
|
333
|
-
const highlightActive = () => {
|
|
334
|
-
const activeTaskEl = document.getElementById(`or_task_${this.currentTaskIndex}`);
|
|
335
|
-
if (activeTaskEl) {
|
|
336
|
-
Object.assign(activeTaskEl.style, styles.taskNumberActive);
|
|
337
|
-
}
|
|
338
|
-
for (let i = 0; i < this.currentTaskIndex; i++) {
|
|
339
|
-
const taskEl = document.getElementById(`or_task_${i}`);
|
|
340
|
-
if (taskEl) {
|
|
341
|
-
Object.assign(taskEl.style, styles.taskNumberDone);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
};
|
|
345
|
-
titleContainer.onclick = toggleTasksVisibility;
|
|
346
|
-
closePanelButton.onclick = this.collapseWidget;
|
|
347
|
-
nextButton.onclick = () => {
|
|
348
|
-
const textAnswer = tasks[this.currentTaskIndex].allow_typing ? inputArea.value : undefined;
|
|
349
|
-
inputArea.value = '';
|
|
350
|
-
void this.signalManager?.signalTask(tasks[this.currentTaskIndex].task_id, 'done', textAnswer);
|
|
351
|
-
if (this.currentTaskIndex < tasks.length - 1) {
|
|
352
|
-
this.currentTaskIndex++;
|
|
353
|
-
updateTaskContent();
|
|
354
|
-
const durations = this.signalManager?.getDurations();
|
|
355
|
-
if (durations &&
|
|
356
|
-
durations.tasks.findIndex((t) => t.taskId === tasks[this.currentTaskIndex].task_id) === -1) {
|
|
357
|
-
durations.tasks.push({
|
|
358
|
-
taskId: tasks[this.currentTaskIndex].task_id,
|
|
359
|
-
started: this.app.timestamp(),
|
|
360
|
-
});
|
|
361
|
-
this.signalManager?.setDurations(durations);
|
|
362
|
-
}
|
|
363
|
-
void this.signalManager?.signalTask(tasks[this.currentTaskIndex].task_id, 'begin');
|
|
364
|
-
highlightActive();
|
|
365
|
-
}
|
|
366
|
-
else {
|
|
367
|
-
this.showEndSection();
|
|
368
|
-
}
|
|
369
|
-
this.app.localStorage.setItem('or_uxt_task_index', this.currentTaskIndex.toString());
|
|
370
|
-
};
|
|
371
|
-
setTimeout(() => {
|
|
372
|
-
const firstTaskEl = document.getElementById('or_task_0');
|
|
373
|
-
if (firstTaskEl) {
|
|
374
|
-
Object.assign(firstTaskEl.style, styles.taskNumberActive);
|
|
375
|
-
}
|
|
376
|
-
updateTaskContent();
|
|
377
|
-
highlightActive();
|
|
378
|
-
}, 1);
|
|
379
|
-
return section;
|
|
380
|
-
}
|
|
381
|
-
showEndSection() {
|
|
382
|
-
let isLoading = true;
|
|
383
|
-
void this.signalManager?.signalTest('done');
|
|
384
|
-
const section = createElement('div', 'end_section_or', styles.endSectionStyle);
|
|
385
|
-
const title = createElement('div', 'end_title_or', {
|
|
386
|
-
fontSize: '1.25rem',
|
|
387
|
-
fontWeight: '500',
|
|
388
|
-
}, 'Thank you! 👍');
|
|
389
|
-
const description = createElement('div', 'end_description_or', {}, this.test?.conclusion ??
|
|
390
|
-
'Thank you for participating in our usability test. Your feedback has been captured and will be used to enhance our website. \n' +
|
|
391
|
-
'\n' +
|
|
392
|
-
'We appreciate your time and valuable input.');
|
|
393
|
-
const button = createElement('div', 'end_button_or', styles.buttonWidgetStyle, 'Submitting Feedback');
|
|
394
|
-
const spinner = createSpinner();
|
|
395
|
-
button.appendChild(spinner);
|
|
396
|
-
if (this.test?.reqMic || this.test?.reqCamera) {
|
|
397
|
-
void this.userRecorder
|
|
398
|
-
.sendToAPI()
|
|
399
|
-
.then(() => {
|
|
400
|
-
button.removeChild(spinner);
|
|
401
|
-
button.textContent = 'End Session';
|
|
402
|
-
isLoading = false;
|
|
403
|
-
})
|
|
404
|
-
.catch((err) => {
|
|
405
|
-
console.error(err);
|
|
406
|
-
button.removeChild(spinner);
|
|
407
|
-
button.textContent = 'End Session';
|
|
408
|
-
isLoading = false;
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
else {
|
|
412
|
-
button.removeChild(spinner);
|
|
413
|
-
button.textContent = 'End Session';
|
|
414
|
-
isLoading = false;
|
|
415
|
-
}
|
|
416
|
-
if (this.taskSection) {
|
|
417
|
-
this.container.removeChild(this.taskSection);
|
|
418
|
-
}
|
|
419
|
-
if (this.descriptionSection) {
|
|
420
|
-
this.container.removeChild(this.descriptionSection);
|
|
421
|
-
}
|
|
422
|
-
if (this.stopButton && this.stopButtonContainer) {
|
|
423
|
-
this.container.removeChild(this.stopButtonContainer);
|
|
424
|
-
}
|
|
425
|
-
button.onclick = () => {
|
|
426
|
-
if (isLoading)
|
|
427
|
-
return;
|
|
428
|
-
window.close();
|
|
429
|
-
document.body.removeChild(this.bg);
|
|
430
|
-
};
|
|
431
|
-
section.append(title, description, button);
|
|
432
|
-
this.endSection = section;
|
|
433
|
-
this.container.append(section);
|
|
434
|
-
}
|
|
435
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
export const Quality = {
|
|
2
|
-
Standard: { width: 1280, height: 720 },
|
|
3
|
-
High: { width: 1920, height: 1080 },
|
|
4
|
-
};
|
|
5
|
-
export default class Recorder {
|
|
6
|
-
constructor(app) {
|
|
7
|
-
this.app = app;
|
|
8
|
-
this.mediaRecorder = null;
|
|
9
|
-
this.recordedChunks = [];
|
|
10
|
-
this.stream = null;
|
|
11
|
-
this.recStartTs = null;
|
|
12
|
-
}
|
|
13
|
-
async startRecording(fps, quality, micReq, camReq) {
|
|
14
|
-
this.recStartTs = this.app.timestamp();
|
|
15
|
-
const videoConstraints = quality;
|
|
16
|
-
try {
|
|
17
|
-
this.stream = await navigator.mediaDevices.getUserMedia({
|
|
18
|
-
video: camReq ? { ...videoConstraints, frameRate: { ideal: fps } } : false,
|
|
19
|
-
audio: micReq,
|
|
20
|
-
});
|
|
21
|
-
this.mediaRecorder = new MediaRecorder(this.stream, {
|
|
22
|
-
mimeType: 'video/webm;codecs=vp9',
|
|
23
|
-
});
|
|
24
|
-
this.recordedChunks = [];
|
|
25
|
-
this.mediaRecorder.ondataavailable = (event) => {
|
|
26
|
-
if (event.data.size > 0) {
|
|
27
|
-
this.recordedChunks.push(event.data);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
this.mediaRecorder.start();
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
console.error(error);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
async stopRecording() {
|
|
37
|
-
return new Promise((resolve) => {
|
|
38
|
-
if (!this.mediaRecorder)
|
|
39
|
-
return;
|
|
40
|
-
this.mediaRecorder.onstop = () => {
|
|
41
|
-
const blob = new Blob(this.recordedChunks, {
|
|
42
|
-
type: 'video/webm',
|
|
43
|
-
});
|
|
44
|
-
resolve(blob);
|
|
45
|
-
};
|
|
46
|
-
this.mediaRecorder.stop();
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
async sendToAPI() {
|
|
50
|
-
const blob = await this.stopRecording();
|
|
51
|
-
// const formData = new FormData()
|
|
52
|
-
// formData.append('file', blob, 'record.webm')
|
|
53
|
-
// formData.append('start', this.recStartTs?.toString() ?? '')
|
|
54
|
-
return fetch(`${this.app.options.ingestPoint}/v1/web/uxt/upload-url`, {
|
|
55
|
-
headers: {
|
|
56
|
-
Authorization: `Bearer ${this.app.session.getSessionToken()}`,
|
|
57
|
-
},
|
|
58
|
-
})
|
|
59
|
-
.then((r) => {
|
|
60
|
-
if (r.ok) {
|
|
61
|
-
return r.json();
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
throw new Error('Failed to get upload url');
|
|
65
|
-
}
|
|
66
|
-
})
|
|
67
|
-
.then(({ url }) => {
|
|
68
|
-
return fetch(url, {
|
|
69
|
-
method: 'PUT',
|
|
70
|
-
headers: {
|
|
71
|
-
'Content-Type': 'video/webm',
|
|
72
|
-
},
|
|
73
|
-
body: blob,
|
|
74
|
-
});
|
|
75
|
-
})
|
|
76
|
-
.catch(console.error)
|
|
77
|
-
.finally(() => {
|
|
78
|
-
this.discard();
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
async saveToFile(fileName = 'recorded-video.webm') {
|
|
82
|
-
const blob = await this.stopRecording();
|
|
83
|
-
const url = URL.createObjectURL(blob);
|
|
84
|
-
const a = document.createElement('a');
|
|
85
|
-
a.style.display = 'none';
|
|
86
|
-
a.href = url;
|
|
87
|
-
a.download = fileName;
|
|
88
|
-
document.body.appendChild(a);
|
|
89
|
-
a.click();
|
|
90
|
-
window.URL.revokeObjectURL(url);
|
|
91
|
-
document.body.removeChild(a);
|
|
92
|
-
}
|
|
93
|
-
discard() {
|
|
94
|
-
this.mediaRecorder?.stop();
|
|
95
|
-
this.stream?.getTracks().forEach((track) => track.stop());
|
|
96
|
-
}
|
|
97
|
-
}
|