-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(replays): Add snapshot function to replay canvas integration #10066
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
Merged
Merged
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
64a84af
feat(replay): Add `ReplayCanvas` integration
mydea f9507ef
refactor out integrations abstraction
billyvg 1e91917
update
c298lee e1ec42e
it works
c298lee 16d99e6
add manual snapshot option
c298lee f74f12b
add manual snapshot option
c298lee fd5c9e6
feat(replay): Add `ReplayCanvas` integration
mydea 1b2b670
new quality options
billyvg 1b21a37
fix
billyvg 446aea7
create replay-canvas package
billyvg f9a887d
cleanup repo
billyvg 32b4ccd
change to not use `_experiments` for canvas
billyvg 255fa86
revert entrypoint change
billyvg 425f1ab
move tests to dev-packages
billyvg 97fa4e7
update tests
billyvg cd8f159
remove old template
billyvg eedcf21
do not publish as separate package
billyvg f103983
remove yarn lockfile
billyvg c4e957f
refactor out integrations abstraction
billyvg fbe85d5
add replaycanvas to replay bundles
billyvg 20e61fd
forgot shims
billyvg 645bbbb
debug playwright test
billyvg 6e51bff
Revert "debug playwright test"
billyvg 26d834e
fix types
billyvg fed7da2
lint
billyvg 5aa96e3
Revert "add replaycanvas to replay bundles"
billyvg 6d5a0f2
Revert "forgot shims"
billyvg 833ee6f
add `canvas` to options event
billyvg 1f790e2
move replay-canvas to devDeps
billyvg 1121e89
canvas --> shouldRecordCanvas
billyvg e805e6c
move back to deps
billyvg ec1bbe9
remove private: true, fails the e2e tests
billyvg 7ee6be0
feat(replay): Add `ReplayCanvas` integration
mydea 0f32f8a
refactor out integrations abstraction
billyvg 3a5ea02
Merge branch 'fn/replay-canvas-integration-sep-package' into snapshot…
c298lee 9a09eff
add snapshot to shim
c298lee d3f23cc
lint
c298lee 43daae2
test and snapshot
c298lee 0a1350c
fix
c298lee 8db7bde
fix again
c298lee 6324d18
done fix hopefully
c298lee b8a8a3a
comments and update test
c298lee 8807086
typo
c298lee b3f5889
typo
c298lee 64e0a5b
lint
c298lee 9f769b4
update enableManualSnapshot
c298lee bdb58a4
fix merge
c298lee 7382f97
fix merge and change rrweb to 2.9.0
c298lee 3d6df92
lint
c298lee 6e6b808
Merge branch 'develop' into snapshot-replay-canvas
c298lee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
dev-packages/browser-integration-tests/suites/replay/canvas/manualSnapshot/init.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as Sentry from '@sentry/browser'; | ||
|
||
window.Sentry = Sentry; | ||
window.Replay = new Sentry.Replay({ | ||
flushMinDelay: 50, | ||
flushMaxDelay: 50, | ||
minReplayDuration: 0, | ||
}); | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
sampleRate: 0, | ||
replaysSessionSampleRate: 1.0, | ||
replaysOnErrorSampleRate: 0.0, | ||
debug: true, | ||
|
||
integrations: [window.Replay, new Sentry.ReplayCanvas({ enableManualSnapshot: true })], | ||
}); |
26 changes: 26 additions & 0 deletions
26
dev-packages/browser-integration-tests/suites/replay/canvas/manualSnapshot/template.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
</head> | ||
<body> | ||
<canvas id="canvas" width="150" height="150"></canvas> | ||
<button id="draw">Draw</button> | ||
</body> | ||
|
||
|
||
<script> | ||
function draw() { | ||
const canvas = document.getElementById("canvas"); | ||
if (canvas.getContext) { | ||
console.log('has canvas') | ||
const ctx = canvas.getContext("2d"); | ||
|
||
ctx.fillRect(25, 25, 100, 100); | ||
ctx.clearRect(45, 45, 60, 60); | ||
ctx.strokeRect(50, 50, 50, 50); | ||
} | ||
} | ||
document.getElementById('draw').addEventListener('click', draw); | ||
</script> | ||
</html> |
79 changes: 79 additions & 0 deletions
79
dev-packages/browser-integration-tests/suites/replay/canvas/manualSnapshot/test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import { sentryTest } from '../../../../utils/fixtures'; | ||
import { getReplayRecordingContent, shouldSkipReplayTest, waitForReplayRequest } from '../../../../utils/replayHelpers'; | ||
|
||
sentryTest('can manually snapshot canvas', async ({ getLocalTestUrl, page, browserName }) => { | ||
if (shouldSkipReplayTest() || browserName === 'webkit' || (process.env.PW_BUNDLE || '').startsWith('bundle')) { | ||
sentryTest.skip(); | ||
} | ||
|
||
const reqPromise0 = waitForReplayRequest(page, 0); | ||
const reqPromise1 = waitForReplayRequest(page, 1); | ||
const reqPromise2 = waitForReplayRequest(page, 2); | ||
const reqPromise3 = waitForReplayRequest(page, 3); | ||
|
||
await page.route('https://dsn.ingest.sentry.io/**/*', route => { | ||
return route.fulfill({ | ||
status: 200, | ||
contentType: 'application/json', | ||
body: JSON.stringify({ id: 'test-id' }), | ||
}); | ||
}); | ||
|
||
const url = await getLocalTestUrl({ testDir: __dirname }); | ||
|
||
await page.goto(url); | ||
await reqPromise0; | ||
await Promise.all([page.click('#draw'), reqPromise1]); | ||
|
||
const { incrementalSnapshots } = getReplayRecordingContent(await reqPromise2); | ||
expect(incrementalSnapshots).toEqual([]); | ||
|
||
await page.evaluate(() => { | ||
(window as any).Sentry.getClient().getIntegrationById('ReplayCanvas').snapshot(); | ||
}); | ||
|
||
const { incrementalSnapshots: incrementalSnapshotsManual } = getReplayRecordingContent(await reqPromise3); | ||
expect(incrementalSnapshotsManual).toEqual( | ||
expect.arrayContaining([ | ||
{ | ||
data: { | ||
commands: [ | ||
{ | ||
args: [0, 0, 150, 150], | ||
property: 'clearRect', | ||
}, | ||
{ | ||
args: [ | ||
{ | ||
args: [ | ||
{ | ||
data: [ | ||
{ | ||
base64: expect.any(String), | ||
rr_type: 'ArrayBuffer', | ||
}, | ||
], | ||
rr_type: 'Blob', | ||
type: 'image/webp', | ||
}, | ||
], | ||
rr_type: 'ImageBitmap', | ||
}, | ||
0, | ||
0, | ||
], | ||
property: 'drawImage', | ||
}, | ||
], | ||
id: 9, | ||
source: 9, | ||
type: 0, | ||
}, | ||
timestamp: 0, | ||
type: 3, | ||
}, | ||
]), | ||
); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.