Skip to content

Commit 6e10bb3

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 9f06d48 commit 6e10bb3

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
@@ -906,6 +906,7 @@ export class ReplayContainer implements ReplayContainerInterface {
906906
segmentId: segment_id,
907907
includeReplayStartTimestamp,
908908
eventContext,
909+
timestamp = new Date().getTime(),
909910
}: SendReplay): Promise<void | TransportMakeRequestResponse> {
910911
const recordingData = createRecordingData({
911912
events,
@@ -916,8 +917,6 @@ export class ReplayContainer implements ReplayContainerInterface {
916917

917918
const { urls, errorIds, traceIds, initialTimestamp } = eventContext;
918919

919-
const currentTimestamp = new Date().getTime();
920-
921920
const hub = getCurrentHub();
922921
const client = hub.getClient();
923922
const scope = hub.getScope();
@@ -932,7 +931,7 @@ export class ReplayContainer implements ReplayContainerInterface {
932931
// @ts-ignore private api
933932
type: REPLAY_EVENT_NAME,
934933
...(includeReplayStartTimestamp ? { replay_start_timestamp: initialTimestamp / 1000 } : {}),
935-
timestamp: currentTimestamp / 1000,
934+
timestamp,
936935
error_ids: errorIds,
937936
trace_ids: traceIds,
938937
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)