Repository navigation
chore(rrweb): move the recorder onto upstream rrweb 2.2.1 #190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,11 +28,11 @@ | |
| "test:coverage": "vitest run --coverage" | ||
| }, | ||
| "dependencies": { | ||
| "@rrweb/types": "^2.2.0", | ||
| "rrweb": "^2.2.0" | ||
| "@rrweb/types": "^2.2.1", | ||
| "rrweb": "^2.2.1" | ||
| }, | ||
| "devDependencies": { | ||
| "@bugsee/rrweb-record": "github:bugsee/rrweb#987d0765a76607f81767b3bde2d65a8382caf7fa", | ||
| "@bugsee/rrweb-record": "file:../../vendor/rrweb-record", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| "jsdom": "^25.0.1" | ||
| }, | ||
| "publishConfig": { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,49 @@ | ||
| import { createHash } from 'node:crypto'; | ||
| import { readFileSync } from 'node:fs'; | ||
| import { createRequire } from 'node:module'; | ||
| import { dirname, join } from 'node:path'; | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { record } from './index'; | ||
|
|
||
| const require = createRequire(import.meta.url); | ||
|
|
||
| describe('@bugsee/rrweb wrapper', () => { | ||
| it('re-exports the rrweb record function (the single record-path import point)', () => { | ||
| // The wrapper decouples @bugsee/replay from rrweb's packaging — swapping npm → the Bugsee fork touches | ||
| // only this module. Assert the value it forwards is rrweb's callable record(). | ||
| expect(typeof record).toBe('function'); | ||
| }); | ||
|
|
||
| it('is wired to the 2.2.1 record-only bundle', () => { | ||
| const pkg = JSON.parse( | ||
| readFileSync(join(dirname(require.resolve('@bugsee/rrweb-record')), 'package.json'), 'utf8'), | ||
| ) as { version: string }; | ||
| expect(pkg.version).toBe('2.2.1'); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity: P2 Medium |
||
| }); | ||
|
|
||
| // Provenance pin: the vendored bundle is the ONLY copy until bugsee/rrweb has bugsee-dist-2.2.1, so a | ||
| // silent swap (e.g. a plain upstream build) must fail loudly. Update together with the README when rebuilt. | ||
| it('pins the vendored record.js by sha256', () => { | ||
| const file = join(dirname(require.resolve('@bugsee/rrweb-record')), 'record.js'); | ||
| const sha = createHash('sha256').update(readFileSync(file)).digest('hex'); | ||
| expect(sha).toBe('b87d6029f188501f9208036a6213b4455d150d279b96b2ad30234d0c5b423135'); | ||
| }); | ||
|
|
||
| it('records media interaction for a <video> inside an iframe (cross-realm nodeName check)', async () => { | ||
| const iframe = document.createElement('iframe'); | ||
| document.body.appendChild(iframe); | ||
| const doc = iframe.contentDocument as Document; | ||
| const video = doc.createElement('video'); | ||
| doc.body.appendChild(video); | ||
| const events: Array<{ type: number; data: { source?: number; type?: number } }> = []; | ||
| const stop = record({ emit: (e) => events.push(e as never), recordCrossOriginIframes: false }); | ||
| await new Promise((r) => setTimeout(r, 50)); | ||
| video.dispatchEvent(new (doc.defaultView as unknown as typeof globalThis).Event('play')); | ||
| await new Promise((r) => setTimeout(r, 50)); | ||
| stop?.(); | ||
| iframe.remove(); | ||
| // IncrementalSource.MediaInteraction === 7. Upstream's `instanceof HTMLMediaElement` is false across | ||
| // realms and would drop this event. | ||
| expect(events.some((e) => e.type === 3 && e.data.source === 7)).toBe(true); | ||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Severity: P2 Medium
Problem: The dependency changes from a content-addressed git pin (
github:bugsee/rrweb#<sha>, which carried anintegrityhash in the lockfile) to a 198 KB minified blob committed directly into this repo. The lockfile now records onlyresolution: {directory: vendor/rrweb-record}. The SHAs the README and PROGRESS cite (69633fc…,5a46e7d…) are not on GitHub, so nobody can rebuild the file and compare it today.Impact: This bundle is inlined into the published
@bugsee/rrweband runs inside customers' pages on every recorded DOM mutation. Review can't verify minified code, and the provenance claim ("same files asbugsee-dist-2.2.1") rests on this PR's description alone. This is a supply-chain and auditability regression compared with the previous pin.Scenario: The fork branches are never pushed, or are force-pushed. The vendored file then becomes the only copy, and no one can check what it contains against source.
Fix: Don't release from this branch until
bugsee-dist-2.2.1is pushed and this goes back to the git pin. If it has to merge first, add a TODO or tracking issue for the switch-back and a CI or test check of therecord.jssha256, so the file can be tied to the commit once it exists.