@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,79 @@
|
|
|
1
1
|
# @vitrinka/web
|
|
2
2
|
|
|
3
|
+
## 0.12.0
|
|
4
|
+
|
|
5
|
+
- **Report a problem opens from a drop on the screen's edge.** The default
|
|
6
|
+
launcher is no longer the large button in a corner, which sat over a
|
|
7
|
+
page's own bottom bars (an order bar, a phone's tab dock): it is a small
|
|
8
|
+
ink drop resting on the right edge, a little below the middle, with a
|
|
9
|
+
meniscus where it meets the edge. Hovered or focused it grows its name
|
|
10
|
+
and swells; it slides up or down the edge (click, hold and move, or
|
|
11
|
+
Alt+↑/↓), stretches while it moves, settles when let go and is remembered
|
|
12
|
+
per site (`vitrinka.report.edge`). It never moves on its own; under
|
|
13
|
+
reduced motion it neither swells, stretches nor wobbles. The card opens
|
|
14
|
+
beside it, centred on it.
|
|
15
|
+
- **Upgrading:** to keep the corner button, pass `launcher: 'corner'` (or
|
|
16
|
+
the attribute `launcher="corner"`); its dock and its remembered corner are
|
|
17
|
+
unchanged.
|
|
18
|
+
- `edgeInsets: {top, bottom}` sets what the drop keeps clear of (default
|
|
19
|
+
80 px and 136 px); `--vr-drop-fill` and `--vr-drop-ink` on the HUD host
|
|
20
|
+
theme it.
|
|
21
|
+
- The handle has `setButton(on)`: hide the launcher while your own modal is
|
|
22
|
+
up, show it again after.
|
|
23
|
+
- **Slovak.** The report face speaks `sk` (`locale: 'sk'`, or a Slovak
|
|
24
|
+
browser), beside `cs` and `en`.
|
|
25
|
+
|
|
26
|
+
## 0.11.0
|
|
27
|
+
|
|
28
|
+
- **A report shows how the reporter got there.** Report a problem sent a
|
|
29
|
+
replay and one marked frame: the report's timeline in vitrinka held a
|
|
30
|
+
single step, with no page, click, console line or request before it. The
|
|
31
|
+
report face now keeps the clicks and page changes of the kept minutes
|
|
32
|
+
beside the replay (the recorder pill's click and navigation lanes, under
|
|
33
|
+
the `interactions` capture class) and sends them with the report, and each
|
|
34
|
+
network entry says when it finished (`ts`). vitrinka places all of them on
|
|
35
|
+
the report's timeline, with a frame for each click and page.
|
|
36
|
+
- A click is sent as its selector, its text as the replay shows it (nothing
|
|
37
|
+
under strict masking, never a field's value), its box and its route; a page
|
|
38
|
+
change as its origin and path, never a query or a fragment, with token-shaped
|
|
39
|
+
path segments scrubbed. A profile without `interactions` keeps neither.
|
|
40
|
+
- A report that goes without a replay sends no clicks or page changes: there
|
|
41
|
+
is no session for them to stand on.
|
|
42
|
+
- A press at or under a region the replay blocks (`.rr-block`, the
|
|
43
|
+
recorder's own `data-vitrinka-recorder`) is not sent at all.
|
|
44
|
+
- A report with a **Cover** sends no clicks (its page changes still go): a
|
|
45
|
+
click carries its element's text from when it was pressed, and nothing
|
|
46
|
+
matches that against what the reporter covered.
|
|
47
|
+
- While Report a problem runs a page's capture, what it captures goes to the
|
|
48
|
+
report's own buffer alone, even when another tab of the site is recording
|
|
49
|
+
with the pill; before, its console and network entries were written into
|
|
50
|
+
that recording.
|
|
51
|
+
- **Reports from one sitting stay together: test rounds.** The first report
|
|
52
|
+
a browser sends opens a test round in vitrinka, which hands back the
|
|
53
|
+
round's token; Report a problem keeps it for the site (every tab, across
|
|
54
|
+
reloads) and sends it as `round` with each later report, so the team sees
|
|
55
|
+
which reports came from one person's one sitting. vitrinka decides when a
|
|
56
|
+
round is over (two quiet hours, or the reporter ending it) and opens a new
|
|
57
|
+
one for the next report. Nothing to configure: no option, no attribute.
|
|
58
|
+
- The token is kept in localStorage under its own key per vitrinka and
|
|
59
|
+
report key (`vitrinka.recorder.report.round:<vitrinka>|<key>`), so two
|
|
60
|
+
projects' widgets on one site never share a round. It names no person and
|
|
61
|
+
reads nothing.
|
|
62
|
+
|
|
63
|
+
Upgrading:
|
|
64
|
+
|
|
65
|
+
- **The server side ships in vitrinka first.** An older vitrinka ignores a
|
|
66
|
+
network entry's `ts` and files the clicks and page changes as it would any
|
|
67
|
+
staged row; its timeline shows the clicks and pages but no console or
|
|
68
|
+
network steps.
|
|
69
|
+
- **The report face now wraps `history.pushState` and `replaceState`** while
|
|
70
|
+
it captures (as the recorder pill always has), and restores them when it
|
|
71
|
+
unmounts.
|
|
72
|
+
- An older vitrinka also refuses the unknown `round` by name; the widget then sends the report again without
|
|
73
|
+
it, once, as it does for `type`, and every report files on its own.
|
|
74
|
+
- Ending a round from the widget has no control yet: it arrives with the
|
|
75
|
+
pill. Until then a round ends after two quiet hours.
|
|
76
|
+
|
|
3
77
|
## 0.10.1
|
|
4
78
|
|
|
5
79
|
- Rebuilt from the cleaned repository history, with no behaviour change.
|
package/README.md
CHANGED
|
@@ -15,8 +15,8 @@ screenshots), **clicks** (selector, text, rect), **navigation**, **network**
|
|
|
15
15
|
the last minute as a bug report ([Report a bug](#report-a-bug)).
|
|
16
16
|
|
|
17
17
|
The same engine has a second face for the people who use your app:
|
|
18
|
-
**[Report a problem](#report-a-problem-vitrinkawebreport)** — a
|
|
19
|
-
|
|
18
|
+
**[Report a problem](#report-a-problem-vitrinkawebreport)** — a drop
|
|
19
|
+
resting on the screen's edge and one card: "What went wrong?", optional marks drawn on the page,
|
|
20
20
|
files, and the last minutes attached under your project's capture profile.
|
|
21
21
|
No React needed; it also ships as one file vitrinka serves.
|
|
22
22
|
|
|
@@ -295,8 +295,8 @@ offered only during one.
|
|
|
295
295
|
|
|
296
296
|
## Report a problem (`@vitrinka/web/report`)
|
|
297
297
|
|
|
298
|
-
The report face of the same engine, for the people using your app: a
|
|
299
|
-
|
|
298
|
+
The report face of the same engine, for the people using your app: a quiet
|
|
299
|
+
drop on the right edge of the screen and ONE card. Its header
|
|
300
300
|
says who is reporting (the account chip) and holds the ⋯ menu; its body
|
|
301
301
|
takes the reporter's word for it — **Bug · Suggestion · Question · Other**,
|
|
302
302
|
optional, sent as `type`, a hint for your team's triage — and **What went
|
|
@@ -307,6 +307,20 @@ view. The minutes before are attached under your project's **capture
|
|
|
307
307
|
profile** (set in vitrinka; see [`docs/PROTOCOL.md`](../../docs/PROTOCOL.md)
|
|
308
308
|
§ Report a problem). You need the project's report key (`vkb_…`).
|
|
309
309
|
|
|
310
|
+
**The drop.** The launcher is a small ink drop resting on the right edge, a
|
|
311
|
+
little below the middle — the edge is the flat surface it sits on, with a
|
|
312
|
+
meniscus where they meet. Hovered or focused it grows its name (**Report a
|
|
313
|
+
problem** / **Nahlásit problém** / **Nahlásiť problém**) and swells; click,
|
|
314
|
+
hold and move it to slide it up or down the edge (Alt+↑/↓ from the
|
|
315
|
+
keyboard) — it stretches while it moves, settles when let go and is
|
|
316
|
+
remembered per site (`vitrinka.report.edge`). It never moves on its own,
|
|
317
|
+
and under reduced motion it neither swells, stretches nor wobbles. It keeps
|
|
318
|
+
clear of your top bar and bottom bars (`edgeInsets`, default 80 px top and
|
|
319
|
+
136 px bottom), and the card opens beside it, centred on it; on a phone the
|
|
320
|
+
card takes the width. Theme it with `--vr-drop-fill` and `--vr-drop-ink` on
|
|
321
|
+
the HUD host. `launcher: 'corner'` (attribute `launcher="corner"`) keeps the
|
|
322
|
+
large button in a corner instead.
|
|
323
|
+
|
|
310
324
|
**Marking.** **Show us where** puts a glass bar at the top of the page —
|
|
311
325
|
"Mark where the problem is", a segmented **Box · Circle · Arrow · Cover**
|
|
312
326
|
(Box picked) and **Cancel** — and you box, circle, point at or cover parts
|
|
@@ -371,8 +385,10 @@ function ReportAProblem({ locale, token }: { locale: string; token?: string }) {
|
|
|
371
385
|
|---|---|
|
|
372
386
|
| `key` | the project's `vkb_` report key (required) |
|
|
373
387
|
| `base` | vitrinka's origin (the script tag defaults to where it was served from) |
|
|
374
|
-
| `locale` | `cs` · `en`; live as an attribute, and through `setLocale()` |
|
|
375
|
-
| `button` | `false` hides the
|
|
388
|
+
| `locale` | `cs` · `en` · `sk`; live as an attribute, and through `setLocale()` |
|
|
389
|
+
| `button` | `false` hides the launcher: open the card from your own control; live as an attribute, and through `setButton()` |
|
|
390
|
+
| `launcher` | `edge` (default) — the drop on the right edge — or `corner`, the large button in a corner; live as an attribute |
|
|
391
|
+
| `edgeInsets` | `{top, bottom}` in px the drop keeps clear of (your top bar, bottom bars); default `{top: 80, bottom: 136}` (npm only) |
|
|
376
392
|
| `open-selector` / `openSelector` | a CSS selector of your control(s) that open the card |
|
|
377
393
|
| `face` | `report` (default) or `recorder` — the recorder pill on the same engine (npm only; it takes a `vkr_` key or the device link). A linked member also switches in place: **The face switch** below |
|
|
378
394
|
| `capture` | narrow the capture profile: `{storage: 'memory', windowSec, maxBytes, classes}` |
|
|
@@ -382,7 +398,8 @@ function ReportAProblem({ locale, token }: { locale: string; token?: string }) {
|
|
|
382
398
|
|
|
383
399
|
The handle (and the element) has `open()`, `close()`, `identify()`,
|
|
384
400
|
`setContext()`, `setLocale()` and `face`, the face on screen (`recorder` while a member has
|
|
385
|
-
switched to the pill); the handle also `
|
|
401
|
+
switched to the pill); the handle also has `setButton()` (hide the launcher
|
|
402
|
+
while your own modal is up) and `unmount()`s. For the tag from npm, call
|
|
386
403
|
`defineReportElement()` once. Closing the card hands focus back to whatever
|
|
387
404
|
had it when the card opened (your control, the field the shortcut fired in),
|
|
388
405
|
else to the button: call `open()` once your control holds focus again — after
|
|
@@ -8,6 +8,8 @@ export declare function noteNavigation(force?: boolean): boolean;
|
|
|
8
8
|
export declare function primeNavigation(): void;
|
|
9
9
|
/** Wrap pushState/replaceState + popstate/hashchange. Idempotent across HMR. */
|
|
10
10
|
export declare function installNavLane(): void;
|
|
11
|
+
/** Remove this module's History wrap and its listeners; another bundle's live wrap is its own to remove. */
|
|
12
|
+
export declare function uninstallNavLane(): void;
|
|
11
13
|
/**
|
|
12
14
|
* Make this module's History wrap the live one (ONE recorder): the first
|
|
13
15
|
* recorder bundle on the page installs it, but whichever bundle leads must
|
|
@@ -70,6 +70,13 @@ export function installNavLane() {
|
|
|
70
70
|
delete g[UNPATCH_MARK];
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
+
/** Remove this module's History wrap and its listeners; another bundle's live wrap is its own to remove. */
|
|
74
|
+
export function uninstallNavLane() {
|
|
75
|
+
const g = globalThis;
|
|
76
|
+
if (g[PATCH_MARK] !== OWNER)
|
|
77
|
+
return;
|
|
78
|
+
g[UNPATCH_MARK]?.();
|
|
79
|
+
}
|
|
73
80
|
/**
|
|
74
81
|
* Make this module's History wrap the live one (ONE recorder): the first
|
|
75
82
|
* recorder bundle on the page installs it, but whichever bundle leads must
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import { isVitrinkaUrl } from '../config';
|
|
17
17
|
import { flightTarget } from '../flight';
|
|
18
18
|
import { getState, pushEvent, trackCapture } from '../queue';
|
|
19
|
-
import { currentRoute, leadState } from '../state';
|
|
19
|
+
import { captureFace, currentRoute, leadState } from '../state';
|
|
20
20
|
import { redactAndCap, redactHeaders, redactUrl } from './redact';
|
|
21
21
|
const BODY_CAP = 64 * 1024;
|
|
22
22
|
/**
|
|
@@ -52,6 +52,11 @@ function captureTarget() {
|
|
|
52
52
|
// A follower captures nothing (ONE recorder D2).
|
|
53
53
|
if (leadState.following)
|
|
54
54
|
return null;
|
|
55
|
+
// The report face runs this document's capture: its requests are the
|
|
56
|
+
// report buffer's, whatever recording another tab of the origin holds —
|
|
57
|
+
// live, paused or dead (queue.ts pushEvent sends them there).
|
|
58
|
+
if (captureFace() === 'report')
|
|
59
|
+
return flightTarget();
|
|
55
60
|
const rec = getState();
|
|
56
61
|
if (rec)
|
|
57
62
|
return !rec.paused && !rec.dead ? rec.sessionId : null;
|
package/build/recorder/queue.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { api, permanentStatus, uploadChunk, uploadImage, VitrinkaApiError } from './api';
|
|
2
2
|
import { pushFlightEvent } from './flight';
|
|
3
|
-
import { leadState, notify } from './state';
|
|
3
|
+
import { captureFace, leadState, notify } from './state';
|
|
4
4
|
import { getRecorderStorage } from './storage';
|
|
5
5
|
import { getRecorderBlobStore } from './storage/blobs';
|
|
6
6
|
const FLUSH_MS = 2000;
|
|
@@ -970,6 +970,13 @@ export function pushEvent(kind, payload, route, images = []) {
|
|
|
970
970
|
// A follower captures nothing: the leader records this document (ONE recorder D2).
|
|
971
971
|
if (leadState.following)
|
|
972
972
|
return null;
|
|
973
|
+
// The report face runs this document's capture: its lanes feed the
|
|
974
|
+
// report's own buffer, under its profile's shapes, and nothing leaves until
|
|
975
|
+
// the reporter presses Send — never the recording another tab of this
|
|
976
|
+
// origin started (the session state is the origin's, the capture claim is
|
|
977
|
+
// this document's).
|
|
978
|
+
if (captureFace() === 'report')
|
|
979
|
+
return pushFlightEvent(kind, payload, route);
|
|
973
980
|
const rec = getState();
|
|
974
981
|
if (!rec)
|
|
975
982
|
return pushFlightEvent(kind, payload, route);
|
|
@@ -46,6 +46,8 @@ export declare const leadState: {
|
|
|
46
46
|
export type CaptureFace = 'recorder' | 'report';
|
|
47
47
|
/** Take the runtime for `face`; its release token, or null when a report face finds it taken. */
|
|
48
48
|
export declare function claimCapture(face: CaptureFace, yieldTo?: () => void): string | null;
|
|
49
|
+
/** The face that runs this document's capture now; null when none does. */
|
|
50
|
+
export declare function captureFace(): CaptureFace | null;
|
|
49
51
|
/** Give the runtime back — only the claim that `token` names. */
|
|
50
52
|
export declare function releaseCapture(token: string | null | undefined): void;
|
|
51
53
|
export declare function subscribe(fn: () => void): () => void;
|
package/build/recorder/state.js
CHANGED
|
@@ -70,6 +70,10 @@ export function claimCapture(face, yieldTo) {
|
|
|
70
70
|
g[OWNER_KEY] = { face, token, ...(yieldTo ? { yieldTo } : {}) };
|
|
71
71
|
return token;
|
|
72
72
|
}
|
|
73
|
+
/** The face that runs this document's capture now; null when none does. */
|
|
74
|
+
export function captureFace() {
|
|
75
|
+
return globalThis[OWNER_KEY]?.face ?? null;
|
|
76
|
+
}
|
|
73
77
|
/** Give the runtime back — only the claim that `token` names. */
|
|
74
78
|
export function releaseCapture(token) {
|
|
75
79
|
const g = globalThis;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** Sent as `meta.recorder` and written as `data-vitrinka-page`; bumped with the package version. */
|
|
2
|
-
export declare const RECORDER_VERSION = "0.
|
|
3
|
-
export declare const RECORDER_ID = "web/0.
|
|
2
|
+
export declare const RECORDER_VERSION = "0.12.0";
|
|
3
|
+
export declare const RECORDER_ID = "web/0.12.0";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The edge drop (vt-3811): the default launcher rests on the right edge of the
|
|
3
|
+
* viewport, a little below the middle, and slides up or down along it — never
|
|
4
|
+
* off it. Its place is a fraction of the band it may use (0 = the top of the
|
|
5
|
+
* band, 1 = the bottom), so it lands in the same proportion when the window
|
|
6
|
+
* changes height; the band keeps clear of a page's top bar and its bottom bars
|
|
7
|
+
* (an order bar, a phone's tab dock). The fraction is remembered per origin.
|
|
8
|
+
*
|
|
9
|
+
* The card opens beside the drop, toward the middle of the page, centred on
|
|
10
|
+
* it and kept inside the viewport.
|
|
11
|
+
*/
|
|
12
|
+
import type { Corner } from './place';
|
|
13
|
+
export type Launcher = 'edge' | 'corner';
|
|
14
|
+
export declare const EDGE_KEY = "vitrinka.report.edge";
|
|
15
|
+
/** A little below the middle: under the content people read, above the bottom bars. */
|
|
16
|
+
export declare const EDGE_DEFAULT = 0.62;
|
|
17
|
+
/** Alt+↑/↓ moves the drop by this share of its band. */
|
|
18
|
+
export declare const EDGE_STEP = 0.1;
|
|
19
|
+
/** The clear space the drop keeps at the top and the bottom of the viewport, in CSS px. */
|
|
20
|
+
export interface EdgeInsets {
|
|
21
|
+
top: number;
|
|
22
|
+
bottom: number;
|
|
23
|
+
}
|
|
24
|
+
/** Clear of a typical top bar (64–72 px) and of a bottom bar plus a phone's tab dock. */
|
|
25
|
+
export declare const EDGE_INSETS: Readonly<EdgeInsets>;
|
|
26
|
+
/** The launcher a raw option or attribute names; anything but `corner` is the edge drop. */
|
|
27
|
+
export declare function parseLauncher(raw: string | null | undefined): Launcher;
|
|
28
|
+
/** Host insets are untrusted: only finite, non-negative numbers replace the defaults. */
|
|
29
|
+
export declare function edgeInsets(raw?: Partial<EdgeInsets> | null): EdgeInsets;
|
|
30
|
+
/** The stored place; a value this module never wrote (garbage, out of range) falls back to the default. */
|
|
31
|
+
export declare function readEdge(): number;
|
|
32
|
+
export declare function saveEdge(fraction: number): void;
|
|
33
|
+
/**
|
|
34
|
+
* The drop's top in px for `fraction` of its band. A viewport too short for
|
|
35
|
+
* the band (a phone in landscape) centres the drop instead.
|
|
36
|
+
*/
|
|
37
|
+
export declare function edgeTop(fraction: number, vh: number, h: number, insets: EdgeInsets): number;
|
|
38
|
+
/** The fraction a drop whose top is at `top` stands at — dragged past the band, it stops at its end. */
|
|
39
|
+
export declare function edgeFraction(top: number, vh: number, h: number, insets: EdgeInsets): number;
|
|
40
|
+
/** Alt+↑/↓: the next place in that direction (staying at the end); null for any other key. */
|
|
41
|
+
export declare function edgeToward(fraction: number, key: string): number | null;
|
|
42
|
+
/**
|
|
43
|
+
* The corner marking parks the card from, and the coach reads its side from:
|
|
44
|
+
* the upper half of the band is a top-right drop, the lower half a bottom-right one.
|
|
45
|
+
*/
|
|
46
|
+
export declare function edgeCorner(fraction: number): Corner;
|
|
47
|
+
/** The card's top beside a drop at `dropTop`: centred on it, `margin` inside the viewport. */
|
|
48
|
+
export declare function cardTopBeside(dropTop: number, dropH: number, cardH: number, vh: number, margin?: number): number;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { readPref, writePref } from './settings';
|
|
2
|
+
export const EDGE_KEY = 'vitrinka.report.edge';
|
|
3
|
+
/** A little below the middle: under the content people read, above the bottom bars. */
|
|
4
|
+
export const EDGE_DEFAULT = 0.62;
|
|
5
|
+
/** Alt+↑/↓ moves the drop by this share of its band. */
|
|
6
|
+
export const EDGE_STEP = 0.1;
|
|
7
|
+
/** Clear of a typical top bar (64–72 px) and of a bottom bar plus a phone's tab dock. */
|
|
8
|
+
export const EDGE_INSETS = { top: 80, bottom: 136 };
|
|
9
|
+
/** The launcher a raw option or attribute names; anything but `corner` is the edge drop. */
|
|
10
|
+
export function parseLauncher(raw) {
|
|
11
|
+
return raw === 'corner' ? 'corner' : 'edge';
|
|
12
|
+
}
|
|
13
|
+
/** Host insets are untrusted: only finite, non-negative numbers replace the defaults. */
|
|
14
|
+
export function edgeInsets(raw) {
|
|
15
|
+
const pick = (v, d) => (typeof v === 'number' && Number.isFinite(v) && v >= 0 ? v : d);
|
|
16
|
+
return { top: pick(raw?.top, EDGE_INSETS.top), bottom: pick(raw?.bottom, EDGE_INSETS.bottom) };
|
|
17
|
+
}
|
|
18
|
+
function clamp01(v) {
|
|
19
|
+
return Math.min(1, Math.max(0, v));
|
|
20
|
+
}
|
|
21
|
+
/** The stored place; a value this module never wrote (garbage, out of range) falls back to the default. */
|
|
22
|
+
export function readEdge() {
|
|
23
|
+
const raw = readPref(EDGE_KEY);
|
|
24
|
+
if (raw === null || raw.trim() === '')
|
|
25
|
+
return EDGE_DEFAULT;
|
|
26
|
+
const v = Number(raw);
|
|
27
|
+
return Number.isFinite(v) && v >= 0 && v <= 1 ? v : EDGE_DEFAULT;
|
|
28
|
+
}
|
|
29
|
+
export function saveEdge(fraction) {
|
|
30
|
+
writePref(EDGE_KEY, String(Math.round(clamp01(fraction) * 1000) / 1000));
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The drop's top in px for `fraction` of its band. A viewport too short for
|
|
34
|
+
* the band (a phone in landscape) centres the drop instead.
|
|
35
|
+
*/
|
|
36
|
+
export function edgeTop(fraction, vh, h, insets) {
|
|
37
|
+
const room = vh - insets.top - insets.bottom - h;
|
|
38
|
+
if (room <= 0)
|
|
39
|
+
return Math.max(0, Math.round((vh - h) / 2));
|
|
40
|
+
return Math.round(insets.top + clamp01(fraction) * room);
|
|
41
|
+
}
|
|
42
|
+
/** The fraction a drop whose top is at `top` stands at — dragged past the band, it stops at its end. */
|
|
43
|
+
export function edgeFraction(top, vh, h, insets) {
|
|
44
|
+
const room = vh - insets.top - insets.bottom - h;
|
|
45
|
+
if (room <= 0)
|
|
46
|
+
return EDGE_DEFAULT;
|
|
47
|
+
return clamp01((top - insets.top) / room);
|
|
48
|
+
}
|
|
49
|
+
/** Alt+↑/↓: the next place in that direction (staying at the end); null for any other key. */
|
|
50
|
+
export function edgeToward(fraction, key) {
|
|
51
|
+
if (key === 'ArrowUp')
|
|
52
|
+
return clamp01(Math.round((fraction - EDGE_STEP) * 1000) / 1000);
|
|
53
|
+
if (key === 'ArrowDown')
|
|
54
|
+
return clamp01(Math.round((fraction + EDGE_STEP) * 1000) / 1000);
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The corner marking parks the card from, and the coach reads its side from:
|
|
59
|
+
* the upper half of the band is a top-right drop, the lower half a bottom-right one.
|
|
60
|
+
*/
|
|
61
|
+
export function edgeCorner(fraction) {
|
|
62
|
+
return fraction < 0.5 ? 'tr' : 'br';
|
|
63
|
+
}
|
|
64
|
+
/** The card's top beside a drop at `dropTop`: centred on it, `margin` inside the viewport. */
|
|
65
|
+
export function cardTopBeside(dropTop, dropH, cardH, vh, margin = 16) {
|
|
66
|
+
const centred = dropTop + dropH / 2 - cardH / 2;
|
|
67
|
+
const max = vh - cardH - margin;
|
|
68
|
+
if (max < margin)
|
|
69
|
+
return Math.max(0, Math.round((vh - cardH) / 2));
|
|
70
|
+
return Math.round(Math.min(max, Math.max(margin, centred)));
|
|
71
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ReportContextInput } from './context';
|
|
2
2
|
import type { RecordLoader } from './engine';
|
|
3
|
+
import { type EdgeInsets, type Launcher } from './edge';
|
|
3
4
|
import { type Locale } from './i18n';
|
|
4
5
|
import type { IdentifyInput } from './identity';
|
|
5
6
|
import type { CaptureNarrowing } from './profile';
|
|
@@ -12,6 +13,8 @@ export interface ReportScriptOptions {
|
|
|
12
13
|
capture?: CaptureNarrowing;
|
|
13
14
|
/** Rewrite captured URLs and routes before redaction (credentials in paths). */
|
|
14
15
|
sanitizeUrl?: (url: string) => string;
|
|
16
|
+
/** The clear space (px) the edge drop keeps at the top and the bottom of the viewport: your top bar and bottom bars. */
|
|
17
|
+
edgeInsets?: Partial<EdgeInsets>;
|
|
15
18
|
}
|
|
16
19
|
export interface ReportOptions extends ReportScriptOptions {
|
|
17
20
|
/** The project's `vkb_` report key (`face: 'recorder'`: a `vkr_` key, or none for the device link). */
|
|
@@ -20,10 +23,12 @@ export interface ReportOptions extends ReportScriptOptions {
|
|
|
20
23
|
base?: string;
|
|
21
24
|
/** Default `report`. */
|
|
22
25
|
face?: ReportFace;
|
|
23
|
-
/** `cs` | `en`; default: the browser's language. */
|
|
26
|
+
/** `cs` | `en` | `sk`; default: the browser's language. */
|
|
24
27
|
locale?: Locale | string;
|
|
25
|
-
/** The
|
|
28
|
+
/** The launcher (default true); false = open it from your own control. */
|
|
26
29
|
button?: boolean;
|
|
30
|
+
/** `edge` (default): the drop resting on the right edge; `corner`: the large button in a corner. */
|
|
31
|
+
launcher?: Launcher;
|
|
27
32
|
/** Your control(s) that open the card, as a CSS selector. */
|
|
28
33
|
openSelector?: string;
|
|
29
34
|
/** Who reports: a token your server signed, or an asserted email. */
|
|
@@ -46,6 +51,8 @@ export interface ReportHandle {
|
|
|
46
51
|
/** Replace the whole context the next report carries; `{}` or null clears it. Invalid entries are dropped and warned about. */
|
|
47
52
|
setContext(next: ReportContextInput): void;
|
|
48
53
|
setLocale(locale: Locale | string): void;
|
|
54
|
+
/** Show or hide the launcher, live — e.g. hide it while your own modal is open. */
|
|
55
|
+
setButton(on: boolean): void;
|
|
49
56
|
unmount(): void;
|
|
50
57
|
}
|
|
51
58
|
/** `<vitrinka-report>` as script sees it. */
|
package/build/report/element.js
CHANGED
|
@@ -21,11 +21,12 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import { listen } from '../recorder/hud/listen';
|
|
23
23
|
import { normalizeContext } from './context';
|
|
24
|
+
import { parseLauncher } from './edge';
|
|
24
25
|
import { memberLinked, pillRecording, rememberFace, startFace, watchMemberLink } from './face';
|
|
25
26
|
import { parseLocale } from './i18n';
|
|
26
27
|
import { hitsOpener, ReportWidget } from './widget';
|
|
27
28
|
export const REPORT_TAG = 'vitrinka-report';
|
|
28
|
-
const ATTRS = ['key', 'base', 'open-selector', 'locale', 'button'];
|
|
29
|
+
const ATTRS = ['key', 'base', 'open-selector', 'locale', 'button', 'launcher'];
|
|
29
30
|
function trimBase(raw) {
|
|
30
31
|
return raw.trim().replace(/\/+$/, '');
|
|
31
32
|
}
|
|
@@ -88,6 +89,8 @@ export function defineReportElement(faces) {
|
|
|
88
89
|
this.widget.setLocale(value);
|
|
89
90
|
else if (name === 'button')
|
|
90
91
|
this.widget.setButton(value !== 'false');
|
|
92
|
+
else if (name === 'launcher')
|
|
93
|
+
this.widget.setLauncher(parseLauncher(value));
|
|
91
94
|
else if (name === 'open-selector')
|
|
92
95
|
this.widget.setOpenSelector(value);
|
|
93
96
|
}
|
|
@@ -187,6 +190,8 @@ export function defineReportElement(faces) {
|
|
|
187
190
|
key: at.key,
|
|
188
191
|
locale: parseLocale(this.getAttribute('locale')),
|
|
189
192
|
button: this.getAttribute('button') !== 'false',
|
|
193
|
+
launcher: parseLauncher(this.getAttribute('launcher')),
|
|
194
|
+
edgeInsets: this.options.edgeInsets,
|
|
190
195
|
openSelector: this.getAttribute('open-selector'),
|
|
191
196
|
identity: this.pendingIdentity,
|
|
192
197
|
context: this.context,
|
|
@@ -266,9 +271,11 @@ export function mountReport(opts, faces) {
|
|
|
266
271
|
el.setAttribute('locale', String(opts.locale));
|
|
267
272
|
if (opts.button === false)
|
|
268
273
|
el.setAttribute('button', 'false');
|
|
274
|
+
if (opts.launcher)
|
|
275
|
+
el.setAttribute('launcher', opts.launcher);
|
|
269
276
|
if (opts.openSelector)
|
|
270
277
|
el.setAttribute('open-selector', opts.openSelector);
|
|
271
|
-
el.options = { appVersion: opts.appVersion, capture: opts.capture, sanitizeUrl: opts.sanitizeUrl };
|
|
278
|
+
el.options = { appVersion: opts.appVersion, capture: opts.capture, sanitizeUrl: opts.sanitizeUrl, edgeInsets: opts.edgeInsets };
|
|
272
279
|
// null is a choice (anonymous, whatever the page-wide identity); only undefined defers.
|
|
273
280
|
if (opts.identity !== undefined)
|
|
274
281
|
el.identify(opts.identity);
|
|
@@ -284,6 +291,7 @@ export function mountReport(opts, faces) {
|
|
|
284
291
|
identify: (who) => el.identify(who),
|
|
285
292
|
setContext: (next) => el.setContext(next),
|
|
286
293
|
setLocale: (l) => el.setLocale(l),
|
|
294
|
+
setButton: (on) => el.setAttribute('button', on ? 'true' : 'false'),
|
|
287
295
|
unmount: () => el.remove(),
|
|
288
296
|
};
|
|
289
297
|
}
|
|
@@ -313,6 +321,7 @@ function mountRecorder(opts, faces) {
|
|
|
313
321
|
identify: inert,
|
|
314
322
|
setContext: inert,
|
|
315
323
|
setLocale: inert,
|
|
324
|
+
setButton: inert,
|
|
316
325
|
unmount: () => {
|
|
317
326
|
gone = true;
|
|
318
327
|
unmount?.();
|
package/build/report/engine.d.ts
CHANGED
|
@@ -10,8 +10,10 @@
|
|
|
10
10
|
* 2. The redaction rules first, then the lanes — so capture runs under the
|
|
11
11
|
* project's rules from its first byte: the console lane (errors, every
|
|
12
12
|
* level with `console`), the network lane in metadata-only mode
|
|
13
|
-
* (`errors`: failures, `network`: every request), and
|
|
14
|
-
*
|
|
13
|
+
* (`errors`: failures, `network`: every request), and with
|
|
14
|
+
* `interactions` the rrweb lane plus the click and navigation lanes —
|
|
15
|
+
* the journey a report's timeline is built from (vt-3094) — all into
|
|
16
|
+
* the flight buffer.
|
|
15
17
|
* 3. The flight buffer under the profile's window and cap, in memory or
|
|
16
18
|
* also in IndexedDB (`storage: browser`, storage/capture.ts), whose
|
|
17
19
|
* expired windows the start sweeps.
|
|
@@ -24,7 +26,7 @@
|
|
|
24
26
|
*/
|
|
25
27
|
import type { eventWithTime } from '@rrweb/types';
|
|
26
28
|
import { type RecordFn } from '../recorder/capture/rrweb-lane';
|
|
27
|
-
import { type FlightClip, type FlightLaneEvent } from '../recorder/flight';
|
|
29
|
+
import { type FlightClip, type FlightLaneEvent, type FlightProfile } from '../recorder/flight';
|
|
28
30
|
import { EVENTS_PER_POST } from '../recorder/queue';
|
|
29
31
|
import { type AttachmentCaps } from './attachments';
|
|
30
32
|
import { type Marker } from './markers';
|
|
@@ -65,6 +67,14 @@ export interface NetEntry {
|
|
|
65
67
|
path: string;
|
|
66
68
|
status: number;
|
|
67
69
|
ms: number;
|
|
70
|
+
/** When it finished: what places it on the report's timeline (a vitrinka before vt-3094 ignores it). */
|
|
71
|
+
ts: string;
|
|
72
|
+
}
|
|
73
|
+
/** One step of the journey before a report: a click or a page change, as the recorder's lanes shape them. */
|
|
74
|
+
export interface JourneyEntry {
|
|
75
|
+
kind: 'click' | 'nav';
|
|
76
|
+
ts: string;
|
|
77
|
+
payload: Record<string, unknown>;
|
|
68
78
|
}
|
|
69
79
|
/** The capture as frozen when the card opened (the buffer keeps rolling). */
|
|
70
80
|
export interface Frozen {
|
|
@@ -89,9 +99,13 @@ export interface BuiltCapture {
|
|
|
89
99
|
truncated: boolean;
|
|
90
100
|
console: ConsoleEntry[];
|
|
91
101
|
network: NetEntry[];
|
|
102
|
+
/** The clicks and page changes of the kept minutes, oldest first; staged beside the replay's rows. */
|
|
103
|
+
journey: JourneyEntry[];
|
|
92
104
|
}
|
|
93
105
|
/** A request URL (already through the redaction engine) as the wire's path: pathname only, token runs scrubbed. */
|
|
94
106
|
export declare function reportPath(url: unknown): string;
|
|
107
|
+
/** A page URL as a report carries one: origin and path, never a query or a fragment, token runs scrubbed. */
|
|
108
|
+
export declare function reportPageUrl(url: unknown): string;
|
|
95
109
|
/**
|
|
96
110
|
* Whole windows only: rrweb's stream is stateful, so a window holding an
|
|
97
111
|
* event over the wire cap (a huge full snapshot) goes entirely — its
|
|
@@ -101,6 +115,17 @@ export declare function wholeWindows(events: readonly eventWithTime[], hardBytes
|
|
|
101
115
|
events: eventWithTime[];
|
|
102
116
|
dropped: boolean;
|
|
103
117
|
};
|
|
118
|
+
/** What the flight buffer keeps of each lane event under the profile's classes: the wire's shapes only. */
|
|
119
|
+
export declare function laneKeeper(lanes: CaptureLanes): NonNullable<FlightProfile['keepLane']>;
|
|
120
|
+
/**
|
|
121
|
+
* The clicks and page changes among a clip's lane events, newest
|
|
122
|
+
* `MAX_ENTRIES`, oldest first. `clicks: false` leaves the clicks out: a
|
|
123
|
+
* report with a Cover sends none, because a click carries its element's
|
|
124
|
+
* text and box from when it was pressed, and nothing matches that against
|
|
125
|
+
* what the reporter covered at Send — fail closed, as a hide without a
|
|
126
|
+
* mirror withholds the replay.
|
|
127
|
+
*/
|
|
128
|
+
export declare function journeyOf(lanes: readonly FlightLaneEvent[], clicks?: boolean): JourneyEntry[];
|
|
104
129
|
export declare class CaptureEngine {
|
|
105
130
|
readonly opts: EngineOptions;
|
|
106
131
|
readonly ready: Promise<ReportConfig>;
|