Skip to content

Commit a3cdb7a

Browse files
committed
Merge branch 'main' into denrase/test-native-plugin-init
# Conflicts: # flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutterPlugin.kt
2 parents 2b774a1 + d189e01 commit a3cdb7a

File tree

9 files changed

+129
-106
lines changed

9 files changed

+129
-106
lines changed

.github/workflows/flutter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ jobs:
160160
steps:
161161
- uses: actions/checkout@v3
162162
# https://github.com/CocoaPods/CocoaPods/issues/5275#issuecomment-315461879
163-
- run: pod lib lint ios/sentry_flutter.podspec --configuration=Debug --skip-import-validation --allow-warnings
163+
- run: pod lib lint ios/sentry_flutter.podspec --configuration=Debug --skip-import-validation --allow-warnings --verbose
164164

165165
swift-lint:
166166
runs-on: ubuntu-latest

.github/workflows/flutter_integration_test.yml

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -16,72 +16,72 @@ jobs:
1616
uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 # [email protected]
1717
with:
1818
access_token: ${{ github.token }}
19-
19+
2020
test-android:
2121
runs-on: macos-latest
2222
timeout-minutes: 30
2323
defaults:
24-
run:
25-
working-directory: ./flutter/example
24+
run:
25+
working-directory: ./flutter/example
2626
strategy:
27-
fail-fast: false
28-
matrix:
29-
sdk: ['stable', 'beta']
27+
fail-fast: false
28+
matrix:
29+
sdk: ['stable', 'beta']
3030
steps:
31-
- name: checkout
32-
uses: actions/checkout@v3
33-
34-
- uses: actions/setup-java@v3
35-
with:
36-
distribution: 'adopt'
37-
java-version: '11'
38-
39-
- uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa # [email protected]
40-
with:
41-
channel: ${{ matrix.sdk }}
42-
43-
- name: flutter upgrade
44-
run: flutter upgrade
45-
46-
- name: flutter pub get
47-
run: flutter pub get
48-
49-
- name: Gradle cache
50-
uses: gradle/gradle-build-action@v2
51-
52-
- name: AVD cache
53-
uses: actions/cache@v3
54-
id: avd-cache
55-
with:
56-
path: |
57-
~/.android/avd/*
58-
~/.android/adb*
31+
- name: checkout
32+
uses: actions/checkout@v3
33+
34+
- uses: actions/setup-java@v3
35+
with:
36+
distribution: 'adopt'
37+
java-version: '11'
38+
39+
- uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa # [email protected]
40+
with:
41+
channel: ${{ matrix.sdk }}
42+
43+
- name: flutter upgrade
44+
run: flutter upgrade
45+
46+
- name: flutter pub get
47+
run: flutter pub get
48+
49+
- name: Gradle cache
50+
uses: gradle/gradle-build-action@v2
51+
52+
- name: AVD cache
53+
uses: actions/cache@v3
54+
id: avd-cache
55+
with:
56+
path: |
57+
~/.android/avd/*
58+
~/.android/adb*
5959
key: avd-21
6060

61-
- name: create AVD and generate snapshot for caching
62-
if: steps.avd-cache.outputs.cache-hit != 'true'
63-
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #[email protected]
64-
with:
65-
working-directory: ./flutter/example
66-
api-level: 21
67-
force-avd-creation: false
68-
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
69-
disable-animations: false
70-
arch: x86_64
71-
profile: Nexus 6
72-
script: echo "Generated AVD snapshot for caching."
73-
74-
- name: launch android emulator & run android integration test
75-
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #[email protected]
76-
with:
77-
working-directory: ./flutter/example
78-
api-level: 21
79-
force-avd-creation: false
80-
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
81-
disable-animations: true
82-
arch: x86_64
83-
profile: Nexus 6
84-
script: flutter test integration_test/integration_test.dart --verbose
61+
- name: create AVD and generate snapshot for caching
62+
if: steps.avd-cache.outputs.cache-hit != 'true'
63+
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #[email protected]
64+
with:
65+
working-directory: ./flutter/example
66+
api-level: 21
67+
force-avd-creation: false
68+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
69+
disable-animations: false
70+
arch: x86_64
71+
profile: Nexus 6
72+
script: echo 'Generated AVD snapshot for caching.'
73+
74+
- name: launch android emulator & run android integration test
75+
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #[email protected]
76+
with:
77+
working-directory: ./flutter/example
78+
api-level: 21
79+
force-avd-creation: false
80+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
81+
disable-animations: true
82+
arch: x86_64
83+
profile: Nexus 6
84+
script: flutter test integration_test/integration_test.dart --verbose
8585

8686
test-ios:
8787
runs-on: macos-13

.github/workflows/web-example-ghpages.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
workingDir: flutter/example
2121
customArgs: --source-maps
2222
webRenderer: canvaskit
23+
baseHref: "/sentry-dart/"
2324

2425
- name: Upload source maps
2526
run: |

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Fixes
6+
7+
- Fixing memory leak issue in SentryFlutterPlugin (Android Plugin) ([#1588](https://github.com/getsentry/sentry-dart/pull/1588))
8+
9+
### Dependencies
10+
11+
- Bump Android SDK from v6.25.2 to v6.28.0 ([#1586](https://github.com/getsentry/sentry-dart/pull/1586))
12+
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#6280)
13+
- [diff](https://github.com/getsentry/sentry-java/compare/6.25.2...6.28.0)
14+
- Bump Cocoa SDK from v8.9.1 to v8.10.0 ([#1584](https://github.com/getsentry/sentry-dart/pull/1584), [#1606](https://github.com/getsentry/sentry-dart/pull/1606))
15+
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8100)
16+
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.9.1...8.10.0)
17+
318
## 7.9.0
419

520
### Features

flutter/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ android {
6060
}
6161

6262
dependencies {
63-
api 'io.sentry:sentry-android:6.25.2'
63+
api 'io.sentry:sentry-android:6.28.0'
6464
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
6565

6666
// Required -- JUnit 4 framework

flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutterPlugin.kt

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ import io.flutter.plugin.common.MethodChannel
1111
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
1212
import io.flutter.plugin.common.MethodChannel.Result
1313
import io.sentry.Breadcrumb
14+
import io.sentry.DateUtils
15+
import io.sentry.Hint
1416
import io.sentry.HubAdapter
17+
import io.sentry.Sentry
1518
import io.sentry.SentryEvent
1619
import io.sentry.SentryLevel
17-
import io.sentry.Sentry
18-
import io.sentry.DateUtils
20+
import io.sentry.SentryOptions
1921
import io.sentry.android.core.ActivityFramesTracker
2022
import io.sentry.android.core.AppStartState
2123
import io.sentry.android.core.BuildConfig.VERSION_NAME
@@ -26,7 +28,6 @@ import io.sentry.protocol.DebugImage
2628
import io.sentry.protocol.SdkVersion
2729
import io.sentry.protocol.SentryId
2830
import io.sentry.protocol.User
29-
import io.sentry.protocol.Geo
3031
import java.io.File
3132
import java.lang.ref.WeakReference
3233
import java.util.Locale
@@ -41,10 +42,6 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
4142
private var framesTracker: ActivityFramesTracker? = null
4243
private var autoPerformanceTracingEnabled = false
4344

44-
private val flutterSdk = "sentry.dart.flutter"
45-
private val androidSdk = "sentry.java.android.flutter"
46-
private val nativeSdk = "sentry.native.android.flutter"
47-
4845
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
4946
context = flutterPluginBinding.applicationContext
5047
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "sentry_flutter")
@@ -134,11 +131,7 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
134131
framesTracker = ActivityFramesTracker(LoadClass(), options)
135132
}
136133

137-
options.setBeforeSend { event, _ ->
138-
setEventOriginTag(event)
139-
addPackages(event, options.sdkVersion)
140-
event
141-
}
134+
options.beforeSend = BeforeSendCallbackImpl(options.sdkVersion)
142135
}
143136
result.success("")
144137
}
@@ -353,30 +346,50 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
353346
result.success("")
354347
}
355348

356-
private fun setEventOriginTag(event: SentryEvent) {
357-
event.sdk?.let {
358-
when (it.name) {
359-
flutterSdk -> setEventEnvironmentTag(event, "flutter", "dart")
360-
androidSdk -> setEventEnvironmentTag(event, environment = "java")
361-
nativeSdk -> setEventEnvironmentTag(event, environment = "native")
362-
else -> return
363-
}
349+
private class BeforeSendCallbackImpl(
350+
private val sdkVersion: SdkVersion?
351+
) : SentryOptions.BeforeSendCallback {
352+
override fun execute(event: SentryEvent, hint: Hint): SentryEvent {
353+
setEventOriginTag(event)
354+
addPackages(event, sdkVersion)
355+
return event
364356
}
365357
}
366358

367-
private fun setEventEnvironmentTag(event: SentryEvent, origin: String = "android", environment: String) {
368-
event.setTag("event.origin", origin)
369-
event.setTag("event.environment", environment)
370-
}
371-
372-
private fun addPackages(event: SentryEvent, sdk: SdkVersion?) {
373-
event.sdk?.let {
374-
if (it.name == flutterSdk) {
375-
sdk?.packageSet?.forEach { sentryPackage ->
376-
it.addPackage(sentryPackage.name, sentryPackage.version)
359+
companion object {
360+
361+
private const val flutterSdk = "sentry.dart.flutter"
362+
private const val androidSdk = "sentry.java.android.flutter"
363+
private const val nativeSdk = "sentry.native.android.flutter"
364+
private fun setEventOriginTag(event: SentryEvent) {
365+
event.sdk?.let {
366+
when (it.name) {
367+
flutterSdk -> setEventEnvironmentTag(event, "flutter", "dart")
368+
androidSdk -> setEventEnvironmentTag(event, environment = "java")
369+
nativeSdk -> setEventEnvironmentTag(event, environment = "native")
370+
else -> return
377371
}
378-
sdk?.integrationSet?.forEach { integration ->
379-
it.addIntegration(integration)
372+
}
373+
}
374+
375+
private fun setEventEnvironmentTag(
376+
event: SentryEvent,
377+
origin: String = "android",
378+
environment: String
379+
) {
380+
event.setTag("event.origin", origin)
381+
event.setTag("event.environment", environment)
382+
}
383+
384+
private fun addPackages(event: SentryEvent, sdk: SdkVersion?) {
385+
event.sdk?.let {
386+
if (it.name == flutterSdk) {
387+
sdk?.packageSet?.forEach { sentryPackage ->
388+
it.addPackage(sentryPackage.name, sentryPackage.version)
389+
}
390+
sdk?.integrationSet?.forEach { integration ->
391+
it.addIntegration(integration)
392+
}
380393
}
381394
}
382395
}

flutter/example/ios/Podfile

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
wanted_project_target = '11.0'
2-
31
# Uncomment this line to define a global platform for your project
4-
platform :ios, wanted_project_target
2+
platform :ios, '11.0'
53

64
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
75
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
@@ -43,15 +41,6 @@ target 'Runner' do
4341
end
4442

4543
post_install do |installer|
46-
# remove after https://github.com/flutter/flutter/issues/124340 getting into all channels
47-
installer.generated_projects.each do |project|
48-
project.targets.each do |target|
49-
target.build_configurations.each do |config|
50-
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = wanted_project_target
51-
end
52-
end
53-
end
54-
5544
installer.pods_project.targets.each do |target|
5645
flutter_additional_ios_build_settings(target)
5746
end

flutter/ios/Classes/SentryFlutterPluginApple.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ public class SentryFlutterPluginApple: NSObject, FlutterPlugin {
368368
}
369369

370370
private func fetchNativeAppStart(result: @escaping FlutterResult) {
371+
#if os(iOS) || os(tvOS)
371372
guard let appStartMeasurement = PrivateSentrySDKOnly.appStartMeasurement else {
372373
print("warning: appStartMeasurement is null")
373374
result(nil)
@@ -383,6 +384,10 @@ public class SentryFlutterPluginApple: NSObject, FlutterPlugin {
383384
]
384385

385386
result(item)
387+
#else
388+
print("note: appStartMeasurement not available on this platform")
389+
result(nil)
390+
#endif
386391
}
387392

388393
private var totalFrames: UInt = 0

flutter/ios/sentry_flutter.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ Pod::Spec.new do |s|
66
Sentry SDK for Flutter with support to native through sentry-cocoa.
77
DESC
88
s.homepage = 'https://sentry.io'
9-
s.license = { :file => '../LICENSE' }
9+
s.license = { :type => 'MIT', :file => '../LICENSE' }
1010
s.authors = "Sentry"
1111
s.source = { :git => "https://github.com/getsentry/sentry-dart.git",
1212
:tag => s.version.to_s }
1313
s.source_files = 'Classes/**/*'
1414
s.public_header_files = 'Classes/**/*.h'
15-
s.dependency 'Sentry/HybridSDK', '8.9.1'
15+
s.dependency 'Sentry/HybridSDK', '8.10.0'
1616
s.ios.dependency 'Flutter'
1717
s.osx.dependency 'FlutterMacOS'
1818
s.ios.deployment_target = '11.0'

0 commit comments

Comments
 (0)