@@ -3,6 +3,7 @@ import 'dart:convert';
33
44import 'package:http/http.dart' ;
55import 'package:meta/meta.dart' ;
6+ import 'package:sentry/sentry.dart' ;
67
78import 'client_stub.dart'
89 if (dart.library.html) 'browser_client.dart'
@@ -136,9 +137,10 @@ abstract class SentryClient {
136137 }
137138
138139 /// Reports an [event] to Sentry.io.
139- Future <SentryResponse > captureEvent ({
140- @required Event event,
140+ Future <SentryId > captureEvent (
141+ Event event, {
141142 StackFrameFilter stackFrameFilter,
143+ Scope scope,
142144 }) async {
143145 final now = _clock ();
144146 var authHeader = 'Sentry sentry_version=6, sentry_client=$clientId , '
@@ -183,27 +185,38 @@ abstract class SentryClient {
183185 );
184186
185187 if (response.statusCode != 200 ) {
186- var errorMessage = 'Sentry.io responded with HTTP ${response .statusCode }' ;
188+ /* var errorMessage = 'Sentry.io responded with HTTP ${response.statusCode}';
187189 if (response.headers['x-sentry-error'] != null) {
188190 errorMessage += ': ${response.headers['x-sentry-error']}';
189- }
190- return SentryResponse . failure (errorMessage );
191+ }*/
192+ return SentryId . empty ( );
191193 }
192194
193- final eventId = '${ json .decode (response .body )['id' ]}' ;
194- return SentryResponse . success (eventId: eventId );
195+ final eventId = json.decode (response.body)['id' ];
196+ return eventId != null ? SentryId (eventId) : SentryId . empty ( );
195197 }
196198
197- /// Reports the [exception] and optionally its [stackTrace] to Sentry.io.
198- Future <SentryResponse > captureException ({
199- @required dynamic exception,
200- dynamic stackTrace,
201- }) {
199+ /// Reports the [throwable] and optionally its [stackTrace] to Sentry.io.
200+ Future <SentryId > captureException (dynamic throwable, {dynamic stackTrace}) {
202201 final event = Event (
203- exception: exception ,
202+ exception: throwable ,
204203 stackTrace: stackTrace,
205204 );
206- return captureEvent (event: event);
205+ return captureEvent (event);
206+ }
207+
208+ /// Reports the [template]
209+ Future <SentryId > captureMessage (
210+ String formatted, {
211+ SeverityLevel level = SeverityLevel .info,
212+ String template,
213+ List <dynamic > params,
214+ }) {
215+ final event = Event (
216+ message: Message (formatted, template: template, params: params),
217+ level: level,
218+ );
219+ return captureEvent (event);
207220 }
208221
209222 Future <void > close () async {
0 commit comments