Skip to content

Commit

Permalink
Create assetStatus type as per Justin's request
Browse files Browse the repository at this point in the history
  • Loading branch information
eoghanmurray committed Apr 3, 2024
1 parent c88f8d8 commit dfcfee4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 3 additions & 7 deletions packages/rrweb/src/record/observers/asset-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { encode } from 'base64-arraybuffer';

import { patch } from '../../utils';

import type { recordOptions } from '../../types';
import type { recordOptions, assetStatus } from '../../types';
import { isAttributeCapturable, getSourcesFromSrcset } from 'rrweb-snapshot';

export default class AssetManager {
Expand Down Expand Up @@ -126,9 +126,7 @@ export default class AssetManager {
}
}

public capture(asset: asset): {
status: 'capturing' | 'captured' | 'error' | 'refused';
} {
public capture(asset: asset): assetStatus {
if (asset.attr === 'srcset') {
getSourcesFromSrcset(asset.value).forEach((url) => {
this.captureUrl(url);
Expand All @@ -138,9 +136,7 @@ export default class AssetManager {
}
}

public captureUrl(url): {
status: 'capturing' | 'captured' | 'error' | 'refused';
} {
public captureUrl(url): assetStatus {
if (this.shouldIgnore(url)) return { status: 'refused' };

if (this.capturedURLs.has(url)) {
Expand Down
8 changes: 8 additions & 0 deletions packages/rrweb/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,11 @@ export type CrossOriginIframeMessageEvent =
MessageEvent<CrossOriginIframeMessageEventContent>;

export type ErrorHandler = (error: unknown) => void | boolean;

export type assetStatus = {
status:
| 'capturing'
| 'captured'
| 'error'
| 'refused'
};

0 comments on commit dfcfee4

Please sign in to comment.