@mikeci/pos-analytics-replay 0.1.1 → 0.2.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 +9 -0
- package/README.md +5 -0
- package/dist/components.d.ts +32 -0
- package/dist/components.d.ts.map +1 -0
- package/dist/components.js +58 -0
- package/dist/components.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/recorder.d.ts +100 -0
- package/dist/recorder.d.ts.map +1 -0
- package/dist/recorder.js +343 -0
- package/dist/recorder.js.map +1 -0
- package/package.json +11 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
- Ghi patch, lifecycle gap, privacy boundary và viewport thật thay vì khung 390×844 cố định.
|
|
6
|
+
- Chunk quá lớn hoặc lỗi mã hóa không tăng `chunkSequence`. Hàng đợi đầy thì chunk kế tiếp mang `lifecycle/gap`.
|
|
7
|
+
- `prepareScreen` chỉ đổi cây node đang focus. `screenInstanceId` trên chunk giữ giá trị lúc mở phiên.
|
|
8
|
+
- `accountChanged` nhận `segmentId` mới. Node giữ `style`, `contentId` và `contentVersion`.
|
|
9
|
+
- Checksum dùng `@mikeci/pos-replay-protocol` 0.2.0, kể cả runtime không có Web Crypto.
|
package/README.md
CHANGED
|
@@ -85,3 +85,8 @@ const body = buildChunk({
|
|
|
85
85
|
```
|
|
86
86
|
|
|
87
87
|
JSON có `app_id`, `environment`, `session_id`, `seq`, `ts` và `payload`.
|
|
88
|
+
|
|
89
|
+
## Recorder
|
|
90
|
+
|
|
91
|
+
`ReplayRecorder` ghi snapshot, patch và tap/scroll theo protocol mới. Hàng đợi replay tách khỏi hàng đợi event. Input và component nhạy cảm được mask trước khi vào chunk. `ReplayScreen`, `ReplayView`, `ReplayButton`, `ReplayText` và `ReplayInput` đăng ký node. Sampling và kill switch lấy từ `GET /v1/sdk/config`.
|
|
92
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ReplayBounds, ReplayNode, ReplayNodeType } from "@mikeci/pos-replay-protocol";
|
|
2
|
+
import { type ReactNode } from "react";
|
|
3
|
+
import { ReplayRecorder } from "./recorder.js";
|
|
4
|
+
export declare function ReplayProvider({ recorder, children }: {
|
|
5
|
+
recorder: ReplayRecorder;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}): import("react").JSX.Element;
|
|
8
|
+
export declare function ReplayScreen({ name, screenInstanceId, bounds, children, }: {
|
|
9
|
+
name: string;
|
|
10
|
+
screenInstanceId?: string;
|
|
11
|
+
bounds?: ReplayBounds;
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
14
|
+
export declare function ReplayNodeView({ nodeId, componentId, type, bounds, contentId, contentVersion, publicText, style, children, }: {
|
|
15
|
+
nodeId?: string;
|
|
16
|
+
componentId: string;
|
|
17
|
+
type?: ReplayNodeType;
|
|
18
|
+
bounds: ReplayBounds;
|
|
19
|
+
contentId?: string;
|
|
20
|
+
contentVersion?: string;
|
|
21
|
+
publicText?: string;
|
|
22
|
+
style?: ReplayNode["style"];
|
|
23
|
+
children?: ReactNode;
|
|
24
|
+
}): import("react").JSX.Element;
|
|
25
|
+
export declare const ReplayView: (props: Omit<Parameters<typeof ReplayNodeView>[0], "type">) => import("react").JSX.Element;
|
|
26
|
+
export declare const ReplayText: (props: Omit<Parameters<typeof ReplayNodeView>[0], "type">) => import("react").JSX.Element;
|
|
27
|
+
export declare function ReplayButton(props: Omit<Parameters<typeof ReplayNodeView>[0], "type"> & {
|
|
28
|
+
onPress?: () => void;
|
|
29
|
+
publicLabel?: string;
|
|
30
|
+
}): import("react").JSX.Element;
|
|
31
|
+
export declare const ReplayInput: (props: Omit<Parameters<typeof ReplayNodeView>[0], "type">) => import("react").JSX.Element;
|
|
32
|
+
//# sourceMappingURL=components.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../src/components.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC5F,OAAO,EAA+C,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAK/C,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,cAAc,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAA;CAAE,+BAEvG;AAED,wBAAgB,YAAY,CAAC,EAC3B,IAAI,EACJ,gBAAgB,EAChB,MAAM,EACN,QAAQ,GACT,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,QAAQ,EAAE,SAAS,CAAC;CACrB,+BAmBA;AAED,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,WAAW,EACX,IAAa,EACb,MAAM,EACN,SAAS,EACT,cAAc,EACd,UAAU,EACV,KAAK,EACL,QAAQ,GACT,EAAE;IACD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,MAAM,EAAE,YAAY,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC5B,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,+BAoBA;AAED,eAAO,MAAM,UAAU,GAAI,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,gCAA8C,CAAC;AACnI,eAAO,MAAM,UAAU,GAAI,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,gCAA8C,CAAC;AACnI,wBAAgB,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,+BAGtI;AACD,eAAO,MAAM,WAAW,GAAI,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,gCAA+C,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useEffect, useId } from "react";
|
|
4
|
+
const RecorderContext = createContext(null);
|
|
5
|
+
const ParentContext = createContext(null);
|
|
6
|
+
export function ReplayProvider({ recorder, children }) {
|
|
7
|
+
return _jsx(RecorderContext.Provider, { value: recorder, children: children });
|
|
8
|
+
}
|
|
9
|
+
export function ReplayScreen({ name, screenInstanceId, bounds, children, }) {
|
|
10
|
+
const recorder = useContext(RecorderContext);
|
|
11
|
+
const generated = useId();
|
|
12
|
+
const nodeId = screenInstanceId ?? generated;
|
|
13
|
+
const box = bounds ?? { x: 0, y: 0, width: recorder?.viewport.width ?? 390, height: recorder?.viewport.height ?? 844 };
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (screenInstanceId)
|
|
16
|
+
recorder?.prepareScreen(screenInstanceId);
|
|
17
|
+
recorder?.upsert({
|
|
18
|
+
id: nodeId,
|
|
19
|
+
parentId: null,
|
|
20
|
+
type: "view",
|
|
21
|
+
bounds: { x: 0, y: 0, width: box.width, height: box.height },
|
|
22
|
+
componentId: name,
|
|
23
|
+
text: name,
|
|
24
|
+
style: { backgroundColor: "#ffffff" },
|
|
25
|
+
});
|
|
26
|
+
return () => recorder?.remove(nodeId);
|
|
27
|
+
}, [recorder, nodeId, name, screenInstanceId, box.width, box.height]);
|
|
28
|
+
return _jsx(ParentContext.Provider, { value: nodeId, children: children });
|
|
29
|
+
}
|
|
30
|
+
export function ReplayNodeView({ nodeId, componentId, type = "view", bounds, contentId, contentVersion, publicText, style, children, }) {
|
|
31
|
+
const recorder = useContext(RecorderContext);
|
|
32
|
+
const parentId = useContext(ParentContext);
|
|
33
|
+
const generated = useId();
|
|
34
|
+
const id = nodeId ?? componentId ?? generated;
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
recorder?.upsert({
|
|
37
|
+
id,
|
|
38
|
+
parentId,
|
|
39
|
+
type,
|
|
40
|
+
bounds,
|
|
41
|
+
componentId,
|
|
42
|
+
contentId,
|
|
43
|
+
contentVersion,
|
|
44
|
+
text: publicText,
|
|
45
|
+
...(style ? { style } : {}),
|
|
46
|
+
});
|
|
47
|
+
return () => recorder?.remove(id);
|
|
48
|
+
}, [recorder, id, parentId, type, componentId, contentId, contentVersion, publicText, style, bounds.x, bounds.y, bounds.width, bounds.height]);
|
|
49
|
+
return _jsx(ParentContext.Provider, { value: id, children: children });
|
|
50
|
+
}
|
|
51
|
+
export const ReplayView = (props) => _jsx(ReplayNodeView, { ...props, type: "view" });
|
|
52
|
+
export const ReplayText = (props) => _jsx(ReplayNodeView, { ...props, type: "text" });
|
|
53
|
+
export function ReplayButton(props) {
|
|
54
|
+
const { onPress: _onPress, publicLabel, ...rest } = props;
|
|
55
|
+
return _jsx(ReplayNodeView, { ...rest, type: "button", publicText: publicLabel ?? rest.publicText });
|
|
56
|
+
}
|
|
57
|
+
export const ReplayInput = (props) => _jsx(ReplayNodeView, { ...props, type: "input" });
|
|
58
|
+
//# sourceMappingURL=components.js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,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/I,OAAO,KAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,YAAG,QAAQ,GAA0B,CAAC;AAChF,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAyD,EAAE,EAAE,CAAC,KAAC,cAAc,OAAK,KAAK,EAAE,IAAI,EAAC,MAAM,GAAG,CAAC;AACnI,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAyD,EAAE,EAAE,CAAC,KAAC,cAAc,OAAK,KAAK,EAAE,IAAI,EAAC,MAAM,GAAG,CAAC;AACnI,MAAM,UAAU,YAAY,CAAC,KAA0G;IACrI,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IAC1D,OAAO,KAAC,cAAc,OAAK,IAAI,EAAE,IAAI,EAAC,QAAQ,EAAC,UAAU,EAAE,WAAW,IAAI,IAAI,CAAC,UAAU,GAAI,CAAC;AAChG,CAAC;AACD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAyD,EAAE,EAAE,CAAC,KAAC,cAAc,OAAK,KAAK,EAAE,IAAI,EAAC,OAAO,GAAG,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export type { ReplayChunk, ReplayNode, ReplayNodeType, ReplayViewport } from "@mikeci/pos-replay-protocol";
|
|
1
2
|
export { applyFrames, buildChunk, maskText, maskTree, shouldMask } from "./protocol.js";
|
|
2
3
|
export type { WireframeFrame, WireNode } from "./protocol.js";
|
|
4
|
+
export { ReplayRecorder, backoffMs } from "./recorder.js";
|
|
5
|
+
export { ReplayButton, ReplayInput, ReplayNodeView, ReplayProvider, ReplayScreen, ReplayText, ReplayView } from "./components.js";
|
|
3
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACxF,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC3G,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACxF,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { applyFrames, buildChunk, maskText, maskTree, shouldMask } from "./protocol.js";
|
|
2
|
+
export { ReplayRecorder, backoffMs } from "./recorder.js";
|
|
3
|
+
export { ReplayButton, ReplayInput, ReplayNodeView, ReplayProvider, ReplayScreen, ReplayText, ReplayView } from "./components.js";
|
|
2
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAExF,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { type ReplayChunk, type ReplayNode, type ReplayViewport } from "@mikeci/pos-replay-protocol";
|
|
2
|
+
export interface RecorderOptions {
|
|
3
|
+
replayId: string;
|
|
4
|
+
sessionId: string;
|
|
5
|
+
segmentId?: string;
|
|
6
|
+
screenInstanceId?: string;
|
|
7
|
+
viewport: ReplayViewport;
|
|
8
|
+
now?: () => number;
|
|
9
|
+
enabled?: boolean;
|
|
10
|
+
sampleRate?: number;
|
|
11
|
+
random?: () => number;
|
|
12
|
+
maxNodes?: number;
|
|
13
|
+
maxChunkBytes?: number;
|
|
14
|
+
patchWindowMs?: number;
|
|
15
|
+
chunkWindowMs?: number;
|
|
16
|
+
maxScrollHz?: number;
|
|
17
|
+
maxQueuedChunks?: number;
|
|
18
|
+
}
|
|
19
|
+
export declare class ReplayRecorder {
|
|
20
|
+
readonly replayId: string;
|
|
21
|
+
readonly sessionId: string;
|
|
22
|
+
private readonly now;
|
|
23
|
+
private readonly random;
|
|
24
|
+
readonly sampled: boolean;
|
|
25
|
+
readonly viewport: ReplayViewport;
|
|
26
|
+
/** Dừng hẳn phiên ghi. Khác với background, foreground không mở lại. */
|
|
27
|
+
stopped: boolean;
|
|
28
|
+
private enabled;
|
|
29
|
+
private segmentId;
|
|
30
|
+
/** Giữ nguyên trên mọi chunk. Đổi màn không đổi giá trị này. */
|
|
31
|
+
private readonly screenInstanceId?;
|
|
32
|
+
private focusedScreenId?;
|
|
33
|
+
private nodes;
|
|
34
|
+
private dirty;
|
|
35
|
+
private removed;
|
|
36
|
+
private records;
|
|
37
|
+
private seq;
|
|
38
|
+
private origin;
|
|
39
|
+
private lastPatchAt;
|
|
40
|
+
private lastScrollAt;
|
|
41
|
+
private chunkSequence;
|
|
42
|
+
private sensitive;
|
|
43
|
+
private gapPending;
|
|
44
|
+
private forceSnapshot;
|
|
45
|
+
private nodeBudget;
|
|
46
|
+
private dropped;
|
|
47
|
+
private rotating;
|
|
48
|
+
readonly queue: ReplayChunk[];
|
|
49
|
+
private readonly maxNodes;
|
|
50
|
+
private readonly maxChunkBytes;
|
|
51
|
+
private readonly patchWindowMs;
|
|
52
|
+
private readonly chunkWindowMs;
|
|
53
|
+
private readonly maxScrollHz;
|
|
54
|
+
private readonly maxQueuedChunks;
|
|
55
|
+
constructor(options: RecorderOptions);
|
|
56
|
+
get active(): boolean;
|
|
57
|
+
setPolicy(input: {
|
|
58
|
+
enabled?: boolean;
|
|
59
|
+
sampleRate?: number;
|
|
60
|
+
}): void;
|
|
61
|
+
private offset;
|
|
62
|
+
upsert(node: ReplayNode): void;
|
|
63
|
+
remove(id: string): void;
|
|
64
|
+
tap(targetId: string, point?: {
|
|
65
|
+
x?: number;
|
|
66
|
+
y?: number;
|
|
67
|
+
actionId?: string;
|
|
68
|
+
}): void;
|
|
69
|
+
scroll(targetId: string, point: {
|
|
70
|
+
scrollX?: number;
|
|
71
|
+
scrollY?: number;
|
|
72
|
+
force?: boolean;
|
|
73
|
+
}): void;
|
|
74
|
+
privacy(blocked: boolean, reason?: string): void;
|
|
75
|
+
background(): void;
|
|
76
|
+
foreground(): void;
|
|
77
|
+
accountChanged(segmentId?: string): void;
|
|
78
|
+
/** Đổi màn đang focus. Chunk vẫn giữ screenInstanceId lúc mở phiên. */
|
|
79
|
+
prepareScreen(screenInstanceId: string): void;
|
|
80
|
+
tick(): Promise<void> | Promise<ReplayChunk | null>;
|
|
81
|
+
private snapshotRecord;
|
|
82
|
+
private emittedNodes;
|
|
83
|
+
private include;
|
|
84
|
+
private screenOf;
|
|
85
|
+
private absolute;
|
|
86
|
+
private onViewport;
|
|
87
|
+
private flushPatch;
|
|
88
|
+
private push;
|
|
89
|
+
private fail;
|
|
90
|
+
rotate(force: boolean): Promise<ReplayChunk | null>;
|
|
91
|
+
private enqueue;
|
|
92
|
+
stats(): {
|
|
93
|
+
dropped: number;
|
|
94
|
+
queued: number;
|
|
95
|
+
segmentId: string;
|
|
96
|
+
chunkSequence: number;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
export declare function backoffMs(attempt: number, random?: () => number): number;
|
|
100
|
+
//# sourceMappingURL=recorder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recorder.d.ts","sourceRoot":"","sources":["../src/recorder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqD,KAAK,WAAW,EAAE,KAAK,UAAU,EAAqB,KAAK,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE3K,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,cAAc,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eA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AAC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAc,GAAG,MAAM,CAGvE"}
|
package/dist/recorder.js
ADDED
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import { MAX_TEXT, PROTOCOL_VERSION, encodeChunk, maskNode } from "@mikeci/pos-replay-protocol";
|
|
2
|
+
export class ReplayRecorder {
|
|
3
|
+
replayId;
|
|
4
|
+
sessionId;
|
|
5
|
+
now;
|
|
6
|
+
random;
|
|
7
|
+
sampled;
|
|
8
|
+
viewport;
|
|
9
|
+
/** Dừng hẳn phiên ghi. Khác với background, foreground không mở lại. */
|
|
10
|
+
stopped = false;
|
|
11
|
+
enabled;
|
|
12
|
+
segmentId;
|
|
13
|
+
/** Giữ nguyên trên mọi chunk. Đổi màn không đổi giá trị này. */
|
|
14
|
+
screenInstanceId;
|
|
15
|
+
focusedScreenId;
|
|
16
|
+
nodes = new Map();
|
|
17
|
+
dirty = new Set();
|
|
18
|
+
removed = [];
|
|
19
|
+
records = [];
|
|
20
|
+
seq = 1;
|
|
21
|
+
origin = 0;
|
|
22
|
+
lastPatchAt = 0;
|
|
23
|
+
lastScrollAt = new Map();
|
|
24
|
+
chunkSequence = 0;
|
|
25
|
+
sensitive = false;
|
|
26
|
+
gapPending = false;
|
|
27
|
+
forceSnapshot = false;
|
|
28
|
+
nodeBudget;
|
|
29
|
+
dropped = 0;
|
|
30
|
+
rotating = Promise.resolve();
|
|
31
|
+
queue = [];
|
|
32
|
+
maxNodes;
|
|
33
|
+
maxChunkBytes;
|
|
34
|
+
patchWindowMs;
|
|
35
|
+
chunkWindowMs;
|
|
36
|
+
maxScrollHz;
|
|
37
|
+
maxQueuedChunks;
|
|
38
|
+
constructor(options) {
|
|
39
|
+
this.replayId = options.replayId;
|
|
40
|
+
this.sessionId = options.sessionId;
|
|
41
|
+
this.now = options.now ?? (() => Date.now());
|
|
42
|
+
this.random = options.random ?? Math.random;
|
|
43
|
+
this.origin = this.now();
|
|
44
|
+
this.viewport = options.viewport;
|
|
45
|
+
this.segmentId = options.segmentId ?? "segment-1";
|
|
46
|
+
this.screenInstanceId = options.screenInstanceId;
|
|
47
|
+
this.focusedScreenId = options.screenInstanceId;
|
|
48
|
+
const rate = options.sampleRate ?? 1;
|
|
49
|
+
this.sampled = options.enabled !== false && this.random() < rate;
|
|
50
|
+
this.enabled = this.sampled;
|
|
51
|
+
this.maxNodes = options.maxNodes ?? 400;
|
|
52
|
+
this.nodeBudget = this.maxNodes;
|
|
53
|
+
this.maxChunkBytes = options.maxChunkBytes ?? 256 * 1024;
|
|
54
|
+
this.patchWindowMs = options.patchWindowMs ?? 150;
|
|
55
|
+
this.chunkWindowMs = options.chunkWindowMs ?? 12_000;
|
|
56
|
+
this.maxScrollHz = options.maxScrollHz ?? 10;
|
|
57
|
+
this.maxQueuedChunks = options.maxQueuedChunks ?? 8;
|
|
58
|
+
}
|
|
59
|
+
get active() {
|
|
60
|
+
return this.enabled && this.sampled && !this.stopped;
|
|
61
|
+
}
|
|
62
|
+
setPolicy(input) {
|
|
63
|
+
if (input.enabled === false || input.sampleRate === 0)
|
|
64
|
+
this.enabled = false;
|
|
65
|
+
}
|
|
66
|
+
offset() {
|
|
67
|
+
return Math.max(0, this.now() - this.origin);
|
|
68
|
+
}
|
|
69
|
+
upsert(node) {
|
|
70
|
+
if (!this.active || this.sensitive)
|
|
71
|
+
return;
|
|
72
|
+
if (node.bounds.width <= 0 || node.bounds.height <= 0)
|
|
73
|
+
return;
|
|
74
|
+
if (this.nodes.size >= this.maxNodes && !this.nodes.has(node.id)) {
|
|
75
|
+
this.fail("node_limit");
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const text = node.text && node.text.length > MAX_TEXT ? node.text.slice(0, MAX_TEXT) : node.text;
|
|
79
|
+
const masked = maskNode({ ...node, ...(text !== undefined ? { text } : {}) });
|
|
80
|
+
const previous = this.nodes.get(masked.id);
|
|
81
|
+
this.nodes.set(masked.id, masked);
|
|
82
|
+
if (previous && JSON.stringify(previous) === JSON.stringify(masked))
|
|
83
|
+
return;
|
|
84
|
+
this.dirty.add(masked.id);
|
|
85
|
+
if (this.records.length === 0)
|
|
86
|
+
this.push(this.snapshotRecord());
|
|
87
|
+
}
|
|
88
|
+
remove(id) {
|
|
89
|
+
if (!this.active)
|
|
90
|
+
return;
|
|
91
|
+
if (!this.nodes.delete(id))
|
|
92
|
+
return;
|
|
93
|
+
this.removed.push(id);
|
|
94
|
+
this.dirty.delete(id);
|
|
95
|
+
}
|
|
96
|
+
tap(targetId, point = {}) {
|
|
97
|
+
if (!this.active || this.sensitive)
|
|
98
|
+
return;
|
|
99
|
+
this.flushPatch(true);
|
|
100
|
+
this.push({ type: "interaction", seq: this.seq++, offsetMs: this.offset(), kind: "tap", targetId, ...point });
|
|
101
|
+
}
|
|
102
|
+
scroll(targetId, point) {
|
|
103
|
+
if (!this.active || this.sensitive)
|
|
104
|
+
return;
|
|
105
|
+
const at = this.now();
|
|
106
|
+
const previous = this.lastScrollAt.get(targetId) ?? 0;
|
|
107
|
+
if (!point.force && at - previous < 1000 / this.maxScrollHz)
|
|
108
|
+
return;
|
|
109
|
+
this.lastScrollAt.set(targetId, at);
|
|
110
|
+
this.push({ type: "interaction", seq: this.seq++, offsetMs: this.offset(), kind: "scroll", targetId, scrollX: point.scrollX, scrollY: point.scrollY });
|
|
111
|
+
}
|
|
112
|
+
privacy(blocked, reason) {
|
|
113
|
+
if (!this.sampled || this.stopped)
|
|
114
|
+
return;
|
|
115
|
+
this.sensitive = blocked;
|
|
116
|
+
this.push({ type: "privacy_boundary", seq: this.seq++, offsetMs: this.offset(), blocked, ...(reason ? { reason } : {}) });
|
|
117
|
+
}
|
|
118
|
+
background() {
|
|
119
|
+
if (!this.active)
|
|
120
|
+
return;
|
|
121
|
+
this.flushPatch(true);
|
|
122
|
+
this.push({ type: "lifecycle", seq: this.seq++, offsetMs: this.offset(), kind: "background" });
|
|
123
|
+
void this.rotate(true);
|
|
124
|
+
this.enabled = false;
|
|
125
|
+
}
|
|
126
|
+
foreground() {
|
|
127
|
+
if (!this.sampled || this.stopped)
|
|
128
|
+
return;
|
|
129
|
+
this.enabled = true;
|
|
130
|
+
this.gapPending = false;
|
|
131
|
+
if (this.sensitive)
|
|
132
|
+
return;
|
|
133
|
+
this.forceSnapshot = true;
|
|
134
|
+
this.push(this.snapshotRecord());
|
|
135
|
+
}
|
|
136
|
+
accountChanged(segmentId) {
|
|
137
|
+
if (!this.sampled || this.stopped)
|
|
138
|
+
return;
|
|
139
|
+
this.push({ type: "lifecycle", seq: this.seq++, offsetMs: this.offset(), kind: "account_changed" });
|
|
140
|
+
void this.rotate(true);
|
|
141
|
+
this.segmentId = segmentId ?? `${this.segmentId}-next`;
|
|
142
|
+
this.nodes.clear();
|
|
143
|
+
this.dirty.clear();
|
|
144
|
+
this.removed = [];
|
|
145
|
+
this.records = [];
|
|
146
|
+
this.forceSnapshot = true;
|
|
147
|
+
}
|
|
148
|
+
/** Đổi màn đang focus. Chunk vẫn giữ screenInstanceId lúc mở phiên. */
|
|
149
|
+
prepareScreen(screenInstanceId) {
|
|
150
|
+
if (!this.sampled || this.stopped || this.focusedScreenId === screenInstanceId)
|
|
151
|
+
return;
|
|
152
|
+
this.flushPatch(true);
|
|
153
|
+
void this.rotate(true);
|
|
154
|
+
this.focusedScreenId = screenInstanceId;
|
|
155
|
+
this.forceSnapshot = true;
|
|
156
|
+
for (const node of this.nodes.values()) {
|
|
157
|
+
if (this.include(node))
|
|
158
|
+
this.dirty.add(node.id);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
tick() {
|
|
162
|
+
if (!this.active)
|
|
163
|
+
return Promise.resolve();
|
|
164
|
+
if (this.offset() - this.lastPatchAt >= this.patchWindowMs || this.forceSnapshot)
|
|
165
|
+
this.flushPatch(this.forceSnapshot);
|
|
166
|
+
const due = this.offset() >= this.chunkWindowMs * (this.chunkSequence + 1);
|
|
167
|
+
if (due || this.records.length > 0 && this.forceSnapshot)
|
|
168
|
+
return this.rotate(due);
|
|
169
|
+
return Promise.resolve();
|
|
170
|
+
}
|
|
171
|
+
snapshotRecord() {
|
|
172
|
+
return { type: "snapshot", seq: this.seq++, offsetMs: this.offset(), nodes: this.emittedNodes() };
|
|
173
|
+
}
|
|
174
|
+
emittedNodes() {
|
|
175
|
+
return [...this.nodes.values()].filter((node) => this.include(node)).slice(0, this.nodeBudget);
|
|
176
|
+
}
|
|
177
|
+
include(node) {
|
|
178
|
+
if (this.focusedScreenId) {
|
|
179
|
+
const screen = this.screenOf(node.id);
|
|
180
|
+
if (screen && screen !== this.focusedScreenId)
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
return this.onViewport(node.id);
|
|
184
|
+
}
|
|
185
|
+
screenOf(id) {
|
|
186
|
+
const seen = new Set();
|
|
187
|
+
let current = this.nodes.get(id);
|
|
188
|
+
while (current && !seen.has(current.id)) {
|
|
189
|
+
if (!current.parentId)
|
|
190
|
+
return current.id;
|
|
191
|
+
seen.add(current.id);
|
|
192
|
+
const parent = this.nodes.get(current.parentId);
|
|
193
|
+
if (!parent)
|
|
194
|
+
return current.parentId;
|
|
195
|
+
current = parent;
|
|
196
|
+
}
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
absolute(id) {
|
|
200
|
+
const node = this.nodes.get(id);
|
|
201
|
+
if (!node)
|
|
202
|
+
return null;
|
|
203
|
+
let x = node.bounds.x;
|
|
204
|
+
let y = node.bounds.y;
|
|
205
|
+
let parentId = node.parentId;
|
|
206
|
+
const seen = new Set([id]);
|
|
207
|
+
while (parentId) {
|
|
208
|
+
if (seen.has(parentId))
|
|
209
|
+
return null;
|
|
210
|
+
seen.add(parentId);
|
|
211
|
+
const parent = this.nodes.get(parentId);
|
|
212
|
+
if (!parent)
|
|
213
|
+
return null;
|
|
214
|
+
x += parent.bounds.x;
|
|
215
|
+
y += parent.bounds.y;
|
|
216
|
+
parentId = parent.parentId;
|
|
217
|
+
}
|
|
218
|
+
return { x, y, width: node.bounds.width, height: node.bounds.height };
|
|
219
|
+
}
|
|
220
|
+
onViewport(id) {
|
|
221
|
+
const box = this.absolute(id);
|
|
222
|
+
if (!box)
|
|
223
|
+
return true;
|
|
224
|
+
const { width, height } = this.viewport;
|
|
225
|
+
if (box.x >= width || box.y >= height || box.x + box.width <= 0 || box.y + box.height <= 0)
|
|
226
|
+
return false;
|
|
227
|
+
let parentId = this.nodes.get(id)?.parentId;
|
|
228
|
+
const seen = new Set([id]);
|
|
229
|
+
while (parentId && !seen.has(parentId)) {
|
|
230
|
+
seen.add(parentId);
|
|
231
|
+
const parent = this.absolute(parentId);
|
|
232
|
+
if (parent && (box.x >= parent.x + parent.width || box.y >= parent.y + parent.height || box.x + box.width <= parent.x || box.y + box.height <= parent.y))
|
|
233
|
+
return false;
|
|
234
|
+
parentId = this.nodes.get(parentId)?.parentId;
|
|
235
|
+
}
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
flushPatch(force) {
|
|
239
|
+
if (!this.dirty.size && !this.removed.length && !this.forceSnapshot)
|
|
240
|
+
return;
|
|
241
|
+
if (!force && this.offset() - this.lastPatchAt < this.patchWindowMs)
|
|
242
|
+
return;
|
|
243
|
+
const needsSnapshot = this.forceSnapshot || this.gapPending || !this.records.some((record) => record.type === "snapshot");
|
|
244
|
+
if (needsSnapshot) {
|
|
245
|
+
this.push(this.snapshotRecord());
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
const upserts = [...this.dirty].flatMap((id) => {
|
|
249
|
+
const node = this.nodes.get(id);
|
|
250
|
+
return node && this.include(node) ? [node] : [];
|
|
251
|
+
});
|
|
252
|
+
if (!upserts.length && !this.removed.length) {
|
|
253
|
+
this.dirty.clear();
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
this.push({ type: "patch", seq: this.seq++, offsetMs: this.offset(), upserts, removedIds: this.removed });
|
|
257
|
+
}
|
|
258
|
+
this.dirty.clear();
|
|
259
|
+
this.removed = [];
|
|
260
|
+
this.forceSnapshot = false;
|
|
261
|
+
this.lastPatchAt = this.offset();
|
|
262
|
+
}
|
|
263
|
+
push(record) {
|
|
264
|
+
if (this.gapPending && record.type !== "snapshot" && record.type !== "lifecycle" && record.type !== "privacy_boundary")
|
|
265
|
+
return;
|
|
266
|
+
if (record.type === "snapshot")
|
|
267
|
+
this.gapPending = false;
|
|
268
|
+
this.records.push(record);
|
|
269
|
+
}
|
|
270
|
+
fail(reason) {
|
|
271
|
+
this.dropped += 1;
|
|
272
|
+
if (reason === "bytes")
|
|
273
|
+
this.nodeBudget = Math.max(20, Math.floor(this.nodeBudget / 2));
|
|
274
|
+
const gap = { type: "lifecycle", seq: this.seq++, offsetMs: this.offset(), kind: "gap" };
|
|
275
|
+
this.records.unshift(gap);
|
|
276
|
+
this.gapPending = true;
|
|
277
|
+
this.forceSnapshot = true;
|
|
278
|
+
}
|
|
279
|
+
rotate(force) {
|
|
280
|
+
this.flushPatch(true);
|
|
281
|
+
if (!this.records.length)
|
|
282
|
+
return Promise.resolve(null);
|
|
283
|
+
if (!force && this.offset() < this.chunkWindowMs && !this.gapPending)
|
|
284
|
+
return Promise.resolve(null);
|
|
285
|
+
let records = this.records;
|
|
286
|
+
if (this.queue.length >= this.maxQueuedChunks) {
|
|
287
|
+
records = [{ type: "lifecycle", seq: this.seq++, offsetMs: records[0]?.offsetMs ?? this.offset(), kind: "gap" }, ...records];
|
|
288
|
+
}
|
|
289
|
+
if (!records.some((record) => record.type === "snapshot")) {
|
|
290
|
+
records = [{ type: "snapshot", seq: 0, offsetMs: records[0]?.offsetMs ?? 0, nodes: this.emittedNodes() }, ...records];
|
|
291
|
+
}
|
|
292
|
+
const segmentId = this.segmentId;
|
|
293
|
+
this.records = [];
|
|
294
|
+
this.gapPending = false;
|
|
295
|
+
const job = this.rotating.then(() => this.enqueue(records, segmentId));
|
|
296
|
+
this.rotating = job.then(() => undefined, () => undefined);
|
|
297
|
+
return job;
|
|
298
|
+
}
|
|
299
|
+
async enqueue(records, segmentId) {
|
|
300
|
+
const start = records[0]?.offsetMs ?? 0;
|
|
301
|
+
const end = records[records.length - 1]?.offsetMs ?? start;
|
|
302
|
+
const sequence = this.chunkSequence;
|
|
303
|
+
const draft = {
|
|
304
|
+
protocolVersion: PROTOCOL_VERSION,
|
|
305
|
+
replayId: this.replayId,
|
|
306
|
+
segmentId,
|
|
307
|
+
chunkId: `${this.replayId}-${segmentId}-${sequence}`,
|
|
308
|
+
chunkSequence: sequence,
|
|
309
|
+
sessionId: this.sessionId,
|
|
310
|
+
...(this.screenInstanceId ? { screenInstanceId: this.screenInstanceId } : {}),
|
|
311
|
+
startOffsetMs: start,
|
|
312
|
+
endOffsetMs: Math.max(start, end),
|
|
313
|
+
viewport: this.viewport,
|
|
314
|
+
records,
|
|
315
|
+
};
|
|
316
|
+
let encoded;
|
|
317
|
+
try {
|
|
318
|
+
encoded = await encodeChunk(draft);
|
|
319
|
+
}
|
|
320
|
+
catch {
|
|
321
|
+
this.fail("encode");
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
if (JSON.stringify(encoded).length > this.maxChunkBytes) {
|
|
325
|
+
this.fail("bytes");
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
if (this.queue.length >= this.maxQueuedChunks)
|
|
329
|
+
this.queue.shift();
|
|
330
|
+
this.queue.push(encoded);
|
|
331
|
+
this.chunkSequence += 1;
|
|
332
|
+
this.nodeBudget = this.maxNodes;
|
|
333
|
+
return encoded;
|
|
334
|
+
}
|
|
335
|
+
stats() {
|
|
336
|
+
return { dropped: this.dropped, queued: this.queue.length, segmentId: this.segmentId, chunkSequence: this.chunkSequence };
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
export function backoffMs(attempt, random = Math.random) {
|
|
340
|
+
const base = Math.min(30_000, 250 * 2 ** attempt);
|
|
341
|
+
return Math.round(base * (0.5 + random() * 0.5));
|
|
342
|
+
}
|
|
343
|
+
//# sourceMappingURL=recorder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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AK,CAAC,MAAM,IAAI,IAAI,CAAC,eAAe;YAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QAClE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzB,IAAI,CAAC,aAAa,IAAI,CAAC,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC;QAChC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,KAAK;QACH,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC;IAC5H,CAAC;CACF;AAED,MAAM,UAAU,SAAS,CAAC,OAAe,EAAE,MAAM,GAAG,IAAI,CAAC,MAAM;IAC7D,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,OAAO,CAAC,CAAC;IAClD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,GAAG,GAAG,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;AACnD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikeci/pos-analytics-replay",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Session replay wireframe helpers for the Pos Analytics React Native SDK.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -13,13 +13,22 @@
|
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
15
|
"dist",
|
|
16
|
-
"README.md"
|
|
16
|
+
"README.md",
|
|
17
|
+
"CHANGELOG.md"
|
|
17
18
|
],
|
|
18
19
|
"publishConfig": {
|
|
19
20
|
"registry": "https://registry.npmjs.org/",
|
|
20
21
|
"access": "public"
|
|
21
22
|
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@mikeci/pos-replay-protocol": "0.2.0"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"react": ">=19.0.0"
|
|
28
|
+
},
|
|
22
29
|
"devDependencies": {
|
|
30
|
+
"@types/react": "^19.0.2",
|
|
31
|
+
"react": "^19.0.0",
|
|
23
32
|
"typescript": "^5.7.2"
|
|
24
33
|
},
|
|
25
34
|
"scripts": {
|