Skip to content

Commit 76cee35

Browse files
committed
Merge branch 'main' into chore/format-and-analyze-check-only
2 parents 72e9520 + f370d52 commit 76cee35

File tree

6 files changed

+130
-96
lines changed

6 files changed

+130
-96
lines changed

.github/workflows/flutter_integration_test.yml

+58-58
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

+1
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

+15
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.9.4 ([#1584](https://github.com/getsentry/sentry-dart/pull/1584))
15+
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#894)
16+
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.9.1...8.9.4)
17+
318
## 7.9.0
419

520
### Features

flutter/android/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ 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
}

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

+54-36
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
@@ -40,10 +41,6 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
4041
private var framesTracker: ActivityFramesTracker? = null
4142
private var autoPerformanceTracingEnabled = false
4243

43-
private val flutterSdk = "sentry.dart.flutter"
44-
private val androidSdk = "sentry.java.android.flutter"
45-
private val nativeSdk = "sentry.native.android.flutter"
46-
4744
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
4845
context = flutterPluginBinding.applicationContext
4946
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "sentry_flutter")
@@ -127,9 +124,15 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
127124
args.getIfNotNull<String>("environment") { options.environment = it }
128125
args.getIfNotNull<String>("release") { options.release = it }
129126
args.getIfNotNull<String>("dist") { options.dist = it }
130-
args.getIfNotNull<Boolean>("enableAutoSessionTracking") { options.isEnableAutoSessionTracking = it }
131-
args.getIfNotNull<Long>("autoSessionTrackingIntervalMillis") { options.sessionTrackingIntervalMillis = it }
132-
args.getIfNotNull<Long>("anrTimeoutIntervalMillis") { options.anrTimeoutIntervalMillis = it }
127+
args.getIfNotNull<Boolean>("enableAutoSessionTracking") {
128+
options.isEnableAutoSessionTracking = it
129+
}
130+
args.getIfNotNull<Long>("autoSessionTrackingIntervalMillis") {
131+
options.sessionTrackingIntervalMillis = it
132+
}
133+
args.getIfNotNull<Long>("anrTimeoutIntervalMillis") {
134+
options.anrTimeoutIntervalMillis = it
135+
}
133136
args.getIfNotNull<Boolean>("attachThreads") { options.isAttachThreads = it }
134137
args.getIfNotNull<Boolean>("attachStacktrace") { options.isAttachStacktrace = it }
135138
args.getIfNotNull<Boolean>("enableAutoNativeBreadcrumbs") {
@@ -183,12 +186,7 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
183186
options.sdkVersion = sdkVersion
184187
options.sentryClientName = "$androidSdk/$VERSION_NAME"
185188
options.nativeSdkName = nativeSdk
186-
187-
options.setBeforeSend { event, _ ->
188-
setEventOriginTag(event)
189-
addPackages(event, options.sdkVersion)
190-
event
191-
}
189+
options.beforeSend = BeforeSendCallbackImpl(options.sdkVersion)
192190

193191
args.getIfNotNull<Int>("connectionTimeoutMillis") { options.connectionTimeoutMillis = it }
194192
args.getIfNotNull<Int>("readTimeoutMillis") { options.readTimeoutMillis = it }
@@ -408,30 +406,50 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
408406
result.success("")
409407
}
410408

411-
private fun setEventOriginTag(event: SentryEvent) {
412-
event.sdk?.let {
413-
when (it.name) {
414-
flutterSdk -> setEventEnvironmentTag(event, "flutter", "dart")
415-
androidSdk -> setEventEnvironmentTag(event, environment = "java")
416-
nativeSdk -> setEventEnvironmentTag(event, environment = "native")
417-
else -> return
418-
}
409+
private class BeforeSendCallbackImpl(
410+
private val sdkVersion: SdkVersion?
411+
) : SentryOptions.BeforeSendCallback {
412+
override fun execute(event: SentryEvent, hint: Hint): SentryEvent {
413+
setEventOriginTag(event)
414+
addPackages(event, sdkVersion)
415+
return event
419416
}
420417
}
421418

422-
private fun setEventEnvironmentTag(event: SentryEvent, origin: String = "android", environment: String) {
423-
event.setTag("event.origin", origin)
424-
event.setTag("event.environment", environment)
425-
}
426-
427-
private fun addPackages(event: SentryEvent, sdk: SdkVersion?) {
428-
event.sdk?.let {
429-
if (it.name == flutterSdk) {
430-
sdk?.packageSet?.forEach { sentryPackage ->
431-
it.addPackage(sentryPackage.name, sentryPackage.version)
419+
companion object {
420+
421+
private const val flutterSdk = "sentry.dart.flutter"
422+
private const val androidSdk = "sentry.java.android.flutter"
423+
private const val nativeSdk = "sentry.native.android.flutter"
424+
private fun setEventOriginTag(event: SentryEvent) {
425+
event.sdk?.let {
426+
when (it.name) {
427+
flutterSdk -> setEventEnvironmentTag(event, "flutter", "dart")
428+
androidSdk -> setEventEnvironmentTag(event, environment = "java")
429+
nativeSdk -> setEventEnvironmentTag(event, environment = "native")
430+
else -> return
432431
}
433-
sdk?.integrationSet?.forEach { integration ->
434-
it.addIntegration(integration)
432+
}
433+
}
434+
435+
private fun setEventEnvironmentTag(
436+
event: SentryEvent,
437+
origin: String = "android",
438+
environment: String
439+
) {
440+
event.setTag("event.origin", origin)
441+
event.setTag("event.environment", environment)
442+
}
443+
444+
private fun addPackages(event: SentryEvent, sdk: SdkVersion?) {
445+
event.sdk?.let {
446+
if (it.name == flutterSdk) {
447+
sdk?.packageSet?.forEach { sentryPackage ->
448+
it.addPackage(sentryPackage.name, sentryPackage.version)
449+
}
450+
sdk?.integrationSet?.forEach { integration ->
451+
it.addIntegration(integration)
452+
}
435453
}
436454
}
437455
}

flutter/ios/sentry_flutter.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Sentry SDK for Flutter with support to native through sentry-cocoa.
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.9.4'
1616
s.ios.dependency 'Flutter'
1717
s.osx.dependency 'FlutterMacOS'
1818
s.ios.deployment_target = '11.0'

0 commit comments

Comments
 (0)