Skip to content

Commit 10752f4

Browse files
committed
vendor util in
1 parent 8a8cb58 commit 10752f4

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

packages/replay-internal/src/replay.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable max-lines */ // TODO: We might want to split this file up
22
import type { ReplayRecordingMode, Span } from '@sentry/core';
33
import { getActiveSpan, getClient, getRootSpan, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, spanToJSON } from '@sentry/core';
4-
import { EventType, record, utils as rrwebUtils } from '@sentry-internal/rrweb';
4+
import { EventType, record } from '@sentry-internal/rrweb';
55
import {
66
BUFFER_CHECKOUT_TIME,
77
SESSION_IDLE_EXPIRE_DURATION,
@@ -53,6 +53,7 @@ import { isExpired } from './util/isExpired';
5353
import { isSessionExpired } from './util/isSessionExpired';
5454
import { logger } from './util/logger';
5555
import { resetReplayIdOnDynamicSamplingContext } from './util/resetReplayIdOnDynamicSamplingContext';
56+
import { closestElementOfNode } from './util/rrweb';
5657
import { sendReplay } from './util/sendReplay';
5758
import { RateLimitError } from './util/sendReplayRequest';
5859
import type { SKIPPED } from './util/throttle';
@@ -1309,7 +1310,7 @@ export class ReplayContainer implements ReplayContainerInterface {
13091310
if (ignoreMutations?.length) {
13101311
if (
13111312
mutations.some(mutation => {
1312-
const el = rrwebUtils.closestElementOfNode(mutation.target);
1313+
const el = closestElementOfNode(mutation.target);
13131314
const selector = ignoreMutations.join(',');
13141315
return el?.matches(selector);
13151316
})
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Vendored in from @sentry-internal/rrweb.
3+
*
4+
* This is a copy of the function from rrweb, it is not nicely exported there.
5+
*/
6+
export function closestElementOfNode(node: Node | null): HTMLElement | null {
7+
if (!node) {
8+
return null;
9+
}
10+
11+
// Catch access to node properties to avoid Firefox "permission denied" errors
12+
try {
13+
const el: HTMLElement | null = node.nodeType === node.ELEMENT_NODE ? (node as HTMLElement) : node.parentElement;
14+
return el;
15+
} catch (error) {
16+
return null;
17+
}
18+
}

0 commit comments

Comments
 (0)