Skip to content

Commit 012ff34

Browse files
billyvgmydea
andauthored
fix(replay): Fix ts errors with replay_type (#6681)
Co-authored-by: Francesco Novy <francesco.novy@sentry.io>
1 parent 2fbd835 commit 012ff34

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

packages/replay/src/replay.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable max-lines */ // TODO: We might want to split this file up
22
import { addGlobalEventProcessor, captureException, getCurrentHub, setContext } from '@sentry/core';
3-
import { Breadcrumb, ReplayEvent, TransportMakeRequestResponse } from '@sentry/types';
3+
import type { Breadcrumb, ReplayEvent, ReplayRecordingMode, TransportMakeRequestResponse } from '@sentry/types';
44
import { addInstrumentationHandler, logger } from '@sentry/utils';
55
import { EventType, record } from 'rrweb';
66

@@ -34,7 +34,6 @@ import type {
3434
RecordingOptions,
3535
ReplayContainer as ReplayContainerInterface,
3636
ReplayPluginOptions,
37-
ReplayRecordingMode,
3837
SendReplay,
3938
Session,
4039
} from './types';
@@ -922,7 +921,7 @@ export class ReplayContainer implements ReplayContainerInterface {
922921
const transport = client && client.getTransport();
923922
const dsn = client?.getDsn();
924923

925-
if (!client || !scope || !transport || !dsn) {
924+
if (!client || !scope || !transport || !dsn || !this.session || !this.session.sampled) {
926925
return;
927926
}
928927

@@ -936,7 +935,7 @@ export class ReplayContainer implements ReplayContainerInterface {
936935
urls,
937936
replay_id: replayId,
938937
segment_id,
939-
replay_type: this.session?.sampled,
938+
replay_type: this.session.sampled,
940939
};
941940

942941
const replayEvent = await getReplayEvent({ scope, client, replayId, event: baseEvent });

packages/replay/src/types.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ReplayRecordingData } from '@sentry/types';
1+
import type { ReplayRecordingData, ReplayRecordingMode } from '@sentry/types';
22

33
import type { eventWithTime, recordOptions } from './types/rrweb';
44

@@ -9,8 +9,6 @@ export type RecordedEvents = Uint8Array | string;
99

1010
export type AllPerformanceEntry = PerformancePaintTiming | PerformanceResourceTiming | PerformanceNavigationTiming;
1111

12-
export type ReplayRecordingMode = 'session' | 'error';
13-
1412
export interface SendReplay {
1513
events: RecordedEvents;
1614
replayId: string;

packages/replay/test/unit/util/getReplayEvent.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ describe('getReplayEvent', () => {
3434
urls: ['https://sentry.io/'],
3535
replay_id: replayId,
3636
event_id: replayId,
37+
replay_type: 'session',
3738
segment_id: 3,
3839
};
3940

@@ -46,6 +47,7 @@ describe('getReplayEvent', () => {
4647
trace_ids: ['trace-ID'],
4748
urls: ['https://sentry.io/'],
4849
replay_id: 'replay-ID',
50+
replay_type: 'session',
4951
segment_id: 3,
5052
platform: 'javascript',
5153
event_id: 'replay-ID',

packages/types/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export type { ExtractedNodeRequestData, HttpHeaderValue, Primitive, WorkerLocati
4040
export type { ClientOptions, Options } from './options';
4141
export type { Package } from './package';
4242
export type { PolymorphicEvent, PolymorphicRequest } from './polymorphics';
43-
export type { ReplayEvent, ReplayRecordingData } from './replay';
43+
export type { ReplayEvent, ReplayRecordingData, ReplayRecordingMode } from './replay';
4444
export type { QueryParams, Request } from './request';
4545
export type { Runtime } from './runtime';
4646
export type { CaptureContext, Scope, ScopeContext } from './scope';

packages/types/src/replay.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,17 @@ export interface ReplayEvent extends Event {
1010
trace_ids: string[];
1111
replay_id: string;
1212
segment_id: number;
13+
replay_type: ReplayRecordingMode;
1314
}
1415

1516
/**
1617
* NOTE: These types are still considered Beta and subject to change.
1718
* @hidden
1819
*/
1920
export type ReplayRecordingData = string | Uint8Array;
21+
22+
/**
23+
* NOTE: These types are still considered Beta and subject to change.
24+
* @hidden
25+
*/
26+
export type ReplayRecordingMode = 'session' | 'error';

0 commit comments

Comments
 (0)