Skip to content

Commit

Permalink
Merge branch 'main' into fix/flutter-multiview-support
Browse files Browse the repository at this point in the history
* main:
  release: 8.8.0
  chore: fix cocoa bump changelog (#2248)
  chore(deps): update Cocoa SDK to v8.35.1 (#2247)
  Provide a way to cause an example native crash from Flutter (#2239)
  • Loading branch information
martinhaintz committed Aug 27, 2024
2 parents caf888c + 103eb14 commit e449941
Show file tree
Hide file tree
Showing 28 changed files with 107 additions and 48 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Changelog

## Unreleased
## 8.8.0

### Features

- Add `SentryFlutter.nativeCrash()` using MethodChannels for Android and iOS ([#2239](https://github.com/getsentry/sentry-dart/pull/2239))
- This can be used to test if native crash reporting works
- Add `ignoreRoutes` parameter to `SentryNavigatorObserver`. ([#2218](https://github.com/getsentry/sentry-dart/pull/2218))
- This will ignore the Routes and prevent the Route from being pushed to the Sentry server.
- Ignored routes will also create no TTID and TTFD spans.
Expand All @@ -17,6 +19,9 @@ SentryNavigatorObserver(ignoreRoutes: ["/ignoreThisRoute"]),

### Dependencies

- Bump Cocoa SDK from v8.33.0 to v8.35.1 ([#2247](https://github.com/getsentry/sentry-dart/pull/2247))
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8351)
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.33.0...8.35.1)
- Bump Android SDK from v7.13.0 to v7.14.0 ([#2228](https://github.com/getsentry/sentry-dart/pull/2228))
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#7140)
- [diff](https://github.com/getsentry/sentry-java/compare/7.13.0...7.14.0)
Expand Down
2 changes: 1 addition & 1 deletion dart/lib/src/version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
library version;

/// The SDK version reported to Sentry.io in the submitted events.
const String sdkVersion = '8.7.0';
const String sdkVersion = '8.8.0';

String sdkName(bool isWeb) => isWeb ? _browserSdkName : _ioSdkName;

Expand Down
2 changes: 1 addition & 1 deletion dart/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sentry
version: 8.7.0
version: 8.8.0
description: >
A crash reporting library for Dart that sends crash reports to Sentry.io.
This library supports Dart VM and Web. For Flutter consider sentry_flutter instead.
Expand Down
2 changes: 1 addition & 1 deletion dio/lib/src/version.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// The SDK version reported to Sentry.io in the submitted events.
const String sdkVersion = '8.7.0';
const String sdkVersion = '8.8.0';

/// The package name reported to Sentry.io in the submitted events.
const String packageName = 'pub:sentry_dio';
4 changes: 2 additions & 2 deletions dio/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: sentry_dio
description: An integration which adds support for performance tracing for the Dio package.
version: 8.7.0
version: 8.8.0
homepage: https://docs.sentry.io/platforms/dart/
repository: https://github.com/getsentry/sentry-dart
issue_tracker: https://github.com/getsentry/sentry-dart/issues
Expand All @@ -19,7 +19,7 @@ platforms:

dependencies:
dio: ^5.0.0
sentry: 8.7.0
sentry: 8.8.0

dev_dependencies:
meta: ^1.3.0
Expand Down
2 changes: 1 addition & 1 deletion drift/lib/src/version.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// The SDK version reported to Sentry.io in the submitted events.
const String sdkVersion = '8.7.0';
const String sdkVersion = '8.8.0';

/// The package name reported to Sentry.io in the submitted events.
const String packageName = 'pub:sentry_drift';
4 changes: 2 additions & 2 deletions drift/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: sentry_drift
description: An integration which adds support for performance tracing for the drift package.
version: 8.7.0
version: 8.8.0
homepage: https://docs.sentry.io/platforms/flutter/
repository: https://github.com/getsentry/sentry-dart
issue_tracker: https://github.com/getsentry/sentry-dart/issues
Expand All @@ -17,7 +17,7 @@ platforms:
web:

dependencies:
sentry: 8.7.0
sentry: 8.8.0
meta: ^1.3.0
drift: ^2.13.0

Expand Down
2 changes: 1 addition & 1 deletion file/lib/src/version.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// The SDK version reported to Sentry.io in the submitted events.
const String sdkVersion = '8.7.0';
const String sdkVersion = '8.8.0';

/// The package name reported to Sentry.io in the submitted events.
const String packageName = 'pub:sentry_file';
4 changes: 2 additions & 2 deletions file/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: sentry_file
description: An integration which adds support for performance tracing for dart.io.File.
version: 8.7.0
version: 8.8.0
homepage: https://docs.sentry.io/platforms/dart/
repository: https://github.com/getsentry/sentry-dart
issue_tracker: https://github.com/getsentry/sentry-dart/issues
Expand All @@ -17,7 +17,7 @@ platforms:
windows:

dependencies:
sentry: 8.7.0
sentry: 8.8.0
meta: ^1.3.0

dev_dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package io.sentry.flutter
import android.app.Activity
import android.content.Context
import android.os.Build
import android.os.Looper
import android.util.Log
import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.embedding.engine.plugins.activity.ActivityAware
Expand Down Expand Up @@ -49,8 +50,8 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {

sentryFlutter =
SentryFlutter(
androidSdk = androidSdk,
nativeSdk = nativeSdk,
androidSdk = ANDROID_SDK,
nativeSdk = NATIVE_SDK,
)
}

Expand All @@ -74,6 +75,7 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
"removeTag" -> removeTag(call.argument("key"), result)
"loadContexts" -> loadContexts(result)
"displayRefreshRate" -> displayRefreshRate(result)
"nativeCrash" -> crash()
else -> result.notImplemented()
}
}
Expand Down Expand Up @@ -413,16 +415,17 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
}

companion object {
private const val FLUTTER_SDK = "sentry.dart.flutter"
private const val ANDROID_SDK = "sentry.java.android.flutter"
private const val NATIVE_SDK = "sentry.native.android.flutter"
private const val NATIVE_CRASH_WAIT_TIME = 500L

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")
FLUTTER_SDK -> setEventEnvironmentTag(event, "flutter", "dart")
ANDROID_SDK -> setEventEnvironmentTag(event, environment = "java")
NATIVE_SDK -> setEventEnvironmentTag(event, environment = "native")
else -> return
}
}
Expand All @@ -439,7 +442,7 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {

private fun addPackages(event: SentryEvent, sdk: SdkVersion?) {
event.sdk?.let {
if (it.name == flutterSdk) {
if (it.name == FLUTTER_SDK) {
sdk?.packageSet?.forEach { sentryPackage ->
it.addPackage(sentryPackage.name, sentryPackage.version)
}
Expand All @@ -449,6 +452,13 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
}
}
}

private fun crash() {
val exception = RuntimeException("FlutterSentry Native Integration: Sample RuntimeException")
val mainThread = Looper.getMainLooper().thread
mainThread.uncaughtExceptionHandler.uncaughtException(mainThread, exception)
mainThread.join(NATIVE_CRASH_WAIT_TIME)
}
}

private fun loadContexts(result: Result) {
Expand Down
12 changes: 12 additions & 0 deletions flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,12 @@ class AndroidExample extends StatelessWidget {
},
child: const Text('Platform exception'),
),
ElevatedButton(
onPressed: () async {
SentryFlutter.nativeCrash();
},
child: const Text('Sentry.nativeCrash'),
),
]);
}
}
Expand Down Expand Up @@ -873,6 +879,12 @@ class CocoaExample extends StatelessWidget {
},
child: const Text('Objective-C SEGFAULT'),
),
ElevatedButton(
onPressed: () async {
SentryFlutter.nativeCrash();
},
child: const Text('Sentry.nativeCrash'),
),
],
);
}
Expand Down
2 changes: 1 addition & 1 deletion flutter/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: sentry_flutter_example
description: Demonstrates how to use the sentry_flutter plugin.
version: 8.7.0
version: 8.8.0

publish_to: 'none' # Remove this line if you wish to publish to pub.dev

Expand Down
7 changes: 7 additions & 0 deletions flutter/ios/Classes/SentryFlutterPluginApple.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ public class SentryFlutterPluginApple: NSObject, FlutterPlugin {
case "resumeAppHangTracking":
resumeAppHangTracking(result)

case "nativeCrash":
crash()

default:
result(FlutterMethodNotImplemented)
}
Expand Down Expand Up @@ -729,6 +732,10 @@ public class SentryFlutterPluginApple: NSObject, FlutterPlugin {
SentrySDK.resumeAppHangTracking()
result("")
}

private func crash() {
SentrySDK.crash()
}
}

// swiftlint:enable function_body_length
Expand Down
2 changes: 1 addition & 1 deletion flutter/ios/sentry_flutter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Sentry SDK for Flutter with support to native through sentry-cocoa.
:tag => s.version.to_s }
s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Sentry/HybridSDK', '8.33.0'
s.dependency 'Sentry/HybridSDK', '8.35.1'
s.ios.dependency 'Flutter'
s.osx.dependency 'FlutterMacOS'
s.ios.deployment_target = '12.0'
Expand Down
2 changes: 2 additions & 0 deletions flutter/lib/src/native/sentry_native_binding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,6 @@ abstract class SentryNativeBinding {
Future<void> pauseAppHangTracking();

Future<void> resumeAppHangTracking();

Future<void> nativeCrash();
}
3 changes: 3 additions & 0 deletions flutter/lib/src/native/sentry_native_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,7 @@ class SentryNativeChannel
@override
Future<void> resumeAppHangTracking() =>
_channel.invokeMethod('resumeAppHangTracking');

@override
Future<void> nativeCrash() => _channel.invokeMethod('nativeCrash');
}
31 changes: 21 additions & 10 deletions flutter/lib/src/sentry_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,7 @@ mixin SentryFlutter {
/// Only for iOS and macOS.
static Future<void> pauseAppHangTracking() {
if (_native == null) {
// ignore: invalid_use_of_internal_member
Sentry.currentHub.options.logger(
SentryLevel.debug,
'Native integration is not available. Make sure SentryFlutter is initialized before accessing the pauseAppHangTracking API.',
);
_logNativeIntegrationNotAvailable("pauseAppHangTracking");
return Future<void>.value();
}
return _native!.pauseAppHangTracking();
Expand All @@ -263,11 +259,7 @@ mixin SentryFlutter {
/// Only for iOS and macOS
static Future<void> resumeAppHangTracking() {
if (_native == null) {
// ignore: invalid_use_of_internal_member
Sentry.currentHub.options.logger(
SentryLevel.debug,
'Native integration is not available. Make sure SentryFlutter is initialized before accessing the resumeAppHangTracking API.',
);
_logNativeIntegrationNotAvailable("resumeAppHangTracking");
return Future<void>.value();
}
return _native!.resumeAppHangTracking();
Expand All @@ -280,4 +272,23 @@ mixin SentryFlutter {
static set native(SentryNativeBinding? value) => _native = value;

static SentryNativeBinding? _native;

/// Use `nativeCrash()` to crash the native implementation and test/debug the crash reporting for native code.
/// This should not be used in production code.
/// Only for Android, iOS and macOS
static Future<void> nativeCrash() {
if (_native == null) {
_logNativeIntegrationNotAvailable("nativeCrash");
return Future<void>.value();
}
return _native!.nativeCrash();
}

static void _logNativeIntegrationNotAvailable(String methodName) {
// ignore: invalid_use_of_internal_member
Sentry.currentHub.options.logger(
SentryLevel.debug,
'Native integration is not available. Make sure SentryFlutter is initialized before accessing the $methodName API.',
);
}
}
2 changes: 1 addition & 1 deletion flutter/lib/src/version.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// The SDK version reported to Sentry.io in the submitted events.
const String sdkVersion = '8.7.0';
const String sdkVersion = '8.8.0';

/// The default SDK name reported to Sentry.io in the submitted events.
const String sdkName = 'sentry.dart.flutter';
4 changes: 2 additions & 2 deletions flutter/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sentry_flutter
version: 8.7.0
version: 8.8.0
description: Sentry SDK for Flutter. This package aims to support different Flutter targets by relying on the many platforms supported by Sentry with native SDKs.
homepage: https://docs.sentry.io/platforms/flutter/
repository: https://github.com/getsentry/sentry-dart
Expand All @@ -23,7 +23,7 @@ dependencies:
sdk: flutter
flutter_web_plugins:
sdk: flutter
sentry: 8.7.0
sentry: 8.8.0
package_info_plus: '>=1.0.0'
meta: ^1.3.0
ffi: ^2.0.0
Expand Down
9 changes: 9 additions & 0 deletions flutter/test/sentry_native_channel_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,15 @@ void main() {

verify(channel.invokeMethod('resumeAppHangTracking'));
});

test('nativeCrash', () async {
when(channel.invokeMethod('nativeCrash'))
.thenAnswer((_) => Future.value());

await sut.nativeCrash();

verify(channel.invokeMethod('nativeCrash'));
});
});
}
}
2 changes: 1 addition & 1 deletion hive/lib/src/version.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// The SDK version reported to Sentry.io in the submitted events.
const String sdkVersion = '8.7.0';
const String sdkVersion = '8.8.0';

/// The package name reported to Sentry.io in the submitted events.
const String packageName = 'pub:sentry_hive';
4 changes: 2 additions & 2 deletions hive/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: sentry_hive
description: An integration which adds support for performance tracing for the hive package.
version: 8.7.0
version: 8.8.0
homepage: https://docs.sentry.io/platforms/flutter/
repository: https://github.com/getsentry/sentry-dart
issue_tracker: https://github.com/getsentry/sentry-dart/issues
Expand All @@ -17,7 +17,7 @@ platforms:
web:

dependencies:
sentry: 8.7.0
sentry: 8.8.0
hive: ^2.2.3
meta: ^1.3.0

Expand Down
2 changes: 1 addition & 1 deletion isar/lib/src/version.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// The SDK version reported to Sentry.io in the submitted events.
const String sdkVersion = '8.7.0';
const String sdkVersion = '8.8.0';

/// The package name reported to Sentry.io in the submitted events.
const String packageName = 'pub:sentry_isar';
Loading

0 comments on commit e449941

Please sign in to comment.