Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add dart file to min test
  • Loading branch information
marandaneto committed Dec 6, 2022
commit 88b619463a0b6085a81f7dcbf242f902a1f3eeb6
1 change: 1 addition & 0 deletions .github/workflows/min_version_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ jobs:
flutter pub get
flutter build ios --no-codesign
flutter build appbundle
flutter build web
60 changes: 50 additions & 10 deletions min_version_test/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,25 +1,52 @@
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:sentry/sentry.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:sentry_dio/sentry_dio.dart';
import 'package:sentry_logging/sentry_logging.dart';
import 'package:sentry_file/sentry_file.dart';

// ATTENTION: Change the DSN below with your own to see the events in Sentry. Get one at sentry.io
const String _exampleDsn =
'https://[email protected]/5428562';

Future<void> main() async {
await SentryFlutter.init(
(options) {
options.dsn = _exampleDsn;
options.addIntegration(LoggingIntegration());
},
// Init your App.
appRunner: () => runApp(const MyApp()),
);
await setupSentry(() => runApp(
SentryScreenshotWidget(
child: SentryUserInteractionWidget(
child: DefaultAssetBundle(
bundle: SentryAssetBundle(enableStructuredDataTracing: true),
child: const MyApp(),
),
),
),
));
}

Future<void> setupSentry(AppRunner appRunner) async {
await SentryFlutter.init((options) {
options.dsn = _exampleDsn;
options.tracesSampleRate = 1.0;
options.attachThreads = true;
options.enableWindowMetricBreadcrumbs = true;
options.addIntegration(LoggingIntegration());
options.sendDefaultPii = true;
options.reportSilentFlutterErrors = true;
options.enableNdkScopeSync = true;
options.enableUserInteractionTracing = true;
options.attachScreenshot = true;
// We can enable Sentry debug logging during development. This is likely
// going to log too much for your app, but can be useful when figuring out
// configuration issues, e.g. finding out why your events are not uploaded.
options.debug = true;
},
// Init your App.
appRunner: appRunner);
}

class MyApp extends StatelessWidget {
Expand Down Expand Up @@ -70,6 +97,12 @@ class _MyHomePageState extends State<MyHomePage> {

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

// 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
Expand All @@ -78,12 +111,19 @@ class _MyHomePageState extends State<MyHomePage> {
_counter++;

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

try {
await dio.get<String>('https://flutter.dev/');
final file = File('response.txt');
final sentryFile = file.sentryTrace();
final response = await dio.get<String>('https://flutter.dev/');
await sentryFile.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
3 changes: 3 additions & 0 deletions min_version_test/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dependencies:
sentry_flutter:
sentry_dio:
sentry_logging:
sentry_file:
dio: ^4.0.0
logging: ^1.0.0

Expand All @@ -52,6 +53,8 @@ dependency_overrides:
path: ../dio
sentry_logging:
path: ../logging
sentry_file:
path: ../file

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
Expand Down