Skip to content

Commit 5af1762

Browse files
mtopo27claude
andcommitted
docs: Add Snapshots EA product documentation
Add three new pages for the Snapshots visual regression testing feature (Early Adopter). Covers the overview and prerequisites, upload setup with CI workflow, and the review/approval workflow with project settings. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7b73fc9 commit 5af1762

File tree

3 files changed

+199
-0
lines changed

3 files changed

+199
-0
lines changed

docs/product/snapshots/index.mdx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
title: Snapshots
3+
sidebar_order: 138
4+
description: Detect visual changes by comparing PNG snapshots against a baseline on every pull request.
5+
new: true
6+
---
7+
8+
<Include name="feature-available-for-user-group-early-adopter" />
9+
10+
Snapshots catches visual regressions before they reach users. Your CI pipeline generates PNG screenshots, uploads them to Sentry, and Sentry compares each image against a baseline from your main branch using pixel-level diffing.
11+
12+
When a snapshot changes, Sentry posts a failing GitHub Check on your pull request. You review the diff in Sentry's comparison viewer and approve or reject the changes.
13+
14+
## How It Works
15+
16+
1. **Generate snapshots** — Your CI job produces PNG screenshots however you like: Playwright, Storybook, simulator captures, or any tool that outputs PNGs.
17+
2. **Upload to Sentry**`sentry-cli` uploads the snapshot directory along with Git metadata so Sentry can associate each upload with a commit.
18+
3. **Sentry diffs against the baseline** — Sentry finds the most recent snapshot set from your base branch (matched by `app_id`) and categorizes each image as added, removed, modified, renamed, or unchanged.
19+
4. **Result posted to your PR** — A "Snapshot Testing" GitHub Check appears on the pull request. It passes if nothing changed and fails if any snapshots need approval.
20+
5. **Review and approve** — Click through to Sentry's comparison viewer to inspect diffs, then approve to resolve the failing check.
21+
22+
## Prerequisites
23+
24+
- **Early Adopter access** — Enable the Early Adopter toggle in your [organization settings](/organization/early-adopter-features/).
25+
- **Auth token** — A Sentry auth token with `project:write` scope (personal token) or `org:ci` scope (org-level token).
26+
- **sentry-cli >= 3.3.4** — The `build snapshots` command requires version 3.3.4 or later.
27+
- **GitHub integration** — Install the [Sentry GitHub App](/organization/integrations/source-code-mgmt/github/) and grant it access to your repository so Sentry can post Check Runs.
28+
29+
<PageGrid />
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
title: Review Snapshots
3+
sidebar_order: 20
4+
description: Review snapshot diffs on your pull request and approve changes.
5+
---
6+
7+
<Include name="feature-available-for-user-group-early-adopter" />
8+
9+
## Status Checks
10+
11+
After you upload snapshots from a pull request branch, a **Snapshot Testing** GitHub Check appears on the pull request. If no snapshots changed, the check passes. If any snapshots were added, removed, or modified, the check fails and requires approval.
12+
13+
IMAGE: GitHub Check showing Snapshot Testing results on a pull request
14+
15+
## Comparison Viewer
16+
17+
Click **Details** on the GitHub Check to open Sentry's comparison viewer. The viewer has two panels:
18+
19+
- **Sidebar** — Lists all snapshots grouped by status: modified, added, removed, renamed, and unchanged. Click a snapshot to view it.
20+
- **Main panel** — Displays the selected snapshot's diff with three viewing modes:
21+
- **Split** — Side-by-side view of base and current branch with a diff overlay highlighting changed pixels.
22+
- **Wipe** — Drag a slider across the image to compare base and current branch.
23+
- **Onion** — Overlay both images with an adjustable opacity slider.
24+
25+
IMAGE: Sentry Snapshot comparison viewer showing a modified image with split diff
26+
27+
## Approve Changes
28+
29+
There are two ways to approve snapshot changes:
30+
31+
- Click the **Approve** button on the GitHub Check Run.
32+
- Click **Approve** in the Sentry comparison viewer.
33+
34+
Approval resolves the failing check. If new changes are pushed to the PR, the check resets and requires approval again.
35+
36+
## Settings
37+
38+
Configure snapshot behavior in **Project Settings > Mobile Builds > Snapshots**.
39+
40+
| Setting | Default | Description |
41+
| --- | :---: | --- |
42+
| Status Checks Enabled | On | Post GitHub Check Runs for snapshot comparisons. |
43+
| Fail on Added Snapshots | Off | Require approval when new snapshots are added. |
44+
| Fail on Removed Snapshots | On | Require approval when existing snapshots are removed. |
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
---
2+
title: Upload Snapshots
3+
sidebar_order: 10
4+
description: Structure your snapshot directory and upload from CI with sentry-cli.
5+
---
6+
7+
<Include name="feature-available-for-user-group-early-adopter" />
8+
9+
Each snapshot consists of two files: a `.png` image and a `.json` metadata sidecar with the same base name. You can organize snapshots into subdirectories — the CLI reads the entire directory tree.
10+
11+
```
12+
snapshots/
13+
├── homepage.png
14+
├── homepage.json
15+
├── settings/
16+
│ ├── profile.png
17+
│ ├── profile.json
18+
│ ├── billing.png
19+
│ └── billing.json
20+
```
21+
22+
Filenames are the identity key for each snapshot. Keep them stable across runs so Sentry can accurately diff head against base.
23+
24+
## Metadata
25+
26+
The `.json` sidecar describes its paired `.png`:
27+
28+
```json
29+
{
30+
"display_name": "Billing Page",
31+
"group": "Settings"
32+
}
33+
```
34+
35+
| Field | Type | Description |
36+
| --- | --- | --- |
37+
| `display_name` | string | Human-readable label shown in the comparison viewer. |
38+
| `group` | string | Groups related snapshots in the comparison viewer sidebar. |
39+
40+
You can add arbitrary custom key-value pairs to the JSON file — they are preserved as metadata.
41+
42+
The CLI automatically computes and adds `content_hash`, `width`, and `height` at upload time. Do not set these yourself.
43+
44+
## Upload With CI
45+
46+
To see the workflow Sentry uses on its own codebase, view the [frontend snapshots workflow](https://github.com/getsentry/sentry/blob/master/.github/workflows/frontend-snapshots.yml).
47+
48+
Below is a complete GitHub Actions workflow you can copy into your repository. Replace the placeholder values with your own snapshot generation command, app ID, and Sentry project slug.
49+
50+
```yml {filename:.github/workflows/snapshots.yml}
51+
name: Snapshots
52+
53+
on:
54+
push:
55+
branches: [main]
56+
pull_request:
57+
58+
concurrency:
59+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
60+
cancel-in-progress: true
61+
62+
env:
63+
SNAPSHOT_OUTPUT_DIR: .artifacts/snapshots
64+
65+
jobs:
66+
snapshots:
67+
runs-on: ubuntu-24.04
68+
timeout-minutes: 20
69+
steps:
70+
- uses: actions/checkout@v4
71+
with:
72+
# Use PR head SHA, not the merge commit — avoids phantom diffs
73+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
74+
75+
# -------------------------------------------------------
76+
# YOUR SNAPSHOT GENERATION STEP(S) HERE
77+
# -------------------------------------------------------
78+
# Generate PNG + JSON pairs into $SNAPSHOT_OUTPUT_DIR.
79+
# Examples:
80+
# - Playwright screenshots
81+
# - Storybook captures
82+
# - iOS/Android simulator screenshots
83+
# - Any tool that produces PNGs
84+
# -------------------------------------------------------
85+
- name: Generate snapshots
86+
run: <your-snapshot-command>
87+
88+
- name: Install sentry-cli
89+
if: ${{ !cancelled() }}
90+
run: curl -sL https://sentry.io/get-cli/ | SENTRY_CLI_VERSION=3.3.4 sh
91+
92+
- name: Upload snapshots
93+
if: ${{ !cancelled() }}
94+
env:
95+
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_SNAPSHOTS_AUTH_TOKEN }}
96+
run: |
97+
ARGS=(
98+
--auth-token "$SENTRY_AUTH_TOKEN"
99+
build snapshots "${{ env.SNAPSHOT_OUTPUT_DIR }}"
100+
--app-id <your-app-id>
101+
--project <your-sentry-project>
102+
--head-sha "${{ github.event.pull_request.head.sha || github.sha }}"
103+
--vcs-provider github
104+
--head-repo-name "${{ github.repository }}"
105+
)
106+
107+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
108+
ARGS+=(
109+
--base-sha "${{ github.event.pull_request.base.sha }}"
110+
--base-repo-name "${{ github.repository }}"
111+
--head-ref "${{ github.head_ref }}"
112+
--base-ref "${{ github.base_ref }}"
113+
--pr-number "${{ github.event.number }}"
114+
)
115+
fi
116+
117+
sentry-cli "${ARGS[@]}"
118+
```
119+
120+
A few things to note about this workflow:
121+
122+
- **Checkout at PR head SHA** — Using `ref: ${{ github.event.pull_request.head.sha || github.sha }}` avoids phantom diffs caused by the merge commit GitHub generates by default.
123+
- **Upload even on partial failure** — The `if: ${{ !cancelled() }}` condition ensures partial results still get uploaded if some snapshot tests fail.
124+
- **Keep `--app-id` consistent** — The `app_id` ties head and base uploads together. Sentry finds the baseline by matching the same `app_id` at the `base_sha`. Use one `app_id` per logical app or bundle.
125+
126+
Other CI systems work by passing the same flags to `sentry-cli build snapshots` explicitly.

0 commit comments

Comments
 (0)