From c970be1dbd6b2a885b45efc4c3b81487912fb38b Mon Sep 17 00:00:00 2001 From: Billy Vong Date: Mon, 9 Jan 2023 14:52:54 -0500 Subject: [PATCH 1/2] ref(replay): Allow `timestamp` to be passed as an argument to `sendReplayRequest` This will be needed when attempting to send a replay request at a different time (e.g. after a reload). --- packages/replay/src/replay.ts | 5 ++--- packages/replay/src/types.ts | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/replay/src/replay.ts b/packages/replay/src/replay.ts index 612bf5a71c10..a93151dd913f 100644 --- a/packages/replay/src/replay.ts +++ b/packages/replay/src/replay.ts @@ -895,6 +895,7 @@ export class ReplayContainer implements ReplayContainerInterface { segmentId: segment_id, includeReplayStartTimestamp, eventContext, + timestamp = new Date().getTime(), }: SendReplay): Promise { const recordingData = createRecordingData({ events, @@ -905,8 +906,6 @@ export class ReplayContainer implements ReplayContainerInterface { const { urls, errorIds, traceIds, initialTimestamp } = eventContext; - const currentTimestamp = new Date().getTime(); - const hub = getCurrentHub(); const client = hub.getClient(); const scope = hub.getScope(); @@ -921,7 +920,7 @@ export class ReplayContainer implements ReplayContainerInterface { // @ts-ignore private api type: REPLAY_EVENT_NAME, ...(includeReplayStartTimestamp ? { replay_start_timestamp: initialTimestamp / 1000 } : {}), - timestamp: currentTimestamp / 1000, + timestamp, error_ids: errorIds, trace_ids: traceIds, urls, diff --git a/packages/replay/src/types.ts b/packages/replay/src/types.ts index 029bd109c31f..0c05bdeaabcf 100644 --- a/packages/replay/src/types.ts +++ b/packages/replay/src/types.ts @@ -15,6 +15,7 @@ export interface SendReplay { segmentId: number; includeReplayStartTimestamp: boolean; eventContext: PopEventContext; + timestamp?: number; } export type InstrumentationTypeBreadcrumb = 'dom' | 'scope'; From d0a164e4f64214a2249a8fc4a9fddb71606413f2 Mon Sep 17 00:00:00 2001 From: Billy Vong Date: Mon, 9 Jan 2023 15:04:39 -0500 Subject: [PATCH 2/2] Update packages/replay/src/replay.ts --- packages/replay/src/replay.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/replay/src/replay.ts b/packages/replay/src/replay.ts index a93151dd913f..3f4761c4ccab 100644 --- a/packages/replay/src/replay.ts +++ b/packages/replay/src/replay.ts @@ -920,7 +920,7 @@ export class ReplayContainer implements ReplayContainerInterface { // @ts-ignore private api type: REPLAY_EVENT_NAME, ...(includeReplayStartTimestamp ? { replay_start_timestamp: initialTimestamp / 1000 } : {}), - timestamp, + timestamp: timestamp / 1000, error_ids: errorIds, trace_ids: traceIds, urls,