A Flutter e-commerce application showcasing comprehensive Sentry instrumentation for error monitoring, performance tracking, session replay, and user feedback.
For Solution Engineers: This guide focuses on Android setup, which has been fully tested. iOS and other platforms have not been validated yet.
- Flutter SDK >= 3.22.0 (Install Guide)
- Android Studio or Android SDK command-line tools
- Android Emulator or physical device
- Sentry Account with a project created
- (Optional) Sentry CLI for size analysis:
brew install sentry-cli(macOS) or other platforms
-
Clone and navigate:
git clone https://github.com/sentry-demos/flutter.git cd flutter -
Configure your Sentry credentials:
cp .env.example .env
Edit
.envwith your Sentry project details:SENTRY_AUTH_TOKEN=sntryu_your_token_here SENTRY_DSN=https://your_key@o123456.ingest.us.sentry.io/123456 SENTRY_RELEASE=com.example.empower_flutter@9.14.0+1 SENTRY_ENVIRONMENT=development SENTRY_ORG=your-org-slug SENTRY_PROJECT=your-project-slug SENTRY_SIZE_ANALYSIS_ENABLED=true # Optional -
Set your engineer identifier:
Edit
lib/se_config.dart:const String se = 'your-name'; // Replace with your name
This tags all your Sentry events with your identifier, allowing multiple SEs to use the same project without interference.
-
Verify setup:
./demo.sh verify
Use the unified build script which handles everything automatically:
# Build Android APK with full Sentry integration
./demo.sh build android
# Output location:
# build/app/outputs/flutter-apk/app-release.apkWhat the script does:
- ✅ Creates Sentry release
- ✅ Builds APK with obfuscation
- ✅ Uploads debug symbols for readable stack traces
- ✅ Uploads ProGuard mapping (Android)
- ✅ (Optional) Uploads build for size analysis
- ✅ Finalizes release
Method 1: Drag & Drop (Easiest)
- Start your Android emulator (via Android Studio or
emulator -avd <device-name>) - Locate the APK:
build/app/outputs/flutter-apk/app-release.apk - Drag and drop the APK file into the emulator window
- App will install automatically
Method 2: ADB Install
adb install build/app/outputs/flutter-apk/app-release.apkMethod 3: Run Script (Build + Install + Create Deploy)
./demo.sh run androidThis builds, installs, launches the app, and creates a Sentry deploy marker.
-
Enable USB debugging on your device:
- Settings → About Phone → Tap "Build Number" 7 times
- Settings → Developer Options → Enable USB Debugging
-
Connect device via USB and run:
./demo.sh run android
All errors appear in your Sentry Issues dashboard with:
- Full stack traces (readable thanks to uploaded symbols)
- Session replay showing what led to the error
- Device context and breadcrumbs
- Your engineer tag (
se:your-name)
- TTID (Time to Initial Display) - Automatic on all screens
- TTFD (Time to Full Display) - Manual, measured when content fully loads
- HTTP Requests - API calls with timing
- User Interactions - Taps, swipes, navigation
- Database Operations - Simulated performance issues
Navigate through the app (Home → Product Details → Cart → Checkout) and check the Performance tab in Sentry.
- Trigger any error from the drawer menu
- Go to Sentry Issues → Click on the error
- View the attached session replay showing user actions leading up to the error
- Financial information (prices in checkout) is automatically masked for privacy
Complete a checkout flow to see:
- Structured logs with searchable attributes
- Custom metrics (counters, gauges, distributions)
- API latency tracking
- Promo code validation attempts
View in Sentry → Metrics and Logs sections.
Trigger from drawer menu: ANR (Android)
- Freezes main thread for 10 seconds
- Creates ANR event in Sentry with thread states
- Shows which operations were blocking
- Dart Exception, Timeout, Platform, State, Range, Type errors
- Assertion failures
- Missing plugin exceptions
- File I/O on main thread
- C++ segfault via method channel
- Kotlin exceptions
- ANR detection (5-second threshold)
- ProGuard obfuscation with symbol upload
After running ./demo.sh build android:
build/app/outputs/
├── flutter-apk/
│ └── app-release.apk # Install this on emulator/device
├── bundle/release/
│ └── app-release.aab # For Google Play Store
└── mapping/release/
└── mapping.txt # ProGuard mapping (auto-uploaded)
Debug symbols location:
- Obfuscation map:
build/app/obfuscation.map.json - Debug info:
build/debug-info/
All symbols are automatically uploaded to Sentry by the build script.
Track your app's build size over time in Sentry.
Setup:
- Install Sentry CLI:
brew install sentry-cli(or other methods) - Ensure
SENTRY_SIZE_ANALYSIS_ENABLED=truein.env - Build:
./demo.sh build android
View results at:
https://sentry.io/organizations/your-org/projects/your-project/size-analysis/
Both APK and AAB are uploaded with detailed DEX breakdown (thanks to ProGuard mapping).
For more details, see SIZE_ANALYSIS_GUIDE.md.
# Ensure Flutter is in PATH
flutter doctor# List available devices
flutter devices
# Start Android emulator
emulator -list-avds
emulator -avd <device-name>- Verify DSN in
.envis correct - Check Sentry project settings
- Ensure you're on the correct environment filter in Sentry UI
- Look for errors in app logs:
adb logcat | grep Sentry
Spotlight is a local Sentry event viewer — events sent in debug mode appear here without going to the cloud.
Install (one-time):
npm install -g @spotlightjs/spotlightUsage:
# 1. Start the Spotlight sidecar server (in a separate terminal):
spotlight
# 2. Run the app in debug mode:
flutter run -d emulator-5554
# 3. Open in browser:
# http://localhost:8969/The Sentry SDK automatically forwards events to Spotlight when running in kDebugMode.
Make sure you used ./demo.sh build android (not flutter build), which uploads debug symbols automatically.
lib/
├── main.dart # App entry point, home page
├── sentry_setup.dart # Comprehensive Sentry configuration
├── se_config.dart # Engineer identifier (EDIT THIS)
├── navbar_destination.dart # Navigation drawer + error triggers
├── product_list.dart # Product catalog, performance demos
├── product_details.dart # Product detail view
├── cart.dart # Shopping cart
├── checkout.dart # Checkout with metrics/logging
└── models/
└── cart_state_model.dart # Shopping cart state (Provider)
demo.sh # Unified build script (USE THIS)
.env # Sentry credentials (CONFIGURE THIS)
.env.example # Configuration template
pubspec.yaml # Dependencies and version
.env - Sentry credentials and configuration (git-ignored)
lib/se_config.dart - Your engineer identifier for event tagging
This demo showcases all Sentry Flutter features:
✅ Error tracking (Dart, native crashes) ✅ Performance monitoring (transactions, spans, TTFD/TTID) ✅ Session replay (100% capture for demo) ✅ User interactions tracing ✅ HTTP request tracking (SentryHttpClient, Dio) ✅ File I/O instrumentation ✅ Structured logging with attributes ✅ Custom metrics (counters, gauges, distributions) ✅ ANR detection (Android) ✅ App hang detection (iOS/macOS - not tested) ✅ Profiling (iOS/macOS/Android) ✅ User feedback collection ✅ Breadcrumbs and context ✅ Screenshot capture ✅ View hierarchy attachments ✅ Thread information ✅ Spotlight debugging (development)
All features are configured at 100% sampling for demo purposes. Adjust in lib/sentry_setup.dart for production.
- CLAUDE.md - Comprehensive project context for AI assistance
- BUILD_GUIDE.md - Detailed build instructions for all platforms
- SIZE_ANALYSIS_GUIDE.md - Size analysis setup and usage
- SENTRY_FEATURES.md - Complete Sentry feature documentation
This demo has only been validated on Android. iOS, Web, macOS, Linux, and Windows builds may work but have not been tested by the team.
If you want to try other platforms:
# iOS (requires macOS + Xcode)
./demo.sh build ios
# Web
./demo.sh build web
# Others
./demo.sh build macos
./demo.sh build linux
./demo.sh build windowsPlatform-specific documentation exists in the codebase but is not guaranteed to be accurate.
- Sentry Flutter Docs: https://docs.sentry.io/platforms/flutter/
- Sentry CLI Docs: https://docs.sentry.io/cli/
- Flutter Docs: https://docs.flutter.dev/
For issues with this demo, check existing documentation or reach out to the SE team.
Current Version: 9.14.0+1 (matches Sentry SDK) Tested Platform: Android only App Name: Empower Plant (com.example.empower_flutter)