Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/actions/size-analysis-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Size Analysis Setup
description: Common setup steps for size analysis builds (Flutter, Sentry CLI, version parsing)

runs:
using: composite

steps:
- name: Read configured Flutter SDK version
id: conf
shell: bash
working-directory: packages/flutter/example
run: |
version=$(grep "version" ../../../metrics/flutter.properties | cut -d'=' -f2 | xargs)
echo "flutter=$version" >> "$GITHUB_OUTPUT"

- name: Install Flutter v${{ steps.conf.outputs.flutter }}
uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e # pin@v2.21.0
with:
flutter-version: ${{ steps.conf.outputs.flutter }}

- name: Install Sentry CLI
if: env.SENTRY_AUTH_TOKEN != ''
shell: bash
run: curl -sL https://sentry.io/get-cli/ | SENTRY_CLI_VERSION=2.58.2 sh

- name: Determine build version
shell: bash
working-directory: packages/flutter/example
run: |
version_line=$(grep '^version:' pubspec.yaml | awk '{print $2}')
# Remove any + suffix first (for pubspec.yaml versions like 1.2.3+4)
version=${version_line%%+*}

# Parse version: x.y.z-suffix.n → build_name=x.y.z, build_number=n
# Supports: x.y.z, x.y.z-alpha.n, x.y.z-beta.n, x.y.z-rc.n, etc.
# Note: build_name is x.y.z only (plist/Android compatibility)
if [[ $version =~ ^([0-9]+\.[0-9]+\.[0-9]+)-[a-zA-Z]+\.([0-9]+)$ ]]; then
build_name="${BASH_REMATCH[1]}"
build_number="${BASH_REMATCH[2]}"
elif [[ $version =~ ^([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
build_name="${BASH_REMATCH[1]}"
build_number=1
else
build_name="$version"
build_number=1
fi

echo "SIZE_VERSION=$build_name" >> "$GITHUB_ENV"
echo "SIZE_BUILD=$build_number" >> "$GITHUB_ENV"
114 changes: 114 additions & 0 deletions .github/workflows/size-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Size Analysis

on:
push:
branches:
- main
paths:
- 'packages/**'
- 'metrics/flutter.properties'
- '.github/workflows/size-analysis.yml'
- '.github/actions/size-analysis-setup/**'
pull_request:
paths:
- 'packages/**'
- 'metrics/flutter.properties'
- '.github/workflows/size-analysis.yml'
- '.github/actions/size-analysis-setup/**'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
SENTRY_ORG: sentry-sdks
SENTRY_PROJECT: sentry-flutter
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}

jobs:
android:
name: Android
runs-on: ubuntu-latest
timeout-minutes: 30
defaults:
run:
working-directory: packages/flutter/example

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0

- uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
with:
distribution: 'adopt'
java-version: '17'

- uses: ./.github/actions/size-analysis-setup

- name: Build Android Appbundle
run: |
flutter pub get
flutter build appbundle --release \
--build-name "$SIZE_VERSION" \
--build-number "$SIZE_BUILD"

- name: Upload Android Bundle to Sentry Size Analysis
if: env.SENTRY_AUTH_TOKEN != ''
run: |
sentry-cli build upload \
"build/app/outputs/bundle/release/app-release.aab" \
--org "${{ env.SENTRY_ORG }}" \
--project "${{ env.SENTRY_PROJECT }}" \
--build-configuration "Release"

ios:
name: iOS
runs-on: macos-15
timeout-minutes: 45
defaults:
run:
working-directory: packages/flutter/example

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0

- uses: ./.github/actions/size-analysis-setup

# QuickFix for failing iOS 18.0 builds https://github.com/actions/runner-images/issues/12758#issuecomment-3187115656
- name: Switch to Xcode 16.4 for iOS 18.5
run: sudo xcode-select --switch /Applications/Xcode_16.4.app

- name: Build Flutter iOS
run: |
flutter pub get
flutter build ios --release --no-codesign \
--build-name "$SIZE_VERSION" \
--build-number "$SIZE_BUILD"

- uses: ruby/setup-ruby@dffb23f65a78bba8db45d387d5ea1bbd6be3ef18 # pin@v1.293.0
with:
ruby-version: '2.7.5'

- name: Install Fastlane
working-directory: packages/flutter/example/ios
run: bundle install

- name: Build signed IPA
working-directory: packages/flutter/example/ios
env:
APP_STORE_CONNECT_KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }}
APP_STORE_CONNECT_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_ISSUER_ID }}
APP_STORE_CONNECT_KEY: ${{ secrets.APP_STORE_CONNECT_KEY }}
FASTLANE_KEYCHAIN_PASSWORD: ${{ secrets.FASTLANE_KEYCHAIN_PASSWORD }}
MATCH_GIT_PRIVATE_KEY: ${{ secrets.MATCH_GIT_PRIVATE_KEY }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
MATCH_USERNAME: ${{ secrets.MATCH_USERNAME }}
run: bundle exec fastlane build_release

- name: Upload iOS build to Sentry Size Analysis
if: env.SENTRY_AUTH_TOKEN != ''
working-directory: packages/flutter/example/ios
run: bundle exec fastlane upload_size_analysis
4 changes: 2 additions & 2 deletions packages/flutter/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (flutterVersionName == null) {
}

android {
namespace = "io.sentry.samples.flutter"
namespace = "io.sentry.flutter.sample"
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -44,7 +44,7 @@ android {
}

defaultConfig {
applicationId "io.sentry.samples.flutter"
applicationId "io.sentry.flutter.sample"
minSdkVersion flutter.minSdkVersion
targetSdkVersion 36
versionCode flutterVersionCode.toInteger()
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/example/android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-keep class io.sentry.samples.flutter.** { *; }
-keep class io.sentry.flutter.sample.** { *; }
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.sentry.samples.flutter">
package="io.sentry.flutter.sample">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.sentry.samples.flutter
package io.sentry.flutter.sample

import android.os.Handler
import io.flutter.embedding.android.FlutterActivity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,7 @@ void main() {
final contexts = await SentryFlutter.native?.loadContexts();

final appPackageInfo = await PackageInfo.fromPlatform();
final expectedAppId = Platform.isAndroid
? 'io.sentry.samples.flutter'
: 'io.sentry.flutter.sample';
const expectedAppId = 'io.sentry.flutter.sample';
final expectedSdkName =
Platform.isAndroid ? 'maven:sentry-android' : 'cocoapods:sentry-cocoa';
final expectedVersion = appPackageInfo.version;
Expand Down
1 change: 1 addition & 0 deletions packages/flutter/example/ios/Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source "https://rubygems.org"

gem "fastlane"
gem "fastlane-plugin-sentry"

# Ruby 3.4.0 has removed some libraries from the standard library.
gem "mutex_m"
Expand Down
3 changes: 3 additions & 0 deletions packages/flutter/example/ios/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ GEM
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.4.1)
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
fastlane-plugin-sentry (2.4.0)
os (~> 1.1, >= 1.1.4)
fastlane-sirp (1.0.0)
sysrandom (~> 1.0)
gh_inspector (1.1.3)
Expand Down Expand Up @@ -231,6 +233,7 @@ DEPENDENCIES
benchmark
csv
fastlane
fastlane-plugin-sentry
mutex_m
ostruct

Expand Down
10 changes: 10 additions & 0 deletions packages/flutter/example/ios/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ platform :ios do
)
end

desc "Upload build to Sentry Size Analysis"
lane :upload_size_analysis do
sentry_upload_build(
org_slug: ENV["SENTRY_ORG"],
project_slug: ENV["SENTRY_PROJECT"],
ipa_path: "./build/sentry_flutter_sample.ipa",
build_configuration: "Release"
)
end

desc "Fetch ASC API Key"
lane :fetch_api_key do
app_store_connect_api_key(
Expand Down
5 changes: 5 additions & 0 deletions packages/flutter/example/ios/fastlane/Pluginfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Autogenerated by fastlane
#
# Ensure this file is checked in to source control!

gem 'fastlane-plugin-sentry'
2 changes: 1 addition & 1 deletion packages/flutter/example/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if [ "$1" == "ios" ]; then
elif [ "$1" == "android" ]; then
flutter build apk --split-debug-info=$symbolsDir --obfuscate
adb install build/app/outputs/flutter-apk/app-release.apk
launchCmd='adb shell am start -n io.sentry.samples.flutter/io.sentry.samples.flutter.MainActivity'
launchCmd='adb shell am start -n io.sentry.flutter.sample/io.sentry.flutter.sample.MainActivity'
echo -e "[\033[92mrun\033[0m] Android app installed"
elif [ "$1" == "web" ]; then
flutter build web --dart-define=SENTRY_RELEASE="$SENTRY_RELEASE" --source-maps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ const _jvmStackTrace =
at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:292)
at io.flutter.plugin.common.StandardMethodCodec.encodeSuccessEnvelope(StandardMethodCodec.java:59)
at io.flutter.plugin.common.MethodChannel\$IncomingMethodCallHandler\$1.success(MethodChannel.java:267)
at io.sentry.samples.flutter.MainActivity.configureFlutterEngine\$lambda-0(MainActivity.kt:40)
at io.sentry.samples.flutter.MainActivity.lambda\$TiSaAm1LIEmKLVswI4BlR_5sw5Y(Unknown Source:0)
at io.sentry.samples.flutter.-\$\$Lambda\$MainActivity\$TiSaAm1LIEmKLVswI4BlR_5sw5Y.onMethodCall(Unknown Source:2)
at io.sentry.flutter.sample.MainActivity.configureFlutterEngine\$lambda-0(MainActivity.kt:40)
at io.sentry.flutter.sample.MainActivity.lambda\$TiSaAm1LIEmKLVswI4BlR_5sw5Y(Unknown Source:0)
at io.sentry.flutter.sample.-\$\$Lambda\$MainActivity\$TiSaAm1LIEmKLVswI4BlR_5sw5Y.onMethodCall(Unknown Source:2)
at io.flutter.plugin.common.MethodChannel\$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:296)
at io.flutter.embedding.engine.dart.DartMessenger.lambda\$dispatchMessageToQueue\$0\$DartMessenger(DartMessenger.java:320)
Expand Down
8 changes: 4 additions & 4 deletions packages/flutter/test/jvm/jvm_exception_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ java.lang.IllegalArgumentException: Unsupported value: '[Ljava.lang.StackTraceEl
at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:292)
at io.flutter.plugin.common.StandardMethodCodec.encodeSuccessEnvelope(StandardMethodCodec.java:59)
at io.flutter.plugin.common.MethodChannel\$IncomingMethodCallHandler\$1.success(MethodChannel.java:267)
at io.sentry.samples.flutter.MainActivity.configureFlutterEngine\$lambda-0(MainActivity.kt:40)
at io.sentry.samples.flutter.MainActivity.lambda\$TiSaAm1LIEmKLVswI4BlR_5sw5Y(Unknown Source:0)
at io.sentry.samples.flutter.-\$\$Lambda\$MainActivity\$TiSaAm1LIEmKLVswI4BlR_5sw5Y.onMethodCall(Unknown Source:2)
at io.sentry.flutter.sample.MainActivity.configureFlutterEngine\$lambda-0(MainActivity.kt:40)
at io.sentry.flutter.sample.MainActivity.lambda\$TiSaAm1LIEmKLVswI4BlR_5sw5Y(Unknown Source:0)
at io.sentry.flutter.sample.-\$\$Lambda\$MainActivity\$TiSaAm1LIEmKLVswI4BlR_5sw5Y.onMethodCall(Unknown Source:2)
at io.flutter.plugin.common.MethodChannel\$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:296)
at io.flutter.embedding.engine.dart.DartMessenger.lambda\$dispatchMessageToQueue\$0\$DartMessenger(DartMessenger.java:320)
Expand Down Expand Up @@ -248,7 +248,7 @@ android.content.res.Resources\$NotFoundException: Unable to find resource ID #0x

const platformExceptionWithEmptyStackFrames = '''
java.lang.RuntimeException: Catch this platform exception!
at io.sentry.samples.flutter.MainActivity\$configureFlutterEngine\$1.onMethodCall(MainActivity.kt:40)
at io.sentry.flutter.sample.MainActivity\$configureFlutterEngine\$1.onMethodCall(MainActivity.kt:40)
at io.flutter.plugin.common.MethodChannel\$IncomingMethodCallHandler.onMessage(MethodChannel.java:258)
at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
at io.flutter.embedding.engine.dart.DartMessenger.lambda\$dispatchMessageToQueue\$0\$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322)
Expand Down
4 changes: 2 additions & 2 deletions packages/flutter/test/jvm/jvm_frame_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ void main() {

test('parses frame with lambda and unknown source', () {
final frame = JvmFrame.parse(
'at io.sentry.samples.flutter.-\$\$Lambda\$MainActivity\$TiSaAm1LIEmKLVswI4BlR_5sw5Y.onMethodCall(Unknown Source:2)',
'at io.sentry.flutter.sample.-\$\$Lambda\$MainActivity\$TiSaAm1LIEmKLVswI4BlR_5sw5Y.onMethodCall(Unknown Source:2)',
);
expect(frame.fileName, 'Unknown Source');
expect(frame.lineNumber, 2);
expect(frame.method, 'onMethodCall');
expect(
frame.className,
'io.sentry.samples.flutter.-\$\$Lambda\$MainActivity\$TiSaAm1LIEmKLVswI4BlR_5sw5Y',
'io.sentry.flutter.sample.-\$\$Lambda\$MainActivity\$TiSaAm1LIEmKLVswI4BlR_5sw5Y',
);
expect(frame.skippedFrames, null);
expect(frame.isNativeMethod, false);
Expand Down
Loading