Skip to content

feat(replay): Add beforeStoreFrame callback for snapshot testing#5386

Open
runningcode wants to merge 3 commits intomainfrom
no/java-504-replay-before-store-frame-callback
Open

feat(replay): Add beforeStoreFrame callback for snapshot testing#5386
runningcode wants to merge 3 commits intomainfrom
no/java-504-replay-before-store-frame-callback

Conversation

@runningcode
Copy link
Copy Markdown
Contributor

Summary

  • Add an experimental BeforeStoreFrameCallback to SentryReplayOptions that fires right before a replay frame is stored to disk, receiving the masked bitmap, timestamp, and screen name via Hint
  • Add a Kotlin extension SentryReplayOptions.beforeStoreFrame { bitmap, ts, screen -> } for ergonomic usage
  • Add ReplaySnapshotTest UI integration test that captures masked replay frames via TestStorage on Sauce Labs
  • Enable useTestStorageService and *.png artifact collection in the Sauce Labs config, with sentry-cli build snapshots upload in CI

Relates to JAVA-504

🤖 Generated with Claude Code

Add an experimental callback that fires right before a replay frame is
stored to disk. The callback receives the masked bitmap (via Hint),
timestamp, and current screen name. This enables snapshot testing of
replay masking without needing to decode stored video segments.

Includes a Kotlin extension for ergonomic usage:
  options.sessionReplay.beforeStoreFrame { bitmap, ts, screen -> ... }

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 8, 2026

JAVA-504

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Fails
🚫 Please consider adding a changelog entry for the next release.
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Features

- Add beforeStoreFrame callback for snapshot testing ([#5386](https://github.com/getsentry/sentry-java/pull/5386))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against 90ff469

@sentry
Copy link
Copy Markdown

sentry Bot commented May 8, 2026

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.41.0 (1) release

⚙️ sentry-android Build Distribution Settings

@runningcode runningcode force-pushed the no/java-504-replay-before-store-frame-callback branch 2 times, most recently from 5b10cdd to e7452f7 Compare May 8, 2026 08:36
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 316.30 ms 354.64 ms 38.34 ms
Size 0 B 0 B 0 B

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
5865051 319.74 ms 365.60 ms 45.86 ms
0220a5c 452.20 ms 479.33 ms 27.12 ms
2124a46 319.19 ms 415.04 ms 95.85 ms
2195398 322.52 ms 361.91 ms 39.39 ms
bbc35bb 298.53 ms 372.17 ms 73.64 ms
d364ace 382.77 ms 443.21 ms 60.44 ms
d15471f 379.40 ms 470.76 ms 91.36 ms
9139b91 351.35 ms 355.63 ms 4.28 ms
fc5ccaf 322.49 ms 405.25 ms 82.76 ms
52feca7 314.77 ms 378.67 ms 63.90 ms

App size

Revision Plain With Sentry Diff
5865051 0 B 0 B 0 B
0220a5c 0 B 0 B 0 B
2124a46 1.58 MiB 2.12 MiB 551.51 KiB
2195398 0 B 0 B 0 B
bbc35bb 1.58 MiB 2.12 MiB 553.01 KiB
d364ace 1.58 MiB 2.11 MiB 539.75 KiB
d15471f 1.58 MiB 2.13 MiB 559.54 KiB
9139b91 1.58 MiB 2.13 MiB 559.52 KiB
fc5ccaf 1.58 MiB 2.13 MiB 557.54 KiB
52feca7 0 B 0 B 0 B

Previous results on branch: no/java-504-replay-before-store-frame-callback

Startup times

Revision Plain With Sentry Diff
62bcea4 359.22 ms 426.90 ms 67.67 ms
1cddad0 342.73 ms 424.14 ms 81.41 ms

App size

Revision Plain With Sentry Diff
62bcea4 0 B 0 B 0 B
1cddad0 0 B 0 B 0 B

…(JAVA-504)

Add ReplaySnapshotTest that uses the beforeStoreFrame callback to
capture masked replay frames during a Compose UI test. Frames are
written to the Downloads/sauce_labs_custom_screenshots/ directory,
which is the standard path Sauce Labs collects screenshots from.

CI changes:
- Add *.png to Sauce Labs artifact match patterns
- Upload collected replay snapshots via sentry-cli build snapshots

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@runningcode runningcode force-pushed the no/java-504-replay-before-store-frame-callback branch from e7452f7 to 2aff4b0 Compare May 8, 2026 08:46
…VA-504)

The Kotlin extension `beforeStoreFrame` comes from `sentry-android-replay`
which may not resolve in the UI test module. Use the Java callback API
directly instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@runningcode runningcode marked this pull request as ready for review May 8, 2026 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant