change(tracker): rm attr removal, add check for img

This commit is contained in:
sylenien 2022-09-13 14:26:19 +02:00 committed by Delirium
parent 73597913ff
commit 112bb3be44
5 changed files with 9 additions and 12 deletions

View file

@ -293,12 +293,6 @@ export default abstract class Observer {
const width = el.clientWidth
const height = el.clientHeight
el = node.cloneNode() as Element
const attrs = el.getAttributeNames()
attrs.forEach((attr) => {
if (!attr.startsWith('data-openreplay') && !BASE_ATTRS.includes(attr)) {
el.removeAttribute(attr)
}
})
;(el as HTMLElement | SVGElement).style.width = `${width}px`
;(el as HTMLElement | SVGElement).style.height = `${height}px`
}

View file

@ -77,7 +77,6 @@ export default class TopObserver extends Observer {
private iframeObservers: IFrameObserver[] = []
private handleIframe(iframe: HTMLIFrameElement): void {
let doc: Document | null = null
let win: Window | null = null
// setTimeout is required. Otherwise some event listeners (scroll, mousemove) applied in modules
// do not work on the iframe document when it 've been loaded dynamically ((why?))
const handle = this.app.safe(() =>

View file

@ -78,10 +78,15 @@ export default class Sanitizer {
isObscured(id: number): boolean {
return this.obscured.has(id)
}
isHiddenContainer(id: number) {
return this.hiddenContainers.has(id)
}
isMasked(id: number): boolean {
return this.isObscured(id) || this.isHiddenContainer(id)
}
getInnerTextSecure(el: HTMLElement): string {
const id = this.app.nodes.getID(el)
if (!id) {

View file

@ -1,11 +1,10 @@
import App, { DEFAULT_INGEST_POINT } from './app/index.js'
export { default as App } from './app/index.js'
import { UserID, UserAnonymousID, RawCustomEvent, CustomIssue } from './app/messages.gen.js'
import { UserAnonymousID, RawCustomEvent, CustomIssue } from './app/messages.gen.js'
import * as _Messages from './app/messages.gen.js'
export const Messages = _Messages
import { SanitizeLevel as SanitizeEnum } from './app/sanitizer.js'
export const SanitizeLevel = SanitizeEnum
export { SanitizeLevel } from './app/sanitizer.js'
import Connection from './modules/connection.js'
import Console from './modules/console.js'

View file

@ -54,7 +54,7 @@ export default function (app: App): void {
if (id === undefined) {
return
}
const { src, complete, naturalWidth, naturalHeight, srcset } = this
const { src, complete, naturalWidth, naturalHeight } = this
if (!complete) {
return
}
@ -63,7 +63,7 @@ export default function (app: App): void {
if (isURL(resolvedSrc)) {
app.send(ResourceTiming(timestamp(), 0, 0, 0, 0, 0, resolvedSrc, 'img'))
}
} else if (resolvedSrc.length >= 1e5 || app.sanitizer.isObscured(id)) {
} else if (resolvedSrc.length >= 1e5 || app.sanitizer.isMasked(id)) {
sendPlaceholder(id, this)
} else {
sendSrc(id, this)