Skip to content

Commit

Permalink
Rename assetCapture to captureAssets
Browse files Browse the repository at this point in the history
Also deprecate a couple inlineImages tests
  • Loading branch information
Juice10 committed Nov 28, 2023
1 parent 3b1b005 commit fe62617
Show file tree
Hide file tree
Showing 18 changed files with 1,347 additions and 228 deletions.
10 changes: 5 additions & 5 deletions docs/recipes/assets.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

## Inline Images (Deprecated)

The `inlineImages` configuration option is deprecated and should not be used anymore. It has some issues, namely rewriting events that are already emitted which might make you miss the inlined image if the event has already been sent to the server. Instead, use the `assetCapture` option to configure asset capture.
The `inlineImages` configuration option is deprecated and should not be used anymore. It has some issues, namely rewriting events that are already emitted which might make you miss the inlined image if the event has already been sent to the server. Instead, use the `captureAssets` option to configure asset capture.

## Asset Capture Configuration

The `assetCapture` configuration option allows you to customize the asset capture process. It is an object with the following properties:
The `captureAssets` configuration option allows you to customize the asset capture process. It is an object with the following properties:

- `objectURLs` (default: `true`): This property specifies whether to capture same-origin `blob:` assets using object URLs. Object URLs are created using the `URL.createObjectURL()` method. Setting `objectURLs` to `true` enables the capture of object URLs.

Expand All @@ -24,7 +24,7 @@ Here is the TypeScript type definition for the `recordOptions` object, which inc
```typescript
export type recordOptions<T> = {
// Other configuration options...
assetCapture?: {
captureAssets?: {
objectURLs: boolean;
origins: string[] | true | false;
};
Expand All @@ -33,8 +33,8 @@ export type recordOptions<T> = {
};
```

This type definition shows that `assetCapture` is an optional property of the `recordOptions` object. It contains the `objectURLs` and `origins` properties, which have the same meanings as described above.
This type definition shows that `captureAssets` is an optional property of the `recordOptions` object. It contains the `objectURLs` and `origins` properties, which have the same meanings as described above.

## Conclusion

By configuring the `assetCapture` option in rrweb, you can control how assets like images are captured during the recording process. This allows you to customize which assets are included in the recorded interactions on your website.
By configuring the `captureAssets` option in rrweb, you can control how assets like images are captured during the recording process. This allows you to customize which assets are included in the recorded interactions on your website.
10 changes: 5 additions & 5 deletions docs/recipes/assets.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

## 内联图像(已弃用)

`inlineImages` 配置选项已被弃用,不应再使用。它存在一些问题,即重写已经发出的事件,这可能使您错过已发送到服务器的内联图像。相反,请使用 `assetCapture` 选项来配置资源捕获。
`inlineImages` 配置选项已被弃用,不应再使用。它存在一些问题,即重写已经发出的事件,这可能使您错过已发送到服务器的内联图像。相反,请使用 `captureAssets` 选项来配置资源捕获。

## 资源捕获配置

`assetCapture` 配置选项允许您自定义资源捕获过程。它是一个具有以下属性的对象:
`captureAssets` 配置选项允许您自定义资源捕获过程。它是一个具有以下属性的对象:

- `objectURLs`(默认值:`true`):此属性指定是否使用对象 URL 捕获同源 `blob:` 资源。对象 URL 是使用 `URL.createObjectURL()` 方法创建的。将 `objectURLs` 设置为 `true` 可以启用对象 URL 的捕获。

Expand All @@ -24,7 +24,7 @@
```typescript
export type recordOptions<T> = {
// 其他配置选项...
assetCapture?: {
captureAssets?: {
objectURLs: boolean;
origins: string[] | true | false;
};
Expand All @@ -33,8 +33,8 @@ export type recordOptions<T> = {
};
```

这种类型定义表明 assetCapture 是 recordOptions 对象的一个可选属性。它包含 objectURLs 和 origins 属性,其含义与上述相同。
这种类型定义表明 captureAssets 是 recordOptions 对象的一个可选属性。它包含 objectURLs 和 origins 属性,其含义与上述相同。

## 结论

通过在 rrweb 中配置 assetCapture 选项,您可以控制在记录过程中如何捕获像图像这样的资源。这允许您
通过在 rrweb 中配置 captureAssets 选项,您可以控制在记录过程中如何捕获像图像这样的资源。这允许您
4 changes: 2 additions & 2 deletions guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ The parameter of `rrweb.record` accepts the following options.
| recordCanvas | false | Whether to record the canvas element. Available options:<br/>`false`, <br/>`true` |
| recordCrossOriginIframes | false | Whether to record cross origin iframes. rrweb has to be injected in each child iframe for this to work. Available options:<br/>`false`, <br/>`true` |
| recordAfter | 'load' | If the document is not ready, then the recorder will start recording after the specified event is fired. Available options: `DOMContentLoaded`, `load` |
| ~inlineImages~ | false | whether to record the image content (deprecated, use `assetCapture` instead) |
| assetCapture | { objectURLs: true, origins: false } | Configure the asset (image) capture and generates async asset events.<br/>Refer to the [asset capture documentation](./docs/recipes/assets.md) for more info. |
| ~inlineImages~ | false | whether to record the image content (deprecated, use `captureAssets` instead) |
| captureAssets | { objectURLs: true, origins: false } | Configure the asset (image) capture and generates async asset events.<br/>Refer to the [asset capture documentation](./docs/recipes/assets.md) for more info. |
| collectFonts | false | whether to collect fonts in the website |
| userTriggeredOnInput | false | whether to add `userTriggered` on input events that indicates if this event was triggered directly by the user or not. [What is `userTriggered`?](https://github.com/rrweb-io/rrweb/pull/495) |
| plugins | [] | load plugins to provide extended record functions. [What is plugins?](./docs/recipes/plugin.md) |
Expand Down
2 changes: 1 addition & 1 deletion guide.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ setInterval(save, 10 * 1000);
| recordCrossOriginIframes | false | 是否记录 cross origin iframes。 必须在每个子 iframe 中注入 rrweb 才能使其工作。 可用选项:`false`, `true` |
| recordAfter | 'load' | 如果 document 还没有加载完成,recorder 将会在指定的事件触发后开始录制。可用选项: `DOMContentLoaded`, `load` |
| ~inlineImages~ | false | 是否将图片内容记内联录制 |
| assetCapture | { objectURLs: true, origins: false } | 配置资源(图像)捕获并生成异步资源事件。<br/>有关更多信息,请参阅[资源捕获文档](./docs/recipes/assets.zh_CN.md) |
| captureAssets | { objectURLs: true, origins: false } | 配置资源(图像)捕获并生成异步资源事件。<br/>有关更多信息,请参阅[资源捕获文档](./docs/recipes/assets.zh_CN.md) |
| collectFonts | false | 是否记录页面中的字体文件 |
| userTriggeredOnInput | false | [什么是 `userTriggered`](https://github.com/rrweb-io/rrweb/pull/495) |
| plugins | [] | 加载插件以获得额外的录制功能. [什么是插件?](./docs/recipes/plugin.zh_CN.md) |
Expand Down
8 changes: 4 additions & 4 deletions packages/rrweb-snapshot/src/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ function serializeNode(
maskInputFn: MaskInputFn | undefined;
dataURLOptions?: DataURLOptions;
/**
* @deprecated please use `assetCapture` instead
* @deprecated please use `captureAssets` instead
*/
inlineImages: boolean;
recordCanvas: boolean;
Expand Down Expand Up @@ -632,7 +632,7 @@ function serializeElementNode(
maskInputFn: MaskInputFn | undefined;
dataURLOptions?: DataURLOptions;
/**
* @deprecated please use `assetCapture` instead
* @deprecated please use `captureAssets` instead
*/
inlineImages: boolean;
recordCanvas: boolean;
Expand Down Expand Up @@ -1000,7 +1000,7 @@ export function serializeNodeWithId(
dataURLOptions?: DataURLOptions;
keepIframeSrcFn?: KeepIframeSrcFn;
/**
* @deprecated please use `assetCapture` instead
* @deprecated please use `captureAssets` instead
*/
inlineImages?: boolean;
recordCanvas?: boolean;
Expand Down Expand Up @@ -1287,7 +1287,7 @@ function snapshot(
slimDOM?: 'all' | boolean | SlimDOMOptions;
dataURLOptions?: DataURLOptions;
/**
* @deprecated please use `assetCapture` instead
* @deprecated please use `captureAssets` instead
*/
inlineImages?: boolean;
recordCanvas?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/rrweb-snapshot/test/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ iframe.contentDocument.querySelector('center').clientHeight
onIframeLoad: function(iframe, sn) {
window.snapshot = sn;
},
assetCapture: {
captureAssets: {
origin: false,
objectURLs: false
}
Expand Down
2 changes: 1 addition & 1 deletion packages/rrweb/scripts/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async function injectRecording(frame) {
recordCanvas: false,
recordCrossOriginIframes: true,
collectFonts: true,
assetCapture: {
captureAssets: {
objectURLs: true,
origins: false,
},
Expand Down
6 changes: 3 additions & 3 deletions packages/rrweb/src/record/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function record<T = eventWithTime>(
userTriggeredOnInput = false,
collectFonts = false,
inlineImages = false,
assetCapture = {
captureAssets = {
objectURLs: true,
origins: false,
},
Expand Down Expand Up @@ -337,7 +337,7 @@ function record<T = eventWithTime>(
assetManager = new AssetManager({
mutationCb: wrappedAssetEmit,
win: window,
assetCapture,
captureAssets,
});

const shadowDomManager = new ShadowDomManager({
Expand Down Expand Up @@ -378,7 +378,7 @@ function record<T = eventWithTime>(
href: window.location.href,
width: getWindowWidth(),
height: getWindowHeight(),
assetCapture,
captureAssets,
},
}),
isCheckout,
Expand Down
2 changes: 1 addition & 1 deletion packages/rrweb/src/record/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export default class MutationBuffer {
private keepIframeSrcFn: observerParam['keepIframeSrcFn'];
private recordCanvas: observerParam['recordCanvas'];
/**
* @deprecated please use `assetCapture` instead
* @deprecated please use `captureAssets` instead
*/
private inlineImages: observerParam['inlineImages'];
private slimDOMOptions: observerParam['slimDOMOptions'];
Expand Down
8 changes: 4 additions & 4 deletions packages/rrweb/src/record/observers/asset-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default class AssetManager {
private resetHandlers: listenerHandler[] = [];
private mutationCb: assetCallback;
public readonly config: Exclude<
recordOptions<eventWithTime>['assetCapture'],
recordOptions<eventWithTime>['captureAssets'],
undefined
>;

Expand All @@ -33,15 +33,15 @@ export default class AssetManager {
constructor(options: {
mutationCb: assetCallback;
win: IWindow;
assetCapture: Exclude<
recordOptions<eventWithTime>['assetCapture'],
captureAssets: Exclude<
recordOptions<eventWithTime>['captureAssets'],
undefined
>;
}) {
const { win } = options;

this.mutationCb = options.mutationCb;
this.config = options.assetCapture;
this.config = options.captureAssets;

const urlObjectMap = this.urlObjectMap;

Expand Down
8 changes: 4 additions & 4 deletions packages/rrweb/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import type {
styleDeclarationCallback,
styleSheetRuleCallback,
viewportResizeCallback,
assetCaptureParam,
captureAssetsParam,
} from '@rrweb/types';
import type ProcessedNodeManager from './record/processed-node-manager';
import type AssetManager from './record/observers/asset-manager';
Expand Down Expand Up @@ -70,10 +70,10 @@ export type recordOptions<T> = {
userTriggeredOnInput?: boolean;
collectFonts?: boolean;
/**
* @deprecated please use `assetCapture` instead
* @deprecated please use `captureAssets` instead
*/
inlineImages?: boolean;
assetCapture?: assetCaptureParam;
captureAssets?: captureAssetsParam;
plugins?: RecordPlugin[];
// departed, please use sampling options
mousemoveWait?: number;
Expand Down Expand Up @@ -110,7 +110,7 @@ export type observerParam = {
recordDOM: boolean;
recordCanvas: boolean;
/**
* @deprecated please use `assetCapture` instead
* @deprecated please use `captureAssets` instead
*/
inlineImages: boolean;
userTriggeredOnInput: boolean;
Expand Down
Loading

0 comments on commit fe62617

Please sign in to comment.