Skip to content

Commit

Permalink
Merge branch 'main' into enha/ui-integration-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marandaneto authored Jul 14, 2023
2 parents 0342b49 + 1596141 commit 984c0a5
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/flutter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ jobs:
- uses: actions/checkout@v3

- name: ktlint
uses: ScaCap/action-ktlint@0169eb4232c76b235d26d94e92111c32aee7660e # pin@1.5.1
uses: ScaCap/action-ktlint@2cf245b99bc91f73bc4c96a3d9d57bb5da3533ae # pin@1.7.1
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/min_version_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,20 @@ jobs:
cd min_version_test
flutter pub get
flutter build ios --no-codesign
build-web:
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- uses: actions/checkout@v3

- uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa # pin@v2.10.0
with:
flutter-version: '3.0.0'

- name: Build web
run: |
cd min_version_test
flutter pub get
flutter build web --source-maps
1 change: 1 addition & 0 deletions flutter/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ sentry:
wait_for_processing: true
commits: true
ignore_missing: true
log_level: info
31 changes: 5 additions & 26 deletions min_version_test/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import 'package:flutter/material.dart';

import 'dart:io' if (dart.library.html) 'dart:html';

import 'package:logging/logging.dart';
import 'package:dio/dio.dart';

import 'package:min_version_test/transaction/transaction_locator.dart'
if (dart.library.html) 'package:min_version_test/transaction/file_transaction.dart'
if (dart.library.io) 'package:min_version_test/transaction/web_transaction.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:sentry_dio/sentry_dio.dart';
import 'package:sentry_logging/sentry_logging.dart';

// ATTENTION: Change the DSN below with your own to see the events in Sentry. Get one at sentry.io
Expand Down Expand Up @@ -94,33 +91,15 @@ class _MyHomePageState extends State<MyHomePage> {

Future<void> _incrementCounter() async {
setState(() async {
final transaction = Sentry.startTransaction(
'incrementCounter',
'task',
bindToScope: true,
);
final transactionTest = getTransaction();
await transactionTest.start();

// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;

final dio = Dio();
dio.addSentry();
final log = Logger('_MyHomePageState');

try {
final file = File('response.txt');
final response = await dio.get<String>('https://flutter.dev/');
await file.writeAsString(response.data ?? 'no response');

await transaction.finish(status: SpanStatus.ok());
} catch (exception, stackTrace) {
log.info(exception.toString(), exception, stackTrace);
await transaction.finish(status: SpanStatus.internalError());
}
});
}

Expand Down
36 changes: 36 additions & 0 deletions min_version_test/lib/transaction/file_transaction.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import 'package:min_version_test/transaction/transaction.dart';
import 'dart:io';

import 'package:logging/logging.dart';
import 'package:dio/dio.dart';

import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:sentry_dio/sentry_dio.dart';

class FileTransaction implements Transaction {
@override
Future<void> start() async {
final transaction = Sentry.startTransaction(
'incrementCounter',
'task',
bindToScope: true,
);

final dio = Dio();
dio.addSentry();
final log = Logger('_MyHomePageState');

try {
final file = File('response.txt');
final response = await dio.get<String>('https://flutter.dev/');
await file.writeAsString(response.data ?? 'no response');

await transaction.finish(status: SpanStatus.ok());
} catch (exception, stackTrace) {
log.info(exception.toString(), exception, stackTrace);
await transaction.finish(status: SpanStatus.internalError());
}
}
}

Transaction getTransaction() => FileTransaction();
5 changes: 5 additions & 0 deletions min_version_test/lib/transaction/transaction.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Transaction {
Future<void> start() async {
// Do nothing...
}
}
4 changes: 4 additions & 0 deletions min_version_test/lib/transaction/transaction_locator.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import 'package:min_version_test/transaction/transaction.dart';

Transaction getTransaction() =>
throw UnsupportedError('Cannot create sample transaction.');
34 changes: 34 additions & 0 deletions min_version_test/lib/transaction/web_transaction.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import 'package:min_version_test/transaction/transaction.dart';

import 'package:logging/logging.dart';
import 'package:dio/dio.dart';

import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:sentry_dio/sentry_dio.dart';

class WebTransaction implements Transaction {
@override
Future<void> start() async {
final transaction = Sentry.startTransaction(
'incrementCounter',
'task',
bindToScope: true,
);

final dio = Dio();
dio.addSentry();
final log = Logger('_MyHomePageState');

try {
final response = await dio.get<String>('https://flutter.dev/');
print(response);

await transaction.finish(status: SpanStatus.ok());
} catch (exception, stackTrace) {
log.info(exception.toString(), exception, stackTrace);
await transaction.finish(status: SpanStatus.internalError());
}
}
}

Transaction getTransaction() => WebTransaction();
Empty file added min_version_test/web/index.html
Empty file.

0 comments on commit 984c0a5

Please sign in to comment.