@vitrinka/web 0.10.1 → 0.12.0
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/CHANGELOG.md +74 -0
- package/README.md +24 -7
- package/build/recorder/capture/nav.d.ts +2 -0
- package/build/recorder/capture/nav.js +7 -0
- package/build/recorder/capture/net.js +6 -1
- package/build/recorder/queue.js +8 -1
- package/build/recorder/state.d.ts +2 -0
- package/build/recorder/state.js +4 -0
- package/build/recorder/version.d.ts +2 -2
- package/build/recorder/version.js +1 -1
- package/build/report/edge.d.ts +48 -0
- package/build/report/edge.js +71 -0
- package/build/report/element.d.ts +9 -2
- package/build/report/element.js +11 -2
- package/build/report/engine.d.ts +28 -3
- package/build/report/engine.js +106 -4
- package/build/report/i18n.d.ts +5 -3
- package/build/report/i18n.js +136 -3
- package/build/report/index.d.ts +1 -0
- package/build/report/profile.d.ts +2 -1
- package/build/report/round.d.ts +56 -0
- package/build/report/round.js +132 -0
- package/build/report/styles.d.ts +1 -1
- package/build/report/styles.js +75 -0
- package/build/report/widget.d.ts +21 -0
- package/build/report/widget.js +107 -13
- package/build/report/wire.d.ts +3 -1
- package/build/report/wire.js +21 -5
- package/build/report-widget.mjs +81 -6
- package/package.json +1 -1
package/build/report/wire.js
CHANGED
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
*/
|
|
36
36
|
import { api, permanentStatus, uploadTo, VitrinkaApiError } from '../recorder/api';
|
|
37
37
|
import { EVENTS_PER_POST } from './engine';
|
|
38
|
+
import { keepRound } from './round';
|
|
38
39
|
/**
|
|
39
40
|
* The top-level field a vitrinka refused as unknown — a 400 whose body names
|
|
40
41
|
* it (`json: unknown field "<name>"`, its quotes escaped once more inside the
|
|
@@ -78,7 +79,7 @@ export async function deadline(what, ms, work) {
|
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
/** What a report carries when its capture could not be prepared. */
|
|
81
|
-
export const EMPTY_CAPTURE = { chunks: [], truncated: false, console: [], network: [] };
|
|
82
|
+
export const EMPTY_CAPTURE = { chunks: [], truncated: false, console: [], network: [], journey: [] };
|
|
82
83
|
/**
|
|
83
84
|
* The capture a report sends, under its deadline like every leg (reading an
|
|
84
85
|
* earlier load's stored windows can hang): past it, or failed, the report
|
|
@@ -138,12 +139,14 @@ export class ReportJob {
|
|
|
138
139
|
const edits = { title: env.title, description: env.description, markers: env.markers, notify: env.notify ?? false };
|
|
139
140
|
const editsKey = JSON.stringify(edits);
|
|
140
141
|
if (!this.id) {
|
|
141
|
-
const { res, memberSent } = await this.create(env);
|
|
142
|
+
const { res, memberSent, roundSent } = await this.create(env);
|
|
142
143
|
if (typeof res.id !== 'string' || !res.id)
|
|
143
144
|
throw new Error('vitrinka: the server filed the report without an id');
|
|
144
145
|
this.id = res.id;
|
|
145
146
|
this.custody = res.custody === 'direct' ? 'direct' : 'quarantined';
|
|
146
147
|
this.sent = editsKey;
|
|
148
|
+
// The round the report was filed into: its token rides the next report.
|
|
149
|
+
keepRound(this.target, res.round, roundSent);
|
|
147
150
|
if (typeof res.memberError === 'string' && res.memberError)
|
|
148
151
|
onMemberRefusal?.(res.memberError, memberSent);
|
|
149
152
|
}
|
|
@@ -173,7 +176,7 @@ export class ReportJob {
|
|
|
173
176
|
* The create leg, answering with the member link the accepted body carried
|
|
174
177
|
* ('' none). A vitrinka older than an optional field refuses it by name;
|
|
175
178
|
* the reporter's word (`type`), the member link (`memberToken`) and the host's context (`context`) are
|
|
176
|
-
* optional, the report is not, so it goes again without each field named,
|
|
179
|
+
* optional, and so is the test round (`round`); the report is not, so it goes again without each field named,
|
|
177
180
|
* once. A refusal naming nothing still in the body fails the leg.
|
|
178
181
|
*/
|
|
179
182
|
async create(env) {
|
|
@@ -181,7 +184,7 @@ export class ReportJob {
|
|
|
181
184
|
for (;;) {
|
|
182
185
|
try {
|
|
183
186
|
const res = await this.call('POST', '/api/v1/reports', body);
|
|
184
|
-
return { res, memberSent: body.memberToken ?? '' };
|
|
187
|
+
return { res, memberSent: body.memberToken ?? '', roundSent: body.round ?? '' };
|
|
185
188
|
}
|
|
186
189
|
catch (e) {
|
|
187
190
|
const field = refusedField(e);
|
|
@@ -195,6 +198,12 @@ export class ReportJob {
|
|
|
195
198
|
const { memberToken: _dropped, ...rest } = body;
|
|
196
199
|
body = rest;
|
|
197
200
|
}
|
|
201
|
+
else if (field === 'round' && body.round !== undefined) {
|
|
202
|
+
// A vitrinka before test rounds (vt-3094): the report files on its own.
|
|
203
|
+
console.warn('vitrinka: this server keeps no test rounds yet — sending the report without one');
|
|
204
|
+
const { round: _dropped, ...rest } = body;
|
|
205
|
+
body = rest;
|
|
206
|
+
}
|
|
198
207
|
else if (field === 'context' && body.context !== undefined) {
|
|
199
208
|
// The host's claimed context is optional like the rest (vt-9515); a signed `ctx` claim rides the token and is not dropped.
|
|
200
209
|
console.warn('vitrinka: this server takes no report context yet; sending the report without it');
|
|
@@ -225,7 +234,7 @@ export class ReportJob {
|
|
|
225
234
|
}
|
|
226
235
|
async sendCapture() {
|
|
227
236
|
const id = encodeURIComponent(this.id);
|
|
228
|
-
const { chunks, truncated } = this.capture;
|
|
237
|
+
const { chunks, truncated, journey } = this.capture;
|
|
229
238
|
for (const c of chunks) {
|
|
230
239
|
if (this.blobKeys.has(c.seq))
|
|
231
240
|
continue;
|
|
@@ -242,6 +251,13 @@ export class ReportJob {
|
|
|
242
251
|
payload: { count: c.count, source: 'replay', truncated },
|
|
243
252
|
blobKey: this.blobKeys.get(c.seq) ?? '',
|
|
244
253
|
}));
|
|
254
|
+
// The journey's rows follow the replay's (vt-3094), each at its own time:
|
|
255
|
+
// vitrinka walks a report's session by time. Without a replay there is no
|
|
256
|
+
// session to walk, so they stay behind.
|
|
257
|
+
if (chunks.length) {
|
|
258
|
+
for (const j of journey)
|
|
259
|
+
rows.push({ seq: rows.length + 1, ts: j.ts, tabHost: this.tabHost, kind: j.kind, payload: j.payload, blobKey: '' });
|
|
260
|
+
}
|
|
245
261
|
while (this.rowsPosted < rows.length) {
|
|
246
262
|
const batch = rows.slice(this.rowsPosted, this.rowsPosted + EVENTS_PER_POST);
|
|
247
263
|
await this.call('POST', `/api/v1/reports/${id}/events`, { events: batch });
|