Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/update min ios version 12 #1820

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
42 changes: 21 additions & 21 deletions .github/workflows/flutter_integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ jobs:
- name: flutter pub get
run: flutter pub get

- name: Gradle cache
uses: gradle/gradle-build-action@v2

- name: AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
- name: Gradle cache
uses: gradle/gradle-build-action@v2

- name: AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-21

- name: create AVD and generate snapshot for caching
Expand All @@ -73,17 +73,17 @@ jobs:
profile: Nexus 6
script: echo 'Generated AVD snapshot for caching.'

- name: launch android emulator & run android integration test
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #[email protected]
with:
working-directory: ./flutter/example
api-level: 21
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
arch: x86_64
profile: Nexus 6
script: flutter test integration_test/integration_test.dart --verbose
- name: launch android emulator & run android integration test
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #[email protected]
with:
working-directory: ./flutter/example
api-level: 21
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
arch: x86_64
profile: Nexus 6
script: flutter test integration_test/integration_test.dart --verbose

test-ios:
runs-on: macos-13
Expand Down
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
# Changelog

## Unreleased
## 8.0.0

### Breaking Changes

- Mark exceptions not handled by the user as `handled: false` ([#1535](https://github.com/getsentry/sentry-dart/pull/1535))
- This will affect your release health data, and is therefore considered a breaking change.
- Refrain from overwriting the span status for unfinished spans ([#1577](https://github.com/getsentry/sentry-dart/pull/1577))
- Older self-hosted sentry instances will drop transactions containing unfinished spans.
- 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))
- Make `hint` non-nullable in `BeforeSendCallback`, `BeforeBreadcrumbCall` and `EventProcessor` ([#1574](https://github.com/getsentry/sentry-dart/pull/1574))
- This will affect your callbacks, making this a breaking change.
- Load Device Contexts from Sentry Java ([#1616](https://github.com/getsentry/sentry-dart/pull/1616))
- Now the device context from Android is available in `BeforeSendCallback`
- Set ip_address to {{auto}} by default, even if sendDefaultPII is disabled ([#1665](https://github.com/getsentry/sentry-dart/pull/1665))
- Instead use the "Prevent Storing of IP Addresses" option in the "Security & Privacy" project settings on sentry.io

## Unreleased

### Fixes

- Fixing memory leak issue in SentryFlutterPlugin (Android Plugin) ([#1588](https://github.com/getsentry/sentry-dart/pull/1588))
Expand Down
2 changes: 1 addition & 1 deletion dart/example/bin/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Future<void> decode() async {

class TagEventProcessor implements EventProcessor {
@override
SentryEvent? apply(SentryEvent event, {hint}) {
SentryEvent? apply(SentryEvent event, hint) {
return event..tags?.addAll({'page-locale': 'en-us'});
}
}
2 changes: 1 addition & 1 deletion dart/example_web/web/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Future<void> parseData() async {

class TagEventProcessor implements EventProcessor {
@override
SentryEvent? apply(SentryEvent event, {hint}) {
SentryEvent? apply(SentryEvent event, Hint hint) {
return event..tags?.addAll({'page-locale': 'en-us'});
}
}
21 changes: 0 additions & 21 deletions dart/lib/src/client_reports/discard_reason.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,3 @@ enum DiscardReason {
cacheOverflow,
rateLimitBackoff,
}

extension OutcomeExtension on DiscardReason {
String toStringValue() {
switch (this) {
case DiscardReason.beforeSend:
return 'before_send';
case DiscardReason.eventProcessor:
return 'event_processor';
case DiscardReason.sampleRate:
return 'sample_rate';
case DiscardReason.networkError:
return 'network_error';
case DiscardReason.queueOverflow:
return 'queue_overflow';
case DiscardReason.cacheOverflow:
return 'cache_overflow';
case DiscardReason.rateLimitBackoff:
return 'ratelimit_backoff';
}
}
}
48 changes: 46 additions & 2 deletions dart/lib/src/client_reports/discarded_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,53 @@ class DiscardedEvent {

Map<String, dynamic> toJson() {
return {
'reason': reason.toStringValue(),
'category': category.toStringValue(),
'reason': reason._toStringValue(),
'category': category._toStringValue(),
'quantity': quantity,
};
}
}

extension _OutcomeExtension on DiscardReason {
String _toStringValue() {
switch (this) {
case DiscardReason.beforeSend:
return 'before_send';
case DiscardReason.eventProcessor:
return 'event_processor';
case DiscardReason.sampleRate:
return 'sample_rate';
case DiscardReason.networkError:
return 'network_error';
case DiscardReason.queueOverflow:
return 'queue_overflow';
case DiscardReason.cacheOverflow:
return 'cache_overflow';
case DiscardReason.rateLimitBackoff:
return 'ratelimit_backoff';
}
}
}

extension _DataCategoryExtension on DataCategory {
String _toStringValue() {
switch (this) {
case DataCategory.all:
return '__all__';
case DataCategory.dataCategoryDefault:
return 'default';
case DataCategory.error:
return 'error';
case DataCategory.session:
return 'session';
case DataCategory.transaction:
return 'transaction';
case DataCategory.attachment:
return 'attachment';
case DataCategory.security:
return 'security';
case DataCategory.unknown:
return 'unknown';
}
}
}
6 changes: 3 additions & 3 deletions dart/lib/src/event_processor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'protocol.dart';
/// null in case the event will be dropped and not sent.
abstract class EventProcessor {
FutureOr<SentryEvent?> apply(
SentryEvent event, {
Hint? hint,
});
SentryEvent event,
Hint hint,
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DeduplicationEventProcessor implements EventProcessor {
final SentryOptions _options;

@override
SentryEvent? apply(SentryEvent event, {Hint? hint}) {
SentryEvent? apply(SentryEvent event, Hint hint) {
if (event is SentryTransaction) {
return event;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class IoEnricherEventProcessor implements EnricherEventProcessor {
final SentryOptions _options;

@override
SentryEvent? apply(SentryEvent event, {Hint? hint}) {
SentryEvent? apply(SentryEvent event, Hint hint) {
// If there's a native integration available, it probably has better
// information available than Flutter.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class WebEnricherEventProcessor implements EnricherEventProcessor {
final SentryOptions _options;

@override
SentryEvent? apply(SentryEvent event, {Hint? hint}) {
SentryEvent? apply(SentryEvent event, Hint hint) {
// Web has no native integration, so no need to check for it

final contexts = event.contexts.copyWith(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class IoExceptionEventProcessor implements ExceptionEventProcessor {
final SentryOptions _options;

@override
SentryEvent? apply(SentryEvent event, {Hint? hint}) {
SentryEvent? apply(SentryEvent event, Hint hint) {
final throwable = event.throwable;
if (throwable is HttpException) {
return _applyHttpException(throwable, event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ ExceptionEventProcessor exceptionEventProcessor(SentryOptions _) =>

class WebExcptionEventProcessor implements ExceptionEventProcessor {
@override
SentryEvent apply(SentryEvent event, {Hint? hint}) => event;
SentryEvent apply(SentryEvent event, Hint hint) => event;
}
8 changes: 4 additions & 4 deletions dart/lib/src/hint.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import 'sentry_attachment/sentry_attachment.dart';
/// Example:
///
/// ```dart
/// options.beforeSend = (event, {hint}) {
/// final syntheticException = hint?.get(TypeCheckHint.syntheticException);
/// options.beforeSend = (event, hint) {
/// final syntheticException = hint.get(TypeCheckHint.syntheticException);
/// if (syntheticException is FlutterErrorDetails) {
/// // Do something with hint data
/// }
Expand All @@ -28,14 +28,14 @@ import 'sentry_attachment/sentry_attachment.dart';
/// ```dart
/// import 'dart:convert';
///
/// options.beforeSend = (event, {hint}) {
/// options.beforeSend = (event, hint) {
/// final text = 'This event should not be sent happen in prod. Investigate.';
/// final textAttachment = SentryAttachment.fromIntList(
/// utf8.encode(text),
/// 'event_info.txt',
/// contentType: 'text/plain',
/// );
/// hint?.attachments.add(textAttachment);
/// hint.attachments.add(textAttachment);
/// return event;
/// };
/// ```
Expand Down
4 changes: 2 additions & 2 deletions dart/lib/src/http_client/failed_request_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class FailedRequestClient extends BaseClient {

// Only check `failedRequestStatusCodes` & `failedRequestTargets` if no exception was thrown.
if (exception == null) {
if (!failedRequestStatusCodes.containsStatusCode(statusCode)) {
if (!failedRequestStatusCodes._containsStatusCode(statusCode)) {
return;
}
if (!containsTargetOrMatchesRegExp(
Expand Down Expand Up @@ -246,7 +246,7 @@ class FailedRequestClient extends BaseClient {
}

extension _ListX on List<SentryStatusCode> {
bool containsStatusCode(int? statusCode) {
bool _containsStatusCode(int? statusCode) {
if (statusCode == null) {
return false;
}
Expand Down
9 changes: 5 additions & 4 deletions dart/lib/src/protocol/sentry_request.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:meta/meta.dart';

import '../utils/iterable_extension.dart';
import '../utils/iterable_utils.dart';
import '../utils/http_sanitizer.dart';

/// The Request interface contains information on a HTTP request related to the event.
Expand Down Expand Up @@ -85,9 +85,10 @@ class SentryRequest {
_headers = headers != null ? Map.from(headers) : null,
// Look for a 'Set-Cookie' header (case insensitive) if not given.
cookies = cookies ??
headers?.entries
.firstWhereOrNull((e) => e.key.toLowerCase() == 'cookie')
?.value,
IterableUtils.firstWhereOrNull(
headers?.entries,
(MapEntry<String, String> e) => e.key.toLowerCase() == 'cookie',
)?.value,
_env = env != null ? Map.from(env) : null,
_other = other != null ? Map.from(other) : null;

Expand Down
10 changes: 6 additions & 4 deletions dart/lib/src/protocol/sentry_response.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:meta/meta.dart';
import 'contexts.dart';
import '../utils/iterable_extension.dart';
import '../utils/iterable_utils.dart';

/// The response interface contains information on a HTTP request related to the event.
@immutable
Expand Down Expand Up @@ -53,9 +53,11 @@ class SentryResponse {
_headers = headers != null ? Map.from(headers) : null,
// Look for a 'Set-Cookie' header (case insensitive) if not given.
cookies = cookies ??
headers?.entries
.firstWhereOrNull((e) => e.key.toLowerCase() == 'set-cookie')
?.value;
IterableUtils.firstWhereOrNull(
headers?.entries,
(MapEntry<String, String> e) =>
e.key.toLowerCase() == 'set-cookie',
)?.value;

/// Deserializes a [SentryResponse] from JSON [Map].
factory SentryResponse.fromJson(Map<String, dynamic> json) {
Expand Down
4 changes: 2 additions & 2 deletions dart/lib/src/run_zoned_guarded_integration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class RunZonedGuardedIntegration extends Integration<SentryOptions> {
stackTrace: stackTrace,
);

// runZonedGuarded doesn't crash the App.
final mechanism = Mechanism(type: 'runZonedGuarded', handled: true);
// runZonedGuarded doesn't crash the app, but is not handled by the user.
final mechanism = Mechanism(type: 'runZonedGuarded', handled: false);
final throwableMechanism = ThrowableMechanism(mechanism, exception);

final event = SentryEvent(
Expand Down
16 changes: 8 additions & 8 deletions dart/lib/src/scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class Scope {

Scope(this._options);

Breadcrumb? _addBreadCrumbSync(Breadcrumb breadcrumb, {Hint? hint}) {
Breadcrumb? _addBreadCrumbSync(Breadcrumb breadcrumb, Hint hint) {
// bail out if maxBreadcrumbs is zero
if (_options.maxBreadcrumbs == 0) {
return null;
Expand All @@ -155,7 +155,7 @@ class Scope {
try {
processedBreadcrumb = _options.beforeBreadcrumb!(
processedBreadcrumb,
hint: hint,
hint,
);
if (processedBreadcrumb == null) {
_options.logger(
Expand Down Expand Up @@ -189,7 +189,7 @@ class Scope {

/// Adds a breadcrumb to the breadcrumbs queue
Future<void> addBreadcrumb(Breadcrumb breadcrumb, {Hint? hint}) async {
final addedBreadcrumb = _addBreadCrumbSync(breadcrumb, hint: hint);
final addedBreadcrumb = _addBreadCrumbSync(breadcrumb, hint ?? Hint());
if (addedBreadcrumb != null) {
await _callScopeObservers((scopeObserver) async =>
await scopeObserver.addBreadcrumb(addedBreadcrumb));
Expand Down Expand Up @@ -275,9 +275,9 @@ class Scope {
}

Future<SentryEvent?> applyToEvent(
SentryEvent event, {
Hint? hint,
}) async {
SentryEvent event,
Hint hint,
) async {
event = event.copyWith(
transaction: event.transaction ?? transaction,
user: _mergeUsers(user, event.user),
Expand Down Expand Up @@ -320,7 +320,7 @@ class Scope {
SentryEvent? processedEvent = event;
for (final processor in _eventProcessors) {
try {
final e = processor.apply(processedEvent!, hint: hint);
final e = processor.apply(processedEvent!, hint);
if (e is Future<SentryEvent?>) {
processedEvent = await e;
} else {
Expand Down Expand Up @@ -429,7 +429,7 @@ class Scope {
}

for (final breadcrumb in List.from(_breadcrumbs)) {
clone._addBreadCrumbSync(breadcrumb);
clone._addBreadCrumbSync(breadcrumb, Hint());
}

for (final eventProcessor in List.from(_eventProcessors)) {
Expand Down
Loading
Loading