Skip to content

Commit bcf93ca

Browse files
Juice10Copiloteoghanmurray
authored
docs: revamp installation docs for esm and umd (rrweb-io#1788)
* 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>
1 parent dab8c29 commit bcf93ca

37 files changed

Lines changed: 658 additions & 208 deletions
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
---
3+
4+
Docs-only update: clarify package recommendation order (`@rrweb/record` + `@rrweb/replay` first, `@rrweb/all` as convenience), and fix example typos.

README.zh_CN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
[![Join the chat at slack](https://img.shields.io/badge/slack-@rrweb-teal.svg?logo=slack)](https://join.slack.com/t/rrweb/shared_invite/zt-siwoc6hx-uWay3s2wyG8t5GpZVb8rWg)
1313
[![Reddit](https://img.shields.io/badge/reddit-r/rrweb-teal.svg?logo=reddit)](https://www.reddit.com/r/rrweb)
14-
![total gzip size](https://img.badgesize.io/https://cdn.jsdelivr.net/npm/rrweb@latest/umd/rrweb.min.js?compression=gzip&label=total%20gzip%20size)
15-
![recorder gzip size](https://img.badgesize.io/https://cdn.jsdelivr.net/npm/@rrweb/record@latest/umd/record.min.js?compression=gzip&label=recorder%20gzip%20size)
14+
![recorder gzip size](https://img.badgesize.io/https://cdn.jsdelivr.net/npm/@rrweb/record@latest/umd/record.min.js?compression=gzip&label=recorder%20gzip%20size&max=200000&softmax=100000)
15+
![replayer gzip size](https://img.badgesize.io/https://cdn.jsdelivr.net/npm/@rrweb/replay@latest/umd/replay.min.js?compression=gzip&label=replayer%20gzip%20size&max=200000&softmax=100000)
1616
[![](https://data.jsdelivr.com/v1/package/npm/rrweb/badge)](https://www.jsdelivr.com/package/npm/rrweb)
1717

1818
> 我已开通 Github Sponsor, 您可以通过赞助的形式帮助 rrweb 的开发。

docs/recipes/canvas.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ There are some options for recording and replaying Canvas.
66
Enable recording Canvas:
77

88
```js
9-
rrweb.record({
9+
import { record } from '@rrweb/record';
10+
11+
record({
1012
emit(event) {},
1113
recordCanvas: true,
1214
});
@@ -15,7 +17,9 @@ rrweb.record({
1517
Alternatively enable image snapshot recording of Canvas at a maximum of 15 frames per second:
1618

1719
```js
18-
rrweb.record({
20+
import { record } from '@rrweb/record';
21+
22+
record({
1923
emit(event) {},
2024
recordCanvas: true,
2125
sampling: {
@@ -32,7 +36,9 @@ rrweb.record({
3236
Enable replaying Canvas:
3337

3438
```js
35-
const replayer = new rrweb.Replayer(events, {
39+
import { Replayer } from '@rrweb/replay';
40+
41+
const replayer = new Replayer(events, {
3642
UNSAFE_replayCanvas: true,
3743
});
3844
replayer.play();

docs/recipes/canvas.zh_CN.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ Canvas 是一种特殊的 HTML 元素,默认情况下其内容不会被 rrweb
55
录制时包含 Canvas 内的内容:
66

77
```js
8-
rrweb.record({
8+
import { record } from '@rrweb/record';
9+
10+
record({
911
emit(event) {},
1012
// 对 canvas 进行录制
1113
recordCanvas: true,
@@ -15,7 +17,9 @@ rrweb.record({
1517
或者启用每秒 15 帧的 Canvas 图像快照记录:
1618

1719
```js
18-
rrweb.record({
20+
import { record } from '@rrweb/record';
21+
22+
record({
1923
emit(event) {},
2024
recordCanvas: true,
2125
sampling: {
@@ -32,7 +36,9 @@ rrweb.record({
3236
回放时对 Canvas 进行回放:
3337

3438
```js
35-
const replayer = new rrweb.Replayer(events, {
39+
import { Replayer } from '@rrweb/replay';
40+
41+
const replayer = new Replayer(events, {
3642
UNSAFE_replayCanvas: true,
3743
});
3844
replayer.play();

docs/recipes/console.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ This feature aims to provide developers with more information about the bug scen
88
You can enable the logger using default option like this:
99

1010
```js
11-
import rrweb from 'rrweb';
11+
import { record } from '@rrweb/record';
1212
import { getRecordConsolePlugin } from '@rrweb/rrweb-plugin-console-record';
1313

14-
rrweb.record({
14+
record({
1515
emit: function emit(event) {
1616
// you should use console.log in this way to avoid errors.
1717
const defaultLog = console.log['__rrweb_original__']
@@ -30,10 +30,10 @@ You should call console.log.\_\_rrweb_original\_\_() instead.
3030
You can also customize the behavior of logger like this:
3131

3232
```js
33-
import rrweb from 'rrweb';
33+
import { record } from '@rrweb/record';
3434
import { getRecordConsolePlugin } from '@rrweb/rrweb-plugin-console-record';
3535

36-
rrweb.record({
36+
record({
3737
emit: function emit(event) {
3838
// you should use console.log in this way to avoid errors.
3939
const defaultLog = console.log['__rrweb_original__']
@@ -70,10 +70,10 @@ All options are described below:
7070
If recorded events include data of console log type, we will automatically play them.
7171

7272
```js
73-
import rrweb from 'rrweb';
73+
import { Replayer } from '@rrweb/replay';
7474
import { getReplayConsolePlugin } from '@rrweb/rrweb-plugin-console-replay';
7575

76-
const replayer = new rrweb.Replayer(events, {
76+
const replayer = new Replayer(events, {
7777
plugins: [
7878
getReplayConsolePlugin({
7979
level: ['info', 'log', 'warn', 'error'],

docs/recipes/console.zh_CN.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
可以通过如下代码使用默认的配置选项
88

99
```js
10-
import rrweb from 'rrweb';
10+
import { record } from '@rrweb/record';
1111
import { getRecordConsolePlugin } from '@rrweb/rrweb-plugin-console-record';
1212

13-
rweb.record({
13+
record({
1414
emit: function emit(event) {
1515
// 如果要使用console来输出信息,请使用如下的写法
1616
const defaultLog = console.log['__rrweb_original__']
@@ -29,10 +29,10 @@ rweb.record({
2929
你也可以定制录制 console 的选项
3030

3131
```js
32-
import rrweb from 'rrweb';
32+
import { record } from '@rrweb/record';
3333
import { getRecordConsolePlugin } from '@rrweb/rrweb-plugin-console-record';
3434

35-
rrweb.record({
35+
record({
3636
emit: function emit(event) {
3737
// 如果要使用console来输出信息,请使用如下的写法
3838
const defaultLog = console.log['__rrweb_original__']
@@ -69,10 +69,10 @@ rrweb.record({
6969
如果 replayer 传入的 events 中包含了 console 类型的数据,我们将自动播放这些数据。
7070

7171
```js
72-
import rrweb from 'rrweb';
72+
import { Replayer } from '@rrweb/replay';
7373
import { getReplayConsolePlugin } from '@rrweb/rrweb-plugin-console-replay';
7474

75-
const replayer = new rrweb.Replayer(events, {
75+
const replayer = new Replayer(events, {
7676
plugins: [
7777
getReplayConsolePlugin({
7878
level: ['info', 'log', 'warn', 'error'],

docs/recipes/cross-origin-iframes.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ Since if you allow recording cross origin iframes, any malicious website can emb
88
Enable recording cross-origin iframes in your parent page:
99

1010
```js
11-
rrweb.record({
11+
import { record } from '@rrweb/record';
12+
13+
record({
1214
emit(event) {}, // all events will be emitted here, including events from cross origin iframes
1315
recordCrossOriginIframes: true,
1416
});
@@ -17,7 +19,9 @@ rrweb.record({
1719
Enable replaying cross-origin iframes in your child page:
1820

1921
```js
20-
rrweb.record({
22+
import { record } from '@rrweb/record';
23+
24+
record({
2125
emit(event) {}, // this is required for rrweb, but the child page will not emit any events
2226
recordCrossOriginIframes: true,
2327
});

docs/recipes/cross-origin-iframes.zh_CN.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
在父页面中启用录制跨域 iframe:
99

1010
```js
11-
rrweb.record({
11+
import { record } from '@rrweb/record';
12+
13+
record({
1214
emit(event) {}, // 所有事件都将在此处发出,包括来自跨源 iframe 的事件
1315
recordCrossOriginIframes: true,
1416
});
@@ -17,7 +19,9 @@ rrweb.record({
1719
在您的子页面中启用重放跨域 iframe:
1820

1921
```js
20-
rrweb.record({
22+
import { record } from '@rrweb/record';
23+
24+
record({
2125
emit(event) {}, // 这是 rrweb 所必需的,但子页面不会发出任何事件
2226
recordCrossOriginIframes: true,
2327
});

docs/recipes/custom-event.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,21 @@ You may need to record some custom events along with the rrweb events, and let t
55
After starting the recording, we can call the `record.addCustomEvent` API to add a custom event.
66

77
```js
8+
import { record } from '@rrweb/record';
9+
810
// start recording
9-
rrweb.record({
11+
record({
1012
emit(event) {
1113
...
1214
}
1315
})
1416

1517
// record some custom events at any time
16-
rrweb.record.addCustomEvent('submit-form', {
18+
record.addCustomEvent('submit-form', {
1719
name: 'Adam',
1820
age: 18
1921
})
20-
rrweb.record.addCustomEvent('some-error', {
22+
record.addCustomEvent('some-error', {
2123
error
2224
})
2325
```
@@ -29,7 +31,9 @@ During the replay, we can add an event listener to custom events, or configure t
2931
**Listen to custom events**
3032

3133
```js
32-
const replayer = new rrweb.Replayer(events);
34+
import { Replayer } from '@rrweb/replay';
35+
36+
const replayer = new Replayer(events);
3337

3438
replayer.on('custom-event', (event) => {
3539
console.log(event.tag, event.payload);

docs/recipes/custom-event.zh_CN.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,21 @@
55
开始录制后,我们就可以通过 `record.addCustomEvent` API 添加自定义事件:
66

77
```js
8+
import { record } from '@rrweb/record';
9+
810
// 开始录制
9-
rrweb.record({
11+
record({
1012
emit(event) {
1113
...
1214
}
1315
})
1416

1517
// 在开始录制后的任意时间点记录自定义事件,例如:
16-
rrweb.record.addCustomEvent('submit-form', {
18+
record.addCustomEvent('submit-form', {
1719
name: '姓名',
1820
age: 18
1921
})
20-
rrweb.record.addCustomEvent('some-error', {
22+
record.addCustomEvent('some-error', {
2123
error
2224
})
2325
```
@@ -29,7 +31,9 @@ rrweb.record.addCustomEvent('some-error', {
2931
**获取对应事件**
3032

3133
```js
32-
const replayer = new rrweb.Replayer(events);
34+
import { Replayer } from '@rrweb/replay';
35+
36+
const replayer = new Replayer(events);
3337

3438
replayer.on('custom-event', (event) => {
3539
console.log(event.tag, event.payload);

0 commit comments

Comments
 (0)