Skip to content

Commit 886cb8f

Browse files
committed
fix: Use dateTimestampInSeconds instead of Date.now
1 parent daad234 commit 886cb8f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

packages/browser/src/transports/base.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
Transport,
99
TransportOptions,
1010
} from '@sentry/types';
11-
import { logger, parseRetryAfterHeader, PromiseBuffer, SentryError } from '@sentry/utils';
11+
import { dateTimestampInSeconds, logger, parseRetryAfterHeader, PromiseBuffer, SentryError } from '@sentry/utils';
1212

1313
const CATEGORY_MAPPING: {
1414
[key in SentryRequestType]: string;
@@ -113,7 +113,7 @@ export abstract class BaseTransport implements Transport {
113113
type: 'client_report',
114114
});
115115
const item = JSON.stringify({
116-
timestamp: Date.now(),
116+
timestamp: dateTimestampInSeconds(),
117117
discarded_events: Object.keys(outcomes).map(key => {
118118
const [category, reason] = key.split(':');
119119
return {

packages/browser/test/unit/transports/base.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('BaseTransport', () => {
2020
return visibilityState;
2121
},
2222
});
23-
jest.spyOn(Date, 'now').mockImplementation(() => 1337);
23+
jest.spyOn(Date, 'now').mockImplementation(() => 12345);
2424
});
2525

2626
beforeEach(() => {
@@ -53,7 +53,7 @@ describe('BaseTransport', () => {
5353

5454
expect(sendBeaconSpy).toHaveBeenCalledWith(
5555
envelopeEndpoint,
56-
`{}\n{"type":"client_report"}\n{"timestamp":1337,"discarded_events":${JSON.stringify(outcomes)}}`,
56+
`{}\n{"type":"client_report"}\n{"timestamp":12.345,"discarded_events":${JSON.stringify(outcomes)}}`,
5757
);
5858
});
5959

@@ -89,7 +89,7 @@ describe('BaseTransport', () => {
8989

9090
expect(sendBeaconSpy).toHaveBeenCalledWith(
9191
envelopeEndpoint,
92-
`{}\n{"type":"client_report"}\n{"timestamp":1337,"discarded_events":${JSON.stringify(outcomes)}}`,
92+
`{}\n{"type":"client_report"}\n{"timestamp":12.345,"discarded_events":${JSON.stringify(outcomes)}}`,
9393
);
9494
});
9595
});

0 commit comments

Comments
 (0)