Skip to content

Commit c970be1

Browse files
committed
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).
1 parent 8f299b6 commit c970be1

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
@@ -895,6 +895,7 @@ export class ReplayContainer implements ReplayContainerInterface {
895895
segmentId: segment_id,
896896
includeReplayStartTimestamp,
897897
eventContext,
898+
timestamp = new Date().getTime(),
898899
}: SendReplay): Promise<void | TransportMakeRequestResponse> {
899900
const recordingData = createRecordingData({
900901
events,
@@ -905,8 +906,6 @@ export class ReplayContainer implements ReplayContainerInterface {
905906

906907
const { urls, errorIds, traceIds, initialTimestamp } = eventContext;
907908

908-
const currentTimestamp = new Date().getTime();
909-
910909
const hub = getCurrentHub();
911910
const client = hub.getClient();
912911
const scope = hub.getScope();
@@ -921,7 +920,7 @@ export class ReplayContainer implements ReplayContainerInterface {
921920
// @ts-ignore private api
922921
type: REPLAY_EVENT_NAME,
923922
...(includeReplayStartTimestamp ? { replay_start_timestamp: initialTimestamp / 1000 } : {}),
924-
timestamp: currentTimestamp / 1000,
923+
timestamp,
925924
error_ids: errorIds,
926925
trace_ids: traceIds,
927926
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)