|
1 | 1 | import type { Envelope, InternalBaseTransportOptions, Transport, TransportMakeRequestResponse } from '@sentry/types';
|
2 |
| -import { forEachEnvelopeItem, logger, parseRetryAfterHeader } from '@sentry/utils'; |
| 2 | +import { envelopeContainItemType, logger, parseRetryAfterHeader } from '@sentry/utils'; |
3 | 3 |
|
4 | 4 | export const MIN_DELAY = 100; // 100 ms
|
5 | 5 | export const START_DELAY = 5_000; // 5 seconds
|
6 | 6 | const MAX_DELAY = 3.6e6; // 1 hour
|
7 | 7 |
|
8 |
| -function isReplayEnvelope(envelope: Envelope): boolean { |
9 |
| - let isReplay = false; |
10 |
| - |
11 |
| - forEachEnvelopeItem(envelope, (_, type) => { |
12 |
| - if (type === 'replay_event') { |
13 |
| - isReplay = true; |
14 |
| - } |
15 |
| - }); |
16 |
| - |
17 |
| - return isReplay; |
18 |
| -} |
19 |
| - |
20 | 8 | function log(msg: string, error?: Error): void {
|
21 | 9 | __DEBUG_BUILD__ && logger.info(`[Offline]: ${msg}`, error);
|
22 | 10 | }
|
@@ -74,7 +62,8 @@ export function makeOfflineTransport<TO>(
|
74 | 62 | // We don't queue Session Replay envelopes because they are:
|
75 | 63 | // - Ordered and Replay relies on the response status to know when they're successfully sent.
|
76 | 64 | // - Likely to fill the queue quickly and block other events from being sent.
|
77 |
| - if (isReplayEnvelope(env)) { |
| 65 | + // We also want to drop client reports because they can be generated when we retry sending events while offline. |
| 66 | + if (envelopeContainItemType(env, 'replay_event', 'replay_recording', 'client_report')) { |
78 | 67 | return false;
|
79 | 68 | }
|
80 | 69 |
|
|
0 commit comments