Skip to content

Commit

Permalink
Merge branch 'main' into enha/debug-enabled-by-default
Browse files Browse the repository at this point in the history
  • Loading branch information
buenaflor authored Jan 22, 2025
2 parents 75dc0c9 + 80734dc commit f13c18d
Show file tree
Hide file tree
Showing 70 changed files with 2,017 additions and 684 deletions.
3 changes: 3 additions & 0 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ targets:
hive:
drift:
isar:
link:
- name: github
- name: registry
sdks:
Expand All @@ -29,3 +30,5 @@ targets:
pub:sentry_drift:
pub:sentry_hive:
pub:sentry_isar:
# TODO: after we published link we need to add it to the registry repo and then uncomment here
# pub:sentry_link:
2 changes: 1 addition & 1 deletion .github/workflows/flutter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 # pin@v2.16.0
- uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff # pin@v2.18.0
with:
channel: main
- run: flutter upgrade
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/flutter_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ jobs:
chrome-version: stable
- run: chrome --version

- uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 # pin@v2.16.0
- uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff # pin@v2.18.0
with:
channel: ${{ matrix.sdk }}

Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/link.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: sentry-link
on:
push:
branches:
- main
- release/**
pull_request:
paths:
- '!**/*.md'
- '!**/class-diagram.svg'
- '.github/workflows/link.yml'
- '.github/workflows/analyze.yml'
- '.github/actions/dart-test/**'
- '.github/actions/coverage/**'
- 'dart/**'
- 'link/**'

jobs:
cancel-previous-workflow:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # [email protected]
with:
access_token: ${{ github.token }}

build:
name: '${{ matrix.os }} | ${{ matrix.sdk }}'
runs-on: ${{ matrix.os }}-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [macos, ubuntu, windows]
sdk: [stable, beta]

steps:
- uses: actions/checkout@v4

- uses: ./.github/actions/dart-test
with:
directory: link
web: false

# TODO: don't set coverage for now to finish publishing it
# - uses: ./.github/actions/coverage
# if: runner.os == 'Linux' && matrix.sdk == 'stable'
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# directory: link
# coverage: sentry_link
# min-coverage: 55

analyze:
uses: ./.github/workflows/analyze.yml
with:
package: link
panaThreshold: 90
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
steps:
- name: Get auth token
id: token
uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1.11.0
uses: actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1.11.1
with:
app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }}
private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff # [email protected]
- run: xcodes select 15.0.1
- uses: ruby/setup-ruby@401c19e14f474b54450cd3905bb8b86e2c8509cf # pin@v1.204.0
- uses: ruby/setup-ruby@28c4deda893d5a96a6b2d958c5b47fc18d65c9d3 # pin@v1.213.0
with:
ruby-version: '2.7.5'
bundler-cache: true
Expand Down
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

## Unreleased

### Enhancements

- Enable `options.debug` when in debug mode ([#2597](https://github.com/getsentry/sentry-dart/pull/2597))

### Fixes

- Fix image flickering when using `SentryAssetBundle` ([#2577](https://github.com/getsentry/sentry-dart/pull/2577))

### Misc

- Transfer ownership of `sentry_link` to Sentry. You can view the changelog for the previous versions [here](https://github.com/getsentry/sentry-dart/blob/main/sentry_link/CHANGELOG_OLD.md) ([#2338](https://github.com/getsentry/sentry-dart/pull/2338))
- No functional changes have been made. This version is identical to the previous one.
- Change license from Apache to MIT

## 8.13.0-beta.2

### Features

- Add SentryReplayQuality setting (`options.experimental.replay.quality`) ([#2582](https://github.com/getsentry/sentry-dart/pull/2582))
Expand All @@ -10,6 +26,8 @@
### Enhancements

- Enable `options.debug` when in debug mode ([#2597](https://github.com/getsentry/sentry-dart/pull/2597))
- Print a warning if the rate limit was reached ([#2595](https://github.com/getsentry/sentry-dart/pull/2595))
- Add replay masking config to tags and report SDKs versions ([#2592](https://github.com/getsentry/sentry-dart/pull/2592))

### Fixes

Expand All @@ -23,6 +41,9 @@
- Bump Android SDK from v7.20.0 to v7.20.1 ([#2593](https://github.com/getsentry/sentry-dart/pull/2593))
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#7201)
- [diff](https://github.com/getsentry/sentry-java/compare/7.20.0...7.20.1)
- Bump Cocoa SDK from v8.43.0 to v8.44.0-beta.1 ([#2598](https://github.com/getsentry/sentry-dart/pull/2598))
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8440-beta1)
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.43.0...8.44.0-beta.1)

## 8.13.0-beta.1

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020-2024 Sentry
Copyright (c) 2020-2025 Sentry

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
76 changes: 76 additions & 0 deletions dart/lib/src/event_processor/run_event_processors.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import 'package:meta/meta.dart';

import '../client_reports/discard_reason.dart';
import '../event_processor.dart';
import '../hint.dart';
import '../protocol/sentry_event.dart';
import '../protocol/sentry_level.dart';
import '../protocol/sentry_transaction.dart';
import '../sentry_options.dart';
import '../transport/data_category.dart';

@internal
Future<SentryEvent?> runEventProcessors(
SentryEvent event,
Hint hint,
List<EventProcessor> eventProcessors,
SentryOptions options,
) async {
int spanCountBeforeEventProcessors =
event is SentryTransaction ? event.spans.length : 0;

SentryEvent? processedEvent = event;
for (final processor in eventProcessors) {
try {
final e = processor.apply(processedEvent!, hint);
processedEvent = e is Future<SentryEvent?> ? await e : e;
} catch (exception, stackTrace) {
options.logger(
SentryLevel.error,
'An exception occurred while processing event by a processor',
exception: exception,
stackTrace: stackTrace,
);
if (options.automatedTestMode) {
rethrow;
}
}

final discardReason = DiscardReason.eventProcessor;
if (processedEvent == null) {
options.recorder.recordLostEvent(discardReason, _getCategory(event));
if (event is SentryTransaction) {
// We dropped the whole transaction, the dropped count includes all child spans + 1 root span
options.recorder.recordLostEvent(
discardReason,
DataCategory.span,
count: spanCountBeforeEventProcessors + 1,
);
}
options.logger(SentryLevel.debug, 'Event was dropped by a processor');
break;
} else if (event is SentryTransaction &&
processedEvent is SentryTransaction) {
// If event processor removed only some spans we still report them as dropped
final spanCountAfterEventProcessors = processedEvent.spans.length;
final droppedSpanCount =
spanCountBeforeEventProcessors - spanCountAfterEventProcessors;
if (droppedSpanCount > 0) {
options.recorder.recordLostEvent(
discardReason,
DataCategory.span,
count: droppedSpanCount,
);
}
}
}

return processedEvent;
}

DataCategory _getCategory(SentryEvent event) {
if (event is SentryTransaction) {
return DataCategory.transaction;
}
return DataCategory.error;
}
29 changes: 2 additions & 27 deletions dart/lib/src/scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'dart:collection';
import 'package:meta/meta.dart';

import 'event_processor.dart';
import 'event_processor/run_event_processors.dart';
import 'hint.dart';
import 'propagation_context.dart';
import 'protocol.dart';
Expand Down Expand Up @@ -341,33 +342,7 @@ class Scope {
}
}

SentryEvent? processedEvent = event;
for (final processor in _eventProcessors) {
try {
final e = processor.apply(processedEvent!, hint);
if (e is Future<SentryEvent?>) {
processedEvent = await e;
} else {
processedEvent = e;
}
} catch (exception, stackTrace) {
_options.logger(
SentryLevel.error,
'An exception occurred while processing event by a processor',
exception: exception,
stackTrace: stackTrace,
);
if (_options.automatedTestMode) {
rethrow;
}
}
if (processedEvent == null) {
_options.logger(SentryLevel.debug, 'Event was dropped by a processor');
break;
}
}

return processedEvent;
return await runEventProcessors(event, hint, _eventProcessors, _options);
}

/// Merge the scope contexts runtimes and the event contexts runtimes.
Expand Down
67 changes: 7 additions & 60 deletions dart/lib/src/sentry_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:meta/meta.dart';

import 'client_reports/client_report_recorder.dart';
import 'client_reports/discard_reason.dart';
import 'event_processor.dart';
import 'event_processor/run_event_processors.dart';
import 'hint.dart';
import 'protocol.dart';
import 'protocol/sentry_feedback.dart';
Expand Down Expand Up @@ -134,10 +134,11 @@ class SentryClient {
return _emptySentryId;
}

preparedEvent = await _runEventProcessors(
preparedEvent = await runEventProcessors(
preparedEvent,
hint,
eventProcessors: _options.eventProcessors,
_options.eventProcessors,
_options,
);

// dropped by event processors
Expand Down Expand Up @@ -374,10 +375,11 @@ class SentryClient {
return _emptySentryId;
}

preparedTransaction = await _runEventProcessors(
preparedTransaction = await runEventProcessors(
preparedTransaction,
hint,
eventProcessors: _options.eventProcessors,
_options.eventProcessors,
_options,
) as SentryTransaction?;

// dropped by event processors
Expand Down Expand Up @@ -551,61 +553,6 @@ class SentryClient {
return processedEvent;
}

Future<SentryEvent?> _runEventProcessors(
SentryEvent event,
Hint hint, {
required List<EventProcessor> eventProcessors,
}) async {
SentryEvent? processedEvent = event;
int spanCountBeforeEventProcessors =
event is SentryTransaction ? event.spans.length : 0;

for (final processor in eventProcessors) {
try {
final e = processor.apply(processedEvent!, hint);
if (e is Future<SentryEvent?>) {
processedEvent = await e;
} else {
processedEvent = e;
}
} catch (exception, stackTrace) {
_options.logger(
SentryLevel.error,
'An exception occurred while processing event by a processor',
exception: exception,
stackTrace: stackTrace,
);
if (_options.automatedTestMode) {
rethrow;
}
}

final discardReason = DiscardReason.eventProcessor;
if (processedEvent == null) {
_options.recorder.recordLostEvent(discardReason, _getCategory(event));
if (event is SentryTransaction) {
// We dropped the whole transaction, the dropped count includes all child spans + 1 root span
_options.recorder.recordLostEvent(discardReason, DataCategory.span,
count: spanCountBeforeEventProcessors + 1);
}
_options.logger(SentryLevel.debug, 'Event was dropped by a processor');
break;
} else if (event is SentryTransaction &&
processedEvent is SentryTransaction) {
// If event processor removed only some spans we still report them as dropped
final spanCountAfterEventProcessors = processedEvent.spans.length;
final droppedSpanCount =
spanCountBeforeEventProcessors - spanCountAfterEventProcessors;
if (droppedSpanCount > 0) {
_options.recorder.recordLostEvent(discardReason, DataCategory.span,
count: droppedSpanCount);
}
}
}

return processedEvent;
}

bool _sampleRate() {
if (_options.sampleRate != null && _random != null) {
return (_options.sampleRate! < _random!.nextDouble());
Expand Down
4 changes: 4 additions & 0 deletions dart/lib/src/transport/http_transport.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ class HttpTransport implements Transport {
if (response.statusCode == 200) {
return _parseEventId(response);
}
if (response.statusCode == 429) {
_options.logger(
SentryLevel.warning, 'Rate limit reached, failed to send envelope');
}
return SentryId.empty();
}

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.13.0-beta.1';
const String sdkVersion = '8.13.0-beta.2';

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

Expand Down
Loading

0 comments on commit f13c18d

Please sign in to comment.