diff --git a/CHANGELOG.md b/CHANGELOG.md index dd24949541..c7d6950f97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # package:sentry changelog +## 0.0.5 + +- remove sub-seconds from the timestamp + +## 0.0.4 + +- parse and report async gaps in stack traces + ## 0.0.3 - environment attributes diff --git a/lib/sentry.dart b/lib/sentry.dart index a2d4343bbd..e65a4b9275 100644 --- a/lib/sentry.dart +++ b/lib/sentry.dart @@ -164,7 +164,7 @@ class SentryClient { Map json = { 'project': projectId, 'event_id': _uuidGenerator(), - 'timestamp': _clock.now().toIso8601String(), + 'timestamp': formatDateAsIso8601WithSecondPrecision(_clock.now()), 'logger': defaultLoggerName, }; diff --git a/lib/src/utils.dart b/lib/src/utils.dart index 550b35ec28..d87b26719b 100644 --- a/lib/src/utils.dart +++ b/lib/src/utils.dart @@ -20,3 +20,11 @@ void mergeAttributes(Map attributes, } }); } + +String formatDateAsIso8601WithSecondPrecision(DateTime date) { + String iso = date.toIso8601String(); + final millisecondSeparatorIndex = iso.lastIndexOf('.'); + if (millisecondSeparatorIndex != -1) + iso = iso.substring(0, millisecondSeparatorIndex); + return iso; +} diff --git a/lib/src/version.dart b/lib/src/version.dart index 1462cfc1ed..7722e1175c 100644 --- a/lib/src/version.dart +++ b/lib/src/version.dart @@ -9,7 +9,7 @@ library version; /// The SDK version reported to Sentry.io in the submitted events. -const String sdkVersion = '0.0.4'; +const String sdkVersion = '0.0.5'; /// The SDK name reported to Sentry.io in the submitted events. const String sdkName = 'dart'; diff --git a/pubspec.yaml b/pubspec.yaml index 8ec03bbf18..f4c6886678 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: sentry -version: 0.0.4 +version: 0.0.5 description: A pure Dart Sentry.io client. author: Yegor Jbanov homepage: https://github.com/yjbanov/sentry diff --git a/test/sentry_test.dart b/test/sentry_test.dart index f79d0828da..a034186349 100644 --- a/test/sentry_test.dart +++ b/test/sentry_test.dart @@ -3,8 +3,8 @@ // found in the LICENSE file. import 'dart:convert'; - import 'dart:io'; + import 'package:http/http.dart'; import 'package:mockito/mockito.dart'; import 'package:quiver/time.dart'; @@ -27,7 +27,7 @@ void main() { testCaptureException(bool compressPayload) async { final MockClient httpMock = new MockClient(); - final Clock fakeClock = new Clock.fixed(new DateTime(2017, 1, 2)); + final Clock fakeClock = new Clock.fixed(new DateTime.utc(2017, 1, 2)); String postUri; Map headers; @@ -101,7 +101,7 @@ void main() { expect(json, { 'project': '1', 'event_id': 'X' * 32, - 'timestamp': '2017-01-02T00:00:00.000', + 'timestamp': '2017-01-02T00:00:00', 'platform': 'dart', 'exception': [ {'type': 'ArgumentError', 'value': 'Invalid argument(s): Test error'} diff --git a/test/utils_test.dart b/test/utils_test.dart index 3fa1e3eb1c..3ee15130dc 100644 --- a/test/utils_test.dart +++ b/test/utils_test.dart @@ -36,4 +36,14 @@ void main() { }); }); }); + + group('formatDateAsIso8601WithSecondPrecision', () { + test('strips sub-millisecond parts', () { + final DateTime testDate = + new DateTime.fromMillisecondsSinceEpoch(1502467721598, isUtc: true); + expect(testDate.toIso8601String(), '2017-08-11T16:08:41.598Z'); + expect(formatDateAsIso8601WithSecondPrecision(testDate), + '2017-08-11T16:08:41'); + }); + }); }