Skip to content

Commit

Permalink
Merge branch 'release/8.0.0' into enha/dont-leak-extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
denrase committed Aug 29, 2023
2 parents 7630cb0 + 852a85e commit 80ab768
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 95 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @marandaneto @krystofwoldrich @stefanosiano
* @krystofwoldrich @stefanosiano @buenaflor
2 changes: 1 addition & 1 deletion .github/workflows/flutter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ jobs:
steps:
- uses: actions/checkout@v3
# https://github.com/CocoaPods/CocoaPods/issues/5275#issuecomment-315461879
- run: pod lib lint ios/sentry_flutter.podspec --configuration=Debug --skip-import-validation --allow-warnings
- run: pod lib lint ios/sentry_flutter.podspec --configuration=Debug --skip-import-validation --allow-warnings --verbose

swift-lint:
runs-on: ubuntu-latest
Expand Down
80 changes: 41 additions & 39 deletions .github/workflows/flutter_integration_test.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name: flutter integration tests
on:
push:
branches:
- main
- release/**
pull_request:
paths-ignore:
- 'file/**'
# Currently broken, enable after fixing
workflow_dispatch
# push:
# branches:
# - main
# - release/**
# pull_request:
# paths-ignore:
# - 'file/**'

jobs:
cancel-previous-workflow:
Expand All @@ -16,35 +18,35 @@ jobs:
uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 # pin@0.11.0
with:
access_token: ${{ github.token }}

test-android:
runs-on: macos-latest
timeout-minutes: 30
defaults:
run:
working-directory: ./flutter/example
run:
working-directory: ./flutter/example
strategy:
fail-fast: false
matrix:
sdk: ['stable', 'beta']
fail-fast: false
matrix:
sdk: ["stable", "beta"]
steps:
- name: checkout
uses: actions/checkout@v3
- name: checkout
uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '11'
- uses: actions/setup-java@v3
with:
distribution: "adopt"
java-version: "11"

- uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa # pin@v2.10.0
with:
channel: ${{ matrix.sdk }}
- uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa # pin@v2.10.0
with:
channel: ${{ matrix.sdk }}

- name: flutter upgrade
run: flutter upgrade
- name: flutter upgrade
run: flutter upgrade

- name: flutter pub get
run: flutter pub get
- name: flutter pub get
run: flutter pub get

- name: Gradle cache
uses: gradle/gradle-build-action@v2
Expand All @@ -58,18 +60,18 @@ jobs:
~/.android/adb*
key: avd-21
- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #pin@v2.28.0
with:
working-directory: ./flutter/example
api-level: 21
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
arch: x86_64
profile: Nexus 6
script: echo "Generated AVD snapshot for caching."
- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #pin@v2.28.0
with:
working-directory: ./flutter/example
api-level: 21
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
arch: x86_64
profile: Nexus 6
script: echo 'Generated AVD snapshot for caching.'

- name: launch android emulator & run android integration test
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #pin@v2.28.0
Expand All @@ -93,7 +95,7 @@ jobs:
fail-fast: false
matrix:
# 'beta' is flaky because of https://github.com/flutter/flutter/issues/124340
sdk: ['stable']
sdk: ["stable"]
steps:
- name: checkout
uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/web-example-ghpages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
workingDir: flutter/example
customArgs: --source-maps
webRenderer: canvaskit
baseHref: "/sentry-dart/"

- name: Upload source maps
run: |
Expand Down
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,23 @@
- This change was introduced in [relay/#1690](https://github.com/getsentry/relay/pull/1690) and released with [22.12.0](https://github.com/getsentry/relay/releases/tag/22.12.0)
- Do not leak extensions of external classes ([#1576](https://github.com/getsentry/sentry-dart/pull/1576))

## 7.9.0
## Unreleased

### Fixes

- Fixing memory leak issue in SentryFlutterPlugin (Android Plugin) ([#1588](https://github.com/getsentry/sentry-dart/pull/1588))

### Dependencies

- Bump Android SDK from v6.25.2 to v6.28.0 ([#1586](https://github.com/getsentry/sentry-dart/pull/1586))
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#6280)
- [diff](https://github.com/getsentry/sentry-java/compare/6.25.2...6.28.0)
- 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))
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8100)
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.9.1...8.10.0)

## 7.9.0

### Features

- Send trace origin ([#1534](https://github.com/getsentry/sentry-dart/pull/1534))
Expand Down
2 changes: 1 addition & 1 deletion flutter/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ android {
}

dependencies {
api 'io.sentry:sentry-android:6.25.2'
api 'io.sentry:sentry-android:6.28.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ import io.flutter.plugin.common.MethodChannel
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
import io.flutter.plugin.common.MethodChannel.Result
import io.sentry.Breadcrumb
import io.sentry.DateUtils
import io.sentry.Hint
import io.sentry.HubAdapter
import io.sentry.Sentry
import io.sentry.SentryEvent
import io.sentry.SentryLevel
import io.sentry.Sentry
import io.sentry.DateUtils
import io.sentry.SentryOptions
import io.sentry.android.core.ActivityFramesTracker
import io.sentry.android.core.AppStartState
import io.sentry.android.core.BuildConfig.VERSION_NAME
Expand All @@ -26,7 +28,6 @@ import io.sentry.protocol.DebugImage
import io.sentry.protocol.SdkVersion
import io.sentry.protocol.SentryId
import io.sentry.protocol.User
import io.sentry.protocol.Geo
import java.io.File
import java.lang.ref.WeakReference
import java.util.Locale
Expand All @@ -40,10 +41,6 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
private var framesTracker: ActivityFramesTracker? = null
private var autoPerformanceTracingEnabled = false

private val flutterSdk = "sentry.dart.flutter"
private val androidSdk = "sentry.java.android.flutter"
private val nativeSdk = "sentry.native.android.flutter"

override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
context = flutterPluginBinding.applicationContext
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "sentry_flutter")
Expand Down Expand Up @@ -127,9 +124,15 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
args.getIfNotNull<String>("environment") { options.environment = it }
args.getIfNotNull<String>("release") { options.release = it }
args.getIfNotNull<String>("dist") { options.dist = it }
args.getIfNotNull<Boolean>("enableAutoSessionTracking") { options.isEnableAutoSessionTracking = it }
args.getIfNotNull<Long>("autoSessionTrackingIntervalMillis") { options.sessionTrackingIntervalMillis = it }
args.getIfNotNull<Long>("anrTimeoutIntervalMillis") { options.anrTimeoutIntervalMillis = it }
args.getIfNotNull<Boolean>("enableAutoSessionTracking") {
options.isEnableAutoSessionTracking = it
}
args.getIfNotNull<Long>("autoSessionTrackingIntervalMillis") {
options.sessionTrackingIntervalMillis = it
}
args.getIfNotNull<Long>("anrTimeoutIntervalMillis") {
options.anrTimeoutIntervalMillis = it
}
args.getIfNotNull<Boolean>("attachThreads") { options.isAttachThreads = it }
args.getIfNotNull<Boolean>("attachStacktrace") { options.isAttachStacktrace = it }
args.getIfNotNull<Boolean>("enableAutoNativeBreadcrumbs") {
Expand Down Expand Up @@ -183,12 +186,7 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
options.sdkVersion = sdkVersion
options.sentryClientName = "$androidSdk/$VERSION_NAME"
options.nativeSdkName = nativeSdk

options.setBeforeSend { event, _ ->
setEventOriginTag(event)
addPackages(event, options.sdkVersion)
event
}
options.beforeSend = BeforeSendCallbackImpl(options.sdkVersion)

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

private fun setEventOriginTag(event: SentryEvent) {
event.sdk?.let {
when (it.name) {
flutterSdk -> setEventEnvironmentTag(event, "flutter", "dart")
androidSdk -> setEventEnvironmentTag(event, environment = "java")
nativeSdk -> setEventEnvironmentTag(event, environment = "native")
else -> return
}
private class BeforeSendCallbackImpl(
private val sdkVersion: SdkVersion?
) : SentryOptions.BeforeSendCallback {
override fun execute(event: SentryEvent, hint: Hint): SentryEvent {
setEventOriginTag(event)
addPackages(event, sdkVersion)
return event
}
}

private fun setEventEnvironmentTag(event: SentryEvent, origin: String = "android", environment: String) {
event.setTag("event.origin", origin)
event.setTag("event.environment", environment)
}

private fun addPackages(event: SentryEvent, sdk: SdkVersion?) {
event.sdk?.let {
if (it.name == flutterSdk) {
sdk?.packageSet?.forEach { sentryPackage ->
it.addPackage(sentryPackage.name, sentryPackage.version)
companion object {

private const val flutterSdk = "sentry.dart.flutter"
private const val androidSdk = "sentry.java.android.flutter"
private const val nativeSdk = "sentry.native.android.flutter"
private fun setEventOriginTag(event: SentryEvent) {
event.sdk?.let {
when (it.name) {
flutterSdk -> setEventEnvironmentTag(event, "flutter", "dart")
androidSdk -> setEventEnvironmentTag(event, environment = "java")
nativeSdk -> setEventEnvironmentTag(event, environment = "native")
else -> return
}
sdk?.integrationSet?.forEach { integration ->
it.addIntegration(integration)
}
}

private fun setEventEnvironmentTag(
event: SentryEvent,
origin: String = "android",
environment: String
) {
event.setTag("event.origin", origin)
event.setTag("event.environment", environment)
}

private fun addPackages(event: SentryEvent, sdk: SdkVersion?) {
event.sdk?.let {
if (it.name == flutterSdk) {
sdk?.packageSet?.forEach { sentryPackage ->
it.addPackage(sentryPackage.name, sentryPackage.version)
}
sdk?.integrationSet?.forEach { integration ->
it.addIntegration(integration)
}
}
}
}
Expand Down
12 changes: 10 additions & 2 deletions flutter/example/integration_test/integration_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: avoid_print

import 'dart:async';
import 'dart:convert';

Expand Down Expand Up @@ -160,6 +162,7 @@ void main() {
final uri = Uri.parse(
'https://sentry.io/api/0/projects/$org/$slug/events/$id/',
);
expect(authToken, isNotEmpty);

final event = await fixture.poll(uri, authToken);
expect(event, isNotNull);
Expand Down Expand Up @@ -206,26 +209,31 @@ class Fixture {

const maxRetries = 10;
const initialDelay = Duration(seconds: 2);
const factor = 2;
const delayIncrease = Duration(seconds: 2);

var retries = 0;
var delay = initialDelay;

while (retries < maxRetries) {
try {
print("Trying to fetch $url [try $retries/$maxRetries]");
final response = await client.get(
url,
headers: <String, String>{'Authorization': 'Bearer $authToken'},
);
print("Response status code: ${response.statusCode}");
if (response.statusCode == 200) {
return jsonDecode(utf8.decode(response.bodyBytes));
} else if (response.statusCode == 401) {
print("Cannot fetch $url - invalid auth token.");
break;
}
} catch (e) {
// Do nothing
} finally {
retries++;
await Future.delayed(delay);
delay *= factor;
delay += delayIncrease;
}
}
return null;
Expand Down
13 changes: 1 addition & 12 deletions flutter/example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
wanted_project_target = '11.0'

# Uncomment this line to define a global platform for your project
platform :ios, wanted_project_target
platform :ios, '11.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down Expand Up @@ -37,15 +35,6 @@ target 'Runner' do
end

post_install do |installer|
# remove after https://github.com/flutter/flutter/issues/124340 getting into all channels
installer.generated_projects.each do |project|
project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = wanted_project_target
end
end
end

installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
Expand Down
Loading

0 comments on commit 80ab768

Please sign in to comment.