Skip to content

Commit

Permalink
Add strict option to upload all (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanjduffy authored Jan 19, 2024
1 parent 96ee8eb commit 5b692ca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
7 changes: 4 additions & 3 deletions packages/replay/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
RecordingEntry,
SourceMapEntry,
UploadAllOptions,
UploadOptions,
} from "./types";
import { add, sanitize, source as sourceMetadata, test as testMetadata } from "../metadata";
import jsonata from "jsonata";
Expand Down Expand Up @@ -328,7 +329,7 @@ async function doUploadRecording(
return recordingId;
}

async function uploadRecording(id: string, opts: Options = {}) {
async function uploadRecording(id: string, opts: UploadOptions = {}) {
const server = getServer(opts);
const dir = getDirectory(opts);
const recordings = readRecordings(dir);
Expand Down Expand Up @@ -391,7 +392,7 @@ async function processRecording(id: string, opts: Options = {}) {
return succeeded ? recordingId : null;
}

async function uploadAllRecordings(opts: Options & UploadAllOptions = {}) {
async function uploadAllRecordings(opts: UploadAllOptions = {}) {
const server = getServer(opts);
const dir = getDirectory(opts);
const allRecordings = readRecordings(dir).filter(r => !uploadSkipReason(r));
Expand Down Expand Up @@ -429,7 +430,7 @@ async function uploadAllRecordings(opts: Options & UploadAllOptions = {}) {
const recordingIds: (string | null)[] = await pMap(
recordings,
(r: RecordingEntry) =>
doUploadRecording(dir, server, r, opts.verbose, opts.apiKey, opts.agent, false),
doUploadRecording(dir, server, r, opts.verbose, opts.apiKey, opts.agent, false, opts.strict),
{ concurrency: batchSize, stopOnError: false }
);

Expand Down
14 changes: 8 additions & 6 deletions packages/replay/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ export interface Options {
apiKey?: string;
verbose?: boolean;
agent?: any;

/**
* Fail the recording upload if any part of the upload fails.
*/
strict?: boolean;
}

export interface SourcemapUploadOptions {
Expand Down Expand Up @@ -64,7 +59,14 @@ export interface ListOptions extends FilterOptions {
all?: boolean;
}

export interface UploadAllOptions extends FilterOptions {
export interface UploadOptions extends Options {
/**
* Fail the recording upload if any part of the upload fails.
*/
strict?: boolean;
}

export interface UploadAllOptions extends FilterOptions, UploadOptions {
batchSize?: number;
warn?: boolean;
}
Expand Down

0 comments on commit 5b692ca

Please sign in to comment.