Skip to content

Commit edbc2df

Browse files
HazATSijaAbhiPrasad
authored
fix: sent_at for envelope headers (getsentry#2597)
* fix: sent_at for envelope headers * chore: Changelog * Update CHANGELOG.md Co-authored-by: Sijawusz Pur Rahnama <sija@sija.pl> * Update packages/core/src/request.ts Co-authored-by: Abhijeet Prasad <AbhiPrasad@users.noreply.github.com> Co-authored-by: Sijawusz Pur Rahnama <sija@sija.pl> Co-authored-by: Abhijeet Prasad <AbhiPrasad@users.noreply.github.com>
1 parent bb41fab commit edbc2df

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
66

77
- [apm] fix: Use proper type name for op #2584
8+
- [core] fix: sent_at for envelope headers to use same clock #2597
89
- [apm] fix: Improve bundle size by moving span status to @sentry/apm #2589
910

1011
## 5.16.0

packages/core/src/request.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { getCurrentHub } from '@sentry/hub';
22
import { Event } from '@sentry/types';
3+
import { timestampWithMs } from '@sentry/utils';
34

45
import { API } from './api';
56

@@ -34,7 +35,9 @@ export function eventToSentryRequest(event: Event, api: API): SentryRequest {
3435
if (useEnvelope) {
3536
const envelopeHeaders = JSON.stringify({
3637
event_id: event.event_id,
37-
sent_at: new Date().toISOString(),
38+
// We need to add * 1000 since we divide it by 1000 by default but JS works with ms precision
39+
// The reason we use timestampWithMs here is that all clocks across the SDK use the same clock
40+
sent_at: new Date(timestampWithMs() * 1000).toISOString(),
3841
});
3942
const itemHeaders = JSON.stringify({
4043
type: event.type,

0 commit comments

Comments
 (0)