|
| 1 | +import { Event } from '@sentry/types'; |
| 2 | + |
| 3 | +import { createReplayEnvelope } from '../../../src/util/createReplayEnvelope'; |
| 4 | + |
| 5 | +describe('createReplayEnvelope', () => { |
| 6 | + it('creates an envelope for a given Replay event', () => { |
| 7 | + const replayId = '1234'; |
| 8 | + const replayEvent = { |
| 9 | + type: 'replay_event', |
| 10 | + timestamp: 1670837008.634, |
| 11 | + error_ids: ['errorId'], |
| 12 | + trace_ids: ['traceId'], |
| 13 | + urls: ['https://example.com'], |
| 14 | + replay_id: 'eventId', |
| 15 | + segment_id: 3, |
| 16 | + platform: 'javascript', |
| 17 | + event_id: 'eventId', |
| 18 | + environment: 'production', |
| 19 | + sdk: { |
| 20 | + integrations: ['BrowserTracing', 'Replay'], |
| 21 | + name: 'sentry.javascript.browser', |
| 22 | + version: '7.25.0', |
| 23 | + }, |
| 24 | + tags: { |
| 25 | + sessionSampleRate: 1, |
| 26 | + errorSampleRate: 0, |
| 27 | + replayType: 'error', |
| 28 | + }, |
| 29 | + }; |
| 30 | + const payloadWithSequence = 'payload'; |
| 31 | + |
| 32 | + const envelope = createReplayEnvelope(replayId, replayEvent as Event, payloadWithSequence); |
| 33 | + |
| 34 | + expect(envelope).toEqual([ |
| 35 | + { |
| 36 | + event_id: '1234', |
| 37 | + sdk: { name: 'sentry.javascript.browser', version: '7.25.0' }, |
| 38 | + sent_at: expect.any(String), |
| 39 | + }, |
| 40 | + [ |
| 41 | + [ |
| 42 | + { type: 'replay_event' }, |
| 43 | + { |
| 44 | + environment: 'production', |
| 45 | + error_ids: ['errorId'], |
| 46 | + event_id: 'eventId', |
| 47 | + platform: 'javascript', |
| 48 | + replay_id: 'eventId', |
| 49 | + sdk: { integrations: ['BrowserTracing', 'Replay'], name: 'sentry.javascript.browser', version: '7.25.0' }, |
| 50 | + segment_id: 3, |
| 51 | + tags: { errorSampleRate: 0, replayType: 'error', sessionSampleRate: 1 }, |
| 52 | + timestamp: 1670837008.634, |
| 53 | + trace_ids: ['traceId'], |
| 54 | + type: 'replay_event', |
| 55 | + urls: ['https://example.com'], |
| 56 | + }, |
| 57 | + ], |
| 58 | + [{ length: 7, type: 'replay_recording' }, 'payload'], |
| 59 | + ], |
| 60 | + ]); |
| 61 | + }); |
| 62 | +}); |
0 commit comments