Skip to content

Commit 9ec436b

Browse files
authored
ref(replay): Allow timestamp to be passed as an argument to sendReplayRequest (#6696)
This will be needed when attempting to send a replay request at a different time (e.g. after a reload).
1 parent b250f9f commit 9ec436b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

packages/replay/src/replay.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,7 @@ export class ReplayContainer implements ReplayContainerInterface {
893893
segmentId: segment_id,
894894
includeReplayStartTimestamp,
895895
eventContext,
896+
timestamp = new Date().getTime(),
896897
}: SendReplay): Promise<void | TransportMakeRequestResponse> {
897898
const recordingData = createRecordingData({
898899
events,
@@ -903,8 +904,6 @@ export class ReplayContainer implements ReplayContainerInterface {
903904

904905
const { urls, errorIds, traceIds, initialTimestamp } = eventContext;
905906

906-
const currentTimestamp = new Date().getTime();
907-
908907
const hub = getCurrentHub();
909908
const client = hub.getClient();
910909
const scope = hub.getScope();
@@ -919,7 +918,7 @@ export class ReplayContainer implements ReplayContainerInterface {
919918
// @ts-ignore private api
920919
type: REPLAY_EVENT_NAME,
921920
...(includeReplayStartTimestamp ? { replay_start_timestamp: initialTimestamp / 1000 } : {}),
922-
timestamp: currentTimestamp / 1000,
921+
timestamp: timestamp / 1000,
923922
error_ids: errorIds,
924923
trace_ids: traceIds,
925924
urls,

packages/replay/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export interface SendReplay {
1515
segmentId: number;
1616
includeReplayStartTimestamp: boolean;
1717
eventContext: PopEventContext;
18+
timestamp?: number;
1819
}
1920

2021
export type InstrumentationTypeBreadcrumb = 'dom' | 'scope';

0 commit comments

Comments
 (0)