From 23fb9f663c8dee76e94ee9c6e45b96fd86129603 Mon Sep 17 00:00:00 2001 From: David Newell Date: Fri, 8 Mar 2024 16:52:15 +0000 Subject: [PATCH] feat: allow custom replay root --- src/extensions/replay/sessionrecording-utils.ts | 1 + src/extensions/replay/sessionrecording.ts | 1 + src/types.ts | 1 + 3 files changed, 3 insertions(+) diff --git a/src/extensions/replay/sessionrecording-utils.ts b/src/extensions/replay/sessionrecording-utils.ts index 51ec354be..fc99011d1 100644 --- a/src/extensions/replay/sessionrecording-utils.ts +++ b/src/extensions/replay/sessionrecording-utils.ts @@ -61,6 +61,7 @@ export declare type recordOptions = { plugins?: RecordPlugin[] mousemoveWait?: number keepIframeSrcFn?: KeepIframeSrcFn + root?: HTMLElement // errorHandler?: ErrorHandler } diff --git a/src/extensions/replay/sessionrecording.ts b/src/extensions/replay/sessionrecording.ts index 519e8a555..83f2ba855 100644 --- a/src/extensions/replay/sessionrecording.ts +++ b/src/extensions/replay/sessionrecording.ts @@ -492,6 +492,7 @@ export class SessionRecording { collectFonts: false, inlineStylesheet: true, recordCrossOriginIframes: false, + root: window?.document.body, } // We switched from loading all of rrweb to just the record part, but // keep backwards compatibility if someone hasn't upgraded PostHog diff --git a/src/types.ts b/src/types.ts index 3c4189345..5e69ebf1c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -171,6 +171,7 @@ export interface SessionRecordingOptions { // our settings here only support a subset of those proposed for rrweb's network capture plugin recordHeaders?: boolean recordBody?: boolean + root?: HTMLElement } export type SessionIdChangedCallback = (sessionId: string, windowId: string | null | undefined) => void