Skip to content

Commit 56d544a

Browse files
authored
remove sub-seconds from the timestamp format (#2)
1 parent b2b5afc commit 56d544a

File tree

7 files changed

+32
-6
lines changed

7 files changed

+32
-6
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# package:sentry changelog
22

3+
## 0.0.5
4+
5+
- remove sub-seconds from the timestamp
6+
7+
## 0.0.4
8+
9+
- parse and report async gaps in stack traces
10+
311
## 0.0.3
412

513
- environment attributes

lib/sentry.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class SentryClient {
164164
Map<String, dynamic> json = <String, dynamic>{
165165
'project': projectId,
166166
'event_id': _uuidGenerator(),
167-
'timestamp': _clock.now().toIso8601String(),
167+
'timestamp': formatDateAsIso8601WithSecondPrecision(_clock.now()),
168168
'logger': defaultLoggerName,
169169
};
170170

lib/src/utils.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,11 @@ void mergeAttributes(Map<String, dynamic> attributes,
2020
}
2121
});
2222
}
23+
24+
String formatDateAsIso8601WithSecondPrecision(DateTime date) {
25+
String iso = date.toIso8601String();
26+
final millisecondSeparatorIndex = iso.lastIndexOf('.');
27+
if (millisecondSeparatorIndex != -1)
28+
iso = iso.substring(0, millisecondSeparatorIndex);
29+
return iso;
30+
}

lib/src/version.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
library version;
1010

1111
/// The SDK version reported to Sentry.io in the submitted events.
12-
const String sdkVersion = '0.0.4';
12+
const String sdkVersion = '0.0.5';
1313

1414
/// The SDK name reported to Sentry.io in the submitted events.
1515
const String sdkName = 'dart';

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sentry
2-
version: 0.0.4
2+
version: 0.0.5
33
description: A pure Dart Sentry.io client.
44
author: Yegor Jbanov <[email protected]>
55
homepage: https://github.com/yjbanov/sentry

test/sentry_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// found in the LICENSE file.
44

55
import 'dart:convert';
6-
76
import 'dart:io';
7+
88
import 'package:http/http.dart';
99
import 'package:mockito/mockito.dart';
1010
import 'package:quiver/time.dart';
@@ -27,7 +27,7 @@ void main() {
2727

2828
testCaptureException(bool compressPayload) async {
2929
final MockClient httpMock = new MockClient();
30-
final Clock fakeClock = new Clock.fixed(new DateTime(2017, 1, 2));
30+
final Clock fakeClock = new Clock.fixed(new DateTime.utc(2017, 1, 2));
3131

3232
String postUri;
3333
Map<String, String> headers;
@@ -101,7 +101,7 @@ void main() {
101101
expect(json, {
102102
'project': '1',
103103
'event_id': 'X' * 32,
104-
'timestamp': '2017-01-02T00:00:00.000',
104+
'timestamp': '2017-01-02T00:00:00',
105105
'platform': 'dart',
106106
'exception': [
107107
{'type': 'ArgumentError', 'value': 'Invalid argument(s): Test error'}

test/utils_test.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,14 @@ void main() {
3636
});
3737
});
3838
});
39+
40+
group('formatDateAsIso8601WithSecondPrecision', () {
41+
test('strips sub-millisecond parts', () {
42+
final DateTime testDate =
43+
new DateTime.fromMillisecondsSinceEpoch(1502467721598, isUtc: true);
44+
expect(testDate.toIso8601String(), '2017-08-11T16:08:41.598Z');
45+
expect(formatDateAsIso8601WithSecondPrecision(testDate),
46+
'2017-08-11T16:08:41');
47+
});
48+
});
3949
}

0 commit comments

Comments
 (0)