@replayio/replay
Advanced tools
Comparing version 0.1.3 to 0.2.0
{ | ||
"name": "@replayio/replay", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"description": "CLI tool for uploading and managing recordings", | ||
@@ -24,5 +24,7 @@ "bin": { | ||
"commander": "^7.2.0", | ||
"is-uuid": "^1.0.2", | ||
"superstruct": "^0.15.4", | ||
"ws": "^7.5.0" | ||
}, | ||
"gitHead": "463e1c33674df61f381a97f7ae54cda984c18249" | ||
"gitHead": "40c7a907a53b8e7ab2c63e6e52f0e4b3531718af" | ||
} |
@@ -13,2 +13,3 @@ const fs = require("fs"); | ||
setRecordingMetadata, | ||
buildRecordingMetadata, | ||
} = require("./upload"); | ||
@@ -321,7 +322,9 @@ const { | ||
} | ||
// validate metadata before uploading so invalid data can block the upload | ||
const metadata = recording.metadata ? buildRecordingMetadata(recording.metadata, { verbose }) : null; | ||
const recordingId = await connectionCreateRecording(recording.id, recording.buildId); | ||
maybeLog(verbose, `Created remote recording ${recordingId}, uploading...`); | ||
if (recording.metadata) { | ||
if (metadata) { | ||
maybeLog(verbose, `Setting recording metadata for ${recordingId}`); | ||
await setRecordingMetadata(recordingId, recording.metadata); | ||
await setRecordingMetadata(recordingId, metadata); | ||
} | ||
@@ -328,0 +331,0 @@ addRecordingEvent(dir, "uploadStarted", recording.id, { |
@@ -1,4 +0,5 @@ | ||
const crypto = require('crypto'); | ||
const crypto = require("crypto"); | ||
const ProtocolClient = require("./client"); | ||
const { defer, maybeLog, isValidUUID } = require("./utils"); | ||
const { sanitize: sanitizeMetadata } = require("../metadata"); | ||
@@ -57,18 +58,26 @@ let gClient; | ||
async function setRecordingMetadata(id, metadata) { | ||
await gClient.sendCommand("Internal.setRecordingMetadata", { | ||
function buildRecordingMetadata(metadata, opts = {}) { | ||
// extract the "standard" metadata and route the `rest` through the sanitizer | ||
const { duration, url, uri, title, operations, ...rest } = metadata; | ||
return { | ||
recordingData: { | ||
duration: metadata.duration || 0, | ||
url: metadata.url || "", | ||
title: metadata.title || "", | ||
operations: metadata.operations || { | ||
duration: duration || 0, | ||
url: url || uri || "", | ||
title: title || "", | ||
operations: operations || { | ||
scriptDomains: [], | ||
}, | ||
id, | ||
lastScreenData: "", | ||
lastScreenMimeType: "", | ||
}, | ||
}); | ||
metadata: sanitizeMetadata(rest, opts), | ||
}; | ||
} | ||
async function setRecordingMetadata(id, metadata) { | ||
metadata.recordingData.id = id; | ||
await gClient.sendCommand("Internal.setRecordingMetadata", metadata); | ||
} | ||
function connectionProcessRecording(recordingId) { | ||
@@ -140,3 +149,4 @@ gClient.sendCommand("Recording.processRecording", { recordingId }); | ||
const { baseURL, targetContentHash, targetURLHash, targetMapURLHash } = metadata; | ||
const { baseURL, targetContentHash, targetURLHash, targetMapURLHash } = | ||
metadata; | ||
const result = await gClient.sendCommand("Recording.addSourceMap", { | ||
@@ -175,2 +185,3 @@ recordingId, | ||
setRecordingMetadata, | ||
buildRecordingMetadata, | ||
}; |
146661
52
2589
4
14
6
+ Addedis-uuid@^1.0.2
+ Addedsuperstruct@^0.15.4
+ Addedis-uuid@1.0.2(transitive)
+ Addedsuperstruct@0.15.5(transitive)