|
1 | 1 | import 'package:flutter/material.dart'; |
2 | 2 |
|
3 | | -import 'dart:io' if (dart.library.html) 'dart:html'; |
4 | | - |
5 | | -import 'package:logging/logging.dart'; |
6 | | -import 'package:dio/dio.dart'; |
7 | | - |
| 3 | +import 'package:min_version_test/transaction/transaction_locator.dart' |
| 4 | + if (dart.library.html) 'package:min_version_test/transaction/file_transaction.dart' |
| 5 | + if (dart.library.io) 'package:min_version_test/transaction/web_transaction.dart'; |
8 | 6 | import 'package:sentry_flutter/sentry_flutter.dart'; |
9 | | -import 'package:sentry_dio/sentry_dio.dart'; |
10 | 7 | import 'package:sentry_logging/sentry_logging.dart'; |
11 | 8 |
|
12 | 9 | // ATTENTION: Change the DSN below with your own to see the events in Sentry. Get one at sentry.io |
@@ -94,33 +91,15 @@ class _MyHomePageState extends State<MyHomePage> { |
94 | 91 |
|
95 | 92 | Future<void> _incrementCounter() async { |
96 | 93 | setState(() async { |
97 | | - final transaction = Sentry.startTransaction( |
98 | | - 'incrementCounter', |
99 | | - 'task', |
100 | | - bindToScope: true, |
101 | | - ); |
| 94 | + final transactionTest = getTransaction(); |
| 95 | + await transactionTest.start(); |
102 | 96 |
|
103 | 97 | // This call to setState tells the Flutter framework that something has |
104 | 98 | // changed in this State, which causes it to rerun the build method below |
105 | 99 | // so that the display can reflect the updated values. If we changed |
106 | 100 | // _counter without calling setState(), then the build method would not be |
107 | 101 | // called again, and so nothing would appear to happen. |
108 | 102 | _counter++; |
109 | | - |
110 | | - final dio = Dio(); |
111 | | - dio.addSentry(); |
112 | | - final log = Logger('_MyHomePageState'); |
113 | | - |
114 | | - try { |
115 | | - final file = File('response.txt'); |
116 | | - final response = await dio.get<String>('https://flutter.dev/'); |
117 | | - await file.writeAsString(response.data ?? 'no response'); |
118 | | - |
119 | | - await transaction.finish(status: SpanStatus.ok()); |
120 | | - } catch (exception, stackTrace) { |
121 | | - log.info(exception.toString(), exception, stackTrace); |
122 | | - await transaction.finish(status: SpanStatus.internalError()); |
123 | | - } |
124 | 103 | }); |
125 | 104 | } |
126 | 105 |
|
|
0 commit comments