|
1 | 1 | import type { Event } from '@sentry/types';
|
2 | 2 |
|
3 | 3 | import type { Replay as ReplayIntegration } from '../../../src';
|
4 |
| -import { REPLAY_EVENT_NAME } from '../../../src/constants'; |
| 4 | +import { REPLAY_EVENT_NAME, SESSION_IDLE_EXPIRE_DURATION } from '../../../src/constants'; |
5 | 5 | import { handleGlobalEventListener } from '../../../src/coreHandlers/handleGlobalEvent';
|
6 | 6 | import type { ReplayContainer } from '../../../src/replay';
|
| 7 | +import { makeSession } from '../../../src/session/Session'; |
7 | 8 | import { Error } from '../../fixtures/error';
|
8 | 9 | import { Transaction } from '../../fixtures/transaction';
|
9 | 10 | import { resetSdkMock } from '../../mocks/resetSdkMock';
|
@@ -102,6 +103,32 @@ describe('Integration | coreHandlers | handleGlobalEvent', () => {
|
102 | 103 | );
|
103 | 104 | });
|
104 | 105 |
|
| 106 | + it('does not add replayId if replay session is expired', async () => { |
| 107 | + const transaction = Transaction(); |
| 108 | + const error = Error(); |
| 109 | + |
| 110 | + const now = Date.now(); |
| 111 | + |
| 112 | + replay.session = makeSession({ |
| 113 | + id: 'test-session-id', |
| 114 | + segmentId: 0, |
| 115 | + lastActivity: now - SESSION_IDLE_EXPIRE_DURATION - 1, |
| 116 | + started: now - SESSION_IDLE_EXPIRE_DURATION - 1, |
| 117 | + sampled: 'session', |
| 118 | + }); |
| 119 | + |
| 120 | + expect(handleGlobalEventListener(replay)(transaction, {})).toEqual( |
| 121 | + expect.objectContaining({ |
| 122 | + tags: expect.not.objectContaining({ replayId: expect.anything() }), |
| 123 | + }), |
| 124 | + ); |
| 125 | + expect(handleGlobalEventListener(replay)(error, {})).toEqual( |
| 126 | + expect.objectContaining({ |
| 127 | + tags: expect.not.objectContaining({ replayId: expect.anything() }), |
| 128 | + }), |
| 129 | + ); |
| 130 | + }); |
| 131 | + |
105 | 132 | it('tags errors and transactions with replay id for session samples', async () => {
|
106 | 133 | let integration: ReplayIntegration;
|
107 | 134 | ({ replay, integration } = await resetSdkMock({}));
|
|
0 commit comments