* feat(flutter): Add web canvas replay
Enable an internal Flutter Web option for JS Replay canvas recording
and attach the active replay ID to Dart events sent through the web
transport.
Co-Authored-By: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(flutter): Sync web scope to JS replay
Mirror Dart scope mutations into the browser JS SDK on web so native
JavaScript events receive Flutter scope data.
Emit replay-compatible breadcrumbs for Flutter cases that the JS replay
bundle filters from its generic breadcrumb handler.
Co-Authored-By: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
* feat(flutter): Mask Flutter Web session replay
Capture masked frames with the Flutter screenshot recorder and draw
them onto a shadow canvas that the JS SDK's replay canvas integration
snapshots manually. Flutter's own canvas is blocked by selector, since
it lives in flt-glass-pane's shadow DOM.
- Register ReplayIntegration on web; the JS SDK handles error mode
- Map replay quality to a web capture scale (0.5x/0.7x/1.0x)
- Drop the JS SDK's flutter-view click breadcrumbs in replays
- Enable web replay from the replay sample rates instead of the
internal enableWebCanvasRecording flag
- Add a replay playground screen to the example app
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* chore(example): Drop playground, now in #4056
The replay playground has its own PR (#4056). This PR now targets
that branch, so the example still has the playground for testing
without duplicating it here.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(flutter): Harden web replay start and teardown
- Script loader: track scripts as they load and remove them if a
later one fails, so close() cleans up and a retry doesn't inject
duplicates
- SentryWeb.close(): await the replay recorder's stop before closing
the JS SDK, so an in-flight capture can't snapshot into it
- setReplayConfig: mark the recorder started only after start()
succeeds, so a failed start is retried on the next config
Adds a createReplayCanvasBridge seam to SentryWeb for testing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(flutter): Keep web replay cadence on resize
A window drag or rotation changes the replay config every frame, and
each change restarted the capture scheduler, which captures on the
next frame. The shadow canvas was resized at frame rate while rrweb
throttled the matching snapshots, so recordings got canvas sizes out
of sync with their content.
While running with an unchanged frame rate, store the new config
without restarting: capture() reads it on every run, so the next
scheduled capture already uses the new size.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(flutter): Replace web replay canvas on resize
Sentry's replay player clones a canvas on its first recorded draw and
keeps drawing into that clone, so later width/height changes never
reach it. After a resize, smaller frames only covered the clone's
top-left corner, leaving the previous frame around them (duplicated
widgets) and squishing content to one side.
Once the shadow canvas has been snapshotted, a size change now swaps
in a new element, which the player clones fresh at the new size. Its
first snapshot waits a task, until rrweb has registered the node.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* feat(flutter): Control web replay via replay API
SentryFlutter.replay's start, startBuffering, stop and flush now drive
the JS SDK's replay on web instead of logging "not supported", and
start or stop the Flutter recorder with it. A stopped replay stays
stopped across config changes (e.g. a window resize) until started
again. pause/resume remain no-ops: the JS SDK can't pause a replay.
The real-binding tests clear the JS SDK's stored replay session first;
a session left by another test on the same origin resumed in `session`
mode, so stop() hung uploading to the fake DSN.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(flutter): Drop labels from web replay crumbs
Tap breadcrumbs carry the widget's label and the labels in its touch
path when sendDefaultPii is on. The replay copy kept them, so text the
replay video masks showed up in the replay timeline. Strip them from
the replay breadcrumb only; the event breadcrumb is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(flutter): Cover release web script selection
Assert the production script lists in release mode, with and without
replay; always picking the debug lists used to pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(flutter): Convert web error replays on Dart errors
Dart events reach the JS SDK through client.sendEnvelope(), which
skips the afterSendEvent hook that client.sendEvent() runs. Replay
switches a buffering replay to a session from that hook, so with
onErrorSampleRate a Dart error never uploaded the buffered replay;
only JS errors did.
Pass the events and transactions in each envelope to the binding,
which emits afterSendEvent for them once the envelope is sent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(flutter): Harden web replay error paths
- Catch errors from the deferred snapshot of a replaced replay canvas;
it runs outside the recorder's error handling.
- close() closes the JS SDK even if stopping the recorder fails.
- stopReplay() during an in-flight recorder start now stops the
recorder once the start completes, instead of leaving it capturing.
Tests: wrap the canvas bridge tests in one subject group, match JS
integration names exactly, and close the SDK after replay-enabled mock
tests so their schedulers stop.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(flutter): Tighten web replay test assertions
- The cadence test measures from a rendered frame to the next capture
instead of waiting a fixed 50ms, so a slow capture can't hide a
scheduler restart.
- Pin the replay block selector as a literal, not the production
constant.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(flutter): Stop web replay if recorder fails
If stopping the replay recorder threw, stopReplay() skipped stopping
the JS replay and left the recorder marked as started, so a later
startReplay() never restarted it. Always stop the JS replay, and mark
the recorder stopped before stopping it.
Also folds the replay controls test group into its parent to keep
test nesting within three levels.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(flutter): Deflake web replay cadence test
The scheduler's interval starts when a capture starts, so asserting a
wall-clock gap after a test-triggered frame failed when a capture was
slow. Assert instead that no capture lands right after the config
changes, and that the next one uses the new size.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(flutter): Guard web scope sync JS calls
Web now registers NativeScopeObserver, so every scope change reaches
SentryWeb, which called JS unguarded. Scope observers are called
without error handling, so a JS failure surfaced in the user's
addBreadcrumb or configureScope call. Wrap the calls in tryCatchSync
like the other native calls.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(flutter): Keep web replay stopped after close
close() stopped the recorder without marking the replay stopped, so a
setReplayConfig still in flight could start the recorder after the JS
SDK was closed. Set the flag before stopping, as stopReplay() does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(flutter): Move web replay processor
Move WebReplayEventProcessor and its test beside the web replay
feature, out of the event_processor/ type-bucket.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(flutter): Keep web replay stopped on restart
_startReplay cleared the stop flag after awaiting the JS call, so a
stopReplay() or close() that ran during that await (e.g. while the JS
flush was pending) was undone and the recorder started anyway. Count
stops and skip starting the recorder if one ran in the meantime.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(flutter): Send web replay with feedback
captureReplay() returned early on web, and the JS SDK only sends a
buffered replay for errors and transactions, so feedback events were
tagged with the ID of a buffered replay that was never uploaded.
On web, flush the active replay for feedback, as the JS SDK's own
feedback integration does. Error replays stay with the JS SDK, and the
sample-rate gate matches the other platforms.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* perf(flutter): Skip copying web replay events
beforeAddRecordingEvent runs for every rrweb event, including full DOM
snapshots and canvas frames with base64 image data, and dartify()
deep-copied each one on the main thread just to find the flutter-view
click breadcrumb. Read the event type in place and only copy custom
events.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* perf(flutter): Skip web capture when not recording
The web recorder captured and masked frames whenever replay was
enabled, even when the JS replay wasn't recording: an unsampled
session, or one the JS SDK stopped on its own (session expiry, max
duration). That cost main-thread time on every interval for frames
nothing recorded.
Add a protected shouldCapture hook to ScheduledScreenshotRecorder and
have the web recorder skip captures while the JS replay has no ID.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* perf(flutter): Decode web events only for replay
captureStructuredEnvelope decoded every event and transaction to emit
the JS SDK's afterSendEvent hook, which only Replay uses. Skip that
work when replay isn't supported.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(flutter): Remove web replay processor on close
WebReplayEventProcessor was added in init() and never removed, so it
kept querying the closed JS SDK for every event after close().
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(flutter): Correct web replay test claims
The canvas bridge docs claimed an integration test that doesn't exist;
the real bridge has a browser unit test. The recorder test header said
video recording isn't supported, which this PR changes. Also wrap the
recorder tests in a top-level group per the test guidelines.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* ref(flutter): Tidy web replay internals
Mark WebReplayEventProcessor @internal and document it, name its test
group after the type, drop a duplicated comment in the JS binding, and
log the errors the binding swallowed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(flutter): Load web replay bundle only if used
The replay bundle and replay-canvas were picked from replay.isEnabled
alone, while SentryWeb only records when screenshots are supported
(CanvasKit or Skwasm). With another renderer, apps downloaded the
heavier bundle and nothing recorded. Use the same gate for both.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(flutter): Await failing web script load
The failure test didn't await its expectation, so the failed load ran
concurrently with the next one, and its cleanup could remove the
scripts that load had just added (flaky on CI).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(flutter): Allow web replay restart after stop
When stopReplay() ran while the recorder was starting, the deferred
stop cleared _replayRecorderStarted only after recorder.stop(). If
that threw, the flag stayed set and later starts returned early. Clear
it first, as stopReplay() does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(flutter): Handle web envelope send rejection
captureEnvelope only attached a rejection handler when the envelope
had events, so an attachment-only envelope whose send rejected (e.g.
a throwing beforeEnvelope listener) left an unhandled rejection.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(flutter): Cover unsampled web replay IDs
The fake binding ignored onlyIfSampled, so dropping it from
WebReplayEventProcessor (attaching unsampled replay IDs) passed.
Mirror the JS SDK and assert unsampled IDs aren't added.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(flutter): Avoid session replay in JS test
The real-binding options test set sessionSampleRate, which could
sample a session replay that uploads to the fake DSN on close. Keep it
in buffer mode and check the session rate mapping with the mock
binding instead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(flutter): Fix recorder doc comment placement
Inserting shouldCapture below _canStartCapture's doc comment moved
that comment onto the new getter. Give each its own doc.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(flutter): Feed only the web replay frame bytes
data.buffer.asUint8List() ignored the ByteData view's offset and
length. If rawRgbaData is backed by a larger buffer (e.g. Wasm
memory), ImageData rejects the frame. Pass the bounded view.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(flutter): Wait for web replay stop on start
A start that ran while stopReplay() was still stopping the recorder
could start it, and the finishing stop then removed the bridge while
the recorder stayed marked started. Starts now wait for an in-flight
stop. The new test checks the end state; it doesn't reproduce the
interleaving deterministically.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(flutter): Guard web afterSendEvent emission
The rejection handler only covered a failed send; an exception from
jsify() or emit() in the success callback escaped as an unhandled
async error. Catch and log it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(flutter): Note web replay start requirement
Manual start on Web needs a sample rate above 0, since the Replay JS
bundle only loads then. Unlike Android/iOS, where explicit start
bypasses sampling entirely.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(flutter): Serialize web replay calls
Replay start, stop, flush, config changes and close now run one at
a time in call order, replacing the flags that tracked their
interleavings. Document the JS SDK behavior the web replay relies
on, and model buffer mode in the event processor test fake.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(flutter): Address web replay review findings
- Always stop the web replay recorder on close, so a failed start
doesn't leave the shadow canvas in the DOM.
- Add ReplayTelemetryIntegration on web and check replay support
when it runs: the replay sample rates are set after the default
integrations are created.
- Read back the captured image before yielding to the event loop.
- Pin a supported renderer in the replay script loading tests.
Co-Authored-By: Lucas Zimerman Fraulob <lzfstudio+sentry@hotmail.com>
* fix(flutter): Read web replay buffering from JS
Nothing puts the JS replay's ID on the Dart scope, so
ReplayTelemetryIntegration marked every web replay as buffering.
Bindings can now report whether the replay is buffering; web asks the
JS Replay for its recording mode, as the JS SDK does for
sentry._internal.replay_is_buffering. Native bindings return null and
keep inferring it from the scope.
* test(flutter): Signal web replay bridge start
Replace the microtask spin loops waiting for bridgeStart with a
Completer on the fake bridge, bounded by a timeout, so a start that
never runs fails the test instead of hanging it.
* fix(flutter): Log failed JS envelope sends as errors
A rejected client.sendEnvelope() drops the envelope, so log it at error
level with its stack trace instead of debug.
Also tighten the web replay tests: pin the shadow canvas id as a
literal and check that the block selector spares it while matching
other canvases, and keep the real-binding replay tests in buffer mode
so they never upload to the test DSN.
* test(flutter): Tighten web replay envelope tests
Enable replay in the attachment-only envelope test, so event
collection is on and the empty-events check means something. Assert
that the manual canvas integration has enableManualSnapshot set.
* fix(flutter): Capture web replay while unfocused
Flutter Web reports inactive when a visible page loses focus. The
resumed-only capture guard, meant for native GPU surface teardown,
froze the replay canvas then. Let the web recorder also capture while
inactive.
* test(flutter): Address low Warden review findings
Rename web replay tests to plain verb phrases, split the scope
payload test per method, pin the JS SDK name and replay-canvas
URLs as literals, and clarify the isReplayBuffering null contract.
Co-Authored-By: Lucas Zimerman Fraulob <lzfstudio+sentry@hotmail.com>
* fix(flutter): Address web replay review comments
- Clear the shadow canvas before drawing each frame so transparent
pixels don't keep the previous frame
- Pick the replay bundle from the binding's supportsReplay
- Drop the unused name-based replayCanvas integration
- Add a regression test feeding a real JS SDK flutter-view click
through the replay click filter
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(flutter): Address Warden review findings
- Drop the no-replay script test, already covered by the default
supportsReplay stub
- Name the click filter tests with verb phrases
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* feat(flutter): Gate web replay behind flag
Add the experimental `options.replay.enableWebReplay` flag, off by
default. Web Session Replay now only starts when it is set alongside a
replay sample rate; otherwise init logs how to enable it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Giancarlo Buenaflor <giancarlobuenaflor97@gmail.com>
Co-authored-by: GPT-5.5 <noreply@openai.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Lucas Zimerman Fraulob <lzfstudio+sentry@hotmail.com>
📜 Description
Adds a Replay Playground screen to the Flutter example app (opened from the Other screen) for eyeballing Session Replay masking in the Sentry dashboard. Example-only change, no SDK code touched.
The screen includes:
Masked content in motion: a moving ball and a bouncing fake-3D cube, each with a switch to wrap it (or only the cube's red face) in
SentryMask. The scene boxes shrink to fit narrow screens.Masked text probes: four "This text should be masked" texts: static, zooming (
Transform.scale), spinning (Transform.rotate), and deliberately clipped (sliding past the edges of aClipRect). They render red but are styled black, so their masks are black and any red visible in a replay is a leak.Navigation test: buttons that reopen the playground on top of itself (title shows the depth, e.g. "Replay Playground remove sub-seconds from the timestamp format #2") at the same scroll position and with the same mask switches, 1 s after the tap, using a chosen page transition:
SwipePageTransitionsBuilder, built fromTransformwidgets, 6 s),SlowPageTransitionsBuilder).The two 6 s options (both ways, push and pop) give slow replay capture (1 fps on mobile) several frames mid-transition; the built-in ones run at their normal length. Only the pushed page uses the chosen transition: the page underneath animates with its own route's transition. Tapping adds a
ui.navigation_testbreadcrumb naming the transition (sent at the tap, before the delay); buttons stay disabled until the opened page is closed. Pushed pages use theReplayPlaygroundroute name, so they show up as navigation breadcrumbs.SentryUnmaskand text field examples (masked by default vs. unmasked).The example's minimum Flutter version is raised from 3.24 to 3.29, where
FadeForwardsPageTransitionsBuilderand thePageTransitionsBuilderduration getters first appear. CI builds the example on stable and beta only.💡 Motivation and Context
While working on web replay masking, we kept needing a repeatable scene to check masks against moving, scaled, rotated and clipped content and page transitions. It already surfaced that masks don't follow
ZoomPageTransitionsBuilder(its zoom is applied in aSnapshotPainter, invisible togetTransformTo). It's useful on its own, so it's split out from the web replay work.💚 How did you test it?
flutter analyze --fatal-warningsanddart formatpass on the example.📝 Checklist
sendDefaultPiiis enabled🔮 Next steps
ZoomPageTransitionsBuilder(and other painter-based) transitions in the SDK; this screen reproduces it.