Files
rrweb/docs/recipes/record-and-replay.zh_CN.md
Yun Feng f878cc032d CI: add a prettier GitHub action to format code automatically (#988)
* CI: add a prettier GitHub action to format code automatically

* improve GitHub Action config and format some files

* Apply formatting changes

* CI: make the prettier action a standalone action

* Apply formatting changes

* CI: add push as new trigger event

Co-authored-by: Mark-Fenng <Mark-Fenng@users.noreply.github.com>
2026-04-01 12:00:00 +08:00

30 lines
832 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 录制与回放
录制与回放是最常用的使用方式,适用于任何需要采集用户行为数据并重新查看的场景。
仅需一个函数调用就可以录制当前页面:
```js
const stopFn = rrweb.record({
emit(event) {
// 保存获取到的 event 数据
},
});
```
你可以使用任何方式保存录制的数据,例如通过网络请求将数据传入至后端持久化保存,但请确保:
- 一组录制的数据按照 event.timestamp 中的时间戳从小至大保存
- 完整保存数据,不缺失任何一个 event。
如果需要手动停止录制,可以调用返回的 `stopFn` 函数。
回放时只需要获取一段录制数据,并传入 rrweb 提供的 Replayer
```js
const events = GET_YOUR_EVENTS;
const replayer = new rrweb.Replayer(events);
replayer.play();
```