Skip to content

remove sub-seconds from the timestamp format #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/sentry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class SentryClient {
Map<String, dynamic> json = <String, dynamic>{
'project': projectId,
'event_id': _uuidGenerator(),
'timestamp': _clock.now().toIso8601String(),
'timestamp': formatDateAsIso8601WithSecondPrecision(_clock.now()),
'logger': defaultLoggerName,
};

Expand Down
8 changes: 8 additions & 0 deletions lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,11 @@ void mergeAttributes(Map<String, dynamic> attributes,
}
});
}

String formatDateAsIso8601WithSecondPrecision(DateTime date) {
String iso = date.toIso8601String();
final millisecondSeparatorIndex = iso.lastIndexOf('.');
if (millisecondSeparatorIndex != -1)
iso = iso.substring(0, millisecondSeparatorIndex);
return iso;
}
2 changes: 1 addition & 1 deletion lib/src/version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sentry
version: 0.0.4
version: 0.0.5
description: A pure Dart Sentry.io client.
author: Yegor Jbanov <[email protected]>
homepage: https://github.com/yjbanov/sentry
Expand Down
6 changes: 3 additions & 3 deletions test/sentry_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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<String, String> headers;
Expand Down Expand Up @@ -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'}
Expand Down
10 changes: 10 additions & 0 deletions test/utils_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
}