Skip to content

Commit

Permalink
Merge branch 'main' into temp/8.13.2
Browse files Browse the repository at this point in the history
  • Loading branch information
buenaflor authored Feb 20, 2025
2 parents 4f01b1d + ea1d45d commit a03f158
Show file tree
Hide file tree
Showing 48 changed files with 540 additions and 137 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
working-directory: ${{ inputs.package }}
steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 # pin@v1
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c # pin@v1
if: ${{ inputs.sdk == 'dart' }}
- uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff # pin@v2.18.0
if: ${{ inputs.sdk == 'flutter' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/diagrams.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
name: "Create class diagrams of all packages"
steps:
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 # pin@v1
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c # pin@v1
with:
sdk: stable

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e_dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
matrix:
sdk: [stable, beta]
steps:
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 # pin@v1
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c # pin@v1
with:
sdk: ${{ matrix.sdk }}
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/flutter-symbols.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 # pin@v1
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c # pin@v1

- run: dart pub get

Expand All @@ -33,7 +33,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 # pin@v1
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c # pin@v1

- run: dart pub get

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 @@ -173,7 +173,7 @@ jobs:
uses: actions/checkout@v4

- name: Install Chrome Browser
uses: browser-actions/setup-chrome@facf10a55b9caf92e0cc749b4f82bf8220989148 # pin@v1.7.2
uses: browser-actions/setup-chrome@c785b87e244131f27c9f19c1a33e2ead956ab7ce # pin@v1.7.3
with:
chrome-version: stable
- run: chrome --version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/format-and-fix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
working-directory: ${{ matrix.package.name }}
steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94 # pin@v1
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c # pin@v1
if: ${{ matrix.package.sdk == 'dart' }}
- uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff # pin@v2.18.0
if: ${{ matrix.package.sdk == 'flutter' }}
Expand Down
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@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1.11.1
uses: actions/create-github-app-token@0d564482f06ca65fa9e77e2510873638c82206f2 # v1.11.5
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 # pin@v2.18.0
- run: xcodes select 15.0.1
- uses: ruby/setup-ruby@1287d2b408066abada82d5ad1c63652e758428d9 # pin@v1.214.0
- uses: ruby/setup-ruby@32110d4e311bd8996b2a82bf2a43b714ccc91777 # pin@v1.221.0
with:
ruby-version: '2.7.5'
bundler-cache: true
Expand Down
50 changes: 50 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,55 @@
# Changelog

## Unreleased

### Behavioral changes

- ⚠️ Auto IP assignment for `SentryUser` is now guarded by `sendDefaultPii` ([#2726](https://github.com/getsentry/sentry-dart/pull/2726))
- If you rely on Sentry automatically processing the IP address of the user, set `options.sendDefaultPii = true` or manually set the IP address of the `SentryUser` to `{{auto}}`

### Features

- Disable `ScreenshotIntegration`, `WidgetsBindingIntegration` and `SentryWidget` in multi-view apps #2366 ([#2366](https://github.com/getsentry/sentry-dart/pull/2366))

### Enhancements

- Use `loadDebugImagesForAddresses` API for Android ([#2706](https://github.com/getsentry/sentry-dart/pull/2706))
- This reduces the envelope size and data transferred across method channels
- If debug images received by `loadDebugImagesForAddresses` are empty, the SDK loads all debug images as fallback

### Fixes

- Reference to `SentryWidgetsFlutterBinding` in warning message in `FramesTrackingIntegration` ([#2704](https://github.com/getsentry/sentry-dart/pull/2704))

### Deprecations

- Deprecate Drift `SentryQueryExecutor` ([#2715](https://github.com/getsentry/sentry-dart/pull/2715))
- This will be replace by `SentryQueryInterceptor` in the next major v9
```dart
// Example usage in Sentry Flutter v9
final executor = NativeDatabase.memory().interceptWith(
SentryQueryInterceptor(databaseName: 'your_db_name'),
);
final db = AppDatabase(executor);
```
- Deprecate `autoAppStart` and `setAppStartEnd` ([#2681](https://github.com/getsentry/sentry-dart/pull/2681))

### Other

- Remove macOS display refresh rate support ([#2628](https://github.com/getsentry/sentry-dart/pull/2628))
- Can't reliably detect on multi-monitor systems and on older macOS versions.
- Not very meaningful, as other applications may be running in parallel and affecting it.

### Dependencies

- Bump Native SDK from v0.7.19 to v0.7.20 ([#2652](https://github.com/getsentry/sentry-dart/pull/2652))
- [changelog](https://github.com/getsentry/sentry-native/blob/master/CHANGELOG.md#0720)
- [diff](https://github.com/getsentry/sentry-native/compare/0.7.19...0.7.20)
- Bump Cocoa SDK from v8.44.0 to v8.45.0 ([#2718](https://github.com/getsentry/sentry-dart/pull/2718))
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8450)
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.44.0...8.45.0)

## 8.13.2

### Fixes
Expand Down
1 change: 1 addition & 0 deletions dart/example_web_legacy/web/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';
// ignore: deprecated_member_use
import 'dart:html';

import 'package:sentry/sentry.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ignore: deprecated_member_use
import 'dart:html' as html show window, Window;

import '../../../sentry.dart';
Expand Down
1 change: 1 addition & 0 deletions dart/lib/src/origin_html.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ignore: deprecated_member_use
import 'dart:html';

/// request origin, used for browser stacktrace
Expand Down
2 changes: 2 additions & 0 deletions dart/lib/src/platform/_html_platform.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// ignore: deprecated_member_use
import 'dart:html' as html;

import 'platform.dart';

const Platform instance = WebPlatform();
Expand Down
19 changes: 14 additions & 5 deletions dart/lib/src/sentry_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ import 'version.dart';
/// to true.
const _defaultIpAddress = '{{auto}}';

@visibleForTesting
String get defaultIpAddress => _defaultIpAddress;

/// Logs crash reports and events to the Sentry.io service.
class SentryClient {
final SentryOptions _options;
Expand Down Expand Up @@ -304,12 +307,18 @@ class SentryClient {
}

SentryEvent _createUserOrSetDefaultIpAddress(SentryEvent event) {
var user = event.user;
if (user == null) {
return event.copyWith(user: SentryUser(ipAddress: _defaultIpAddress));
} else if (event.user?.ipAddress == null) {
return event.copyWith(user: user.copyWith(ipAddress: _defaultIpAddress));
final user = event.user;
final effectiveIpAddress =
user?.ipAddress ?? (_options.sendDefaultPii ? _defaultIpAddress : null);

if (effectiveIpAddress != null) {
final updatedUser = user == null
? SentryUser(ipAddress: effectiveIpAddress)
: user.copyWith(ipAddress: effectiveIpAddress);

return event.copyWith(user: updatedUser);
}

return event;
}

Expand Down
47 changes: 42 additions & 5 deletions dart/test/sentry_client_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1003,16 +1003,17 @@ void main() {
});
});

group('SentryClient: sets user & user ip', () {
group('SentryClient: user & user ip', () {
late Fixture fixture;

setUp(() {
fixture = Fixture();
});

test('event has no user', () async {
test('event has no user and sendDefaultPii = true', () async {
final client = fixture.getSut(sendDefaultPii: true);
var fakeEvent = SentryEvent();
expect(fakeEvent.user, isNull);

await client.captureEvent(fakeEvent);

Expand All @@ -1021,12 +1022,27 @@ void main() {

expect(fixture.transport.envelopes.length, 1);
expect(capturedEvent.user, isNotNull);
expect(capturedEvent.user?.ipAddress, '{{auto}}');
expect(capturedEvent.user?.ipAddress, defaultIpAddress);
});

test('event has no user and sendDefaultPii = false', () async {
final client = fixture.getSut(sendDefaultPii: false);
var fakeEvent = SentryEvent();
expect(fakeEvent.user, isNull);

await client.captureEvent(fakeEvent);

final capturedEnvelope = fixture.transport.envelopes.first;
final capturedEvent = await eventFromEnvelope(capturedEnvelope);

expect(fixture.transport.envelopes.length, 1);
expect(capturedEvent.user, isNull);
});

test('event has a user with IP address', () async {
final client = fixture.getSut(sendDefaultPii: true);

expect(fakeEvent.user?.ipAddress, isNotNull);
await client.captureEvent(fakeEvent);

final capturedEnvelope = fixture.transport.envelopes.first;
Expand All @@ -1040,10 +1056,31 @@ void main() {
expect(capturedEvent.user?.email, fakeEvent.user!.email);
});

test('event has a user without IP address', () async {
test('event has a user without IP address and sendDefaultPii = true',
() async {
final client = fixture.getSut(sendDefaultPii: true);

final event = fakeEvent.copyWith(user: fakeUser);
expect(event.user?.ipAddress, isNull);

await client.captureEvent(event);

final capturedEnvelope = fixture.transport.envelopes.first;
final capturedEvent = await eventFromEnvelope(capturedEnvelope);

expect(fixture.transport.envelopes.length, 1);
expect(capturedEvent.user, isNotNull);
expect(capturedEvent.user?.ipAddress, defaultIpAddress);
expect(capturedEvent.user?.id, fakeUser.id);
expect(capturedEvent.user?.email, fakeUser.email);
});

test('event has a user without IP address and sendDefaultPii = false',
() async {
final client = fixture.getSut(sendDefaultPii: false);

final event = fakeEvent.copyWith(user: fakeUser);
expect(event.user?.ipAddress, isNull);

await client.captureEvent(event);

Expand All @@ -1052,7 +1089,7 @@ void main() {

expect(fixture.transport.envelopes.length, 1);
expect(capturedEvent.user, isNotNull);
expect(capturedEvent.user?.ipAddress, '{{auto}}');
expect(capturedEvent.user?.ipAddress, isNull);
expect(capturedEvent.user?.id, fakeUser.id);
expect(capturedEvent.user?.email, fakeUser.email);
});
Expand Down
3 changes: 3 additions & 0 deletions drift/lib/src/sentry_query_executor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ typedef DatabaseOpener = FutureOr<QueryExecutor> Function();
/// If the constructor parameter queryExecutor is null, [LazyDatabase] will be
/// used as a default.
@experimental
@Deprecated(
'This will be replaced by SentryQueryInterceptor in the next major v9 '
'where you can use executor.interceptWith(...) to attach the SentryQueryInterceptor')
class SentryQueryExecutor extends QueryExecutor {
Hub _hub;

Expand Down
3 changes: 2 additions & 1 deletion drift/lib/src/sentry_span_helper.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:meta/meta.dart';
// ignore_for_file: deprecated_member_use_from_same_package

import 'package:meta/meta.dart';
import 'package:sentry/sentry.dart';

import 'sentry_query_executor.dart';
Expand Down
2 changes: 1 addition & 1 deletion drift/test/sentry_database_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ignore_for_file: invalid_use_of_internal_member, library_annotations
// ignore_for_file: invalid_use_of_internal_member, library_annotations, deprecated_member_use_from_same_package

@TestOn('vm')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class SentryFlutterPlugin :
when (call.method) {
"initNativeSdk" -> initNativeSdk(call, result)
"captureEnvelope" -> captureEnvelope(call, result)
"loadImageList" -> loadImageList(result)
"loadImageList" -> loadImageList(call, result)
"closeNativeSdk" -> closeNativeSdk(result)
"fetchNativeAppStart" -> fetchNativeAppStart(result)
"beginNativeFrames" -> beginNativeFrames(result)
Expand Down Expand Up @@ -483,31 +483,43 @@ class SentryFlutterPlugin :
result.error("3", "Envelope is null or empty", null)
}

private fun loadImageList(result: Result) {
private fun loadImageList(
call: MethodCall,
result: Result,
) {
val options = HubAdapter.getInstance().options as SentryAndroidOptions

val newDebugImages = mutableListOf<Map<String, Any?>>()
val debugImages: List<DebugImage>? = options.debugImagesLoader.loadDebugImages()

debugImages?.let {
it.forEach { image ->
val item = mutableMapOf<String, Any?>()

item["image_addr"] = image.imageAddr
item["image_size"] = image.imageSize
item["code_file"] = image.codeFile
item["type"] = image.type
item["debug_id"] = image.debugId
item["code_id"] = image.codeId
item["debug_file"] = image.debugFile

newDebugImages.add(item)
val addresses = call.arguments() as List<String>? ?: listOf()
val debugImages =
if (addresses.isEmpty()) {
options.debugImagesLoader
.loadDebugImages()
?.toList()
.serialize()
} else {
options.debugImagesLoader
.loadDebugImagesForAddresses(addresses.toSet())
?.ifEmpty { options.debugImagesLoader.loadDebugImages() }
?.toList()
.serialize()
}
}

result.success(newDebugImages)
result.success(debugImages)
}

private fun List<DebugImage>?.serialize() = this?.map { it.serialize() }

private fun DebugImage.serialize() =
mapOf(
"image_addr" to imageAddr,
"image_size" to imageSize,
"code_file" to codeFile,
"type" to type,
"debug_id" to debugId,
"code_id" to codeId,
"debug_file" to debugFile,
)

private fun closeNativeSdk(result: Result) {
HubAdapter.getInstance().close()
framesTracker?.stop()
Expand Down
Loading

0 comments on commit a03f158

Please # to comment.