Skip to content

Commit a171f35

Browse files
authored
fix(replay): fix rrweb issue & vendor it (#6335)
* Introduce patch-package to fix the exact issue we care about in rrweb * Inline rrweb into the replay bundle
1 parent f82ac81 commit a171f35

File tree

6 files changed

+73
-7
lines changed

6 files changed

+73
-7
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ env:
2222

2323
CACHED_DEPENDENCY_PATHS: |
2424
${{ github.workspace }}/node_modules
25-
${{ github.workspace }}/packages/**/node_modules
25+
${{ github.workspace }}/packages/*/node_modules
2626
~/.cache/ms-playwright/
2727
~/.cache/mongodb-binaries/
2828

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"lint:eslint": "lerna run --parallel lint:eslint",
2626
"postpublish": "lerna run --stream --concurrency 1 postpublish",
2727
"test": "lerna run --ignore @sentry-internal/browser-integration-tests --ignore @sentry-internal/node-integration-tests --stream --concurrency 1 --sort test",
28-
"test-ci": "ts-node ./scripts/test.ts"
28+
"test-ci": "ts-node ./scripts/test.ts",
29+
"postinstall": "patch-package"
2930
},
3031
"volta": {
3132
"node": "16.18.1",
@@ -89,6 +90,7 @@
8990
"mocha": "^6.1.4",
9091
"nodemon": "^2.0.16",
9192
"npm-run-all": "^4.1.5",
93+
"patch-package": "^6.5.0",
9294
"prettier": "2.7.1",
9395
"recast": "^0.20.5",
9496
"replace-in-file": "^4.0.0",

packages/replay/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@
5252
"@types/pako": "^2.0.0",
5353
"jsdom-worker": "^0.2.1",
5454
"pako": "^2.0.4",
55+
"rrweb": "1.1.3",
5556
"tslib": "^1.9.3"
5657
},
5758
"dependencies": {
5859
"@sentry/core": "7.23.0",
5960
"@sentry/types": "7.23.0",
6061
"@sentry/utils": "7.23.0",
61-
"lodash.debounce": "^4.0.8",
62-
"rrweb": "^1.1.3"
62+
"lodash.debounce": "^4.0.8"
6363
},
6464
"peerDependencies": {
6565
"@sentry/browser": "7.23.0"

packages/replay/rollup.npm.config.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import path from 'path';
2+
13
import replace from '@rollup/plugin-replace';
24

35
import { makeBaseNPMConfig, makeNPMConfigVariants } from '../../rollup/index';
@@ -8,7 +10,6 @@ export default makeNPMConfigVariants(
810
makeBaseNPMConfig({
911
hasBundles: true,
1012
packageSpecificConfig: {
11-
external: [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})],
1213
plugins: [
1314
// TODO: Remove this - replay version will be in sync w/ SDK version
1415
replace({
@@ -22,6 +23,12 @@ export default makeNPMConfigVariants(
2223
// set exports to 'named' or 'auto' so that rollup doesn't warn about
2324
// the default export in `worker/worker.js`
2425
exports: 'named',
26+
27+
// As we are inlining the rrweb dependency here, we need to ensure the nested folders are correct
28+
// Without this config, you get:
29+
// * build/npm/esm/node_modules/rrweb/...
30+
// * build/npm/esm/packages/replay/...
31+
preserveModulesRoot: path.join(process.cwd(), 'src'),
2532
},
2633
},
2734
}),

patches/rrweb+1.1.3.patch

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
diff --git a/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/index.js b/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/index.js
2+
index 8091399..48e8321 100644
3+
--- a/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/index.js
4+
+++ b/node_modules/rrweb/es/rrweb/packages/rrweb/src/record/index.js
5+
@@ -325,7 +325,11 @@ function record(options) {
6+
}, hooks);
7+
};
8+
iframeManager.addLoadListener(function (iframeEl) {
9+
- handlers_1.push(observe_1(iframeEl.contentDocument));
10+
+ try {
11+
+ handlers_1.push(observe_1(iframeEl.contentDocument));
12+
+ } catch (error) {
13+
+ console.warn('error in rrweb iframe observer', error);
14+
+ }
15+
});
16+
var init_1 = function () {
17+
takeFullSnapshot();

yarn.lock

+42-2
Original file line numberDiff line numberDiff line change
@@ -6043,7 +6043,7 @@
60436043
tslib "^2.3.1"
60446044
upath2 "^3.1.12"
60456045

6046-
"@yarnpkg/[email protected]":
6046+
"@yarnpkg/[email protected]", "@yarnpkg/lockfile@^1.1.0":
60476047
version "1.1.0"
60486048
resolved "https://registry.yarnpkg.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz#e77a97fbd345b76d83245edcd17d393b1b41fb31"
60496049
integrity sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==
@@ -17127,6 +17127,13 @@ kind-of@^6.0.0, kind-of@^6.0.2, kind-of@^6.0.3:
1712717127
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd"
1712817128
integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==
1712917129

17130+
klaw-sync@^6.0.0:
17131+
version "6.0.0"
17132+
resolved "https://registry.yarnpkg.com/klaw-sync/-/klaw-sync-6.0.0.tgz#1fd2cfd56ebb6250181114f0a581167099c2b28c"
17133+
integrity sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==
17134+
dependencies:
17135+
graceful-fs "^4.1.11"
17136+
1713017137
kleur@^3.0.3:
1713117138
version "3.0.3"
1713217139
resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e"
@@ -19600,6 +19607,14 @@ [email protected]:
1960019607
is-docker "^2.0.0"
1960119608
is-wsl "^2.1.1"
1960219609

19610+
open@^7.4.2:
19611+
version "7.4.2"
19612+
resolved "https://registry.yarnpkg.com/open/-/open-7.4.2.tgz#b8147e26dcf3e426316c730089fd71edd29c2321"
19613+
integrity sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==
19614+
dependencies:
19615+
is-docker "^2.0.0"
19616+
is-wsl "^2.1.1"
19617+
1960319618
open@^8.3.0:
1960419619
version "8.4.0"
1960519620
resolved "https://registry.yarnpkg.com/open/-/open-8.4.0.tgz#345321ae18f8138f82565a910fdc6b39e8c244f8"
@@ -20148,6 +20163,26 @@ pascalcase@^0.1.1:
2014820163
resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14"
2014920164
integrity sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=
2015020165

20166+
patch-package@^6.5.0:
20167+
version "6.5.0"
20168+
resolved "https://registry.yarnpkg.com/patch-package/-/patch-package-6.5.0.tgz#feb058db56f0005da59cfa316488321de585e88a"
20169+
integrity sha512-tC3EqJmo74yKqfsMzELaFwxOAu6FH6t+FzFOsnWAuARm7/n2xB5AOeOueE221eM9gtMuIKMKpF9tBy/X2mNP0Q==
20170+
dependencies:
20171+
"@yarnpkg/lockfile" "^1.1.0"
20172+
chalk "^4.1.2"
20173+
cross-spawn "^6.0.5"
20174+
find-yarn-workspace-root "^2.0.0"
20175+
fs-extra "^7.0.1"
20176+
is-ci "^2.0.0"
20177+
klaw-sync "^6.0.0"
20178+
minimist "^1.2.6"
20179+
open "^7.4.2"
20180+
rimraf "^2.6.3"
20181+
semver "^5.6.0"
20182+
slash "^2.0.0"
20183+
tmp "^0.0.33"
20184+
yaml "^1.10.2"
20185+
2015120186
2015220187
version "0.0.1"
2015320188
resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.1.tgz#e6c4ddd7ed3aa27c68a20cc4e50e1a4ee83bbc4a"
@@ -22608,7 +22643,7 @@ rrweb-snapshot@^1.1.14:
2260822643
resolved "https://registry.yarnpkg.com/rrweb-snapshot/-/rrweb-snapshot-1.1.14.tgz#9d4d9be54a28a893373428ee4393ec7e5bd83fcc"
2260922644
integrity sha512-eP5pirNjP5+GewQfcOQY4uBiDnpqxNRc65yKPW0eSoU1XamDfc4M8oqpXGMyUyvLyxFDB0q0+DChuxxiU2FXBQ==
2261022645

22611-
rrweb@^1.1.3:
22646+
2261222647
version "1.1.3"
2261322648
resolved "https://registry.yarnpkg.com/rrweb/-/rrweb-1.1.3.tgz#4fbb3d473d71c79b6c30a54e585e5a01c8ac08bb"
2261422649
integrity sha512-F2qp8LteJLyycsv+lCVJqtVpery63L3U+/ogqMA0da8R7Jx57o6gT+HpjrzdeeGMIBZR7kKNaKyJwDupTTu5KA==
@@ -26608,6 +26643,11 @@ [email protected]:
2660826643
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.1.1.tgz#1e06fb4ca46e60d9da07e4f786ea370ed3c3cfec"
2660926644
integrity sha512-o96x3OPo8GjWeSLF+wOAbrPfhFOGY0W00GNaxCDv+9hkcDJEnev1yh8S7pgHF0ik6zc8sQLuL8hjHjJULZp8bw==
2661026645

26646+
yaml@^1.10.2:
26647+
version "1.10.2"
26648+
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b"
26649+
integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==
26650+
2661126651
[email protected], yargs-parser@^13.1.2:
2661226652
version "13.1.2"
2661326653
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.2.tgz#130f09702ebaeef2650d54ce6e3e5706f7a4fb38"

0 commit comments

Comments
 (0)