change(tracker): fix iframe network handling
This commit is contained in:
parent
d74ed000fa
commit
0e1ba6650d
4 changed files with 20 additions and 2 deletions
|
|
@ -4,6 +4,7 @@
|
|||
- remove useless logs
|
||||
- added gzip compression to large messages
|
||||
- tune mouse thrashing detection
|
||||
- fix iframe handling
|
||||
|
||||
# 6.0.0
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@openreplay/tracker",
|
||||
"description": "The OpenReplay tracker main package",
|
||||
"version": "6.0.1",
|
||||
"version": "6.0.1-beta.1",
|
||||
"keywords": [
|
||||
"logging",
|
||||
"replay"
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import IFrameOffsets, { Offset } from './iframe_offsets.js'
|
|||
|
||||
import { CreateDocument } from '../messages.gen.js'
|
||||
import App from '../index.js'
|
||||
import { IN_BROWSER, hasOpenreplayAttribute } from '../../utils.js'
|
||||
import { IN_BROWSER, hasOpenreplayAttribute, canAccessIframe } from '../../utils.js'
|
||||
|
||||
export interface Options {
|
||||
captureIFrames: boolean
|
||||
|
|
@ -75,6 +75,7 @@ export default class TopObserver extends Observer {
|
|||
//log
|
||||
return
|
||||
}
|
||||
if (!canAccessIframe(iframe)) return
|
||||
const currentWin = iframe.contentWindow
|
||||
const currentDoc = iframe.contentDocument
|
||||
if (currentDoc && currentDoc !== doc) {
|
||||
|
|
|
|||
|
|
@ -81,3 +81,19 @@ export function hasOpenreplayAttribute(e: Element, attr: string): boolean {
|
|||
|
||||
return false
|
||||
}
|
||||
|
||||
export function isIframeCrossdomain(e: HTMLIFrameElement): boolean {
|
||||
try {
|
||||
return e.contentWindow?.location.href !== window.location.href
|
||||
} catch (e) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
export function canAccessIframe(iframe: HTMLIFrameElement) {
|
||||
try {
|
||||
return Boolean(iframe.contentDocument)
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue