* docs: revamp installation docs for esm and umd Document recommended install paths across the main guides and package READMEs for rrweb, @rrweb/all, @rrweb/record, @rrweb/replay, and rrweb-player. Clarify three usage modes: bundler/npm, browser no-build with import maps and +esm, and legacy UMD fallback. * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Apply formatting changes * Apply suggestion from @eoghanmurray Co-authored-by: Eoghan Murray <eoghan@getthere.ie> * Apply formatting changes * docs(all): streamline README usage section Move the guide link next to the import example and remove the duplicated Usage section to keep docs concise and easier to scan. * docs(readme): update gzip size badges in zh-cn readme * docs(plugins): update readme imports to scoped esm packages Replace `rrweb` default imports and `rrweb.Replayer` usage with `@rrweb/record` `record` and `@rrweb/replay` `Replayer` in plugin usage examples. Also update canvas WebRTC plugin imports to scoped `@rrweb/*` package names to keep docs aligned with current package structure. * docs: update docs to prefer scoped esm packages replace `rrweb` default import examples with `@rrweb/record` and `@rrweb/replay` across recipes and guides in en/zh-CN. clarify package selection for new integrations, add `@rrweb/all` convenience guidance, and refresh CDN/style import snippets for ESM and legacy UMD compatibility. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Eoghan Murray <eoghan@getthere.ie>
890 B
890 B
录制与回放
录制与回放是最常用的使用方式,适用于任何需要采集用户行为数据并重新查看的场景。
仅需一个函数调用就可以录制当前页面:
import { record } from '@rrweb/record';
const stopFn = record({
emit(event) {
// 保存获取到的 event 数据
},
});
你可以使用任何方式保存录制的数据,例如通过网络请求将数据传入至后端持久化保存,但请确保:
- 一组录制的数据按照 event.timestamp 中的时间戳从小至大保存
- 完整保存数据,不缺失任何一个 event。
如果需要手动停止录制,可以调用返回的 stopFn 函数。
回放时只需要获取一段录制数据,并传入 Replayer:
import { Replayer } from '@rrweb/replay';
const events = GET_YOUR_EVENTS;
const replayer = new Replayer(events);
replayer.play();