@posthog/browser-common 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/config.js CHANGED
@@ -26,7 +26,7 @@ __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
27
  default: ()=>__WEBPACK_DEFAULT_EXPORT__
28
28
  });
29
- const packageVersion = "0.2.4";
29
+ const packageVersion = "0.2.5";
30
30
  const Config = {
31
31
  DEBUG: false,
32
32
  LIB_VERSION: packageVersion,
package/dist/config.mjs CHANGED
@@ -1,4 +1,4 @@
1
- const packageVersion = "0.2.4";
1
+ const packageVersion = "0.2.5";
2
2
  const Config = {
3
3
  DEBUG: false,
4
4
  LIB_VERSION: packageVersion,
@@ -37,15 +37,26 @@ function getNativeImplementation(name, assignableWindow) {
37
37
  let impl = assignableWindow[name];
38
38
  if ((0, core_namespaceObject.isNativeFunction)(impl) && !(0, external_type_utils_js_namespaceObject.isAngularZonePresent)()) return cachedImplementations[name] = impl.bind(assignableWindow);
39
39
  const document = assignableWindow.document;
40
- if (document && (0, core_namespaceObject.isFunction)(document.createElement)) try {
41
- const sandbox = document.createElement('iframe');
42
- sandbox.hidden = true;
43
- document.head.appendChild(sandbox);
44
- const contentWindow = sandbox.contentWindow;
45
- if (contentWindow && contentWindow[name]) impl = contentWindow[name];
46
- document.head.removeChild(sandbox);
47
- } catch (e) {
48
- external_logger_js_namespaceObject.logger.warn(`Could not create sandbox iframe for ${name} check, bailing to assignableWindow.${name}: `, e);
40
+ if (document && (0, core_namespaceObject.isFunction)(document.createElement)) {
41
+ let sandbox;
42
+ let keepSandboxAttached = false;
43
+ try {
44
+ sandbox = document.createElement('iframe');
45
+ sandbox.hidden = true;
46
+ document.head.appendChild(sandbox);
47
+ const contentWindow = sandbox.contentWindow;
48
+ if (contentWindow && contentWindow[name]) {
49
+ impl = contentWindow[name];
50
+ if ('MutationObserver' === name && (0, core_namespaceObject.isWebKit)(assignableWindow.navigator?.userAgent ?? '')) {
51
+ sandbox.classList.add('rr-block', 'ph-no-capture');
52
+ keepSandboxAttached = true;
53
+ }
54
+ }
55
+ } catch (e) {
56
+ external_logger_js_namespaceObject.logger.warn(`Could not create sandbox iframe for ${name} check, bailing to assignableWindow.${name}: `, e);
57
+ } finally{
58
+ if (!keepSandboxAttached && sandbox?.parentNode) sandbox.parentNode.removeChild(sandbox);
59
+ }
49
60
  }
50
61
  if (!impl || !(0, core_namespaceObject.isFunction)(impl)) return impl;
51
62
  return cachedImplementations[name] = impl.bind(assignableWindow);
@@ -1,4 +1,4 @@
1
- import { isFunction, isNativeFunction } from "@posthog/core";
1
+ import { isFunction, isNativeFunction, isWebKit } from "@posthog/core";
2
2
  import { logger } from "./logger.mjs";
3
3
  import { isAngularZonePresent } from "./type-utils.mjs";
4
4
  const cachedImplementations = {};
@@ -8,15 +8,26 @@ function getNativeImplementation(name, assignableWindow) {
8
8
  let impl = assignableWindow[name];
9
9
  if (isNativeFunction(impl) && !isAngularZonePresent()) return cachedImplementations[name] = impl.bind(assignableWindow);
10
10
  const document = assignableWindow.document;
11
- if (document && isFunction(document.createElement)) try {
12
- const sandbox = document.createElement('iframe');
13
- sandbox.hidden = true;
14
- document.head.appendChild(sandbox);
15
- const contentWindow = sandbox.contentWindow;
16
- if (contentWindow && contentWindow[name]) impl = contentWindow[name];
17
- document.head.removeChild(sandbox);
18
- } catch (e) {
19
- logger.warn(`Could not create sandbox iframe for ${name} check, bailing to assignableWindow.${name}: `, e);
11
+ if (document && isFunction(document.createElement)) {
12
+ let sandbox;
13
+ let keepSandboxAttached = false;
14
+ try {
15
+ sandbox = document.createElement('iframe');
16
+ sandbox.hidden = true;
17
+ document.head.appendChild(sandbox);
18
+ const contentWindow = sandbox.contentWindow;
19
+ if (contentWindow && contentWindow[name]) {
20
+ impl = contentWindow[name];
21
+ if ('MutationObserver' === name && isWebKit(assignableWindow.navigator?.userAgent ?? '')) {
22
+ sandbox.classList.add('rr-block', 'ph-no-capture');
23
+ keepSandboxAttached = true;
24
+ }
25
+ }
26
+ } catch (e) {
27
+ logger.warn(`Could not create sandbox iframe for ${name} check, bailing to assignableWindow.${name}: `, e);
28
+ } finally{
29
+ if (!keepSandboxAttached && sandbox?.parentNode) sandbox.parentNode.removeChild(sandbox);
30
+ }
20
31
  }
21
32
  if (!impl || !isFunction(impl)) return impl;
22
33
  return cachedImplementations[name] = impl.bind(assignableWindow);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/browser-common",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "Internal shared browser utilities and extension primitives for PostHog Browser SDKs",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -65,13 +65,14 @@
65
65
  }
66
66
  },
67
67
  "dependencies": {
68
- "@posthog/core": "^1.45.1",
69
- "@posthog/types": "^1.398.0"
68
+ "@posthog/core": "^1.45.3",
69
+ "@posthog/types": "^1.399.0"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@rslib/core": "0.10.6",
73
73
  "@types/jest": "^29.5.14",
74
74
  "jest": "29.7.0",
75
+ "jest-environment-jsdom": "^29.7.0",
75
76
  "ts-jest": "29.4.11",
76
77
  "typescript": "5.8.2",
77
78
  "@posthog-tooling/tsconfig-base": "1.1.1"