Skip to content

Commit 40680d3

Browse files
marandanetoManoel Aranda Neto
and
Manoel Aranda Neto
authored
Add support for sqflite (#1306)
Co-authored-by: Manoel Aranda Neto <[email protected]>
1 parent 934b4d9 commit 40680d3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+4363
-40
lines changed

.craft.yml

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ targets:
1010
logging:
1111
dio:
1212
file:
13+
sqflite:
1314
- name: github
1415
- name: registry
1516
sdks:
@@ -18,3 +19,4 @@ targets:
1819
pub:sentry_logging:
1920
pub:sentry_dio:
2021
pub:sentry_file:
22+
pub:sentry_sqflite:

.github/workflows/dart.yml

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
paths-ignore:
99
- 'logging/**'
1010
- 'dio/**'
11+
- 'file/**'
12+
- 'sqflite/**'
1113

1214
jobs:
1315
cancel-previous-workflow:

.github/workflows/dio.yml

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
paths-ignore:
99
- 'logging/**'
1010
- 'flutter/**'
11+
- 'file/**'
12+
- 'sqflite/**'
1113

1214
jobs:
1315
cancel-previous-workflow:

.github/workflows/e2e_dart.yml

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
- 'logging/**'
1010
- 'dio/**'
1111
- 'flutter/**'
12+
- 'file/**'
13+
- 'sqflite/**'
1214

1315
env:
1416
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}

.github/workflows/file.yml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
- 'logging/**'
1010
- 'flutter/**'
1111
- 'dio/**'
12+
- 'sqflite/**'
1213

1314
jobs:
1415
cancel-previous-workflow:

.github/workflows/flutter.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
paths-ignore:
99
- 'logging/**'
1010
- 'dio/**'
11+
- 'file/**'
12+
- 'sqflite/**'
1113

1214
jobs:
1315
cancel-previous-workflow:
@@ -62,9 +64,10 @@ jobs:
6264
- uses: actions/checkout@v3
6365

6466
- uses: actions/setup-java@v3
67+
if: ${{ matrix.target == 'android' }}
6568
with:
69+
java-version: '11'
6670
distribution: 'adopt'
67-
java-version: '8'
6871

6972
# Install required dependencies for Flutter on Linux on Ubuntu
7073
- name: 'Setup Linux'

.github/workflows/flutter_integration_test.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ on:
33
push:
44
branches:
55
- main
6+
- release/**
67
pull_request:
8+
paths-ignore:
9+
- 'file/**'
710

811
jobs:
912
cancel-previous-workflow:
@@ -29,7 +32,7 @@ jobs:
2932
- uses: actions/setup-java@v3
3033
with:
3134
distribution: 'adopt'
32-
java-version: '8'
35+
java-version: '11'
3336

3437
- uses: subosito/flutter-action@1e6ee87cb840500837bcd50a667fb28815d8e310 # pin@v2
3538
with:

.github/workflows/logging.yml

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
paths-ignore:
99
- 'dio/**'
1010
- 'flutter/**'
11+
- 'file/**'
12+
- 'sqflite/**'
1113

1214
jobs:
1315
cancel-previous-workflow:

.github/workflows/min_version_test.yml

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
- main
66
- release/**
77
pull_request:
8+
paths-ignore:
9+
- 'file/**'
10+
- 'sqflite/**'
811

912
jobs:
1013
cancel-previous-workflow:

.github/workflows/sqflite.yml

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: sentry-sqflite
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- release/**
7+
pull_request:
8+
paths-ignore:
9+
- 'logging/**'
10+
- 'flutter/**'
11+
- 'dio/**'
12+
- 'file/**'
13+
14+
jobs:
15+
cancel-previous-workflow:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Cancel Previous Runs
19+
uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 # [email protected]
20+
with:
21+
access_token: ${{ github.token }}
22+
23+
build:
24+
name: ${{ matrix.target }} | ${{ matrix.os }} | ${{ matrix.sdk }}
25+
runs-on: ${{ matrix.os }}
26+
timeout-minutes: 30
27+
defaults:
28+
run:
29+
shell: bash
30+
strategy:
31+
fail-fast: false
32+
# max-parallel: 4
33+
matrix:
34+
os: [ubuntu-latest, windows-latest, macos-latest]
35+
target: ['ios', 'android', 'macos', 'linux', 'windows']
36+
sdk: ['stable', 'beta']
37+
exclude:
38+
- os: ubuntu-latest
39+
target: ios
40+
- os: ubuntu-latest
41+
target: macos
42+
- os: ubuntu-latest
43+
target: windows
44+
- os: windows-latest
45+
target: ios
46+
- os: windows-latest
47+
target: macos
48+
- os: windows-latest
49+
target: linux
50+
# macos-latest is taking hours due to limited resources
51+
- os: macos-latest
52+
target: android
53+
- os: macos-latest
54+
target: web
55+
- os: macos-latest
56+
target: linux
57+
- os: macos-latest
58+
target: windows
59+
# Bad CPU type in executable
60+
- os: macos-latest
61+
sdk: beta
62+
63+
steps:
64+
- uses: actions/checkout@v3
65+
66+
- uses: actions/setup-java@v3
67+
if: ${{ matrix.target == 'android' }}
68+
with:
69+
java-version: '11'
70+
distribution: 'adopt'
71+
72+
# Install required dependencies for Flutter on Linux on Ubuntu
73+
- name: 'Setup Linux'
74+
run: |
75+
sudo apt update
76+
sudo apt install -y cmake dbus libblkid-dev libgtk-3-dev liblzma-dev ninja-build pkg-config xvfb
77+
sudo apt install -y network-manager upower
78+
if: matrix.os == 'ubuntu-latest'
79+
80+
- uses: subosito/flutter-action@dbf1fa04f4d2e52c33185153d06cdb5443aa189d # pin@v2
81+
with:
82+
channel: ${{ matrix.sdk }}
83+
84+
- run: flutter upgrade
85+
86+
- name: Pub Get
87+
run: |
88+
cd sqflite
89+
flutter pub get
90+
91+
- name: Test VM with coverage
92+
if: runner.os != 'macOS'
93+
run: |
94+
cd sqflite
95+
flutter test --coverage --test-randomize-ordering-seed=random
96+
97+
- uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # pin@v3
98+
if: runner.os == 'Linux' && matrix.sdk == 'stable' && matrix.target == 'linux'
99+
with:
100+
name: sentry_sqflite
101+
file: ./sqflite/coverage/lcov.info
102+
functionalities: 'search' # remove after https://github.com/codecov/codecov-action/issues/600
103+
104+
- uses: VeryGoodOpenSource/very_good_coverage@84e5b54ab888644554e5573dca87d7f76dec9fb3 # [email protected]
105+
if: runner.os == 'Linux' && matrix.sdk == 'stable' && matrix.target == 'linux'
106+
with:
107+
path: './sqflite/coverage/lcov.info'
108+
min_coverage: 80
109+
110+
analyze:
111+
uses: ./.github/workflows/analyze.yml
112+
with:
113+
package: sqflite
114+
sdk: flutter

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ dart/coverage/*
2020
logging/coverage/*
2121
dio/coverage/*
2222
file/coverage/*
23+
flutter/coverage/*
24+
sqflite/coverage/*
25+
2326
pubspec.lock
2427
Podfile.lock
25-
flutter/coverage/*
2628

2729
.gradle
2830
flutter/.gradle

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Features
6+
7+
- sqflite Support for Flutter ([#1306](https://github.com/getsentry/sentry-dart/pull/1306))
8+
59
### Fixes
610

711
- LoadImageListIntegration won't throw bad state if there is no exceptions in the event ([#1347](https://github.com/getsentry/sentry-dart/pull/1347))

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Sentry SDK for Dart and Flutter
2121
| sentry_logging | [![build](https://github.com/getsentry/sentry-dart/workflows/sentry-logging/badge.svg?branch=main)](https://github.com/getsentry/sentry-dart/actions?query=workflow%3Alogging) | [![pub package](https://img.shields.io/pub/v/sentry_logging.svg)](https://pub.dev/packages/sentry_logging) | [![likes](https://img.shields.io/pub/likes/sentry_logging?logo=dart)](https://pub.dev/packages/sentry_logging/score) | [![popularity](https://img.shields.io/pub/popularity/sentry_logging?logo=dart)](https://pub.dev/packages/sentry_logging/score) | [![pub points](https://img.shields.io/pub/points/sentry_logging?logo=dart)](https://pub.dev/packages/sentry_logging/score)
2222
| sentry_dio | [![build](https://github.com/getsentry/sentry-dart/workflows/sentry-dio/badge.svg?branch=main)](https://github.com/getsentry/sentry-dart/actions?query=workflow%3Asentry-dio) | [![pub package](https://img.shields.io/pub/v/sentry_dio.svg)](https://pub.dev/packages/sentry_dio) | [![likes](https://img.shields.io/pub/likes/sentry_dio?logo=dart)](https://pub.dev/packages/sentry_dio/score) | [![popularity](https://img.shields.io/pub/popularity/sentry_dio?logo=dart)](https://pub.dev/packages/sentry_dio/score) | [![pub points](https://img.shields.io/pub/points/sentry_dio?logo=dart)](https://pub.dev/packages/sentry_dio/score)
2323
| sentry_file | [![build](https://github.com/getsentry/sentry-dart/workflows/sentry-file/badge.svg?branch=main)](https://github.com/getsentry/sentry-dart/actions?query=workflow%3Asentry-file) | [![pub package](https://img.shields.io/pub/v/sentry_file.svg)](https://pub.dev/packages/sentry_file) | [![likes](https://img.shields.io/pub/likes/sentry_file?logo=dart)](https://pub.dev/packages/sentry_file/score) | [![popularity](https://img.shields.io/pub/popularity/sentry_file?logo=dart)](https://pub.dev/packages/sentry_file/score) | [![pub points](https://img.shields.io/pub/points/sentry_file?logo=dart)](https://pub.dev/packages/sentry_file/score)
24+
| sentry_sqflite | [![build](https://github.com/getsentry/sentry-dart/workflows/sentry-sqflite/badge.svg?branch=main)](https://github.com/getsentry/sentry-dart/actions?query=workflow%3Asentry-sqflite) | [![pub package](https://img.shields.io/pub/v/sentry_sqflite.svg)](https://pub.dev/packages/sentry_sqflite) | [![likes](https://img.shields.io/pub/likes/sentry_sqflite)](https://pub.dev/packages/sentry_sqflite/score) | [![popularity](https://img.shields.io/pub/popularity/sentry_sqflite)](https://pub.dev/packages/sentry_sqflite/score) | [![pub points](https://img.shields.io/pub/points/sentry_sqflite)](https://pub.dev/packages/sentry_sqflite/score)
2425

2526
##### Usage
2627

dart/lib/src/protocol/sdk_version.dart

+6
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ class SdkVersion {
8888

8989
/// Adds a package
9090
void addPackage(String name, String version) {
91+
for (final item in _packages) {
92+
if (item.name == name && item.version == version) {
93+
return;
94+
}
95+
}
96+
9197
final package = SentryPackage(name, version);
9298
_packages.add(package);
9399
}

dart/test/protocol/sdk_version_test.dart

+53-28
Original file line numberDiff line numberDiff line change
@@ -3,61 +3,46 @@ import 'package:sentry/sentry.dart';
33
import 'package:test/test.dart';
44

55
void main() {
6-
final sdkVersion = SdkVersion(
7-
name: 'name',
8-
version: 'version',
9-
integrations: ['test'],
10-
packages: [SentryPackage('name', 'version')],
11-
);
12-
13-
final sdkVersionJson = <String, dynamic>{
14-
'name': 'name',
15-
'version': 'version',
16-
'integrations': ['test'],
17-
'packages': [
18-
{
19-
'name': 'name',
20-
'version': 'version',
21-
}
22-
],
23-
};
24-
256
group('json', () {
7+
final fixture = Fixture();
8+
269
test('toJson', () {
27-
final json = sdkVersion.toJson();
10+
final json = fixture.getSut().toJson();
2811

2912
expect(
30-
DeepCollectionEquality().equals(sdkVersionJson, json),
13+
DeepCollectionEquality().equals(fixture.sdkVersionJson, json),
3114
true,
3215
);
3316
});
3417
test('fromJson', () {
35-
final sdkVersion = SdkVersion.fromJson(sdkVersionJson);
18+
final sdkVersion = SdkVersion.fromJson(fixture.sdkVersionJson);
3619
final json = sdkVersion.toJson();
3720

3821
expect(
39-
DeepCollectionEquality().equals(sdkVersionJson, json),
22+
DeepCollectionEquality().equals(fixture.sdkVersionJson, json),
4023
true,
4124
);
4225
});
4326
});
4427

4528
group('copyWith', () {
29+
final fixture = Fixture();
30+
4631
test('copyWith keeps unchanged', () {
47-
final data = sdkVersion;
32+
final sut = fixture.getSut();
4833

49-
final copy = data.copyWith();
34+
final copy = sut.copyWith();
5035

51-
expect(data.toJson(), copy.toJson());
36+
expect(sut.toJson(), copy.toJson());
5237
});
5338

5439
test('copyWith takes new values', () {
55-
final data = sdkVersion;
40+
final sut = fixture.getSut();
5641

5742
final packages = [SentryPackage('name1', 'version1')];
5843
final integrations = ['test1'];
5944

60-
final copy = data.copyWith(
45+
final copy = sut.copyWith(
6146
name: 'name1',
6247
version: 'version1',
6348
integrations: integrations,
@@ -76,4 +61,44 @@ void main() {
7661
expect('version1', copy.version);
7762
});
7863
});
64+
65+
group('addPackage', () {
66+
final fixture = Fixture();
67+
68+
test('add package if not same name and version', () {
69+
final sut = fixture.getSut();
70+
sut.addPackage('name1', 'version1');
71+
72+
final last = sut.packages.last;
73+
expect('name1', last.name);
74+
expect('version1', last.version);
75+
});
76+
test('does not add package if the same name and version', () {
77+
final sut = fixture.getSut();
78+
sut.addPackage('name', 'version');
79+
80+
expect(1, sut.packages.length);
81+
});
82+
});
83+
}
84+
85+
class Fixture {
86+
final sdkVersionJson = <String, dynamic>{
87+
'name': 'name',
88+
'version': 'version',
89+
'integrations': ['test'],
90+
'packages': [
91+
{
92+
'name': 'name',
93+
'version': 'version',
94+
}
95+
],
96+
};
97+
98+
SdkVersion getSut() => SdkVersion(
99+
name: 'name',
100+
version: 'version',
101+
integrations: ['test'],
102+
packages: [SentryPackage('name', 'version')],
103+
);
79104
}

dart/test/scope_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ void main() {
507507
updatedEvent?.contexts[SentryOperatingSystem.type].name, 'event-os');
508508
});
509509

510-
test('should apply the scope.contexts values ', () async {
510+
test('should apply the scope.contexts values', () async {
511511
final event = SentryEvent();
512512
final scope = Scope(SentryOptions(dsn: fakeDsn));
513513
await scope.setContexts(

0 commit comments

Comments
 (0)