Skip to content

Commit 31cef09

Browse files
authored
ref(replay): Restructure event type export naming (#8866)
This renames & restructures the type exports from `@sentry/replay`. We want to deprecate the `@sentry/replay` package eventually - users should import everything they need directly from e.g. `@sentry/browser` or `@sentry/react`. ref #8864
1 parent fe2c801 commit 31cef09

28 files changed

+295
-210
lines changed

packages/browser-integration-tests/utils/replayHelpers.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import type { fullSnapshotEvent, incrementalSnapshotEvent } from '@sentry-internal/rrweb';
22
import { EventType } from '@sentry-internal/rrweb';
3+
import type { ReplayEventWithTime } from '@sentry/browser';
34
import type {
45
InternalEventContext,
56
RecordingEvent,
67
ReplayContainer,
78
Session,
89
} from '@sentry/replay/build/npm/types/types';
9-
import type { eventWithTime } from '@sentry/replay/build/npm/types/types/rrweb';
1010
import type { Breadcrumb, Event, ReplayEvent, ReplayRecordingMode } from '@sentry/types';
1111
import pako from 'pako';
1212
import type { Page, Request, Response } from 'playwright';
@@ -22,12 +22,12 @@ export type PerformanceSpan = {
2222
data: Record<string, number>;
2323
};
2424

25-
export type FullRecordingSnapshot = eventWithTime & {
25+
export type FullRecordingSnapshot = ReplayEventWithTime & {
2626
timestamp: 0;
2727
data: fullSnapshotEvent['data'];
2828
};
2929

30-
export type IncrementalRecordingSnapshot = eventWithTime & {
30+
export type IncrementalRecordingSnapshot = ReplayEventWithTime & {
3131
timestamp: 0;
3232
data: incrementalSnapshotEvent['data'];
3333
};
@@ -270,7 +270,7 @@ function getOptionsEvents(replayRequest: Request): CustomRecordingEvent[] {
270270
export function getDecompressedRecordingEvents(resOrReq: Request | Response): RecordingSnapshot[] {
271271
const replayRequest = getRequest(resOrReq);
272272
return (
273-
(replayEnvelopeRequestParser(replayRequest, 5) as eventWithTime[])
273+
(replayEnvelopeRequestParser(replayRequest, 5) as ReplayEventWithTime[])
274274
.sort((a, b) => a.timestamp - b.timestamp)
275275
// source 1 is MouseMove, which is a bit flaky and we don't care about
276276
.filter(

packages/browser/src/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ const INTEGRATIONS = {
2121
export { INTEGRATIONS as Integrations };
2222

2323
export { Replay } from '@sentry/replay';
24+
export type {
25+
ReplayEventType,
26+
ReplayEventWithTime,
27+
ReplayBreadcrumbFrame,
28+
ReplayBreadcrumbFrameEvent,
29+
ReplayOptionFrameEvent,
30+
ReplayFrame,
31+
ReplayFrameEvent,
32+
ReplaySpanFrame,
33+
ReplaySpanFrameEvent,
34+
} from '@sentry/replay';
35+
2436
export {
2537
BrowserTracing,
2638
defaultRequestInstrumentationOptions,

packages/replay/.eslintignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,3 @@ demo/build/
44
# TODO: Check if we can re-introduce linting in demo
55
demo
66
metrics
7-
# For whatever reason, the eslint-ignore comment in this file is not working, so skipping this file
8-
src/types/rrweb.ts

packages/replay/.eslintrc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,11 @@ module.exports = {
3232
'@typescript-eslint/no-floating-promises': 'off',
3333
},
3434
},
35+
{
36+
files: ['src/types/deprecated.ts'],
37+
rules: {
38+
'@typescript-eslint/naming-convention': 'off',
39+
},
40+
},
3541
],
3642
};

packages/replay/src/coreHandlers/handleClick.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import type { Breadcrumb } from '@sentry/types';
22

33
import { WINDOW } from '../constants';
4-
import type { MultiClickFrame, ReplayClickDetector, ReplayContainer, SlowClickConfig, SlowClickFrame } from '../types';
4+
import type {
5+
ReplayClickDetector,
6+
ReplayContainer,
7+
ReplayMultiClickFrame,
8+
ReplaySlowClickFrame,
9+
SlowClickConfig,
10+
} from '../types';
511
import { timestampToS } from '../util/timestamp';
612
import { addBreadcrumbEvent } from './util/addBreadcrumbEvent';
713
import { getClickTargetNode } from './util/domUtils';
@@ -216,7 +222,7 @@ export class ClickDetector implements ReplayClickDetector {
216222
const timeAfterClickMs = Math.min(click.mutationAfter || this._timeout, this._timeout) * 1000;
217223
const endReason = timeAfterClickMs < this._timeout * 1000 ? 'mutation' : 'timeout';
218224

219-
const breadcrumb: SlowClickFrame = {
225+
const breadcrumb: ReplaySlowClickFrame = {
220226
type: 'default',
221227
message: clickBreadcrumb.message,
222228
timestamp: clickBreadcrumb.timestamp,
@@ -239,7 +245,7 @@ export class ClickDetector implements ReplayClickDetector {
239245

240246
// Multi click
241247
if (clickCount > 1) {
242-
const breadcrumb: MultiClickFrame = {
248+
const breadcrumb: ReplayMultiClickFrame = {
243249
type: 'default',
244250
message: clickBreadcrumb.message,
245251
timestamp: clickBreadcrumb.timestamp,

packages/replay/src/index.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
export { Replay } from './integration';
2+
23
export type {
3-
EventType,
4-
eventWithTime,
5-
BreadcrumbFrame,
6-
BreadcrumbFrameEvent,
7-
OptionFrameEvent,
4+
ReplayEventType,
5+
ReplayEventWithTime,
6+
ReplayBreadcrumbFrame,
7+
ReplayBreadcrumbFrameEvent,
8+
ReplayOptionFrameEvent,
89
ReplayFrame,
910
ReplayFrameEvent,
10-
SpanFrame,
11-
SpanFrameEvent,
11+
ReplaySpanFrame,
12+
ReplaySpanFrameEvent,
1213
} from './types';
14+
15+
// TODO (v8): Remove deprecated types
16+
export * from './types/deprecated';

packages/replay/src/replay.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,20 @@ import type {
2525
AddEventResult,
2626
AddUpdateCallback,
2727
AllPerformanceEntry,
28-
BreadcrumbFrame,
2928
EventBuffer,
3029
InternalEventContext,
3130
PopEventContext,
3231
RecordingEvent,
3332
RecordingOptions,
33+
ReplayBreadcrumbFrame,
3434
ReplayContainer as ReplayContainerInterface,
3535
ReplayPluginOptions,
3636
SendBufferedReplayOptions,
3737
Session,
3838
SlowClickConfig,
3939
Timeouts,
4040
} from './types';
41+
import { ReplayEventTypeCustom } from './types';
4142
import { addEvent } from './util/addEvent';
4243
import { addGlobalListeners } from './util/addGlobalListeners';
4344
import { addMemoryEntry } from './util/addMemoryEntry';
@@ -688,7 +689,7 @@ export class ReplayContainer implements ReplayContainerInterface {
688689

689690
this.addUpdate(() => {
690691
void addEvent(this, {
691-
type: EventType.Custom,
692+
type: ReplayEventTypeCustom,
692693
timestamp: breadcrumb.timestamp || 0,
693694
data: {
694695
tag: 'breadcrumb',
@@ -919,7 +920,7 @@ export class ReplayContainer implements ReplayContainerInterface {
919920
/**
920921
* Tasks to run when we consider a page to be hidden (via blurring and/or visibility)
921922
*/
922-
private _doChangeToBackgroundTasks(breadcrumb?: BreadcrumbFrame): void {
923+
private _doChangeToBackgroundTasks(breadcrumb?: ReplayBreadcrumbFrame): void {
923924
if (!this.session) {
924925
return;
925926
}
@@ -939,7 +940,7 @@ export class ReplayContainer implements ReplayContainerInterface {
939940
/**
940941
* Tasks to run when we consider a page to be visible (via focus and/or visibility)
941942
*/
942-
private _doChangeToForegroundTasks(breadcrumb?: BreadcrumbFrame): void {
943+
private _doChangeToForegroundTasks(breadcrumb?: ReplayBreadcrumbFrame): void {
943944
if (!this.session) {
944945
return;
945946
}
@@ -992,7 +993,7 @@ export class ReplayContainer implements ReplayContainerInterface {
992993
/**
993994
* Helper to create (and buffer) a replay breadcrumb from a core SDK breadcrumb
994995
*/
995-
private _createCustomBreadcrumb(breadcrumb: BreadcrumbFrame): void {
996+
private _createCustomBreadcrumb(breadcrumb: ReplayBreadcrumbFrame): void {
996997
this.addUpdate(() => {
997998
void this.throttledAddEvent({
998999
type: EventType.Custom,
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import type {
2+
ReplayBreadcrumbFrame,
3+
ReplayBreadcrumbFrameEvent,
4+
ReplayEventType,
5+
ReplayEventWithTime,
6+
ReplayOptionFrameEvent,
7+
ReplaySpanFrame,
8+
ReplaySpanFrameEvent,
9+
} from '.';
10+
11+
/** @deprecated use ReplayEventType instead */
12+
export type EventType = ReplayEventType;
13+
14+
/** @deprecated use ReplayEventWithTime instead */
15+
export type eventWithTime = ReplayEventWithTime;
16+
17+
/** @deprecated use ReplayBreadcrumbFrame instead */
18+
export type BreadcrumbFrame = ReplayBreadcrumbFrame;
19+
20+
/** @deprecated use ReplayBreadcrumbFrameEvent instead */
21+
export type BreadcrumbFrameEvent = ReplayBreadcrumbFrameEvent;
22+
23+
/** @deprecated use ReplayOptionFrameEvent instead */
24+
export type OptionFrameEvent = ReplayOptionFrameEvent;
25+
26+
/** @deprecated use ReplaySpanFrame instead */
27+
export type SpanFrame = ReplaySpanFrame;
28+
29+
/** @deprecated use ReplaySpanFrameEvent instead */
30+
export type SpanFrameEvent = ReplaySpanFrameEvent;

packages/replay/src/types/replay.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import type { SKIPPED, THROTTLED } from '../util/throttle';
1313
import type { AllPerformanceEntry } from './performance';
1414
import type { ReplayFrameEvent } from './replayFrame';
1515
import type { ReplayNetworkRequestOrResponse } from './request';
16-
import type { eventWithTime, recordOptions } from './rrweb';
16+
import type { ReplayEventWithTime, RrwebRecordOptions } from './rrweb';
1717

18-
export type RecordingEvent = ReplayFrameEvent | eventWithTime;
19-
export type RecordingOptions = recordOptions;
18+
export type RecordingEvent = ReplayFrameEvent | ReplayEventWithTime;
19+
export type RecordingOptions = RrwebRecordOptions;
2020

2121
export interface SendReplayData {
2222
recordingData: ReplayRecordingData;

0 commit comments

Comments
 (0)