Add emitFromIframe option to support iframe in iframe #1726
+5
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thank you for maintaining rrweb and supporting the modern web dev tooling ecosystem
Description
This PR introduces a new
emitFromIframe
boolean in rrweb'srecordOptions
that allows iframe-in-iframe monitoring when hosted in a parent that doesn't have rrweb.Problem
Consider a "host website" (which doesn't have rrweb) which hosts a "parent iframe" (which has rrweb) which nests another "child iframe" (which also has rrweb).
Currently, the
recordCrossOriginIframes
option would need to be enabled in rrweb in both parent and child iframes in order to monitor iframe-in-iframe traffic correctly. However we cannot monitor the parent iframe as therecordCrossOriginIframes
option is ALSO used to pass all events to the host website since the parent iframe is not the top level page. i.e: TherecordCrossOriginIframes
is used for both receiving events from a child iframe and passing those events without recording, to the host website.Thus the parent iframe will emit events to the host website since
recordCrossOriginIframes
is true and the host website will ignore these events as it doesn't have rrweb.Solution
Adding a
emitFromIframe
option allows the parent iframe to record events directly without passing events to the host website while usingrecordCrossOriginIframes
to collect events from child iframes.Status
This is a proof-of-concept but it should already work in production. I would like to get feedback on whether this is something that aligns with the rrweb team's roadmap before investing more effort in adding documentation and tests.