From eb6c4bc220127d5d71a993ac9d7bdbc12557b6c4 Mon Sep 17 00:00:00 2001 From: Nick Dowell Date: Mon, 23 May 2022 10:36:38 +0100 Subject: [PATCH 01/26] Add bugsnag_flutter_http --- Makefile | 4 + packages/bugsnag_flutter_http/.gitignore | 30 ++++++++ packages/bugsnag_flutter_http/.metadata | 10 +++ .../analysis_options.yaml | 4 + packages/bugsnag_flutter_http/lib/http.dart | 51 ++++++++++++ .../lib/src/breadcrumb.dart | 34 ++++++++ .../bugsnag_flutter_http/lib/src/client.dart | 41 ++++++++++ packages/bugsnag_flutter_http/pubspec.yaml | 25 ++++++ .../test/breadcrumb_test.dart | 77 +++++++++++++++++++ 9 files changed, 276 insertions(+) create mode 100644 packages/bugsnag_flutter_http/.gitignore create mode 100644 packages/bugsnag_flutter_http/.metadata create mode 100644 packages/bugsnag_flutter_http/analysis_options.yaml create mode 100644 packages/bugsnag_flutter_http/lib/http.dart create mode 100644 packages/bugsnag_flutter_http/lib/src/breadcrumb.dart create mode 100644 packages/bugsnag_flutter_http/lib/src/client.dart create mode 100644 packages/bugsnag_flutter_http/pubspec.yaml create mode 100644 packages/bugsnag_flutter_http/test/breadcrumb_test.dart diff --git a/Makefile b/Makefile index 05d9556e..ef0bac6c 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ all: format build lint test clean: cd packages/bugsnag_flutter && flutter clean --suppress-analytics + cd packages/bugsnag_flutter_http && flutter clean --suppress-analytics cd example && flutter clean --suppress-analytics && \ rm -rf .idea bugsnag_flutter_example.iml \ ios/{Pods,.symlinks,Podfile.lock} \ @@ -19,6 +20,7 @@ ifeq ($(VERSION),) endif sed -i '' "s/## TBD/## $(VERSION) ($(shell date '+%Y-%m-%d'))/" CHANGELOG.md sed -i '' "s/^version: .*/version: $(VERSION)/" packages/bugsnag_flutter/pubspec.yaml + sed -i '' "s/^version: .*/version: $(VERSION)/" packages/bugsnag_flutter_http/pubspec.yaml sed -i '' "s/^ 'version': .*/ 'version': '$(VERSION)'/" packages/bugsnag_flutter/lib/src/client.dart stage: clean @@ -39,6 +41,7 @@ example: test: cd packages/bugsnag_flutter && flutter test -r expanded --suppress-analytics + cd packages/bugsnag_flutter_http && flutter test -r expanded --suppress-analytics test-fixtures: ## Build the end-to-end test fixtures @./features/scripts/build_ios_app.sh @@ -49,6 +52,7 @@ format: lint: cd packages/bugsnag_flutter && flutter analyze --suppress-analytics + cd packages/bugsnag_flutter_http && flutter analyze --suppress-analytics e2e_android_local: features/fixtures/app/build/app/outputs/flutter-apk/app-release.apk $(HOME)/Library/Android/sdk/platform-tools/adb uninstall com.bugsnag.flutter.test.app || true diff --git a/packages/bugsnag_flutter_http/.gitignore b/packages/bugsnag_flutter_http/.gitignore new file mode 100644 index 00000000..96486fd9 --- /dev/null +++ b/packages/bugsnag_flutter_http/.gitignore @@ -0,0 +1,30 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.packages +build/ diff --git a/packages/bugsnag_flutter_http/.metadata b/packages/bugsnag_flutter_http/.metadata new file mode 100644 index 00000000..c79dee43 --- /dev/null +++ b/packages/bugsnag_flutter_http/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851 + channel: stable + +project_type: package diff --git a/packages/bugsnag_flutter_http/analysis_options.yaml b/packages/bugsnag_flutter_http/analysis_options.yaml new file mode 100644 index 00000000..a5744c1c --- /dev/null +++ b/packages/bugsnag_flutter_http/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/packages/bugsnag_flutter_http/lib/http.dart b/packages/bugsnag_flutter_http/lib/http.dart new file mode 100644 index 00000000..0d3be869 --- /dev/null +++ b/packages/bugsnag_flutter_http/lib/http.dart @@ -0,0 +1,51 @@ +library bugsnag_flutter_http; + +import 'src/client.dart'; + +import 'dart:convert'; +import 'dart:typed_data'; + +import 'package:http/http.dart' as http; + +export 'src/client.dart'; + +Future head(Uri url, {Map? headers}) => + _withClient((client) => client.head(url, headers: headers)); + +Future get(Uri url, {Map? headers}) => + _withClient((client) => client.get(url, headers: headers)); + +Future post(Uri url, + {Map? headers, Object? body, Encoding? encoding}) => + _withClient((client) => + client.post(url, headers: headers, body: body, encoding: encoding)); + +Future put(Uri url, + {Map? headers, Object? body, Encoding? encoding}) => + _withClient((client) => + client.put(url, headers: headers, body: body, encoding: encoding)); + +Future patch(Uri url, + {Map? headers, Object? body, Encoding? encoding}) => + _withClient((client) => + client.patch(url, headers: headers, body: body, encoding: encoding)); + +Future delete(Uri url, + {Map? headers, Object? body, Encoding? encoding}) => + _withClient((client) => + client.delete(url, headers: headers, body: body, encoding: encoding)); + +Future read(Uri url, {Map? headers}) => + _withClient((client) => client.read(url, headers: headers)); + +Future readBytes(Uri url, {Map? headers}) => + _withClient((client) => client.readBytes(url, headers: headers)); + +Future _withClient(Future Function(Client) fn) async { + var client = Client(); + try { + return await fn(client); + } finally { + client.close(); + } +} diff --git a/packages/bugsnag_flutter_http/lib/src/breadcrumb.dart b/packages/bugsnag_flutter_http/lib/src/breadcrumb.dart new file mode 100644 index 00000000..a2587716 --- /dev/null +++ b/packages/bugsnag_flutter_http/lib/src/breadcrumb.dart @@ -0,0 +1,34 @@ +import 'package:bugsnag_flutter/bugsnag.dart'; +import 'package:http/http.dart' as http; + +class Breadcrumb { + static BugsnagBreadcrumb build( + dynamic client, + http.BaseRequest request, + Stopwatch stopwatch, + http.BaseResponse? response, + ) { + final clientName = client.runtimeType.toString(); + final requestContentLength = request.contentLength; + final responseContentLength = response?.contentLength; + final status = (response == null) + ? 'error' + : response.statusCode < 400 + ? 'succeeded' + : 'failed'; + return BugsnagBreadcrumb('$clientName request $status', + metadata: { + 'duration': stopwatch.elapsed.inMilliseconds, + 'method': request.method, + 'url': request.url.toString().split('?').first, + if (request.url.queryParameters.isNotEmpty) + 'urlParams': request.url.queryParameters, + if (requestContentLength != null && requestContentLength != 0) + 'requestContentLength': requestContentLength, + if (response != null) 'status': response.statusCode, + if (responseContentLength != null) + 'responseContentLength': responseContentLength, + }, + type: BreadcrumbType.request); + } +} diff --git a/packages/bugsnag_flutter_http/lib/src/client.dart b/packages/bugsnag_flutter_http/lib/src/client.dart new file mode 100644 index 00000000..9cabf0fd --- /dev/null +++ b/packages/bugsnag_flutter_http/lib/src/client.dart @@ -0,0 +1,41 @@ +import 'package:bugsnag_flutter/bugsnag.dart'; +import 'package:http/http.dart' as http; + +import 'breadcrumb.dart'; + +/// An HTTP client wrapper that logs requests as Bugsnag breadcrumbs. +class Client extends http.BaseClient { + /// The wrapped client. + final http.Client _inner; + + Client() : _inner = http.Client(); + + Client.withClient(http.Client client) : _inner = client; + + @override + Future send(http.BaseRequest request) async { + final stopwatch = Stopwatch()..start(); + try { + final response = await _inner.send(request); + await _requestFinished(request, stopwatch, response); + return response; + } catch (e) { + await _requestFinished(request, stopwatch); + rethrow; + } + } + + Future _requestFinished( + http.BaseRequest request, + Stopwatch stopwatch, [ + http.StreamedResponse? response, + ]) => + _leaveBreadcrumb(Breadcrumb.build(_inner, request, stopwatch, response)); +} + +Future _leaveBreadcrumb(BugsnagBreadcrumb breadcrumb) async => + bugsnag.leaveBreadcrumb( + breadcrumb.message, + metadata: breadcrumb.metadata, + type: breadcrumb.type, + ); diff --git a/packages/bugsnag_flutter_http/pubspec.yaml b/packages/bugsnag_flutter_http/pubspec.yaml new file mode 100644 index 00000000..7afe056a --- /dev/null +++ b/packages/bugsnag_flutter_http/pubspec.yaml @@ -0,0 +1,25 @@ +name: bugsnag_flutter_http +description: Bugsnag network breadcrumbs for https://pub.dev/packages/http +version: 2.0.0-rc6 +homepage: https://www.bugsnag.com/ +documentation: https://docs.bugsnag.com/platforms/flutter/ +repository: https://github.com/bugsnag/bugsnag-flutter +issue_tracker: https://github.com/bugsnag/bugsnag-flutter/issues + +publish_to: none + +environment: + sdk: ">=2.15.1 <3.0.0" + flutter: ">=2.0.0" + +dependencies: + flutter: + sdk: flutter + bugsnag_flutter: + path: ../bugsnag_flutter + http: ^0.13.4 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^1.0.0 diff --git a/packages/bugsnag_flutter_http/test/breadcrumb_test.dart b/packages/bugsnag_flutter_http/test/breadcrumb_test.dart new file mode 100644 index 00000000..61ce190c --- /dev/null +++ b/packages/bugsnag_flutter_http/test/breadcrumb_test.dart @@ -0,0 +1,77 @@ +import 'package:bugsnag_flutter/bugsnag.dart'; +import 'package:bugsnag_flutter_http/src/breadcrumb.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:http/http.dart' as http; + +void main() { + group('Breadcrumb', () { + test('Successful POST request', () { + const body = '{"hello":"world"}'; + final breadcrumb = Breadcrumb.build( + http.Client(), + http.Request('POST', Uri.parse('https://example.com/'))..body = body, + Stopwatch()..start(), + DummyResponse(200, contentLength: 123)); + expect(breadcrumb.type, BreadcrumbType.request); + expect(breadcrumb.message, 'IOClient request succeeded'); + expect(breadcrumb.metadata?['duration'], isNotNull); + expect(breadcrumb.metadata?['method'], 'POST'); + expect(breadcrumb.metadata?['requestContentLength'], body.length); + expect(breadcrumb.metadata?['responseContentLength'], 123); + expect(breadcrumb.metadata?['status'], 200); + expect(breadcrumb.metadata?['url'], 'https://example.com/'); + expect(breadcrumb.metadata?['urlParams'], isNull); + }); + + test('Request with URL params', () { + final breadcrumb = Breadcrumb.build( + http.Client(), + http.Request('GET', Uri.parse('https://example.com?type=all')), + Stopwatch()..start(), + DummyResponse(200, contentLength: 123)); + expect(breadcrumb.metadata?['url'], 'https://example.com'); + expect(breadcrumb.metadata?['urlParams'], {'type': 'all'}); + }); + + test('Request failed', () { + final breadcrumb = Breadcrumb.build( + http.Client(), + http.Request('GET', Uri.parse('https://example.com?type=all')), + Stopwatch()..start(), + DummyResponse(400, contentLength: 213)); + expect(breadcrumb.message, 'IOClient request failed'); + expect(breadcrumb.metadata?['duration'], isNotNull); + expect(breadcrumb.metadata?['status'], 400); + expect(breadcrumb.metadata?['responseContentLength'], 213); + }); + + test('Request error', () { + final breadcrumb = Breadcrumb.build( + http.Client(), + http.Request('GET', Uri.parse('https://example.com')), + Stopwatch()..start(), + null); + expect(breadcrumb.message, 'IOClient request error'); + expect(breadcrumb.metadata?['duration'], isNotNull); + expect(breadcrumb.metadata?['status'], isNull); + expect(breadcrumb.metadata?['responseContentLength'], isNull); + }); + }); +} + +class DummyResponse extends http.BaseResponse { + DummyResponse(int statusCode, + {int? contentLength, + http.BaseRequest? request, + Map headers = const {}, + bool isRedirect = false, + bool persistentConnection = true, + String? reasonPhrase}) + : super(statusCode, + contentLength: contentLength, + request: request, + headers: headers, + isRedirect: isRedirect, + persistentConnection: persistentConnection, + reasonPhrase: reasonPhrase); +} From 7b74d30d76b7b441bfe6bfad62b962f668ae9875 Mon Sep 17 00:00:00 2001 From: Nick Dowell Date: Mon, 23 May 2022 11:07:49 +0100 Subject: [PATCH 02/26] Add network breadcrumbs to example app --- example/lib/main.dart | 38 +++++++++++++++++++++++++++++++++++--- example/pubspec.yaml | 5 +++++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 45eea505..36ab79dc 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:bugsnag_example/native_crashes.dart'; +import 'package:bugsnag_flutter_http/http.dart' as http; import 'package:bugsnag_flutter/bugsnag.dart'; import 'package:bugsnag_flutter/widgets.dart'; import 'package:flutter/material.dart'; @@ -75,6 +76,17 @@ class ExampleHomeScreen extends StatelessWidget { // Additional data can be attached to breadcrumbs as metadata metadata: {'from': 'a', 'to': 'z'}); + // Use the bugsnag_flutter_http package to automatically capture breadcrumbs + // for network requests: + // import 'package:bugsnag_flutter_http/http.dart' as http; + void _networkSuccess() async => http.get(Uri.parse('https://example.com')); + + void _networkFailure() async => + http.post(Uri.parse('https://example.com/invalid')); + + void _networkError() async => + http.get(Uri.parse('https://example.invalid')).ignore(); + @override Widget build(BuildContext context) { return Scaffold( @@ -82,10 +94,11 @@ class ExampleHomeScreen extends StatelessWidget { title: const Text('Bugsnag example app'), ), body: Center( - child: Column( + child: ListView( + padding: const EdgeInsets.symmetric(horizontal: 16), children: [ Padding( - padding: const EdgeInsets.all(16.0), + padding: const EdgeInsets.symmetric(vertical: 16), child: Text( 'Unhandled Errors', style: Theme.of(context).textTheme.headline6, @@ -119,7 +132,7 @@ class ExampleHomeScreen extends StatelessWidget { ), ), Padding( - padding: const EdgeInsets.all(16.0), + padding: const EdgeInsets.symmetric(vertical: 16), child: Text( 'Breadcrumbs', style: Theme.of(context).textTheme.headline6, @@ -129,6 +142,25 @@ class ExampleHomeScreen extends StatelessWidget { onPressed: _leaveBreadcrumb, child: const Text('Leave a breadcrumb'), ), + Padding( + padding: const EdgeInsets.symmetric(vertical: 16), + child: Text( + 'Network Breadcrumbs', + style: Theme.of(context).textTheme.headline6, + ), + ), + ElevatedButton( + onPressed: _networkSuccess, + child: const Text('Success'), + ), + ElevatedButton( + onPressed: _networkFailure, + child: const Text('Failure'), + ), + ElevatedButton( + onPressed: _networkError, + child: const Text('Error'), + ), ], ), ), diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 56fb5727..e9a97081 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -26,11 +26,16 @@ dependencies: # The example app is bundled with the plugin so we use a path dependency on # the parent directory to use the current plugin's version. path: ../packages/bugsnag_flutter + + bugsnag_flutter_http: + path: ../packages/bugsnag_flutter_http # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 + http: ^0.13.4 + dev_dependencies: flutter_test: sdk: flutter From d37b75e1e304c533c5fdbe0bd723a7f6f5b8aab3 Mon Sep 17 00:00:00 2001 From: Josh Edney Date: Mon, 30 May 2022 10:40:11 +0100 Subject: [PATCH 03/26] chore: update makefile and pipeline to accept flutter versions --- .buildkite/pipeline.yml | 145 +++++++++++++++++++++++--- Makefile | 18 ++-- features/scripts/build_android_app.sh | 4 +- features/scripts/build_ios_app.sh | 4 +- 4 files changed, 144 insertions(+), 27 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index a69f31fa..32935031 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -1,20 +1,54 @@ agents: - queue: opensource-arm-mac-cocoa-12 + queue: ms-arm-12-8 steps: - - label: ":test_tube:" + - label: ":test_tube: 2.8.1" timeout_in_minutes: 10 + env: + FLUTTER_VERSION: 2.8.1 commands: - make test - - label: ":lint-roller:" + - label: ":test_tube: 3.0.1" timeout_in_minutes: 10 + env: + FLUTTER_VERSION: 3.0.1 + commands: + - make test + + - label: ":lint-roller: 2.8.1" + timeout_in_minutes: 10 + env: + FLUTTER_VERSION: 2.8.1 commands: - make lint - - label: Build Example App + - label: ":lint-roller: 3.0.1" timeout_in_minutes: 10 + env: + FLUTTER_VERSION: 3.0.1 + commands: + - make lint + + - label: Build Example App 2.8.1 + timeout_in_minutes: 10 + env: + FLUTTER_VERSION: 2.8.1 + commands: + - pod repo update + - make example + # Verify that App.framework's UUID (and therefore our `codeIdentifier`) changes when Dart code is touched + - dwarfdump --arch=arm64 --uuid example/build/ios/iphoneos/Runner.app/Frameworks/App.framework/App | tee uuid_before + - sed -i '' -e 's/add_your_api_key_here/my_api_key/' example/lib/main.dart + - make example + - dwarfdump --arch=arm64 --uuid example/build/ios/iphoneos/Runner.app/Frameworks/App.framework/App | tee uuid_after + - test "$(cat uuid_before)" != "$(cat uuid_after)" + + - label: Build Example App 3.0.1 + timeout_in_minutes: 10 + env: + FLUTTER_VERSION: 3.0.1 commands: - pod repo update - make example @@ -28,19 +62,35 @@ steps: # # iOS # - - label: Build iOS Test Fixture - key: ios-fixture + - label: Build iOS Test Fixture 2.8.1 + key: "ios-fixture-2-0-0" + timeout_in_minutes: 20 + env: + FLUTTER_VERSION: 2.8.1 + commands: + - pod repo update trunk + - features/scripts/build_ios_app.sh + plugins: + artifacts#v1.5.0: + upload: "features/fixtures/app/build/ios/ipa/app-2.8.1.ipa" + + - label: Build iOS Test Fixture 3.0.1 + key: "ios-fixture-3-0-1" timeout_in_minutes: 20 + env: + FLUTTER_VERSION: 3.0.1 commands: - pod repo update trunk - features/scripts/build_ios_app.sh plugins: artifacts#v1.5.0: - upload: "features/fixtures/app/build/ios/ipa/app.ipa" + upload: "features/fixtures/app/build/ios/ipa/app-3.0.1.ipa" - - label: 'iOS 14 end-to-end tests' - depends_on: "ios-fixture" + - label: 'iOS 14 end-to-end tests 2.8.1' + depends_on: "ios-fixture-2-0-0" timeout_in_minutes: 10 + env: + FLUTTER_VERSION: 2.8.1 agents: queue: opensource plugins: @@ -51,7 +101,30 @@ steps: pull: maze-runner run: maze-runner command: - - "--app=/app/features/fixtures/app/build/ios/ipa/app.ipa" + - "--app=/app/features/fixtures/app/build/ios/ipa/app-2.8.1.ipa" + - "--farm=bs" + - "--device=IOS_14" + - "--fail-fast" + concurrency: 24 + concurrency_group: 'browserstack-app' + concurrency_method: eager + + - label: 'iOS 14 end-to-end tests 3.0.1' + depends_on: "ios-fixture-3-0-1" + timeout_in_minutes: 10 + env: + FLUTTER_VERSION: 3.0.1 + agents: + queue: opensource + plugins: + artifacts#v1.5.0: + download: "features/fixtures/app/build/ios/ipa/app-3.0.1.ipa" + upload: "maze_output/failed/**/*" + docker-compose#v3.7.0: + pull: maze-runner + run: maze-runner + command: + - "--app=/app/features/fixtures/app/build/ios/ipa/app-3.0.1.ipa" - "--farm=bs" - "--device=IOS_14" - "--fail-fast" @@ -62,29 +135,67 @@ steps: # # Android # - - label: Build Android Test Fixture - key: android-fixture + - label: Build Android Test Fixture 2.8.1 + key: "android-fixture-2-0-0" + timeout_in_minutes: 20 + env: + FLUTTER_VERSION: 2.8.1 + commands: + - features/scripts/build_android_app.sh + plugins: + artifacts#v1.5.0: + upload: "features/fixtures/app/build/app/outputs/flutter-apk/app-release-2.8.1.apk" + + - label: Build Android Test Fixture 3.0.1 + key: "android-fixture-3-0-1" timeout_in_minutes: 20 + env: + FLUTTER_VERSION: 3.0.1 commands: - features/scripts/build_android_app.sh plugins: artifacts#v1.5.0: - upload: "features/fixtures/app/build/app/outputs/flutter-apk/app-release.apk" + upload: "features/fixtures/app/build/app/outputs/flutter-apk/app-release-3.0.1.apk" + + - label: 'Android 12 end-to-end tests 2.8.1' + depends_on: "android-fixture-2-0-0" + timeout_in_minutes: 10 + env: + FLUTTER_VERSION: 2.8.1 + agents: + queue: opensource + plugins: + artifacts#v1.5.0: + download: "features/fixtures/app/build/app/outputs/flutter-apk/app-release-2.8.1.apk" + upload: "maze_output/failed/**/*" + docker-compose#v3.7.0: + pull: maze-runner + run: maze-runner + command: + - "--app=/app/features/fixtures/app/build/app/outputs/flutter-apk/app-release-2.8.1.apk" + - "--farm=bs" + - "--device=ANDROID_12_0" + - "--fail-fast" + concurrency: 24 + concurrency_group: 'browserstack-app' + concurrency_method: eager - - label: 'Android 12 end-to-end tests' - depends_on: "android-fixture" + - label: 'Android 12 end-to-end tests 3.0.1' + depends_on: "android-fixture-3-0-1" timeout_in_minutes: 10 + env: + FLUTTER_VERSION: 3.0.1 agents: queue: opensource plugins: artifacts#v1.5.0: - download: "features/fixtures/app/build/app/outputs/flutter-apk/app-release.apk" + download: "features/fixtures/app/build/app/outputs/flutter-apk/app-release-3.0.1.apk" upload: "maze_output/failed/**/*" docker-compose#v3.7.0: pull: maze-runner run: maze-runner command: - - "--app=/app/features/fixtures/app/build/app/outputs/flutter-apk/app-release.apk" + - "--app=/app/features/fixtures/app/build/app/outputs/flutter-apk/app-release-3.0.1.apk" - "--farm=bs" - "--device=ANDROID_12_0" - "--fail-fast" diff --git a/Makefile b/Makefile index 05d9556e..d18dfc48 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,12 @@ +FLUTTER_VERSION?=3.0.1 + all: format build lint test .PHONY: clean build bump aar example test format lint e2e_android_local e2e_ios_local clean: - cd packages/bugsnag_flutter && flutter clean --suppress-analytics - cd example && flutter clean --suppress-analytics && \ + cd packages/bugsnag_flutter && flutter-$(FLUTTER_VERSION) clean --suppress-analytics + cd example && flutter-$(FLUTTER_VERSION) clean --suppress-analytics && \ rm -rf .idea bugsnag_flutter_example.iml \ ios/{Pods,.symlinks,Podfile.lock} \ ios/{Runner.xcworkspace,Runner.xcodeproj,Runner.xcodeproj/project.xcworkspace}/xcuserdata \ @@ -32,13 +34,13 @@ stage: clean sed -i '' -e '1,2d' staging/CHANGELOG.md aar: - cd packages/bugsnag_flutter && flutter build aar --suppress-analytics + cd packages/bugsnag_flutter && flutter-$(FLUTTER_VERSION) build aar --suppress-analytics example: - cd example && flutter build apk --suppress-analytics && flutter build ios --no-codesign --suppress-analytics + cd example && flutter-$(FLUTTER_VERSION) build apk --suppress-analytics && flutter-$(FLUTTER_VERSION) build ios --no-codesign --suppress-analytics test: - cd packages/bugsnag_flutter && flutter test -r expanded --suppress-analytics + cd packages/bugsnag_flutter && flutter-$(FLUTTER_VERSION) test -r expanded --suppress-analytics test-fixtures: ## Build the end-to-end test fixtures @./features/scripts/build_ios_app.sh @@ -48,18 +50,18 @@ format: flutter format packages/bugsnag_flutter example features/fixtures/app lint: - cd packages/bugsnag_flutter && flutter analyze --suppress-analytics + cd packages/bugsnag_flutter && flutter-$(FLUTTER_VERSION) analyze --suppress-analytics e2e_android_local: features/fixtures/app/build/app/outputs/flutter-apk/app-release.apk $(HOME)/Library/Android/sdk/platform-tools/adb uninstall com.bugsnag.flutter.test.app || true bundle exec maze-runner --app=$< --farm=local --os=android --os-version=10 $(FEATURES) features/fixtures/app/build/app/outputs/flutter-apk/app-release.apk: $(shell find packages/bugsnag_flutter features/fixtures/app/android/app/src features/fixtures/app/lib -type f) - cd features/fixtures/app && flutter build apk + cd features/fixtures/app && flutter-$(FLUTTER_VERSION) build apk e2e_ios_local: features/fixtures/app/build/ios/ipa/app.ipa ideviceinstaller --uninstall com.bugsnag.flutter.test.app bundle exec maze-runner --app=$< --farm=local --os=ios --os-version=15 --apple-team-id=372ZUL2ZB7 --udid="$(shell idevice_id -l)" $(FEATURES) features/fixtures/app/build/ios/ipa/app.ipa: $(shell find packages/bugsnag_flutter features/fixtures/app/ios/Runner features/fixtures/app/lib -type f) - cd features/fixtures/app && flutter build ipa --export-options-plist=ios/exportOptions.plist + cd features/fixtures/app && flutter-$(FLUTTER_VERSION) build ipa --export-options-plist=ios/exportOptions.plist diff --git a/features/scripts/build_android_app.sh b/features/scripts/build_android_app.sh index 396cc338..c5bd1b85 100755 --- a/features/scripts/build_android_app.sh +++ b/features/scripts/build_android_app.sh @@ -2,4 +2,6 @@ set -o errexit cd features/fixtures/app -flutter build apk +flutter-$FLUTTER_VERSION build apk + +mv ../../../features/fixtures/app/build/app/outputs/flutter-apk/app-release.apk ../../../features/fixtures/app/build/app/outputs/flutter-apk/app-release-$FLUTTER_VERSION.apk \ No newline at end of file diff --git a/features/scripts/build_ios_app.sh b/features/scripts/build_ios_app.sh index ebc48c2c..9be50761 100755 --- a/features/scripts/build_ios_app.sh +++ b/features/scripts/build_ios_app.sh @@ -2,4 +2,6 @@ set -o errexit cd features/fixtures/app -flutter build ipa --export-options-plist=ios/exportOptions.plist +flutter-$FLUTTER_VERSION build ipa --export-options-plist=ios/exportOptions.plist + +mv ../../../features/fixtures/app/build/ios/ipa/app.ipa ../../../features/fixtures/app/build/ios/ipa/app-$FLUTTER_VERSION.ipa \ No newline at end of file From 8b5a041757e26a8f795616aaacbd8df19e169cf7 Mon Sep 17 00:00:00 2001 From: Josh Edney Date: Mon, 30 May 2022 10:58:51 +0100 Subject: [PATCH 04/26] chore: update makefile and pipeline to accept flutter versions --- .buildkite/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 32935031..0ae992a2 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -95,7 +95,7 @@ steps: queue: opensource plugins: artifacts#v1.5.0: - download: "features/fixtures/app/build/ios/ipa/app.ipa" + download: "features/fixtures/app/build/ios/ipa/app-2.8.1.ipa" upload: "maze_output/failed/**/*" docker-compose#v3.7.0: pull: maze-runner From 4792b3e2b8a7e0240eb52dc8d35fc12456b35fcc Mon Sep 17 00:00:00 2001 From: Josh Edney Date: Mon, 30 May 2022 11:49:49 +0100 Subject: [PATCH 05/26] chore: update makefile and buildscript --- .buildkite/pipeline.yml | 28 +++++++++++++-------------- Makefile | 18 ++++++++--------- features/scripts/build_android_app.sh | 6 +++++- features/scripts/build_ios_app.sh | 6 +++++- 4 files changed, 33 insertions(+), 25 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 0ae992a2..33d65d07 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -6,35 +6,35 @@ steps: - label: ":test_tube: 2.8.1" timeout_in_minutes: 10 env: - FLUTTER_VERSION: 2.8.1 + FLUTTER_DIR: "/usr/local/bin/flutter-2.8.1" commands: - make test - label: ":test_tube: 3.0.1" timeout_in_minutes: 10 env: - FLUTTER_VERSION: 3.0.1 + FLUTTER_DIR: "/usr/local/bin/flutter-3.0.1" commands: - make test - label: ":lint-roller: 2.8.1" timeout_in_minutes: 10 env: - FLUTTER_VERSION: 2.8.1 + FLUTTER_DIR: "/usr/local/bin/flutter-2.8.1" commands: - make lint - label: ":lint-roller: 3.0.1" timeout_in_minutes: 10 env: - FLUTTER_VERSION: 3.0.1 + FLUTTER_DIR: "/usr/local/bin/flutter-3.0.1" commands: - make lint - label: Build Example App 2.8.1 timeout_in_minutes: 10 env: - FLUTTER_VERSION: 2.8.1 + FLUTTER_DIR: "/usr/local/bin/flutter-2.8.1" commands: - pod repo update - make example @@ -48,7 +48,7 @@ steps: - label: Build Example App 3.0.1 timeout_in_minutes: 10 env: - FLUTTER_VERSION: 3.0.1 + FLUTTER_DIR: "/usr/local/bin/flutter-3.0.1" commands: - pod repo update - make example @@ -66,7 +66,7 @@ steps: key: "ios-fixture-2-0-0" timeout_in_minutes: 20 env: - FLUTTER_VERSION: 2.8.1 + FLUTTER_DIR: "/usr/local/bin/flutter-2.8.1" commands: - pod repo update trunk - features/scripts/build_ios_app.sh @@ -78,7 +78,7 @@ steps: key: "ios-fixture-3-0-1" timeout_in_minutes: 20 env: - FLUTTER_VERSION: 3.0.1 + FLUTTER_DIR: "/usr/local/bin/flutter-3.0.1" commands: - pod repo update trunk - features/scripts/build_ios_app.sh @@ -90,7 +90,7 @@ steps: depends_on: "ios-fixture-2-0-0" timeout_in_minutes: 10 env: - FLUTTER_VERSION: 2.8.1 + FLUTTER_DIR: "/usr/local/bin/flutter-2.8.1" agents: queue: opensource plugins: @@ -113,7 +113,7 @@ steps: depends_on: "ios-fixture-3-0-1" timeout_in_minutes: 10 env: - FLUTTER_VERSION: 3.0.1 + FLUTTER_DIR: "/usr/local/bin/flutter-3.0.1" agents: queue: opensource plugins: @@ -139,7 +139,7 @@ steps: key: "android-fixture-2-0-0" timeout_in_minutes: 20 env: - FLUTTER_VERSION: 2.8.1 + FLUTTER_DIR: "/usr/local/bin/flutter-2.8.1" commands: - features/scripts/build_android_app.sh plugins: @@ -150,7 +150,7 @@ steps: key: "android-fixture-3-0-1" timeout_in_minutes: 20 env: - FLUTTER_VERSION: 3.0.1 + FLUTTER_DIR: "/usr/local/bin/flutter-3.0.1" commands: - features/scripts/build_android_app.sh plugins: @@ -161,7 +161,7 @@ steps: depends_on: "android-fixture-2-0-0" timeout_in_minutes: 10 env: - FLUTTER_VERSION: 2.8.1 + FLUTTER_DIR: "/usr/local/bin/flutter-2.8.1" agents: queue: opensource plugins: @@ -184,7 +184,7 @@ steps: depends_on: "android-fixture-3-0-1" timeout_in_minutes: 10 env: - FLUTTER_VERSION: 3.0.1 + FLUTTER_DIR: "/usr/local/bin/flutter-3.0.1" agents: queue: opensource plugins: diff --git a/Makefile b/Makefile index d18dfc48..27f21a7a 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,12 @@ -FLUTTER_VERSION?=3.0.1 +FLUTTER_DIR?=flutter all: format build lint test .PHONY: clean build bump aar example test format lint e2e_android_local e2e_ios_local clean: - cd packages/bugsnag_flutter && flutter-$(FLUTTER_VERSION) clean --suppress-analytics - cd example && flutter-$(FLUTTER_VERSION) clean --suppress-analytics && \ + cd packages/bugsnag_flutter && $(FLUTTER_DIR) clean --suppress-analytics + cd example && $(FLUTTER_DIR) clean --suppress-analytics && \ rm -rf .idea bugsnag_flutter_example.iml \ ios/{Pods,.symlinks,Podfile.lock} \ ios/{Runner.xcworkspace,Runner.xcodeproj,Runner.xcodeproj/project.xcworkspace}/xcuserdata \ @@ -34,13 +34,13 @@ stage: clean sed -i '' -e '1,2d' staging/CHANGELOG.md aar: - cd packages/bugsnag_flutter && flutter-$(FLUTTER_VERSION) build aar --suppress-analytics + cd packages/bugsnag_flutter && $(FLUTTER_DIR) build aar --suppress-analytics example: - cd example && flutter-$(FLUTTER_VERSION) build apk --suppress-analytics && flutter-$(FLUTTER_VERSION) build ios --no-codesign --suppress-analytics + cd example && $(FLUTTER_DIR) build apk --suppress-analytics && $(FLUTTER_DIR) build ios --no-codesign --suppress-analytics test: - cd packages/bugsnag_flutter && flutter-$(FLUTTER_VERSION) test -r expanded --suppress-analytics + cd packages/bugsnag_flutter && $(FLUTTER_DIR) test -r expanded --suppress-analytics test-fixtures: ## Build the end-to-end test fixtures @./features/scripts/build_ios_app.sh @@ -50,18 +50,18 @@ format: flutter format packages/bugsnag_flutter example features/fixtures/app lint: - cd packages/bugsnag_flutter && flutter-$(FLUTTER_VERSION) analyze --suppress-analytics + cd packages/bugsnag_flutter && $(FLUTTER_DIR) analyze --suppress-analytics e2e_android_local: features/fixtures/app/build/app/outputs/flutter-apk/app-release.apk $(HOME)/Library/Android/sdk/platform-tools/adb uninstall com.bugsnag.flutter.test.app || true bundle exec maze-runner --app=$< --farm=local --os=android --os-version=10 $(FEATURES) features/fixtures/app/build/app/outputs/flutter-apk/app-release.apk: $(shell find packages/bugsnag_flutter features/fixtures/app/android/app/src features/fixtures/app/lib -type f) - cd features/fixtures/app && flutter-$(FLUTTER_VERSION) build apk + cd features/fixtures/app && $(FLUTTER_DIR) build apk e2e_ios_local: features/fixtures/app/build/ios/ipa/app.ipa ideviceinstaller --uninstall com.bugsnag.flutter.test.app bundle exec maze-runner --app=$< --farm=local --os=ios --os-version=15 --apple-team-id=372ZUL2ZB7 --udid="$(shell idevice_id -l)" $(FEATURES) features/fixtures/app/build/ios/ipa/app.ipa: $(shell find packages/bugsnag_flutter features/fixtures/app/ios/Runner features/fixtures/app/lib -type f) - cd features/fixtures/app && flutter-$(FLUTTER_VERSION) build ipa --export-options-plist=ios/exportOptions.plist + cd features/fixtures/app && $(FLUTTER_DIR) build ipa --export-options-plist=ios/exportOptions.plist diff --git a/features/scripts/build_android_app.sh b/features/scripts/build_android_app.sh index c5bd1b85..ebbe48c0 100755 --- a/features/scripts/build_android_app.sh +++ b/features/scripts/build_android_app.sh @@ -1,7 +1,11 @@ #!/usr/bin/env bash set -o errexit +if [ -z "$FLUTTER_DIR" ]; then + FLUTTER_DIR="flutter" +fi + cd features/fixtures/app -flutter-$FLUTTER_VERSION build apk +$FLUTTER_DIR build apk mv ../../../features/fixtures/app/build/app/outputs/flutter-apk/app-release.apk ../../../features/fixtures/app/build/app/outputs/flutter-apk/app-release-$FLUTTER_VERSION.apk \ No newline at end of file diff --git a/features/scripts/build_ios_app.sh b/features/scripts/build_ios_app.sh index 9be50761..d6061dd3 100755 --- a/features/scripts/build_ios_app.sh +++ b/features/scripts/build_ios_app.sh @@ -1,7 +1,11 @@ #!/usr/bin/env bash set -o errexit +if [ -z "$FLUTTER_DIR" ]; then + FLUTTER_DIR="flutter" +fi + cd features/fixtures/app -flutter-$FLUTTER_VERSION build ipa --export-options-plist=ios/exportOptions.plist +$FLUTTER_DIR build ipa --export-options-plist=ios/exportOptions.plist mv ../../../features/fixtures/app/build/ios/ipa/app.ipa ../../../features/fixtures/app/build/ios/ipa/app-$FLUTTER_VERSION.ipa \ No newline at end of file From ad326e386745b6ab5dce12e2876a07d60cfc189a Mon Sep 17 00:00:00 2001 From: Josh Edney Date: Mon, 30 May 2022 12:01:53 +0100 Subject: [PATCH 06/26] chore: update build script output file name --- .buildkite/pipeline.yml | 16 ++++++++++++---- features/scripts/build_android_app.sh | 2 -- features/scripts/build_ios_app.sh | 2 -- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 33d65d07..048a3d4e 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -72,7 +72,9 @@ steps: - features/scripts/build_ios_app.sh plugins: artifacts#v1.5.0: - upload: "features/fixtures/app/build/ios/ipa/app-2.8.1.ipa" + upload: + from: "features/fixtures/app/build/ios/ipa/app.ipa" + to: "features/fixtures/app/build/ios/ipa/app-2.8.1.ipa" - label: Build iOS Test Fixture 3.0.1 key: "ios-fixture-3-0-1" @@ -84,7 +86,9 @@ steps: - features/scripts/build_ios_app.sh plugins: artifacts#v1.5.0: - upload: "features/fixtures/app/build/ios/ipa/app-3.0.1.ipa" + upload: + from: "features/fixtures/app/build/ios/ipa/app.ipa" + to: "features/fixtures/app/build/ios/ipa/app-3.0.1.ipa" - label: 'iOS 14 end-to-end tests 2.8.1' depends_on: "ios-fixture-2-0-0" @@ -144,7 +148,9 @@ steps: - features/scripts/build_android_app.sh plugins: artifacts#v1.5.0: - upload: "features/fixtures/app/build/app/outputs/flutter-apk/app-release-2.8.1.apk" + upload: + from: "features/fixtures/app/build/app/outputs/flutter-apk/app-release.apk" + to: "features/fixtures/app/build/app/outputs/flutter-apk/app-release-2.8.1.apk" - label: Build Android Test Fixture 3.0.1 key: "android-fixture-3-0-1" @@ -155,7 +161,9 @@ steps: - features/scripts/build_android_app.sh plugins: artifacts#v1.5.0: - upload: "features/fixtures/app/build/app/outputs/flutter-apk/app-release-3.0.1.apk" + upload: + from: "features/fixtures/app/build/app/outputs/flutter-apk/app-release.apk" + to: "features/fixtures/app/build/app/outputs/flutter-apk/app-release-3.0.1.apk" - label: 'Android 12 end-to-end tests 2.8.1' depends_on: "android-fixture-2-0-0" diff --git a/features/scripts/build_android_app.sh b/features/scripts/build_android_app.sh index ebbe48c0..a1016c51 100755 --- a/features/scripts/build_android_app.sh +++ b/features/scripts/build_android_app.sh @@ -7,5 +7,3 @@ fi cd features/fixtures/app $FLUTTER_DIR build apk - -mv ../../../features/fixtures/app/build/app/outputs/flutter-apk/app-release.apk ../../../features/fixtures/app/build/app/outputs/flutter-apk/app-release-$FLUTTER_VERSION.apk \ No newline at end of file diff --git a/features/scripts/build_ios_app.sh b/features/scripts/build_ios_app.sh index d6061dd3..559d490b 100755 --- a/features/scripts/build_ios_app.sh +++ b/features/scripts/build_ios_app.sh @@ -7,5 +7,3 @@ fi cd features/fixtures/app $FLUTTER_DIR build ipa --export-options-plist=ios/exportOptions.plist - -mv ../../../features/fixtures/app/build/ios/ipa/app.ipa ../../../features/fixtures/app/build/ios/ipa/app-$FLUTTER_VERSION.ipa \ No newline at end of file From cb84f6a4fc98bb80cfb105723e9f9d4e5cbc176e Mon Sep 17 00:00:00 2001 From: Josh Edney Date: Mon, 30 May 2022 16:37:01 +0100 Subject: [PATCH 07/26] chore: update bin directory in pipeline --- .buildkite/pipeline.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 048a3d4e..3cace1e9 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -6,35 +6,35 @@ steps: - label: ":test_tube: 2.8.1" timeout_in_minutes: 10 env: - FLUTTER_DIR: "/usr/local/bin/flutter-2.8.1" + FLUTTER_DIR: "/opt/flutter/2.8.1/bin/flutter" commands: - make test - label: ":test_tube: 3.0.1" timeout_in_minutes: 10 env: - FLUTTER_DIR: "/usr/local/bin/flutter-3.0.1" + FLUTTER_DIR: "/opt/flutter/3.0.1/bin/flutter" commands: - make test - label: ":lint-roller: 2.8.1" timeout_in_minutes: 10 env: - FLUTTER_DIR: "/usr/local/bin/flutter-2.8.1" + FLUTTER_DIR: "/opt/flutter/2.8.1/bin/flutter" commands: - make lint - label: ":lint-roller: 3.0.1" timeout_in_minutes: 10 env: - FLUTTER_DIR: "/usr/local/bin/flutter-3.0.1" + FLUTTER_DIR: "/opt/flutter/3.0.1/bin/flutter" commands: - make lint - label: Build Example App 2.8.1 timeout_in_minutes: 10 env: - FLUTTER_DIR: "/usr/local/bin/flutter-2.8.1" + FLUTTER_DIR: "/opt/flutter/2.8.1/bin/flutter" commands: - pod repo update - make example @@ -48,7 +48,7 @@ steps: - label: Build Example App 3.0.1 timeout_in_minutes: 10 env: - FLUTTER_DIR: "/usr/local/bin/flutter-3.0.1" + FLUTTER_DIR: "/opt/flutter/3.0.1/bin/flutter" commands: - pod repo update - make example @@ -66,7 +66,7 @@ steps: key: "ios-fixture-2-0-0" timeout_in_minutes: 20 env: - FLUTTER_DIR: "/usr/local/bin/flutter-2.8.1" + FLUTTER_DIR: "/opt/flutter/2.8.1/bin/flutter" commands: - pod repo update trunk - features/scripts/build_ios_app.sh @@ -80,7 +80,7 @@ steps: key: "ios-fixture-3-0-1" timeout_in_minutes: 20 env: - FLUTTER_DIR: "/usr/local/bin/flutter-3.0.1" + FLUTTER_DIR: "/opt/flutter/3.0.1/bin/flutter" commands: - pod repo update trunk - features/scripts/build_ios_app.sh @@ -94,7 +94,7 @@ steps: depends_on: "ios-fixture-2-0-0" timeout_in_minutes: 10 env: - FLUTTER_DIR: "/usr/local/bin/flutter-2.8.1" + FLUTTER_DIR: "/opt/flutter/2.8.1/bin/flutter" agents: queue: opensource plugins: @@ -117,7 +117,7 @@ steps: depends_on: "ios-fixture-3-0-1" timeout_in_minutes: 10 env: - FLUTTER_DIR: "/usr/local/bin/flutter-3.0.1" + FLUTTER_DIR: "/opt/flutter/3.0.1/bin/flutter" agents: queue: opensource plugins: @@ -143,7 +143,7 @@ steps: key: "android-fixture-2-0-0" timeout_in_minutes: 20 env: - FLUTTER_DIR: "/usr/local/bin/flutter-2.8.1" + FLUTTER_DIR: "/opt/flutter/2.8.1/bin/flutter" commands: - features/scripts/build_android_app.sh plugins: @@ -156,7 +156,7 @@ steps: key: "android-fixture-3-0-1" timeout_in_minutes: 20 env: - FLUTTER_DIR: "/usr/local/bin/flutter-3.0.1" + FLUTTER_DIR: "/opt/flutter/3.0.1/bin/flutter" commands: - features/scripts/build_android_app.sh plugins: @@ -169,7 +169,7 @@ steps: depends_on: "android-fixture-2-0-0" timeout_in_minutes: 10 env: - FLUTTER_DIR: "/usr/local/bin/flutter-2.8.1" + FLUTTER_DIR: "/opt/flutter/2.8.1/bin/flutter" agents: queue: opensource plugins: @@ -192,7 +192,7 @@ steps: depends_on: "android-fixture-3-0-1" timeout_in_minutes: 10 env: - FLUTTER_DIR: "/usr/local/bin/flutter-3.0.1" + FLUTTER_DIR: "/opt/flutter/3.0.1/bin/flutter" agents: queue: opensource plugins: From c450fb0145141936665c387d1323c0fc7ad2c5df Mon Sep 17 00:00:00 2001 From: Nick Dowell Date: Tue, 31 May 2022 10:06:14 +0100 Subject: [PATCH 08/26] Rename http.dart -> bugsnag_flutter_http.dart --- example/lib/main.dart | 4 ++-- .../lib/{http.dart => bugsnag_flutter_http.dart} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename packages/bugsnag_flutter_http/lib/{http.dart => bugsnag_flutter_http.dart} (100%) diff --git a/example/lib/main.dart b/example/lib/main.dart index 7e147017..b791a1e9 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'package:bugsnag_example/native_crashes.dart'; -import 'package:bugsnag_flutter_http/http.dart' as http; +import 'package:bugsnag_flutter_http/bugsnag_flutter_http.dart' as http; import 'package:bugsnag_flutter/bugsnag_flutter.dart'; import 'package:flutter/material.dart'; @@ -75,7 +75,7 @@ class ExampleHomeScreen extends StatelessWidget { // Use the bugsnag_flutter_http package to automatically capture breadcrumbs // for network requests: - // import 'package:bugsnag_flutter_http/http.dart' as http; + // import 'package:bugsnag_flutter_http/bugsnag_flutter_http.dart' as http; void _networkSuccess() async => http.get(Uri.parse('https://example.com')); void _networkFailure() async => diff --git a/packages/bugsnag_flutter_http/lib/http.dart b/packages/bugsnag_flutter_http/lib/bugsnag_flutter_http.dart similarity index 100% rename from packages/bugsnag_flutter_http/lib/http.dart rename to packages/bugsnag_flutter_http/lib/bugsnag_flutter_http.dart From 93347f5b8480265ef33e02e1d3d034171b697c66 Mon Sep 17 00:00:00 2001 From: Josh Edney Date: Tue, 31 May 2022 10:30:44 +0100 Subject: [PATCH 09/26] chore: update pipeline queue --- .buildkite/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 3cace1e9..b4d33d5a 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -1,5 +1,5 @@ agents: - queue: ms-arm-12-8 + queue: macos-12-arm steps: From 03c8e8a98b07f0ccf65ad2351c3ee156e7ab2f59 Mon Sep 17 00:00:00 2001 From: Josh <46817760+joshedney@users.noreply.github.com> Date: Tue, 31 May 2022 15:52:08 +0100 Subject: [PATCH 10/26] Update .buildkite/pipeline.yml Co-authored-by: Steve Kirkland --- .buildkite/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index b4d33d5a..6f57b864 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -63,7 +63,7 @@ steps: # iOS # - label: Build iOS Test Fixture 2.8.1 - key: "ios-fixture-2-0-0" + key: "ios-fixture-2-8-1" timeout_in_minutes: 20 env: FLUTTER_DIR: "/opt/flutter/2.8.1/bin/flutter" From 70de367deccee995500a36a207d52117666c12d7 Mon Sep 17 00:00:00 2001 From: Josh <46817760+joshedney@users.noreply.github.com> Date: Tue, 31 May 2022 15:52:13 +0100 Subject: [PATCH 11/26] Update .buildkite/pipeline.yml Co-authored-by: Steve Kirkland --- .buildkite/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 6f57b864..5d62fdf2 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -140,7 +140,7 @@ steps: # Android # - label: Build Android Test Fixture 2.8.1 - key: "android-fixture-2-0-0" + key: "android-fixture-2-8-1" timeout_in_minutes: 20 env: FLUTTER_DIR: "/opt/flutter/2.8.1/bin/flutter" From 4b4aa8f13b9a90277536fba40d8e3ff21b06dfe2 Mon Sep 17 00:00:00 2001 From: Josh <46817760+joshedney@users.noreply.github.com> Date: Tue, 31 May 2022 15:52:19 +0100 Subject: [PATCH 12/26] Update .buildkite/pipeline.yml Co-authored-by: Steve Kirkland --- .buildkite/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 5d62fdf2..1a0b1d18 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -166,7 +166,7 @@ steps: to: "features/fixtures/app/build/app/outputs/flutter-apk/app-release-3.0.1.apk" - label: 'Android 12 end-to-end tests 2.8.1' - depends_on: "android-fixture-2-0-0" + depends_on: "android-fixture-2-8-1" timeout_in_minutes: 10 env: FLUTTER_DIR: "/opt/flutter/2.8.1/bin/flutter" From 0e477af88b23cbda6741a5cf54a95244b2fd1072 Mon Sep 17 00:00:00 2001 From: Josh <46817760+joshedney@users.noreply.github.com> Date: Tue, 31 May 2022 15:52:27 +0100 Subject: [PATCH 13/26] Update .buildkite/pipeline.yml Co-authored-by: Steve Kirkland --- .buildkite/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 1a0b1d18..5aa19cea 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -91,7 +91,7 @@ steps: to: "features/fixtures/app/build/ios/ipa/app-3.0.1.ipa" - label: 'iOS 14 end-to-end tests 2.8.1' - depends_on: "ios-fixture-2-0-0" + depends_on: "ios-fixture-2-8-1" timeout_in_minutes: 10 env: FLUTTER_DIR: "/opt/flutter/2.8.1/bin/flutter" From d538b52083d970753eaa9f849584faf6688501d3 Mon Sep 17 00:00:00 2001 From: Josh Edney Date: Tue, 31 May 2022 15:54:11 +0100 Subject: [PATCH 14/26] chore: update FLUTTER exe variable --- .buildkite/pipeline.yml | 28 +++++++++++++-------------- Makefile | 18 ++++++++--------- features/scripts/build_android_app.sh | 8 +++++--- features/scripts/build_ios_app.sh | 8 +++++--- 4 files changed, 33 insertions(+), 29 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 5aa19cea..f95ac082 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -6,35 +6,35 @@ steps: - label: ":test_tube: 2.8.1" timeout_in_minutes: 10 env: - FLUTTER_DIR: "/opt/flutter/2.8.1/bin/flutter" + FLUTTER_BIN: "/opt/flutter/2.8.1/bin/flutter" commands: - make test - label: ":test_tube: 3.0.1" timeout_in_minutes: 10 env: - FLUTTER_DIR: "/opt/flutter/3.0.1/bin/flutter" + FLUTTER_BIN: "/opt/flutter/3.0.1/bin/flutter" commands: - make test - label: ":lint-roller: 2.8.1" timeout_in_minutes: 10 env: - FLUTTER_DIR: "/opt/flutter/2.8.1/bin/flutter" + FLUTTER_BIN: "/opt/flutter/2.8.1/bin/flutter" commands: - make lint - label: ":lint-roller: 3.0.1" timeout_in_minutes: 10 env: - FLUTTER_DIR: "/opt/flutter/3.0.1/bin/flutter" + FLUTTER_BIN: "/opt/flutter/3.0.1/bin/flutter" commands: - make lint - label: Build Example App 2.8.1 timeout_in_minutes: 10 env: - FLUTTER_DIR: "/opt/flutter/2.8.1/bin/flutter" + FLUTTER_BIN: "/opt/flutter/2.8.1/bin/flutter" commands: - pod repo update - make example @@ -48,7 +48,7 @@ steps: - label: Build Example App 3.0.1 timeout_in_minutes: 10 env: - FLUTTER_DIR: "/opt/flutter/3.0.1/bin/flutter" + FLUTTER_BIN: "/opt/flutter/3.0.1/bin/flutter" commands: - pod repo update - make example @@ -66,7 +66,7 @@ steps: key: "ios-fixture-2-8-1" timeout_in_minutes: 20 env: - FLUTTER_DIR: "/opt/flutter/2.8.1/bin/flutter" + FLUTTER_BIN: "/opt/flutter/2.8.1/bin/flutter" commands: - pod repo update trunk - features/scripts/build_ios_app.sh @@ -80,7 +80,7 @@ steps: key: "ios-fixture-3-0-1" timeout_in_minutes: 20 env: - FLUTTER_DIR: "/opt/flutter/3.0.1/bin/flutter" + FLUTTER_BIN: "/opt/flutter/3.0.1/bin/flutter" commands: - pod repo update trunk - features/scripts/build_ios_app.sh @@ -94,7 +94,7 @@ steps: depends_on: "ios-fixture-2-8-1" timeout_in_minutes: 10 env: - FLUTTER_DIR: "/opt/flutter/2.8.1/bin/flutter" + FLUTTER_BIN: "/opt/flutter/2.8.1/bin/flutter" agents: queue: opensource plugins: @@ -117,7 +117,7 @@ steps: depends_on: "ios-fixture-3-0-1" timeout_in_minutes: 10 env: - FLUTTER_DIR: "/opt/flutter/3.0.1/bin/flutter" + FLUTTER_BIN: "/opt/flutter/3.0.1/bin/flutter" agents: queue: opensource plugins: @@ -143,7 +143,7 @@ steps: key: "android-fixture-2-8-1" timeout_in_minutes: 20 env: - FLUTTER_DIR: "/opt/flutter/2.8.1/bin/flutter" + FLUTTER_BIN: "/opt/flutter/2.8.1/bin/flutter" commands: - features/scripts/build_android_app.sh plugins: @@ -156,7 +156,7 @@ steps: key: "android-fixture-3-0-1" timeout_in_minutes: 20 env: - FLUTTER_DIR: "/opt/flutter/3.0.1/bin/flutter" + FLUTTER_BIN: "/opt/flutter/3.0.1/bin/flutter" commands: - features/scripts/build_android_app.sh plugins: @@ -169,7 +169,7 @@ steps: depends_on: "android-fixture-2-8-1" timeout_in_minutes: 10 env: - FLUTTER_DIR: "/opt/flutter/2.8.1/bin/flutter" + FLUTTER_BIN: "/opt/flutter/2.8.1/bin/flutter" agents: queue: opensource plugins: @@ -192,7 +192,7 @@ steps: depends_on: "android-fixture-3-0-1" timeout_in_minutes: 10 env: - FLUTTER_DIR: "/opt/flutter/3.0.1/bin/flutter" + FLUTTER_BIN: "/opt/flutter/3.0.1/bin/flutter" agents: queue: opensource plugins: diff --git a/Makefile b/Makefile index 27f21a7a..9a7f3b3b 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,12 @@ -FLUTTER_DIR?=flutter +FLUTTER_BIN?=flutter all: format build lint test .PHONY: clean build bump aar example test format lint e2e_android_local e2e_ios_local clean: - cd packages/bugsnag_flutter && $(FLUTTER_DIR) clean --suppress-analytics - cd example && $(FLUTTER_DIR) clean --suppress-analytics && \ + cd packages/bugsnag_flutter && $(FLUTTER_BIN) clean --suppress-analytics + cd example && $(FLUTTER_BIN) clean --suppress-analytics && \ rm -rf .idea bugsnag_flutter_example.iml \ ios/{Pods,.symlinks,Podfile.lock} \ ios/{Runner.xcworkspace,Runner.xcodeproj,Runner.xcodeproj/project.xcworkspace}/xcuserdata \ @@ -34,13 +34,13 @@ stage: clean sed -i '' -e '1,2d' staging/CHANGELOG.md aar: - cd packages/bugsnag_flutter && $(FLUTTER_DIR) build aar --suppress-analytics + cd packages/bugsnag_flutter && $(FLUTTER_BIN) build aar --suppress-analytics example: - cd example && $(FLUTTER_DIR) build apk --suppress-analytics && $(FLUTTER_DIR) build ios --no-codesign --suppress-analytics + cd example && $(FLUTTER_BIN) build apk --suppress-analytics && $(FLUTTER_BIN) build ios --no-codesign --suppress-analytics test: - cd packages/bugsnag_flutter && $(FLUTTER_DIR) test -r expanded --suppress-analytics + cd packages/bugsnag_flutter && $(FLUTTER_BIN) test -r expanded --suppress-analytics test-fixtures: ## Build the end-to-end test fixtures @./features/scripts/build_ios_app.sh @@ -50,18 +50,18 @@ format: flutter format packages/bugsnag_flutter example features/fixtures/app lint: - cd packages/bugsnag_flutter && $(FLUTTER_DIR) analyze --suppress-analytics + cd packages/bugsnag_flutter && $(FLUTTER_BIN) analyze --suppress-analytics e2e_android_local: features/fixtures/app/build/app/outputs/flutter-apk/app-release.apk $(HOME)/Library/Android/sdk/platform-tools/adb uninstall com.bugsnag.flutter.test.app || true bundle exec maze-runner --app=$< --farm=local --os=android --os-version=10 $(FEATURES) features/fixtures/app/build/app/outputs/flutter-apk/app-release.apk: $(shell find packages/bugsnag_flutter features/fixtures/app/android/app/src features/fixtures/app/lib -type f) - cd features/fixtures/app && $(FLUTTER_DIR) build apk + cd features/fixtures/app && $(FLUTTER_BIN) build apk e2e_ios_local: features/fixtures/app/build/ios/ipa/app.ipa ideviceinstaller --uninstall com.bugsnag.flutter.test.app bundle exec maze-runner --app=$< --farm=local --os=ios --os-version=15 --apple-team-id=372ZUL2ZB7 --udid="$(shell idevice_id -l)" $(FEATURES) features/fixtures/app/build/ios/ipa/app.ipa: $(shell find packages/bugsnag_flutter features/fixtures/app/ios/Runner features/fixtures/app/lib -type f) - cd features/fixtures/app && $(FLUTTER_DIR) build ipa --export-options-plist=ios/exportOptions.plist + cd features/fixtures/app && $(FLUTTER_BIN) build ipa --export-options-plist=ios/exportOptions.plist diff --git a/features/scripts/build_android_app.sh b/features/scripts/build_android_app.sh index a1016c51..3f1e1612 100755 --- a/features/scripts/build_android_app.sh +++ b/features/scripts/build_android_app.sh @@ -1,9 +1,11 @@ #!/usr/bin/env bash set -o errexit -if [ -z "$FLUTTER_DIR" ]; then - FLUTTER_DIR="flutter" +if [ -z "$FLUTTER_BIN" ]; then + FLUTTER_BIN="flutter" fi +echo "Flutter Bin: $FLUTTER_BIN" + cd features/fixtures/app -$FLUTTER_DIR build apk +$FLUTTER_BIN build apk diff --git a/features/scripts/build_ios_app.sh b/features/scripts/build_ios_app.sh index 559d490b..ee16ec79 100755 --- a/features/scripts/build_ios_app.sh +++ b/features/scripts/build_ios_app.sh @@ -1,9 +1,11 @@ #!/usr/bin/env bash set -o errexit -if [ -z "$FLUTTER_DIR" ]; then - FLUTTER_DIR="flutter" +if [ -z "$FLUTTER_BIN" ]; then + FLUTTER_BIN="flutter" fi +echo "Flutter Bin: $FLUTTER_BIN" + cd features/fixtures/app -$FLUTTER_DIR build ipa --export-options-plist=ios/exportOptions.plist +$FLUTTER_BIN build ipa --export-options-plist=ios/exportOptions.plist From 310ddde5ca59acc1adec53ab5fcb330295b56ce1 Mon Sep 17 00:00:00 2001 From: Josh Edney Date: Wed, 1 Jun 2022 10:52:46 +0100 Subject: [PATCH 15/26] chore: update make file --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9a7f3b3b..4d0b607c 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,7 @@ test-fixtures: ## Build the end-to-end test fixtures @./features/scripts/build_android_app.sh format: - flutter format packages/bugsnag_flutter example features/fixtures/app + $(FLUTTER_BIN) format packages/bugsnag_flutter example features/fixtures/app lint: cd packages/bugsnag_flutter && $(FLUTTER_BIN) analyze --suppress-analytics From 7cc889f702f473b8975fad3499864df40d21d117 Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 7 Jun 2022 14:00:33 +0100 Subject: [PATCH 16/26] fix: port to Flutter 2.5.0 --- example/pubspec.yaml | 2 +- .../lib/src/bugsnag_stacktrace.dart | 2 +- packages/bugsnag_flutter/lib/src/client.dart | 10 +++------- packages/bugsnag_flutter/lib/src/enum_utils.dart | 15 +++++++++++++++ .../lib/src/model/breadcrumbs.dart | 5 +++-- packages/bugsnag_flutter/lib/src/model/event.dart | 9 ++++++--- .../bugsnag_flutter/lib/src/model/stackframe.dart | 6 ++++-- .../bugsnag_flutter/lib/src/model/thread.dart | 4 +++- packages/bugsnag_flutter/pubspec.yaml | 4 ++-- 9 files changed, 38 insertions(+), 19 deletions(-) create mode 100644 packages/bugsnag_flutter/lib/src/enum_utils.dart diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 56fb5727..f8d4d664 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -7,7 +7,7 @@ description: Demonstrates how to use the bugsnag_flutter package. publish_to: 'none' # Remove this line if you wish to publish to pub.dev environment: - sdk: ">=2.15.1 <3.0.0" + sdk: ">=2.12.0 <3.0.0" # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions diff --git a/packages/bugsnag_flutter/lib/src/bugsnag_stacktrace.dart b/packages/bugsnag_flutter/lib/src/bugsnag_stacktrace.dart index a0d2d74d..5a0aa31e 100644 --- a/packages/bugsnag_flutter/lib/src/bugsnag_stacktrace.dart +++ b/packages/bugsnag_flutter/lib/src/bugsnag_stacktrace.dart @@ -68,7 +68,7 @@ int? _parseBaseAddress(String line) { BugsnagStacktrace? _parseStackTrace(String stackTraceString) { try { return StackFrame.fromStackTrace(StackTrace.fromString(stackTraceString)) - .map(BugsnagStackframe.fromStackFrame) + .map((frame) => BugsnagStackframe.fromStackFrame(frame)) .toList(); } catch (e) { return null; diff --git a/packages/bugsnag_flutter/lib/src/client.dart b/packages/bugsnag_flutter/lib/src/client.dart index 4dfc1d74..54f65ec6 100644 --- a/packages/bugsnag_flutter/lib/src/client.dart +++ b/packages/bugsnag_flutter/lib/src/client.dart @@ -10,6 +10,7 @@ import 'package:flutter/widgets.dart' show WidgetsFlutterBinding; import 'callbacks.dart'; import 'config.dart'; +import 'enum_utils.dart'; import 'last_run_info.dart'; import 'model.dart'; @@ -714,7 +715,7 @@ class Bugsnag extends BugsnagClient with DelegateClient { 'maxPersistedEvents': maxPersistedEvents, 'autoTrackSessions': autoTrackSessions, 'autoDetectErrors': autoDetectErrors, - 'sendThreads': sendThreads._toName(), + 'sendThreads': sendThreads.toName(), 'launchDurationMillis': launchDurationMillis, 'sendLaunchCrashesSynchronously': sendLaunchCrashesSynchronously, 'appHangThresholdMillis': appHangThresholdMillis, @@ -724,7 +725,7 @@ class Bugsnag extends BugsnagClient with DelegateClient { 'enabledReleaseStages': enabledReleaseStages.toList(), 'enabledBreadcrumbTypes': (enabledBreadcrumbTypes ?? BugsnagEnabledBreadcrumbType.values) - .map((e) => e._toName()) + .map((e) => e.toName()) .toList(), 'projectPackages': projectPackages, if (metadata != null) 'metadata': BugsnagMetadata(metadata), @@ -840,8 +841,3 @@ class BugsnagProjectPackages { /// Primary access to the Bugsnag API, most calls to Bugsnag will start here final Bugsnag bugsnag = Bugsnag._internal(); - -// The official EnumName extension was only added in 2.15 -extension _EnumName on Enum { - String _toName() => toString().split('.').last; -} diff --git a/packages/bugsnag_flutter/lib/src/enum_utils.dart b/packages/bugsnag_flutter/lib/src/enum_utils.dart new file mode 100644 index 00000000..cc32d0e5 --- /dev/null +++ b/packages/bugsnag_flutter/lib/src/enum_utils.dart @@ -0,0 +1,15 @@ +// The official EnumName extension was only added in 2.15 +extension EnumName on Enum { + String toName() => toString().split('.').last; +} + +// The official EnumByName extension was only added in 2.15 +extension EnumByName on Iterable { + T findByName(String name) { + for (var value in this) { + if (value.toName() == name) return value; + } + + throw ArgumentError.value(name, "name", "No enum value with that name"); + } +} diff --git a/packages/bugsnag_flutter/lib/src/model/breadcrumbs.dart b/packages/bugsnag_flutter/lib/src/model/breadcrumbs.dart index b4f651f2..f2cd1b78 100644 --- a/packages/bugsnag_flutter/lib/src/model/breadcrumbs.dart +++ b/packages/bugsnag_flutter/lib/src/model/breadcrumbs.dart @@ -1,3 +1,4 @@ +import '../enum_utils.dart'; import '_model_extensions.dart'; import 'metadata.dart'; @@ -17,14 +18,14 @@ class BugsnagBreadcrumb { BugsnagBreadcrumb.fromJson(Map json) : message = json.safeGet('name'), timestamp = DateTime.parse(json['timestamp'] as String).toUtc(), - type = BugsnagBreadcrumbType.values.byName(json['type'] as String), + type = BugsnagBreadcrumbType.values.findByName(json['type'] as String), metadata = json .safeGet('metaData') ?.let((map) => BugsnagMetadata.sanitizedMap(map.cast())); dynamic toJson() => { 'name': message, - 'type': type.name, + 'type': type.toName(), 'timestamp': timestamp.toIso8601String(), 'metaData': metadata ?? {}, }; diff --git a/packages/bugsnag_flutter/lib/src/model/event.dart b/packages/bugsnag_flutter/lib/src/model/event.dart index 67f3cc5a..8c533ef9 100644 --- a/packages/bugsnag_flutter/lib/src/model/event.dart +++ b/packages/bugsnag_flutter/lib/src/model/event.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import '../enum_utils.dart'; import '_model_extensions.dart'; import 'app.dart'; import 'breadcrumbs.dart'; @@ -152,7 +153,7 @@ class BugsnagEvent { groupingHash = json['groupingHash'] as String?, _unhandled = json['unhandled'] == true, _originalUnhandled = json['unhandled'] == true, - severity = BugsnagSeverity.values.byName(json['severity']), + severity = BugsnagSeverity.values.findByName(json['severity']), _severityReason = _SeverityReason.fromJson(json['severityReason']), _projectPackages = (json['projectPackages'] as List?)?.toList(growable: true).cast() ?? @@ -179,7 +180,7 @@ class BugsnagEvent { if (context != null) 'context': context, if (groupingHash != null) 'groupingHash': groupingHash, 'unhandled': unhandled, - 'severity': severity.name, + 'severity': severity.toName(), 'severityReason': _severityReason, 'projectPackages': _projectPackages, 'user': user, @@ -260,7 +261,9 @@ class BugsnagError { BugsnagError.fromJson(Map json) : errorClass = json.safeGet('errorClass'), message = json.safeGet('message'), - type = json.safeGet('type')?.let(BugsnagErrorType.forName) ?? + type = json + .safeGet('type') + ?.let((type) => BugsnagErrorType.forName(type)) ?? (Platform.isAndroid ? BugsnagErrorType.android : BugsnagErrorType.cocoa), diff --git a/packages/bugsnag_flutter/lib/src/model/stackframe.dart b/packages/bugsnag_flutter/lib/src/model/stackframe.dart index 7bba44b8..a62d9894 100644 --- a/packages/bugsnag_flutter/lib/src/model/stackframe.dart +++ b/packages/bugsnag_flutter/lib/src/model/stackframe.dart @@ -75,7 +75,9 @@ class BugsnagStackframe { }); BugsnagStackframe.fromJson(Map json) - : type = json.safeGet('type')?.let(BugsnagErrorType.forName), + : type = json + .safeGet('type') + ?.let((name) => BugsnagErrorType.forName(name)), file = json.safeGet('file'), lineNumber = json.safeGet('lineNumber')?.toInt(), columnNumber = json.safeGet('columnNumber')?.toInt(), @@ -142,7 +144,7 @@ class BugsnagStackframe { static BugsnagStacktrace stacktraceFromJson( List> json) => - json.map(BugsnagStackframe.fromJson).toList(); + json.map((element) => BugsnagStackframe.fromJson(element)).toList(); } typedef BugsnagStacktrace = List; diff --git a/packages/bugsnag_flutter/lib/src/model/thread.dart b/packages/bugsnag_flutter/lib/src/model/thread.dart index 53012663..1ba17258 100644 --- a/packages/bugsnag_flutter/lib/src/model/thread.dart +++ b/packages/bugsnag_flutter/lib/src/model/thread.dart @@ -43,7 +43,9 @@ class BugsnagThread { name = json.safeGet('name'), state = json.safeGet('state'), isErrorReportingThread = json.safeGet('errorReportingThread') == true, - type = json.safeGet('type')?.let(BugsnagErrorType.forName) ?? + type = json + .safeGet('type') + ?.let((name) => BugsnagErrorType.forName(name)) ?? (Platform.isAndroid ? BugsnagErrorType.android : BugsnagErrorType.cocoa), diff --git a/packages/bugsnag_flutter/pubspec.yaml b/packages/bugsnag_flutter/pubspec.yaml index 7fdac8b5..6f9cf1bf 100644 --- a/packages/bugsnag_flutter/pubspec.yaml +++ b/packages/bugsnag_flutter/pubspec.yaml @@ -7,8 +7,8 @@ repository: https://github.com/bugsnag/bugsnag-flutter issue_tracker: https://github.com/bugsnag/bugsnag-flutter/issues environment: - sdk: ">=2.15.1 <3.0.0" - flutter: ">=2.0.0" + sdk: ">=2.14.0 <3.0.0" + flutter: ">=2.5.0" dependencies: flutter: From 80657f023db68b3522f95a9543001cdb9e5a4151 Mon Sep 17 00:00:00 2001 From: Jason Date: Wed, 8 Jun 2022 08:23:58 +0100 Subject: [PATCH 17/26] chore: target Flutter 2.5.0 and 3.0.1 on CI builds --- .buildkite/pipeline.yml | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index f95ac082..a572027a 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -3,10 +3,10 @@ agents: steps: - - label: ":test_tube: 2.8.1" + - label: ":test_tube: 2.5.0" timeout_in_minutes: 10 env: - FLUTTER_BIN: "/opt/flutter/2.8.1/bin/flutter" + FLUTTER_BIN: "/opt/flutter/2.5.0/bin/flutter" commands: - make test @@ -17,10 +17,10 @@ steps: commands: - make test - - label: ":lint-roller: 2.8.1" + - label: ":lint-roller: 2.5.0" timeout_in_minutes: 10 env: - FLUTTER_BIN: "/opt/flutter/2.8.1/bin/flutter" + FLUTTER_BIN: "/opt/flutter/2.5.0/bin/flutter" commands: - make lint @@ -31,10 +31,10 @@ steps: commands: - make lint - - label: Build Example App 2.8.1 + - label: Build Example App 2.5.0 timeout_in_minutes: 10 env: - FLUTTER_BIN: "/opt/flutter/2.8.1/bin/flutter" + FLUTTER_BIN: "/opt/flutter/2.5.0/bin/flutter" commands: - pod repo update - make example @@ -62,11 +62,11 @@ steps: # # iOS # - - label: Build iOS Test Fixture 2.8.1 + - label: Build iOS Test Fixture 2.5.0 key: "ios-fixture-2-8-1" timeout_in_minutes: 20 env: - FLUTTER_BIN: "/opt/flutter/2.8.1/bin/flutter" + FLUTTER_BIN: "/opt/flutter/2.5.0/bin/flutter" commands: - pod repo update trunk - features/scripts/build_ios_app.sh @@ -74,7 +74,7 @@ steps: artifacts#v1.5.0: upload: from: "features/fixtures/app/build/ios/ipa/app.ipa" - to: "features/fixtures/app/build/ios/ipa/app-2.8.1.ipa" + to: "features/fixtures/app/build/ios/ipa/app-2.5.0.ipa" - label: Build iOS Test Fixture 3.0.1 key: "ios-fixture-3-0-1" @@ -90,22 +90,22 @@ steps: from: "features/fixtures/app/build/ios/ipa/app.ipa" to: "features/fixtures/app/build/ios/ipa/app-3.0.1.ipa" - - label: 'iOS 14 end-to-end tests 2.8.1' + - label: 'iOS 14 end-to-end tests 2.5.0' depends_on: "ios-fixture-2-8-1" timeout_in_minutes: 10 env: - FLUTTER_BIN: "/opt/flutter/2.8.1/bin/flutter" + FLUTTER_BIN: "/opt/flutter/2.5.0/bin/flutter" agents: queue: opensource plugins: artifacts#v1.5.0: - download: "features/fixtures/app/build/ios/ipa/app-2.8.1.ipa" + download: "features/fixtures/app/build/ios/ipa/app-2.5.0.ipa" upload: "maze_output/failed/**/*" docker-compose#v3.7.0: pull: maze-runner run: maze-runner command: - - "--app=/app/features/fixtures/app/build/ios/ipa/app-2.8.1.ipa" + - "--app=/app/features/fixtures/app/build/ios/ipa/app-2.5.0.ipa" - "--farm=bs" - "--device=IOS_14" - "--fail-fast" @@ -139,18 +139,18 @@ steps: # # Android # - - label: Build Android Test Fixture 2.8.1 + - label: Build Android Test Fixture 2.5.0 key: "android-fixture-2-8-1" timeout_in_minutes: 20 env: - FLUTTER_BIN: "/opt/flutter/2.8.1/bin/flutter" + FLUTTER_BIN: "/opt/flutter/2.5.0/bin/flutter" commands: - features/scripts/build_android_app.sh plugins: artifacts#v1.5.0: upload: from: "features/fixtures/app/build/app/outputs/flutter-apk/app-release.apk" - to: "features/fixtures/app/build/app/outputs/flutter-apk/app-release-2.8.1.apk" + to: "features/fixtures/app/build/app/outputs/flutter-apk/app-release-2.5.0.apk" - label: Build Android Test Fixture 3.0.1 key: "android-fixture-3-0-1" @@ -165,22 +165,22 @@ steps: from: "features/fixtures/app/build/app/outputs/flutter-apk/app-release.apk" to: "features/fixtures/app/build/app/outputs/flutter-apk/app-release-3.0.1.apk" - - label: 'Android 12 end-to-end tests 2.8.1' + - label: 'Android 12 end-to-end tests 2.5.0' depends_on: "android-fixture-2-8-1" timeout_in_minutes: 10 env: - FLUTTER_BIN: "/opt/flutter/2.8.1/bin/flutter" + FLUTTER_BIN: "/opt/flutter/2.5.0/bin/flutter" agents: queue: opensource plugins: artifacts#v1.5.0: - download: "features/fixtures/app/build/app/outputs/flutter-apk/app-release-2.8.1.apk" + download: "features/fixtures/app/build/app/outputs/flutter-apk/app-release-2.5.0.apk" upload: "maze_output/failed/**/*" docker-compose#v3.7.0: pull: maze-runner run: maze-runner command: - - "--app=/app/features/fixtures/app/build/app/outputs/flutter-apk/app-release-2.8.1.apk" + - "--app=/app/features/fixtures/app/build/app/outputs/flutter-apk/app-release-2.5.0.apk" - "--farm=bs" - "--device=ANDROID_12_0" - "--fail-fast" From f74cb81176a5bdd4f7a6d990c44fe8faa63fc404 Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 9 Jun 2022 09:25:31 +0100 Subject: [PATCH 18/26] chore: restructure example app and test fixture to build under Flutter 2.5.0 --- example/android/app/build.gradle | 6 +-- .../android/app/src/main/AndroidManifest.xml | 1 - .../fixtures/app/android/app/build.gradle | 4 +- .../android/app/src/main/AndroidManifest.xml | 1 - .../test/app/MazeRunnerMethodCallHandler.java | 12 +++-- .../fixtures/app/lib/scenarios/scenarios.dart | 45 ++++++++++--------- features/fixtures/app/pubspec.lock | 23 ++++------ features/fixtures/app/pubspec.yaml | 4 +- 8 files changed, 47 insertions(+), 49 deletions(-) diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 4d7da016..a8066dfd 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -25,7 +25,7 @@ apply plugin: 'com.android.application' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion flutter.compileSdkVersion + compileSdkVersion flutter.hasProperty('compileSdkVersion') ? flutter.compileSdkVersion : 30 compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 @@ -34,8 +34,8 @@ android { defaultConfig { applicationId "com.bugsnag.examples.flutter" - minSdkVersion flutter.minSdkVersion - targetSdkVersion flutter.targetSdkVersion + minSdkVersion flutter.hasProperty('minSdkVersion') ? flutter.minSdkVersion : 16 + targetSdkVersion flutter.hasProperty('targetSdkVersion') ? flutter.targetSdkVersion : 30 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index 1c504085..7b20627d 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -2,7 +2,6 @@ package="com.bugsnag.examples.flutter"> diff --git a/features/fixtures/app/android/app/src/main/java/com/bugsnag/flutter/test/app/MazeRunnerMethodCallHandler.java b/features/fixtures/app/android/app/src/main/java/com/bugsnag/flutter/test/app/MazeRunnerMethodCallHandler.java index 387b5b09..24909c5c 100644 --- a/features/fixtures/app/android/app/src/main/java/com/bugsnag/flutter/test/app/MazeRunnerMethodCallHandler.java +++ b/features/fixtures/app/android/app/src/main/java/com/bugsnag/flutter/test/app/MazeRunnerMethodCallHandler.java @@ -26,7 +26,7 @@ public class MazeRunnerMethodCallHandler implements MethodChannel.MethodCallHandler { public static final String TAG = "MazeRunner"; - private final Handler scenarioRunner = new Handler(Looper.getMainLooper()); + private final Handler mainHandler = new Handler(Looper.getMainLooper()); private final Context context; MazeRunnerMethodCallHandler(@NonNull Context context) { @@ -103,9 +103,13 @@ private void getCommand(@NonNull MethodCall call, @NonNull MethodChannel.Result for (String line; (line = reader.readLine()) != null; ) { sb.append(line); } - result.success(sb.toString()); + mainHandler.post(() -> { + result.success(sb.toString()); + }); } catch (Exception e) { - result.error(e.getClass().getSimpleName(), e.getMessage(), commandUrl); + mainHandler.post(() -> { + result.error(e.getClass().getSimpleName(), e.getMessage(), commandUrl); + }); } } @@ -122,7 +126,7 @@ private void runScenario(@NonNull MethodCall call, @NonNull MethodChannel.Result if (scenario != null) { // we push all scenarios to the main thread to stop Flutter catching the exceptions - scenarioRunner.post(() -> { + mainHandler.post(() -> { scenario.run(call.argument("extraConfig")); result.success(null); }); diff --git a/features/fixtures/app/lib/scenarios/scenarios.dart b/features/fixtures/app/lib/scenarios/scenarios.dart index 00f8b5df..fee82ff5 100644 --- a/features/fixtures/app/lib/scenarios/scenarios.dart +++ b/features/fixtures/app/lib/scenarios/scenarios.dart @@ -28,25 +28,28 @@ class ScenarioInfo { } // Flutter obfuscation *requires* that we specify the name as a raw String in order to match the runtime class -const List> scenarios = [ - ScenarioInfo('AppHangScenario', AppHangScenario.new), - ScenarioInfo('AttachBugsnagScenario', AttachBugsnagScenario.new), - ScenarioInfo('BreadcrumbsScenario', BreadcrumbsScenario.new), - ScenarioInfo('DetectEnabledErrorsScenario', DetectEnabledErrorsScenario.new), - ScenarioInfo('DiscardClassesScenario', DiscardClassesScenario.new), - ScenarioInfo('ErrorHandlerScenario', ErrorHandlerScenario.new), - ScenarioInfo('FeatureFlagsScenario', FeatureFlagsScenario.new), - ScenarioInfo('FFICrashScenario', FFICrashScenario.new), - ScenarioInfo('HandledExceptionScenario', HandledExceptionScenario.new), - ScenarioInfo('LastRunInfoScenario', LastRunInfoScenario.new), - ScenarioInfo('ManualSessionsScenario', ManualSessionsScenario.new), - ScenarioInfo('MetadataScenario', MetadataScenario.new), - ScenarioInfo('NativeCrashScenario', NativeCrashScenario.new), - ScenarioInfo('NavigatorBreadcrumbScenario', NavigatorBreadcrumbScenario.new), - ScenarioInfo('OnErrorScenario', OnErrorScenario.new), - ScenarioInfo('ProjectPackagesScenario', ProjectPackagesScenario.new), - ScenarioInfo('ReleaseStageScenario', ReleaseStageScenario.new), - ScenarioInfo('StartBugsnagScenario', StartBugsnagScenario.new), - ScenarioInfo('ThrowExceptionScenario', ThrowExceptionScenario.new), - ScenarioInfo('UnhandledExceptionScenario', UnhandledExceptionScenario.new), +final List> scenarios = [ + ScenarioInfo('AppHangScenario', () => AppHangScenario()), + ScenarioInfo('AttachBugsnagScenario', () => AttachBugsnagScenario()), + ScenarioInfo('BreadcrumbsScenario', () => BreadcrumbsScenario()), + ScenarioInfo( + 'DetectEnabledErrorsScenario', () => DetectEnabledErrorsScenario()), + ScenarioInfo('DiscardClassesScenario', () => DiscardClassesScenario()), + ScenarioInfo('ErrorHandlerScenario', () => ErrorHandlerScenario()), + ScenarioInfo('FeatureFlagsScenario', () => FeatureFlagsScenario()), + ScenarioInfo('FFICrashScenario', () => FFICrashScenario()), + ScenarioInfo('HandledExceptionScenario', () => HandledExceptionScenario()), + ScenarioInfo('LastRunInfoScenario', () => LastRunInfoScenario()), + ScenarioInfo('ManualSessionsScenario', () => ManualSessionsScenario()), + ScenarioInfo('MetadataScenario', () => MetadataScenario()), + ScenarioInfo('NativeCrashScenario', () => NativeCrashScenario()), + ScenarioInfo( + 'NavigatorBreadcrumbScenario', () => NavigatorBreadcrumbScenario()), + ScenarioInfo('OnErrorScenario', () => OnErrorScenario()), + ScenarioInfo('ProjectPackagesScenario', () => ProjectPackagesScenario()), + ScenarioInfo('ReleaseStageScenario', () => ReleaseStageScenario()), + ScenarioInfo('StartBugsnagScenario', () => StartBugsnagScenario()), + ScenarioInfo('ThrowExceptionScenario', () => ThrowExceptionScenario()), + ScenarioInfo( + 'UnhandledExceptionScenario', () => UnhandledExceptionScenario()), ]; diff --git a/features/fixtures/app/pubspec.lock b/features/fixtures/app/pubspec.lock index 6ed2d8bc..4cc04402 100644 --- a/features/fixtures/app/pubspec.lock +++ b/features/fixtures/app/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.2" + version: "2.8.1" boolean_selector: dependency: transitive description: @@ -21,14 +21,14 @@ packages: path: "../../../packages/bugsnag_flutter" relative: true source: path - version: "2.0.0-rc5" + version: "2.0.2" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.1.0" charcode: dependency: transitive description: @@ -108,14 +108,7 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.11" - material_color_utilities: - dependency: transitive - description: - name: material_color_utilities - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.3" + version: "0.12.10" meta: dependency: transitive description: @@ -176,7 +169,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.8" + version: "0.4.2" typed_data: dependency: transitive description: @@ -190,7 +183,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.0" sdks: - dart: ">=2.15.1 <3.0.0" - flutter: ">=2.0.0" + dart: ">=2.14.0 <3.0.0" + flutter: ">=2.5.0" diff --git a/features/fixtures/app/pubspec.yaml b/features/fixtures/app/pubspec.yaml index 204dbff1..3f4baf2b 100644 --- a/features/fixtures/app/pubspec.yaml +++ b/features/fixtures/app/pubspec.yaml @@ -18,8 +18,8 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.15.1 <3.0.0" - flutter: "2.0.0" + sdk: ">=2.12.0 <3.0.0" + flutter: "2.5.0" # Dependencies specify other packages that your package needs in order to work. # To automatically upgrade your package dependencies to the latest versions From 7e1ca160bba686de283dd3270084fe2fb2fdcdf3 Mon Sep 17 00:00:00 2001 From: Nick Dowell Date: Thu, 9 Jun 2022 14:22:28 +0100 Subject: [PATCH 19/26] [PLAT-8044] Network breadcrumbs for dart:io HttpClient (#116) --- Makefile | 11 +- example/lib/main.dart | 17 +- example/pubspec.yaml | 7 +- .../.gitignore | 0 .../.metadata | 0 .../analysis_options.yaml | 0 .../lib/bugsnag_breadcrumbs_dart_io.dart | 1 + .../lib/src/breadcrumb.dart | 35 ++++ .../lib/src/httpclient.dart | 160 ++++++++++++++++++ .../bugsnag_breadcrumbs_dart_io/pubspec.yaml | 22 +++ packages/bugsnag_breadcrumbs_http/.gitignore | 30 ++++ packages/bugsnag_breadcrumbs_http/.metadata | 10 ++ .../analysis_options.yaml | 4 + .../lib/bugsnag_breadcrumbs_http.dart} | 0 .../lib/src/breadcrumb.dart | 0 .../lib/src/client.dart | 0 .../pubspec.yaml | 4 +- .../test/breadcrumb_test.dart | 2 +- 18 files changed, 293 insertions(+), 10 deletions(-) rename packages/{bugsnag_flutter_http => bugsnag_breadcrumbs_dart_io}/.gitignore (100%) rename packages/{bugsnag_flutter_http => bugsnag_breadcrumbs_dart_io}/.metadata (100%) rename packages/{bugsnag_flutter_http => bugsnag_breadcrumbs_dart_io}/analysis_options.yaml (100%) create mode 100644 packages/bugsnag_breadcrumbs_dart_io/lib/bugsnag_breadcrumbs_dart_io.dart create mode 100644 packages/bugsnag_breadcrumbs_dart_io/lib/src/breadcrumb.dart create mode 100644 packages/bugsnag_breadcrumbs_dart_io/lib/src/httpclient.dart create mode 100644 packages/bugsnag_breadcrumbs_dart_io/pubspec.yaml create mode 100644 packages/bugsnag_breadcrumbs_http/.gitignore create mode 100644 packages/bugsnag_breadcrumbs_http/.metadata create mode 100644 packages/bugsnag_breadcrumbs_http/analysis_options.yaml rename packages/{bugsnag_flutter_http/lib/bugsnag_flutter_http.dart => bugsnag_breadcrumbs_http/lib/bugsnag_breadcrumbs_http.dart} (100%) rename packages/{bugsnag_flutter_http => bugsnag_breadcrumbs_http}/lib/src/breadcrumb.dart (100%) rename packages/{bugsnag_flutter_http => bugsnag_breadcrumbs_http}/lib/src/client.dart (100%) rename packages/{bugsnag_flutter_http => bugsnag_breadcrumbs_http}/pubspec.yaml (92%) rename packages/{bugsnag_flutter_http => bugsnag_breadcrumbs_http}/test/breadcrumb_test.dart (97%) diff --git a/Makefile b/Makefile index dbc0d28f..560ddaf4 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,8 @@ all: format build lint test clean: cd packages/bugsnag_flutter && $(FLUTTER_BIN) clean --suppress-analytics - cd packages/bugsnag_flutter_http && $(FLUTTER_BIN) clean --suppress-analytics + cd packages/bugsnag_breadcrumbs_dart_io && $(FLUTTER_BIN) clean --suppress-analytics + cd packages/bugsnag_breadcrumbs_http && $(FLUTTER_BIN) clean --suppress-analytics cd example && $(FLUTTER_BIN) clean --suppress-analytics && \ rm -rf .idea bugsnag_flutter_example.iml \ ios/{Pods,.symlinks,Podfile.lock} \ @@ -22,7 +23,8 @@ ifeq ($(VERSION),) endif sed -i '' "s/## TBD/## $(VERSION) ($(shell date '+%Y-%m-%d'))/" CHANGELOG.md sed -i '' "s/^version: .*/version: $(VERSION)/" packages/bugsnag_flutter/pubspec.yaml - sed -i '' "s/^version: .*/version: $(VERSION)/" packages/bugsnag_flutter_http/pubspec.yaml + sed -i '' "s/^version: .*/version: $(VERSION)/" packages/bugsnag_breadcrumbs_dart_io/pubspec.yaml + sed -i '' "s/^version: .*/version: $(VERSION)/" packages/bugsnag_breadcrumbs_http/pubspec.yaml sed -i '' "s/^ 'version': .*/ 'version': '$(VERSION)'/" packages/bugsnag_flutter/lib/src/client.dart stage: clean @@ -43,7 +45,7 @@ example: test: cd packages/bugsnag_flutter && $(FLUTTER_BIN) test -r expanded --suppress-analytics - cd packages/bugsnag_flutter_http && $(FLUTTER_BIN) test -r expanded --suppress-analytics + cd packages/bugsnag_breadcrumbs_http && $(FLUTTER_BIN) test -r expanded --suppress-analytics test-fixtures: ## Build the end-to-end test fixtures @./features/scripts/build_ios_app.sh @@ -54,7 +56,8 @@ format: lint: cd packages/bugsnag_flutter && $(FLUTTER_BIN) analyze --suppress-analytics - cd packages/bugsnag_flutter_http && $(FLUTTER_BIN) analyze --suppress-analytics + cd packages/bugsnag_breadcrumbs_dart_io && $(FLUTTER_BIN) analyze --suppress-analytics + cd packages/bugsnag_breadcrumbs_http && $(FLUTTER_BIN) analyze --suppress-analytics e2e_android_local: features/fixtures/app/build/app/outputs/flutter-apk/app-release.apk $(HOME)/Library/Android/sdk/platform-tools/adb uninstall com.bugsnag.flutter.test.app || true diff --git a/example/lib/main.dart b/example/lib/main.dart index b791a1e9..4713cc45 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,7 +1,8 @@ import 'dart:async'; +import 'package:bugsnag_breadcrumbs_dart_io/bugsnag_breadcrumbs_dart_io.dart'; +import 'package:bugsnag_breadcrumbs_http/bugsnag_breadcrumbs_http.dart' as http; import 'package:bugsnag_example/native_crashes.dart'; -import 'package:bugsnag_flutter_http/bugsnag_flutter_http.dart' as http; import 'package:bugsnag_flutter/bugsnag_flutter.dart'; import 'package:flutter/material.dart'; @@ -84,6 +85,16 @@ class ExampleHomeScreen extends StatelessWidget { void _networkError() async => http.get(Uri.parse('https://example.invalid')).ignore(); + void _networkHttpClient() async { + var client = BugsnagHttpClient(); + try { + final request = await client.getUrl(Uri.parse('https://example.com')); + await request.close(); + } finally { + client.close(); + } + } + @override Widget build(BuildContext context) { return Scaffold( @@ -152,6 +163,10 @@ class ExampleHomeScreen extends StatelessWidget { onPressed: _networkError, child: const Text('Error'), ), + ElevatedButton( + onPressed: _networkHttpClient, + child: const Text('HttpClient'), + ), ], ), ), diff --git a/example/pubspec.yaml b/example/pubspec.yaml index ab9adaf5..5163cc33 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -27,8 +27,11 @@ dependencies: # the parent directory to use the current plugin's version. path: ../packages/bugsnag_flutter - bugsnag_flutter_http: - path: ../packages/bugsnag_flutter_http + bugsnag_breadcrumbs_dart_io: + path: ../packages/bugsnag_breadcrumbs_dart_io + + bugsnag_breadcrumbs_http: + path: ../packages/bugsnag_breadcrumbs_http # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. diff --git a/packages/bugsnag_flutter_http/.gitignore b/packages/bugsnag_breadcrumbs_dart_io/.gitignore similarity index 100% rename from packages/bugsnag_flutter_http/.gitignore rename to packages/bugsnag_breadcrumbs_dart_io/.gitignore diff --git a/packages/bugsnag_flutter_http/.metadata b/packages/bugsnag_breadcrumbs_dart_io/.metadata similarity index 100% rename from packages/bugsnag_flutter_http/.metadata rename to packages/bugsnag_breadcrumbs_dart_io/.metadata diff --git a/packages/bugsnag_flutter_http/analysis_options.yaml b/packages/bugsnag_breadcrumbs_dart_io/analysis_options.yaml similarity index 100% rename from packages/bugsnag_flutter_http/analysis_options.yaml rename to packages/bugsnag_breadcrumbs_dart_io/analysis_options.yaml diff --git a/packages/bugsnag_breadcrumbs_dart_io/lib/bugsnag_breadcrumbs_dart_io.dart b/packages/bugsnag_breadcrumbs_dart_io/lib/bugsnag_breadcrumbs_dart_io.dart new file mode 100644 index 00000000..fb7ca6fd --- /dev/null +++ b/packages/bugsnag_breadcrumbs_dart_io/lib/bugsnag_breadcrumbs_dart_io.dart @@ -0,0 +1 @@ +export 'src/httpclient.dart' show BugsnagHttpClient; diff --git a/packages/bugsnag_breadcrumbs_dart_io/lib/src/breadcrumb.dart b/packages/bugsnag_breadcrumbs_dart_io/lib/src/breadcrumb.dart new file mode 100644 index 00000000..37431717 --- /dev/null +++ b/packages/bugsnag_breadcrumbs_dart_io/lib/src/breadcrumb.dart @@ -0,0 +1,35 @@ +import 'dart:io'; + +import 'package:bugsnag_flutter/bugsnag_flutter.dart'; + +class Breadcrumb { + static BugsnagBreadcrumb build( + String method, + Uri url, + int requestContentLength, + Stopwatch stopwatch, + HttpClientResponse? response, + ) { + final responseContentLength = response?.contentLength; + final status = (response == null) + ? 'error' + : response.statusCode < 400 + ? 'succeeded' + : 'failed'; + return BugsnagBreadcrumb( + 'HttpClient request $status', + metadata: { + 'duration': stopwatch.elapsed.inMilliseconds, + 'method': method, + 'url': url.toString().split('?').first, + if (url.queryParameters.isNotEmpty) 'urlParams': url.queryParameters, + if (requestContentLength > 0) + 'requestContentLength': requestContentLength, + if (response != null) 'status': response.statusCode, + if (responseContentLength != null) + 'responseContentLength': responseContentLength, + }, + type: BugsnagBreadcrumbType.request, + ); + } +} diff --git a/packages/bugsnag_breadcrumbs_dart_io/lib/src/httpclient.dart b/packages/bugsnag_breadcrumbs_dart_io/lib/src/httpclient.dart new file mode 100644 index 00000000..7d1aa480 --- /dev/null +++ b/packages/bugsnag_breadcrumbs_dart_io/lib/src/httpclient.dart @@ -0,0 +1,160 @@ +// ignore_for_file: annotate_overrides + +import 'dart:async'; +import 'dart:io'; + +import 'package:bugsnag_flutter/bugsnag_flutter.dart'; + +import 'breadcrumb.dart'; + +/// An HttpClient wrapper that logs requests as Bugsnag breadcrumbs. +abstract class BugsnagHttpClient implements HttpClient { + factory BugsnagHttpClient([HttpClient? inner]) => _BugsnagHttpClient(inner); +} + +class _BugsnagHttpClient implements BugsnagHttpClient { + /// The wrapped client. + final HttpClient _inner; + + _BugsnagHttpClient([HttpClient? inner]) : _inner = inner ?? HttpClient(); + + void addCredentials( + Uri url, String realm, HttpClientCredentials credentials) => + _inner.addCredentials(url, realm, credentials); + + void addProxyCredentials(String host, int port, String realm, + HttpClientCredentials credentials) => + _inner.addProxyCredentials(host, port, realm, credentials); + + void close({bool force = false}) => _inner.close(force: force); + + set authenticate( + Future Function(Uri url, String scheme, String? realm)? f) => + _inner.authenticate = f; + + set authenticateProxy( + Future Function( + String host, int port, String scheme, String? realm)? + f) => + _inner.authenticateProxy = f; + + bool get autoUncompress => _inner.autoUncompress; + + set autoUncompress(bool value) => _inner.autoUncompress = value; + + set badCertificateCallback( + bool Function(X509Certificate cert, String host, int port)? + callback) => + _inner.badCertificateCallback = callback; + + set connectionFactory( + Future> Function( + Uri url, String? proxyHost, int? proxyPort)? + f) => + (_inner as dynamic).connectionFactory = f; + + Duration? get connectionTimeout => _inner.connectionTimeout; + + set connectionTimeout(Duration? value) => _inner.connectionTimeout = value; + + set findProxy(String Function(Uri url)? f) => _inner.findProxy = f; + + set keyLog(Function(String line)? callback) => + (_inner as dynamic).keyLog = callback; + + Duration get idleTimeout => _inner.idleTimeout; + + set idleTimeout(Duration value) => _inner.idleTimeout = value; + + int? get maxConnectionsPerHost => _inner.maxConnectionsPerHost; + + set maxConnectionsPerHost(int? value) => _inner.maxConnectionsPerHost = value; + + String? get userAgent => _inner.userAgent; + + set userAgent(String? value) => _inner.userAgent = value; + + // HTTP connection functions. + + Future delete(String host, int port, String path) => + _instrument('DELETE', Uri(host: host, port: port, path: path), + () => _inner.delete(host, port, path)); + + Future deleteUrl(Uri url) => + _instrument('DELETE', url, () => _inner.deleteUrl(url)); + + Future get(String host, int port, String path) => + _instrument('GET', Uri(host: host, port: port, path: path), + () => _inner.get(host, port, path)); + + Future getUrl(Uri url) => + _instrument('GET', url, () => _inner.getUrl(url)); + + Future head(String host, int port, String path) => + _instrument('HEAD', Uri(host: host, port: port, path: path), + () => _inner.head(host, port, path)); + + Future headUrl(Uri url) => + _instrument('HEAD', url, () => _inner.headUrl(url)); + + Future open( + String method, String host, int port, String path) => + _instrument(method, Uri(host: host, port: port, path: path), + () => _inner.open(method, host, port, path)); + + Future openUrl(String method, Uri url) => + _instrument(method, url, () => _inner.openUrl(method, url)); + + Future patch(String host, int port, String path) => + _instrument('PATCH', Uri(host: host, port: port, path: path), + () => _inner.patch(host, port, path)); + + Future patchUrl(Uri url) => + _instrument('PATCH', url, () => _inner.patchUrl(url)); + + Future post(String host, int port, String path) => + _instrument('POST', Uri(host: host, port: port, path: path), + () => _inner.post(host, port, path)); + + Future postUrl(Uri url) => + _instrument('POST', url, () => _inner.postUrl(url)); + + Future put(String host, int port, String path) => + _instrument('PUT', Uri(host: host, port: port, path: path), + () => _inner.put(host, port, path)); + + Future putUrl(Uri url) => + _instrument('PUT', url, () => _inner.putUrl(url)); +} + +Future _instrument( + String method, + Uri uri, + Future Function() connect, +) async { + final stopwatch = Stopwatch()..start(); + try { + final request = await connect(); + runZoned(() async { + await _leaveBreadcrumb(Breadcrumb.build( + request.method, + request.uri, + request.contentLength, + stopwatch, + await request.done, + )); + }); + return request; + } catch (e) { + await _leaveBreadcrumb(Breadcrumb.build(method, uri, -1, stopwatch, null)); + rethrow; + } +} + +Future _leaveBreadcrumb(BugsnagBreadcrumb breadcrumb) async { + await bugsnag.leaveBreadcrumb( + breadcrumb.message, + metadata: breadcrumb.metadata, + type: breadcrumb.type, + ); +} diff --git a/packages/bugsnag_breadcrumbs_dart_io/pubspec.yaml b/packages/bugsnag_breadcrumbs_dart_io/pubspec.yaml new file mode 100644 index 00000000..3e3e9d53 --- /dev/null +++ b/packages/bugsnag_breadcrumbs_dart_io/pubspec.yaml @@ -0,0 +1,22 @@ +name: bugsnag_breadcrumbs_dart_io +description: Bugsnag network breadcrumbs for dart:io's HttpClient +version: 2.0.0 +homepage: https://www.bugsnag.com/ +documentation: https://docs.bugsnag.com/platforms/flutter/ +repository: https://github.com/bugsnag/bugsnag-flutter +issue_tracker: https://github.com/bugsnag/bugsnag-flutter/issues + +publish_to: none + +environment: + sdk: ">=2.15.1 <3.0.0" + flutter: ">=2.0.0" + +dependencies: + flutter: + sdk: flutter + bugsnag_flutter: + path: ../bugsnag_flutter + +dev_dependencies: + flutter_lints: ^1.0.0 diff --git a/packages/bugsnag_breadcrumbs_http/.gitignore b/packages/bugsnag_breadcrumbs_http/.gitignore new file mode 100644 index 00000000..96486fd9 --- /dev/null +++ b/packages/bugsnag_breadcrumbs_http/.gitignore @@ -0,0 +1,30 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.packages +build/ diff --git a/packages/bugsnag_breadcrumbs_http/.metadata b/packages/bugsnag_breadcrumbs_http/.metadata new file mode 100644 index 00000000..c79dee43 --- /dev/null +++ b/packages/bugsnag_breadcrumbs_http/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851 + channel: stable + +project_type: package diff --git a/packages/bugsnag_breadcrumbs_http/analysis_options.yaml b/packages/bugsnag_breadcrumbs_http/analysis_options.yaml new file mode 100644 index 00000000..a5744c1c --- /dev/null +++ b/packages/bugsnag_breadcrumbs_http/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/packages/bugsnag_flutter_http/lib/bugsnag_flutter_http.dart b/packages/bugsnag_breadcrumbs_http/lib/bugsnag_breadcrumbs_http.dart similarity index 100% rename from packages/bugsnag_flutter_http/lib/bugsnag_flutter_http.dart rename to packages/bugsnag_breadcrumbs_http/lib/bugsnag_breadcrumbs_http.dart diff --git a/packages/bugsnag_flutter_http/lib/src/breadcrumb.dart b/packages/bugsnag_breadcrumbs_http/lib/src/breadcrumb.dart similarity index 100% rename from packages/bugsnag_flutter_http/lib/src/breadcrumb.dart rename to packages/bugsnag_breadcrumbs_http/lib/src/breadcrumb.dart diff --git a/packages/bugsnag_flutter_http/lib/src/client.dart b/packages/bugsnag_breadcrumbs_http/lib/src/client.dart similarity index 100% rename from packages/bugsnag_flutter_http/lib/src/client.dart rename to packages/bugsnag_breadcrumbs_http/lib/src/client.dart diff --git a/packages/bugsnag_flutter_http/pubspec.yaml b/packages/bugsnag_breadcrumbs_http/pubspec.yaml similarity index 92% rename from packages/bugsnag_flutter_http/pubspec.yaml rename to packages/bugsnag_breadcrumbs_http/pubspec.yaml index 7afe056a..84e5c39e 100644 --- a/packages/bugsnag_flutter_http/pubspec.yaml +++ b/packages/bugsnag_breadcrumbs_http/pubspec.yaml @@ -1,6 +1,6 @@ -name: bugsnag_flutter_http +name: bugsnag_breadcrumbs_http description: Bugsnag network breadcrumbs for https://pub.dev/packages/http -version: 2.0.0-rc6 +version: 2.0.0 homepage: https://www.bugsnag.com/ documentation: https://docs.bugsnag.com/platforms/flutter/ repository: https://github.com/bugsnag/bugsnag-flutter diff --git a/packages/bugsnag_flutter_http/test/breadcrumb_test.dart b/packages/bugsnag_breadcrumbs_http/test/breadcrumb_test.dart similarity index 97% rename from packages/bugsnag_flutter_http/test/breadcrumb_test.dart rename to packages/bugsnag_breadcrumbs_http/test/breadcrumb_test.dart index d9bb94d5..d2bae287 100644 --- a/packages/bugsnag_flutter_http/test/breadcrumb_test.dart +++ b/packages/bugsnag_breadcrumbs_http/test/breadcrumb_test.dart @@ -1,5 +1,5 @@ import 'package:bugsnag_flutter/bugsnag_flutter.dart'; -import 'package:bugsnag_flutter_http/src/breadcrumb.dart'; +import 'package:bugsnag_breadcrumbs_http/src/breadcrumb.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:http/http.dart' as http; From 7acfe3864dacc325029250d41051e402f2698388 Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 9 Jun 2022 14:28:25 +0100 Subject: [PATCH 20/26] chore: change the network breadcrumbs packages to require Flutter 2.5.0 --- packages/bugsnag_breadcrumbs_dart_io/pubspec.yaml | 4 ++-- packages/bugsnag_breadcrumbs_http/pubspec.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/bugsnag_breadcrumbs_dart_io/pubspec.yaml b/packages/bugsnag_breadcrumbs_dart_io/pubspec.yaml index 3e3e9d53..778fa4ff 100644 --- a/packages/bugsnag_breadcrumbs_dart_io/pubspec.yaml +++ b/packages/bugsnag_breadcrumbs_dart_io/pubspec.yaml @@ -9,8 +9,8 @@ issue_tracker: https://github.com/bugsnag/bugsnag-flutter/issues publish_to: none environment: - sdk: ">=2.15.1 <3.0.0" - flutter: ">=2.0.0" + sdk: ">=2.14.0 <3.0.0" + flutter: ">=2.5.0" dependencies: flutter: diff --git a/packages/bugsnag_breadcrumbs_http/pubspec.yaml b/packages/bugsnag_breadcrumbs_http/pubspec.yaml index 84e5c39e..dde3f0e1 100644 --- a/packages/bugsnag_breadcrumbs_http/pubspec.yaml +++ b/packages/bugsnag_breadcrumbs_http/pubspec.yaml @@ -9,8 +9,8 @@ issue_tracker: https://github.com/bugsnag/bugsnag-flutter/issues publish_to: none environment: - sdk: ">=2.15.1 <3.0.0" - flutter: ">=2.0.0" + sdk: ">=2.14.0 <3.0.0" + flutter: ">=2.5.0" dependencies: flutter: From aff41af41b03bc5ff3daed6744b630073b00ffee Mon Sep 17 00:00:00 2001 From: Jason Date: Fri, 10 Jun 2022 13:32:14 +0100 Subject: [PATCH 21/26] fix(navigation): make BugsnagNavigatorObserver.setContext true by default --- packages/bugsnag_flutter/lib/src/breadcrumbs/navigation.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/bugsnag_flutter/lib/src/breadcrumbs/navigation.dart b/packages/bugsnag_flutter/lib/src/breadcrumbs/navigation.dart index f08cd8e6..e9fc68b7 100644 --- a/packages/bugsnag_flutter/lib/src/breadcrumbs/navigation.dart +++ b/packages/bugsnag_flutter/lib/src/breadcrumbs/navigation.dart @@ -26,7 +26,7 @@ class BugsnagNavigatorObserver extends NavigatorObserver { /// ``` BugsnagNavigatorObserver({ this.leaveBreadcrumbs = true, - this.setContext = false, + this.setContext = true, String? navigatorName, }) : _navigatorName = (navigatorName != null) ? navigatorName : 'navigator'; From fc3e4f15495a68aec758c3ea3fd4821df84c59b8 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 13 Jun 2022 11:11:41 +0100 Subject: [PATCH 22/26] fix(stacktrace): replace negative columnNumbers will `null` --- CHANGELOG.md | 5 ++++ .../lib/src/model/stackframe.dart | 2 +- .../test/model/stackframe_test.dart | 24 ++++++++++++++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63c50c2a..9704c0ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## TBD + +- Column numbers will be captured as `null` instead of `-1` when they're not available + []() + ## 2.0.2 (2022-05-30) - Prefixed all class named with 'Bugsnag' to avoid clashing with application code. diff --git a/packages/bugsnag_flutter/lib/src/model/stackframe.dart b/packages/bugsnag_flutter/lib/src/model/stackframe.dart index a62d9894..5e159083 100644 --- a/packages/bugsnag_flutter/lib/src/model/stackframe.dart +++ b/packages/bugsnag_flutter/lib/src/model/stackframe.dart @@ -98,7 +98,7 @@ class BugsnagStackframe { : type = BugsnagErrorType.dart, file = "${frame.packageScheme}:${frame.package}/${frame.packagePath}", lineNumber = frame.line, - columnNumber = frame.column, + columnNumber = frame.column >= 0 ? frame.column : null, method = (frame.className.isNotEmpty) ? '${frame.className}.${frame.method}' : frame.method; diff --git a/packages/bugsnag_flutter/test/model/stackframe_test.dart b/packages/bugsnag_flutter/test/model/stackframe_test.dart index 086d7dc1..56a73707 100644 --- a/packages/bugsnag_flutter/test/model/stackframe_test.dart +++ b/packages/bugsnag_flutter/test/model/stackframe_test.dart @@ -77,12 +77,34 @@ void main() { final stackframe = BugsnagStackframe.fromStackFrame(f); expect(stackframe.file, endsWith(f.packagePath)); expect(stackframe.lineNumber, f.line); - expect(stackframe.columnNumber, f.column); + expect( + stackframe.columnNumber, + f.column >= 0 ? equals(f.column) : isNull, + ); expect( stackframe.method, f.className.isNotEmpty ? '${f.className}.${f.method}' : f.method, ); } }); + + test('null columnNumber when not available', () { + final stack = BugsnagStackframe.fromStackFrame(const StackFrame( + number: 0, + column: -1, + line: 51, + packageScheme: 'dart', + package: 'core_patch', + packagePath: 'object_patch.dart', + className: 'Object', + method: 'noSuchMethod', + source: + '#0 Object.noSuchMethod(dart:core_patch/object_patch.dart:51)', + )); + + expect(stack.lineNumber, equals(51)); + expect(stack.columnNumber, isNull); + expect(stack.file, equals('dart:core_patch/object_patch.dart')); + }); }); } From db78ba449c623c4b66fec5e47d40fc828f446436 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 13 Jun 2022 09:54:04 +0100 Subject: [PATCH 23/26] docs(http): added README file for the `bugsnag_breadcrumbs_http` package --- packages/bugsnag_breadcrumbs_http/README.md | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 packages/bugsnag_breadcrumbs_http/README.md diff --git a/packages/bugsnag_breadcrumbs_http/README.md b/packages/bugsnag_breadcrumbs_http/README.md new file mode 100644 index 00000000..c15abc0a --- /dev/null +++ b/packages/bugsnag_breadcrumbs_http/README.md @@ -0,0 +1,25 @@ +# Network Breadcrumbs for Bugsnag Flutter + +[http](https://pub.dev/packages/http) networking breadcrumbs for [bugsnag-flutter](https://pub.dev/packages/bugsnag_flutter). + +## Getting Started + +1. Install [bugsnag-flutter](https://pub.dev/packages/bugsnag_flutter) +2. Add [bugsnag_breadcrumbs_http](https://pub.dev/packages/bugsnag_breadcrumbs_http) to your project: +```shell +flutter pub add bugsnag_breadcrumbs_http +``` +3. Replace references to the `http` package with `bugsnag_breadcrumbs_http`: +```dart +import 'package:bugsnag_breadcrumbs_http/bugsnag_breadcrumbs_http.dart' as http; +``` +4. Use as normal, and your network breadcrumbs will be automatically logged: +```dart +await http.get(Uri.parse('https://example.com')); +``` + +## License + +The Bugsnag Flutter notifier is free software released under the MIT License. See +the [LICENSE](https://github.com/bugsnag/bugsnag-flutter/blob/master/LICENSE) +for details. \ No newline at end of file From c700557e21739f6c08ef113d730608174d8295e2 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 13 Jun 2022 11:31:45 +0100 Subject: [PATCH 24/26] docs(http): added README file for the `bugsnag_breadcrumbs_dart_io` package --- .../bugsnag_breadcrumbs_dart_io/README.md | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 packages/bugsnag_breadcrumbs_dart_io/README.md diff --git a/packages/bugsnag_breadcrumbs_dart_io/README.md b/packages/bugsnag_breadcrumbs_dart_io/README.md new file mode 100644 index 00000000..cf3a3b60 --- /dev/null +++ b/packages/bugsnag_breadcrumbs_dart_io/README.md @@ -0,0 +1,25 @@ +# Network Breadcrumbs for Bugsnag Flutter + +HTTP networking breadcrumbs for [bugsnag-flutter](https://pub.dev/packages/bugsnag_flutter) when using the `dart:io` [HttpClient](https://api.flutter.dev/flutter/dart-io/HttpClient-class.html). +If you are using the [http](https://pub.dev/packages/http) package then [bugsnag_breadcrumbs_http](https://pub.dev/packages/bugsnag_breadcrumbs_http) should be used for networking breadcrumbs. + +## Getting Started + +1. Install [bugsnag-flutter](https://pub.dev/packages/bugsnag_flutter) +2. Add [bugsnag_breadcrumbs_dart_io](https://pub.dev/packages/bugsnag_breadcrumbs_dart_io) to your project: +```shell +flutter pub add bugsnag_breadcrumbs_dart_io +``` +3. Import `bugsnag_breadcrumbs_dart_io.dart` and use `BugsnagHttpClient` instead of `HttpClient`: +```dart +import 'package:bugsnag_breadcrumbs_dart_io/bugsnag_breadcrumbs_dart_io.dart'; + +final httpClient = BugsnagHttpClient(); +final request = await client.getUrl(Uri.parse('https://example.com')); +``` + +## License + +The Bugsnag Flutter notifier is free software released under the MIT License. See +the [LICENSE](https://github.com/bugsnag/bugsnag-flutter/blob/master/LICENSE) +for details. \ No newline at end of file From 13e95499f207507d4977cfc0882c15879ce859f6 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 13 Jun 2022 11:33:22 +0100 Subject: [PATCH 25/26] docs(http): updated the `bugsnag_breadcrumbs_http` README to reference `bugsnag_breadcrumbs_dart_io` for those using `dart:io` --- packages/bugsnag_breadcrumbs_dart_io/README.md | 4 ++-- packages/bugsnag_breadcrumbs_http/README.md | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/bugsnag_breadcrumbs_dart_io/README.md b/packages/bugsnag_breadcrumbs_dart_io/README.md index cf3a3b60..ae2a0bd4 100644 --- a/packages/bugsnag_breadcrumbs_dart_io/README.md +++ b/packages/bugsnag_breadcrumbs_dart_io/README.md @@ -1,11 +1,11 @@ # Network Breadcrumbs for Bugsnag Flutter -HTTP networking breadcrumbs for [bugsnag-flutter](https://pub.dev/packages/bugsnag_flutter) when using the `dart:io` [HttpClient](https://api.flutter.dev/flutter/dart-io/HttpClient-class.html). +HTTP networking breadcrumbs for [bugsnag_flutter](https://pub.dev/packages/bugsnag_flutter) when using the `dart:io` [HttpClient](https://api.flutter.dev/flutter/dart-io/HttpClient-class.html). If you are using the [http](https://pub.dev/packages/http) package then [bugsnag_breadcrumbs_http](https://pub.dev/packages/bugsnag_breadcrumbs_http) should be used for networking breadcrumbs. ## Getting Started -1. Install [bugsnag-flutter](https://pub.dev/packages/bugsnag_flutter) +1. Install [bugsnag_flutter](https://pub.dev/packages/bugsnag_flutter) 2. Add [bugsnag_breadcrumbs_dart_io](https://pub.dev/packages/bugsnag_breadcrumbs_dart_io) to your project: ```shell flutter pub add bugsnag_breadcrumbs_dart_io diff --git a/packages/bugsnag_breadcrumbs_http/README.md b/packages/bugsnag_breadcrumbs_http/README.md index c15abc0a..305cd1b0 100644 --- a/packages/bugsnag_breadcrumbs_http/README.md +++ b/packages/bugsnag_breadcrumbs_http/README.md @@ -1,10 +1,11 @@ # Network Breadcrumbs for Bugsnag Flutter -[http](https://pub.dev/packages/http) networking breadcrumbs for [bugsnag-flutter](https://pub.dev/packages/bugsnag_flutter). +[http](https://pub.dev/packages/http) networking breadcrumbs for [bugsnag_flutter](https://pub.dev/packages/bugsnag_flutter). +If you are using the [HttpClient](https://api.flutter.dev/flutter/dart-io/HttpClient-class.html) class in `dart:io` then [bugsnag_breadcrumbs_dart_io](https://pub.dev/packages/bugsnag_breadcrumbs_dart_io) should be used for networking breadcrumbs. ## Getting Started -1. Install [bugsnag-flutter](https://pub.dev/packages/bugsnag_flutter) +1. Install [bugsnag_flutter](https://pub.dev/packages/bugsnag_flutter) 2. Add [bugsnag_breadcrumbs_http](https://pub.dev/packages/bugsnag_breadcrumbs_http) to your project: ```shell flutter pub add bugsnag_breadcrumbs_http From f283b3d7f506374c38bda6d4344587bf6c7624c2 Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 14 Jun 2022 09:55:24 +0100 Subject: [PATCH 26/26] v2.1.0 --- CHANGELOG.md | 8 +++-- Makefile | 32 +++++++++++++------ docs/RELEASING.md | 4 ++- .../bugsnag_breadcrumbs_dart_io/pubspec.yaml | 2 +- .../bugsnag_breadcrumbs_http/pubspec.yaml | 2 +- packages/bugsnag_flutter/lib/src/client.dart | 2 +- packages/bugsnag_flutter/pubspec.yaml | 2 +- 7 files changed, 36 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9704c0ce..ee71ced9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,13 @@ # Changelog -## TBD +## 2.1.0 (2022-06-14) +- Networking breadcrumbs can now be easily captured by using the `bugsnag_breadcrumbs_http` or `bugsnag_breadcrumbs_dart_io` packages + [#116](https://github.com/bugsnag/bugsnag-flutter/pull/116) + [#115](https://github.com/bugsnag/bugsnag-flutter/pull/115) +- Added `BugsnagNavigatorObserver` to automatically log navigation breadcrumbs and context - Column numbers will be captured as `null` instead of `-1` when they're not available - []() + [#139](https://github.com/bugsnag/bugsnag-flutter/pull/139) ## 2.0.2 (2022-05-30) diff --git a/Makefile b/Makefile index 560ddaf4..9922db76 100644 --- a/Makefile +++ b/Makefile @@ -27,15 +27,29 @@ endif sed -i '' "s/^version: .*/version: $(VERSION)/" packages/bugsnag_breadcrumbs_http/pubspec.yaml sed -i '' "s/^ 'version': .*/ 'version': '$(VERSION)'/" packages/bugsnag_flutter/lib/src/client.dart -stage: clean - mkdir staging - cd packages/bugsnag_flutter && cp -a . ../../staging/ - rm -f staging/pubspec.lock - cp -r example staging/example - cp README.md staging/. - cp LICENSE staging/. - cp CHANGELOG.md staging/. - sed -i '' -e '1,2d' staging/CHANGELOG.md +staging/bugsnag_flutter: + mkdir -p staging/bugsnag_flutter + cd packages/bugsnag_flutter && cp -a . ../../staging/bugsnag_flutter + rm -f staging/bugsnag_flutter/pubspec.lock + cp -r example staging/bugsnag_flutter/example + cp README.md staging/bugsnag_flutter/. + cp LICENSE staging/bugsnag_flutter/. + cp CHANGELOG.md staging/bugsnag_flutter/. + sed -i '' -e '1,2d' staging/bugsnag_flutter/CHANGELOG.md + +BSG_FLUTTER_VERSION:=$(shell grep 'version: ' packages/bugsnag_flutter/pubspec.yaml | grep -o '[0-9].*') +staging/%: + mkdir -p staging/$* + cd packages/$* && cp -a . ../../staging/$* + rm -f staging/$*/pubspec.lock + cp LICENSE staging/$*/. + cp CHANGELOG.md staging/$*/. + sed -i '' -e '1,2d' staging/$*/CHANGELOG.md + # Replace the path references to bugsnag_flutter with version-based references, and allow publishing (strip lines with 'publish_to: none') + sed -i '' "s/^ bugsnag_flutter:.*/ bugsnag_flutter: ^$(BSG_FLUTTER_VERSION)/" staging/$*/pubspec.yaml + sed -i '' "s/path:.*/ /;s/publish_to: none/ /" staging/$*/pubspec.yaml + +stage: clean staging/bugsnag_flutter staging/bugsnag_breadcrumbs_dart_io staging/bugsnag_breadcrumbs_http aar: cd packages/bugsnag_flutter && $(FLUTTER_BIN) build aar --suppress-analytics diff --git a/docs/RELEASING.md b/docs/RELEASING.md index 8b2b26f9..359d0419 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -11,7 +11,9 @@ Releasing - Run `git clean -df` to ensure no unexpected files make it into the release - Creating the staged release: `make stage` - Publish the new version to pub.dev: - - `cd staging && flutter pub publish` + - `cd staging/bugsnag_flutter && flutter pub publish` + - `cd staging/bugsnag_breadcrumbs_dart_io && flutter pub publish` + - `cd staging/bugsnag_breadcrumbs_http && flutter pub publish` - Release on GitHub: - Create a release and tag from `main` on [GitHub Releases](https://github.com/bugsnag/bugsnag-flutter/releases) diff --git a/packages/bugsnag_breadcrumbs_dart_io/pubspec.yaml b/packages/bugsnag_breadcrumbs_dart_io/pubspec.yaml index 778fa4ff..8d18a0ea 100644 --- a/packages/bugsnag_breadcrumbs_dart_io/pubspec.yaml +++ b/packages/bugsnag_breadcrumbs_dart_io/pubspec.yaml @@ -1,6 +1,6 @@ name: bugsnag_breadcrumbs_dart_io description: Bugsnag network breadcrumbs for dart:io's HttpClient -version: 2.0.0 +version: 2.1.0 homepage: https://www.bugsnag.com/ documentation: https://docs.bugsnag.com/platforms/flutter/ repository: https://github.com/bugsnag/bugsnag-flutter diff --git a/packages/bugsnag_breadcrumbs_http/pubspec.yaml b/packages/bugsnag_breadcrumbs_http/pubspec.yaml index dde3f0e1..0b7e6932 100644 --- a/packages/bugsnag_breadcrumbs_http/pubspec.yaml +++ b/packages/bugsnag_breadcrumbs_http/pubspec.yaml @@ -1,6 +1,6 @@ name: bugsnag_breadcrumbs_http description: Bugsnag network breadcrumbs for https://pub.dev/packages/http -version: 2.0.0 +version: 2.1.0 homepage: https://www.bugsnag.com/ documentation: https://docs.bugsnag.com/platforms/flutter/ repository: https://github.com/bugsnag/bugsnag-flutter diff --git a/packages/bugsnag_flutter/lib/src/client.dart b/packages/bugsnag_flutter/lib/src/client.dart index 54f65ec6..581f9dd4 100644 --- a/packages/bugsnag_flutter/lib/src/client.dart +++ b/packages/bugsnag_flutter/lib/src/client.dart @@ -17,7 +17,7 @@ import 'model.dart'; final _notifier = { 'name': 'Flutter Bugsnag Notifier', 'url': 'https://github.com/bugsnag/bugsnag-flutter', - 'version': '2.0.2' + 'version': '2.1.0' }; abstract class BugsnagClient { diff --git a/packages/bugsnag_flutter/pubspec.yaml b/packages/bugsnag_flutter/pubspec.yaml index 6f9cf1bf..f611ac82 100644 --- a/packages/bugsnag_flutter/pubspec.yaml +++ b/packages/bugsnag_flutter/pubspec.yaml @@ -1,6 +1,6 @@ name: bugsnag_flutter description: Bugsnag crash monitoring and reporting tool for Flutter apps -version: 2.0.2 +version: 2.1.0 homepage: https://www.bugsnag.com/ documentation: https://docs.bugsnag.com/platforms/flutter/ repository: https://github.com/bugsnag/bugsnag-flutter