Skip to content

Commit 9da3f90

Browse files
committed
feat: move posthog-rrweb into the JS monorepo
1 parent 8fd7c76 commit 9da3f90

File tree

390 files changed

+81592
-324
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

390 files changed

+81592
-324
lines changed

.changeset/config.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,19 @@
88
"baseBranch": "main",
99
"updateInternalDependencies": "patch",
1010
"bumpVersionsWithWorkspaceProtocolOnly": true,
11-
"ignore": []
11+
"ignore": [
12+
"@posthog/rrweb-utils",
13+
"@posthog/rrdom",
14+
"@posthog/rrdom-nodejs",
15+
"@posthog/rrweb-snapshot",
16+
"@posthog/rrweb-record",
17+
"@posthog/rrweb-replay",
18+
"@posthog/rrweb-packer",
19+
"@posthog/rrweb-all",
20+
"@posthog/rrweb-plugin-console-replay",
21+
"@posthog/rrweb-plugin-sequential-id-record",
22+
"@posthog/rrweb-plugin-sequential-id-replay",
23+
"@posthog/rrweb-plugin-canvas-webrtc-record",
24+
"@posthog/rrweb-plugin-canvas-webrtc-replay"
25+
]
1226
}

.github/workflows/library-ci.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,45 @@ jobs:
6868
build: true
6969
- run: pnpm test:functional
7070

71+
rrweb:
72+
name: rrweb tests
73+
runs-on: ubuntu-22.04
74+
steps:
75+
- uses: actions/checkout@v4
76+
with:
77+
fetch-depth: 0
78+
79+
- name: Setup environment
80+
uses: ./.github/actions/setup
81+
with:
82+
build: false
83+
84+
- name: Check if rrweb packages changed
85+
id: changed
86+
run: |
87+
CHANGED=$(git diff --name-only origin/main...HEAD | grep -c '^packages/rrweb/' || true)
88+
echo "rrweb-changed=$([[ $CHANGED -gt 0 ]] && echo true || echo false)" >> $GITHUB_OUTPUT
89+
90+
- name: Build rrweb packages
91+
if: steps.changed.outputs.rrweb-changed == 'true'
92+
run: pnpm turbo run build --filter='./packages/rrweb/**' --concurrency=1
93+
94+
- name: Install Chrome for Puppeteer
95+
if: steps.changed.outputs.rrweb-changed == 'true'
96+
run: pnpm --filter @posthog/rrweb exec puppeteer browsers install chrome
97+
98+
- name: Run rrweb tests
99+
if: steps.changed.outputs.rrweb-changed == 'true'
100+
run: xvfb-run --server-args="-screen 0 1920x1080x24" pnpm turbo run test --filter='./packages/rrweb/**'
101+
102+
- name: Upload diff images on failure
103+
uses: actions/upload-artifact@v4
104+
if: failure() && steps.changed.outputs.rrweb-changed == 'true'
105+
with:
106+
name: rrweb-image-diff
107+
path: packages/rrweb/**/__image_snapshots__/__diff_output__/*.png
108+
if-no-files-found: ignore
109+
71110
lint:
72111
name: Lint
73112
runs-on: ubuntu-22.04

.github/workflows/release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ jobs:
159159
- name: '@posthog/nuxt'
160160
- name: '@posthog/rollup-plugin'
161161
- name: '@posthog/webpack-plugin'
162+
- name: '@posthog/rrweb'
163+
- name: '@posthog/rrweb-types'
164+
- name: '@posthog/rrweb-plugin-console-record'
162165

163166
steps:
164167
- name: Checkout repository

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ test-result.json
2626
yarn-error.log
2727
stats.html
2828
bundle-stats*.html
29+
30+
# vite temp files
31+
vite.config.js.timestamp-*
32+
vite.config.ts.timestamp-*
2933
.eslintcache
3034
cypress/downloads/downloads.html
3135
/test-results/

packages/browser/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@
6666
"@jest/globals": "^29.7.0",
6767
"@playwright/test": "^1.52.0",
6868
"@posthog-tooling/rollup-utils": "workspace:*",
69-
"@posthog/rrweb-plugin-console-record": "^0.0.34",
70-
"@posthog/rrweb-record": "^0.0.34",
71-
"@posthog/rrweb-types": "^0.0.34",
69+
"@posthog/rrweb-plugin-console-record": "workspace:*",
70+
"@posthog/rrweb-record": "workspace:*",
71+
"@posthog/rrweb-types": "workspace:*",
7272
"@rollup/plugin-babel": "^6.0.4",
7373
"@rollup/plugin-commonjs": "^28.0.6",
7474
"@rollup/plugin-json": "^6.1.0",

packages/rrweb/.eslintrc.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
module.exports = {
2+
root: true,
3+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
4+
parser: '@typescript-eslint/parser',
5+
plugins: ['@typescript-eslint'],
6+
env: {
7+
browser: true,
8+
es2020: true,
9+
node: true,
10+
},
11+
rules: {
12+
// Disable prettier - rrweb formatting is normalized separately
13+
'prettier/prettier': 'off',
14+
// Disable rules that conflict with rrweb's codebase
15+
'@typescript-eslint/no-explicit-any': 'off',
16+
'@typescript-eslint/no-unused-vars': 'off',
17+
'@typescript-eslint/ban-ts-comment': 'off',
18+
'@typescript-eslint/no-non-null-assertion': 'off',
19+
'@typescript-eslint/no-empty-function': 'off',
20+
'@typescript-eslint/no-this-alias': 'off',
21+
'@typescript-eslint/no-unused-expressions': 'off',
22+
'@typescript-eslint/no-require-imports': 'off',
23+
'no-prototype-builtins': 'off',
24+
'no-useless-escape': 'off',
25+
'no-empty': 'off',
26+
'prefer-const': 'off',
27+
'no-constant-condition': 'off',
28+
'no-extra-semi': 'off',
29+
'no-var': 'off',
30+
'no-global-assign': 'off',
31+
// posthog-js specific rules that don't apply to rrweb
32+
'posthog-js/no-direct-array-check': 'off',
33+
'posthog-js/no-direct-boolean-check': 'off',
34+
'posthog-js/no-direct-document-check': 'off',
35+
'posthog-js/no-direct-function-check': 'off',
36+
'posthog-js/no-direct-navigator-check': 'off',
37+
'posthog-js/no-direct-null-check': 'off',
38+
'posthog-js/no-direct-number-check': 'off',
39+
'posthog-js/no-direct-object-check': 'off',
40+
'posthog-js/no-direct-string-check': 'off',
41+
'posthog-js/no-direct-undefined-check': 'off',
42+
'posthog-js/no-direct-window-check': 'off',
43+
'compat/compat': 'off',
44+
},
45+
ignorePatterns: ['dist/', 'node_modules/', '*.js', '*.cjs', '*.mjs'],
46+
}

packages/rrweb/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# PostHog's copy of RRWeb
2+
3+
this is open because we believe in open source,
4+
and we want to be able to contribute back to upstream rrweb and refer back to this when we do
5+
6+
# but please don't use it yourself
7+
8+
all changes will be only focussed on posthog and we won't make any effort to support anybody else using this
9+
10+
if you say "i started using this, you changed it, and now my thing broke"
11+
we will say "we told you not to use it"
12+
13+
The upstream rrweb is here https://github.com/rrweb-io/rrweb
14+
15+
## Is it an exact fork?
16+
17+
No, there are packages we don't need such as the svelte player and rr-video
18+
So, we deleted them...
19+
20+
## Hello internal PostHog folk
21+
22+
We build this and publish it to NPM so that we can use it in posthog-js
23+
24+
If you want to contribute a change back to upstream rrweb
25+
then you need to open a person fork and contribute from there
26+
27+
### How to use it...
28+
29+
1. `pnpm install` to, erm, install
30+
2. `pnpm build:all` to get a stable base built
31+
3. `pnpm dev` to get auto building of changed things while making changes
32+
4. `pnpm test` to run the tests
33+
5. `pnpm test:update` to update snapshots if necessary
34+
35+
# FAQ
36+
37+
- does this mean you're planning on stopping using RRWEB?
38+
- no
39+
- can I use this repo?
40+
- unless you are contributing changes for posthog, no
41+
- should I sponsor rrweb?
42+
- absolutely, yes. we do, you should too, it's great

packages/rrweb/all/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.turbo
2+
dist
3+
node_modules
4+
yarn-error.log

packages/rrweb/all/CHANGELOG.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# @rrweb/all
2+
3+
## 2.0.0-alpha.18
4+
5+
### Patch Changes
6+
7+
- [#1593](https://github.com/rrweb-io/rrweb/pull/1593) [`5a78938`](https://github.com/rrweb-io/rrweb/commit/5a789385a341311ba327a768fe0e2f0f2f5002ee) Thanks [@daibhin](https://github.com/daibhin)! - `NodeType` enum was moved from rrweb-snapshot to @rrweb/types
8+
The following types where moved from rrweb-snapshot to @rrweb/types: `documentNode`, `documentTypeNode`, `legacyAttributes`, `textNode`, `cdataNode`, `commentNode`, `elementNode`, `serializedNode`, `serializedNodeWithId`, `serializedElementNodeWithId`, `serializedTextNodeWithId`, `IMirror`, `INode`, `mediaAttributes`, `attributes` and `DataURLOptions`
9+
- Updated dependencies [[`04ee6ed`](https://github.com/rrweb-io/rrweb/commit/04ee6eda57157f0e04f18f907d8f3e59ababc753), [`5fbb904`](https://github.com/rrweb-io/rrweb/commit/5fbb904edb653f3da17e6775ee438d81ef0bba83), [`5a78938`](https://github.com/rrweb-io/rrweb/commit/5a789385a341311ba327a768fe0e2f0f2f5002ee), [`53b83bb`](https://github.com/rrweb-io/rrweb/commit/53b83bb037f9cb30c93179548f436ed776f143ab)]:
10+
- rrweb@2.0.0-alpha.18
11+
- @rrweb/types@2.0.0-alpha.18
12+
- @rrweb/packer@2.0.0-alpha.18
13+
14+
## 2.0.0-alpha.17
15+
16+
### Patch Changes
17+
18+
- [`db20184`](https://github.com/rrweb-io/rrweb/commit/db201841accd2b5df3cd7c88779aa62ab158501c) Thanks [@Juice10](https://github.com/Juice10)! - Keep package version in sync with other packages
19+
20+
- Updated dependencies [[`db20184`](https://github.com/rrweb-io/rrweb/commit/db201841accd2b5df3cd7c88779aa62ab158501c), [`40bbc25`](https://github.com/rrweb-io/rrweb/commit/40bbc25fc287badc317a53f2d3f21b1c9f2b211b), [`68076b7`](https://github.com/rrweb-io/rrweb/commit/68076b724ff19d198d4f351a05063b85e1705a8c), [`8059d96`](https://github.com/rrweb-io/rrweb/commit/8059d9695146626b102b2059a3a9b932d5f598f6), [`335639a`](https://github.com/rrweb-io/rrweb/commit/335639af9b0ce7f70eb0f38ce113d877c7325158), [`be6bf52`](https://github.com/rrweb-io/rrweb/commit/be6bf52c248c35de1b3491e3a3440ff61f876414)]:
21+
- @rrweb/packer@2.0.0-alpha.17
22+
- rrweb@2.0.0-alpha.17
23+
- @rrweb/types@2.0.0-alpha.17
24+
25+
## 2.0.0-alpha.15
26+
27+
### Major Changes
28+
29+
- [#1497](https://github.com/rrweb-io/rrweb/pull/1497) [`2606a2a`](https://github.com/rrweb-io/rrweb/commit/2606a2a28f2a6d897b8ae4ea3ec40ef0eeacbfaf) Thanks [@Juice10](https://github.com/Juice10)! - Distributed files have new filenames, paths and extensions. **Important: If you reference distributed files or types directly, you might have to update your paths/filenames. E.g. you import from `rrweb/typings/...` or `rrdom/es`. However you run `import rrweb from '@posthog/rrweb'` you won't notice a difference with this change.** If you include rrweb files directly in a script tag, you might have to update that path to include a the `.umd.cjs` files instead. All `.js` files now use ES modules which can be used in modern browsers, node.js and bundlers that support ES modules. All npm packages now also ship `.cjs` and `.umd.cjs` files. The `.umd.cjs` files are CommonJS modules that bundle all files together to make it easy to ship one file to browser environments (similar to the previous `.js` files). The `.cjs` files are CommonJS modules that can be used in older Node.js environments. Types should be better defined in `package.json` and if you need specific types they might be exported from new packages (for example `PlayerMachineState` and `SpeedMachineState` are now exported from `@rrweb/replay`). Check the `package.json`'s `main` and `exports` field for the available files.
30+
31+
- [#1497](https://github.com/rrweb-io/rrweb/pull/1497) [`2606a2a`](https://github.com/rrweb-io/rrweb/commit/2606a2a28f2a6d897b8ae4ea3ec40ef0eeacbfaf) Thanks [@Juice10](https://github.com/Juice10)! - Remove the rrweb-all.js, rrweb-record.js, and rrweb-replay.js files from `rrweb` package. Now you can use `@rrweb/all`, `@rrweb/record`, and `@rrweb/replay` packages instead. Check out the README of each package for more information or check out [PR #1033](https://github.com/rrweb-io/rrweb/pull/1033) to see the changes.
32+
33+
### Patch Changes
34+
35+
- Updated dependencies [[`7261c43`](https://github.com/rrweb-io/rrweb/commit/7261c43f60973e88325edf832e4d0e057fbff0ae), [`4014305`](https://github.com/rrweb-io/rrweb/commit/40143059446cee5c042c007b1c2e976f36e172f5), [`609b7fa`](https://github.com/rrweb-io/rrweb/commit/609b7fac79a552f746dc880a28927dee382cd082), [`82f6fec`](https://github.com/rrweb-io/rrweb/commit/82f6fecf36413ecbc994a510144487f1de20d1d5), [`2606a2a`](https://github.com/rrweb-io/rrweb/commit/2606a2a28f2a6d897b8ae4ea3ec40ef0eeacbfaf), [`2606a2a`](https://github.com/rrweb-io/rrweb/commit/2606a2a28f2a6d897b8ae4ea3ec40ef0eeacbfaf), [`5c27b76`](https://github.com/rrweb-io/rrweb/commit/5c27b763192bda9dd91806f95df7c1cd0ab083a6), [`d38893f`](https://github.com/rrweb-io/rrweb/commit/d38893f6338facf331fd1f6e63c121120b81177d), [`d7cf8dd`](https://github.com/rrweb-io/rrweb/commit/d7cf8dd07547f6fb22ef82e341a88357c4053bd3), [`2606a2a`](https://github.com/rrweb-io/rrweb/commit/2606a2a28f2a6d897b8ae4ea3ec40ef0eeacbfaf), [`e08706a`](https://github.com/rrweb-io/rrweb/commit/e08706ae60268b6eb05c6292ef948c71bd423ce3)]:
36+
- rrweb@2.0.0-alpha.15
37+
- @rrweb/packer@2.0.0-alpha.15
38+
- @rrweb/types@2.0.0-alpha.15

0 commit comments

Comments
 (0)