Created
August 8, 2023 14:42
-
-
Save jasonLaster/da800531828ba9ceaa3c83e13695bf58 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/instance/testInboxServer.ts b/src/instance/testInboxServer.ts | |
index 4dae6d7c1..5ed5c9523 100644 | |
--- a/src/instance/testInboxServer.ts | |
+++ b/src/instance/testInboxServer.ts | |
@@ -152,9 +152,12 @@ async function replayRecordingTestSnapshots( | |
const snapshotSessionSuccess = await replayRecordingWithTimeout( | |
dispatchAddress, | |
recordingId, | |
- url, | |
{ ...options, skipFuzzing: true }, | |
timeoutSeconds, | |
+ await client.getRecordingTelemetryMetadata( | |
+ recordingId, | |
+ emptyContext("ReplayRecordingTestInbox") | |
+ ), | |
experimentalSettings | |
); | |
@@ -180,9 +183,12 @@ async function replayRecordingTestSnapshots( | |
return replayRecordingWithTimeout( | |
dispatchAddress, | |
recordingId, | |
- url, | |
options, | |
timeoutSeconds, | |
+ await client.getRecordingTelemetryMetadata( | |
+ recordingId, | |
+ emptyContext("ReplayRecordingTestInbox") | |
+ ), | |
experimentalSettings | |
); | |
} | |
@@ -251,12 +257,15 @@ async function handleRecording(recordingId: string, url: string | undefined) { | |
success = await replayRecordingWithTimeout( | |
"ws://agent", | |
recordingId, | |
- url, | |
{ | |
apiKey: process.env.RECORD_REPLAY_TEST_INBOX_API_KEY, | |
uploadSessionRecording: true, | |
}, | |
- ReplayTimeout | |
+ ReplayTimeout, | |
+ await client.getRecordingTelemetryMetadata( | |
+ recordingId, | |
+ emptyContext("ReplayRecordingTestInbox") | |
+ ) | |
); | |
} | |
} catch (e) { | |
diff --git a/src/processing/replayRecording.ts b/src/processing/replayRecording.ts | |
index 64e6e5570..edac9048f 100644 | |
--- a/src/processing/replayRecording.ts | |
+++ b/src/processing/replayRecording.ts | |
@@ -158,6 +158,20 @@ interface PauseInfo extends TimeStampedPoint { | |
pauseId: string; | |
} | |
+type RecordingMetadata = { | |
+ workspace: { | |
+ name: string; | |
+ id: string; | |
+ } | void; | |
+ url: string; | |
+ buildId: string; | |
+ date: string; | |
+ user: { | |
+ id: string; | |
+ email: string; | |
+ } | void; | |
+}; | |
+ | |
export class Fuzzer { | |
dispatchAddress: string; | |
recordingId: string; | |
@@ -165,11 +179,16 @@ export class Fuzzer { | |
sessionId: string | undefined; | |
client: RecordingClient | undefined; | |
buildId: string | undefined; | |
+ recordingMetadata: RecordingMetadata; | |
- constructor(dispatchAddress: string, recordingId: string, url?: string) { | |
+ constructor( | |
+ dispatchAddress: string, | |
+ recordingId: string, | |
+ recordingMetadata: RecordingMetadata | |
+ ) { | |
this.dispatchAddress = dispatchAddress; | |
this.recordingId = recordingId; | |
- this.url = url; | |
+ this.recordingMetadata = recordingMetadata; | |
} | |
async destroy() { | |
@@ -286,10 +305,7 @@ export class Fuzzer { | |
pingTelemetry(event, { | |
recordingId: this.recordingId, | |
buildId: this.buildId, | |
- recording: { | |
- id: this.recordingId, | |
- buildId: this.buildId, | |
- }, | |
+ recording: this.recordingMetadata, | |
sessionId: this.sessionId, | |
...tags, | |
service_name: "testinbox", | |
@@ -899,13 +915,13 @@ export type ReplayOptions = { | |
export async function replayRecording( | |
dispatchAddress: string, | |
recordingId: string, | |
- url?: string, | |
options: ReplayOptions = {}, | |
+ recordingMetadata: RecordingMetadata, | |
experimentalSettings?: Partial<UserExperimentalSettings> | |
): Promise<boolean> { | |
log("Replay recording", recordingId); | |
let sessionId: string | null = null; | |
- const fuzzer = new Fuzzer(dispatchAddress, recordingId, url); | |
+ const fuzzer = new Fuzzer(dispatchAddress, recordingId, recordingMetadata); | |
const startTime = new Date(); | |
let success = false; | |
@@ -1066,9 +1082,9 @@ export async function replayRecording( | |
export async function replayRecordingWithTimeout( | |
dispatchAddress: string, | |
recordingId: string, | |
- url: string | undefined, | |
options: ReplayOptions, | |
timeoutSeconds: number, | |
+ recordingMetadata: RecordingMetadata, | |
experimentalSettings?: Partial<UserExperimentalSettings> | |
): Promise<boolean> { | |
let success = false; | |
@@ -1076,8 +1092,8 @@ export async function replayRecordingWithTimeout( | |
replayRecording( | |
dispatchAddress, | |
recordingId, | |
- url, | |
options, | |
+ recordingMetadata, | |
experimentalSettings | |
).then(rv => { | |
success = rv; | |
@@ -1127,7 +1143,7 @@ if (process.argv[1].includes("replayRecording")) { | |
assert(recordingId, "No recording specified"); | |
- replayRecording(server, recordingId, url, options).catch(() => { | |
+ replayRecording(server, recordingId, options, {}).catch(() => { | |
console.error("Fuzzing failed"); | |
}); | |
} | |
diff --git a/src/shared/graphql.ts b/src/shared/graphql.ts | |
index 5d5b9d0ea..3c2b4a355 100644 | |
--- a/src/shared/graphql.ts | |
+++ b/src/shared/graphql.ts | |
@@ -1020,6 +1020,38 @@ mutation SetControllerCrashReport($id: String!, $crash_report: jsonb!) { | |
return result.data.recordings_by_pk?.workspace?.id || null; | |
} | |
+ async getRecordingTelemetryMetadata(recordingId: string, cx: Context) { | |
+ const result: GraphQLResponse<{ | |
+ recordings_by_pk: { metadata: any } | null; | |
+ }> = await this.queryHasura( | |
+ ` | |
+ query GetRecordingTelemetryMetadata($recordingId: uuid!) { | |
+ recordings_by_pk(id: $recordingId) { | |
+ id | |
+ url | |
+ buildId | |
+ date | |
+ workspace { | |
+ id | |
+ name | |
+ } | |
+ user { | |
+ id | |
+ } | |
+ } | |
+ } | |
+ `, | |
+ "GetRecordingTelemetryMetadata", | |
+ { | |
+ recordingId, | |
+ }, | |
+ cx | |
+ ); | |
+ | |
+ return result.data.recordings_by_pk?.metadata || null; | |
+ } | |
+ | |
async fetchWorkspaceShouldSampleByRecordingId( | |
recordingId: string, | |
cx: Context |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment