File tree 2 files changed +15
-1
lines changed
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 1
1
import 'protocol/sentry_id.dart' ;
2
2
import 'protocol/sdk_version.dart' ;
3
3
import 'sentry_trace_context_header.dart' ;
4
+ import 'utils.dart' ;
4
5
5
6
/// Header containing `SentryId` and `SdkVersion` .
6
7
class SentryEnvelopeHeader {
@@ -9,12 +10,14 @@ class SentryEnvelopeHeader {
9
10
this .sdkVersion, {
10
11
this .dsn,
11
12
this .traceContext,
13
+ this .sentAt,
12
14
});
13
15
SentryEnvelopeHeader .newEventId ()
14
16
: eventId = SentryId .newId (),
15
17
sdkVersion = null ,
16
18
dsn = null ,
17
- traceContext = null ;
19
+ traceContext = null ,
20
+ sentAt = null ;
18
21
19
22
/// The identifier of encoded `SentryEvent` .
20
23
final SentryId ? eventId;
@@ -27,6 +30,8 @@ class SentryEnvelopeHeader {
27
30
/// The `DSN` of the Sentry project.
28
31
final String ? dsn;
29
32
33
+ DateTime ? sentAt;
34
+
30
35
/// Header encoded as JSON
31
36
Map <String , dynamic > toJson () {
32
37
final json = < String , dynamic > {};
@@ -49,6 +54,11 @@ class SentryEnvelopeHeader {
49
54
if (dsn != null ) {
50
55
json['dsn' ] = dsn;
51
56
}
57
+
58
+ if (sentAt != null ) {
59
+ json['sent_at' ] = formatDateAsIso8601WithMillisPrecision (sentAt! );
60
+ }
61
+
52
62
return json;
53
63
}
54
64
}
Original file line number Diff line number Diff line change 1
1
import 'package:sentry/sentry.dart' ;
2
2
import 'package:sentry/src/sentry_envelope_header.dart' ;
3
+ import 'package:sentry/src/utils.dart' ;
3
4
import 'package:test/test.dart' ;
4
5
5
6
import 'mocks.dart' ;
@@ -22,18 +23,21 @@ void main() {
22
23
'trace_id' : '${SentryId .newId ()}' ,
23
24
'public_key' : '123' ,
24
25
});
26
+ final timestamp = DateTime .utc (2019 );
25
27
final sut = SentryEnvelopeHeader (
26
28
eventId,
27
29
sdkVersion,
28
30
dsn: fakeDsn,
29
31
traceContext: context,
32
+ sentAt: timestamp,
30
33
);
31
34
final expextedSkd = sdkVersion.toJson ();
32
35
final expected = < String , dynamic > {
33
36
'event_id' : eventId.toString (),
34
37
'sdk' : expextedSkd,
35
38
'trace' : context.toJson (),
36
39
'dsn' : fakeDsn,
40
+ 'sent_at' : formatDateAsIso8601WithMillisPrecision (timestamp),
37
41
};
38
42
expect (sut.toJson (), expected);
39
43
});
You can’t perform that action at this time.
0 commit comments