Skip to content

ref(replay): Restructure event type export naming #8866

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/browser-integration-tests/utils/replayHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { fullSnapshotEvent, incrementalSnapshotEvent } from '@sentry-internal/rrweb';
import { EventType } from '@sentry-internal/rrweb';
import type { ReplayEventWithTime } from '@sentry/browser';
import type {
InternalEventContext,
RecordingEvent,
ReplayContainer,
Session,
} from '@sentry/replay/build/npm/types/types';
import type { eventWithTime } from '@sentry/replay/build/npm/types/types/rrweb';
import type { Breadcrumb, Event, ReplayEvent, ReplayRecordingMode } from '@sentry/types';
import pako from 'pako';
import type { Page, Request, Response } from 'playwright';
Expand All @@ -22,12 +22,12 @@ export type PerformanceSpan = {
data: Record<string, number>;
};

export type FullRecordingSnapshot = eventWithTime & {
export type FullRecordingSnapshot = ReplayEventWithTime & {
timestamp: 0;
data: fullSnapshotEvent['data'];
};

export type IncrementalRecordingSnapshot = eventWithTime & {
export type IncrementalRecordingSnapshot = ReplayEventWithTime & {
timestamp: 0;
data: incrementalSnapshotEvent['data'];
};
Expand Down Expand Up @@ -270,7 +270,7 @@ function getOptionsEvents(replayRequest: Request): CustomRecordingEvent[] {
export function getDecompressedRecordingEvents(resOrReq: Request | Response): RecordingSnapshot[] {
const replayRequest = getRequest(resOrReq);
return (
(replayEnvelopeRequestParser(replayRequest, 5) as eventWithTime[])
(replayEnvelopeRequestParser(replayRequest, 5) as ReplayEventWithTime[])
.sort((a, b) => a.timestamp - b.timestamp)
// source 1 is MouseMove, which is a bit flaky and we don't care about
.filter(
Expand Down
12 changes: 12 additions & 0 deletions packages/browser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ const INTEGRATIONS = {
export { INTEGRATIONS as Integrations };

export { Replay } from '@sentry/replay';
export type {
ReplayEventType,
ReplayEventWithTime,
ReplayBreadcrumbFrame,
ReplayBreadcrumbFrameEvent,
ReplayOptionFrameEvent,
ReplayFrame,
ReplayFrameEvent,
ReplaySpanFrame,
ReplaySpanFrameEvent,
} from '@sentry/replay';

export {
BrowserTracing,
defaultRequestInstrumentationOptions,
Expand Down
2 changes: 0 additions & 2 deletions packages/replay/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ demo/build/
# TODO: Check if we can re-introduce linting in demo
demo
metrics
# For whatever reason, the eslint-ignore comment in this file is not working, so skipping this file
src/types/rrweb.ts
6 changes: 6 additions & 0 deletions packages/replay/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,11 @@ module.exports = {
'@typescript-eslint/no-floating-promises': 'off',
},
},
{
files: ['src/types/deprecated.ts'],
rules: {
'@typescript-eslint/naming-convention': 'off',
},
},
],
};
12 changes: 9 additions & 3 deletions packages/replay/src/coreHandlers/handleClick.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import type { Breadcrumb } from '@sentry/types';

import { WINDOW } from '../constants';
import type { MultiClickFrame, ReplayClickDetector, ReplayContainer, SlowClickConfig, SlowClickFrame } from '../types';
import type {
ReplayClickDetector,
ReplayContainer,
ReplayMultiClickFrame,
ReplaySlowClickFrame,
SlowClickConfig,
} from '../types';
import { timestampToS } from '../util/timestamp';
import { addBreadcrumbEvent } from './util/addBreadcrumbEvent';
import { getClickTargetNode } from './util/domUtils';
Expand Down Expand Up @@ -216,7 +222,7 @@ export class ClickDetector implements ReplayClickDetector {
const timeAfterClickMs = Math.min(click.mutationAfter || this._timeout, this._timeout) * 1000;
const endReason = timeAfterClickMs < this._timeout * 1000 ? 'mutation' : 'timeout';

const breadcrumb: SlowClickFrame = {
const breadcrumb: ReplaySlowClickFrame = {
type: 'default',
message: clickBreadcrumb.message,
timestamp: clickBreadcrumb.timestamp,
Expand All @@ -239,7 +245,7 @@ export class ClickDetector implements ReplayClickDetector {

// Multi click
if (clickCount > 1) {
const breadcrumb: MultiClickFrame = {
const breadcrumb: ReplayMultiClickFrame = {
type: 'default',
message: clickBreadcrumb.message,
timestamp: clickBreadcrumb.timestamp,
Expand Down
18 changes: 11 additions & 7 deletions packages/replay/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
export { Replay } from './integration';

export type {
EventType,
eventWithTime,
BreadcrumbFrame,
BreadcrumbFrameEvent,
OptionFrameEvent,
ReplayEventType,
ReplayEventWithTime,
ReplayBreadcrumbFrame,
ReplayBreadcrumbFrameEvent,
ReplayOptionFrameEvent,
ReplayFrame,
ReplayFrameEvent,
SpanFrame,
SpanFrameEvent,
ReplaySpanFrame,
ReplaySpanFrameEvent,
} from './types';

// TODO (v8): Remove deprecated types
export * from './types/deprecated';
11 changes: 6 additions & 5 deletions packages/replay/src/replay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,20 @@ import type {
AddEventResult,
AddUpdateCallback,
AllPerformanceEntry,
BreadcrumbFrame,
EventBuffer,
InternalEventContext,
PopEventContext,
RecordingEvent,
RecordingOptions,
ReplayBreadcrumbFrame,
ReplayContainer as ReplayContainerInterface,
ReplayPluginOptions,
SendBufferedReplayOptions,
Session,
SlowClickConfig,
Timeouts,
} from './types';
import { ReplayEventTypeCustom } from './types';
import { addEvent } from './util/addEvent';
import { addGlobalListeners } from './util/addGlobalListeners';
import { addMemoryEntry } from './util/addMemoryEntry';
Expand Down Expand Up @@ -688,7 +689,7 @@ export class ReplayContainer implements ReplayContainerInterface {

this.addUpdate(() => {
void addEvent(this, {
type: EventType.Custom,
type: ReplayEventTypeCustom,
timestamp: breadcrumb.timestamp || 0,
data: {
tag: 'breadcrumb',
Expand Down Expand Up @@ -919,7 +920,7 @@ export class ReplayContainer implements ReplayContainerInterface {
/**
* Tasks to run when we consider a page to be hidden (via blurring and/or visibility)
*/
private _doChangeToBackgroundTasks(breadcrumb?: BreadcrumbFrame): void {
private _doChangeToBackgroundTasks(breadcrumb?: ReplayBreadcrumbFrame): void {
if (!this.session) {
return;
}
Expand All @@ -939,7 +940,7 @@ export class ReplayContainer implements ReplayContainerInterface {
/**
* Tasks to run when we consider a page to be visible (via focus and/or visibility)
*/
private _doChangeToForegroundTasks(breadcrumb?: BreadcrumbFrame): void {
private _doChangeToForegroundTasks(breadcrumb?: ReplayBreadcrumbFrame): void {
if (!this.session) {
return;
}
Expand Down Expand Up @@ -992,7 +993,7 @@ export class ReplayContainer implements ReplayContainerInterface {
/**
* Helper to create (and buffer) a replay breadcrumb from a core SDK breadcrumb
*/
private _createCustomBreadcrumb(breadcrumb: BreadcrumbFrame): void {
private _createCustomBreadcrumb(breadcrumb: ReplayBreadcrumbFrame): void {
this.addUpdate(() => {
void this.throttledAddEvent({
type: EventType.Custom,
Expand Down
30 changes: 30 additions & 0 deletions packages/replay/src/types/deprecated.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type {
ReplayBreadcrumbFrame,
ReplayBreadcrumbFrameEvent,
ReplayEventType,
ReplayEventWithTime,
ReplayOptionFrameEvent,
ReplaySpanFrame,
ReplaySpanFrameEvent,
} from '.';

/** @deprecated use ReplayEventType instead */
export type EventType = ReplayEventType;

/** @deprecated use ReplayEventWithTime instead */
export type eventWithTime = ReplayEventWithTime;

/** @deprecated use ReplayBreadcrumbFrame instead */
export type BreadcrumbFrame = ReplayBreadcrumbFrame;

/** @deprecated use ReplayBreadcrumbFrameEvent instead */
export type BreadcrumbFrameEvent = ReplayBreadcrumbFrameEvent;

/** @deprecated use ReplayOptionFrameEvent instead */
export type OptionFrameEvent = ReplayOptionFrameEvent;

/** @deprecated use ReplaySpanFrame instead */
export type SpanFrame = ReplaySpanFrame;

/** @deprecated use ReplaySpanFrameEvent instead */
export type SpanFrameEvent = ReplaySpanFrameEvent;
6 changes: 3 additions & 3 deletions packages/replay/src/types/replay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import type { SKIPPED, THROTTLED } from '../util/throttle';
import type { AllPerformanceEntry } from './performance';
import type { ReplayFrameEvent } from './replayFrame';
import type { ReplayNetworkRequestOrResponse } from './request';
import type { eventWithTime, recordOptions } from './rrweb';
import type { ReplayEventWithTime, RrwebRecordOptions } from './rrweb';

export type RecordingEvent = ReplayFrameEvent | eventWithTime;
export type RecordingOptions = recordOptions;
export type RecordingEvent = ReplayFrameEvent | ReplayEventWithTime;
export type RecordingOptions = RrwebRecordOptions;

export interface SendReplayData {
recordingData: ReplayRecordingData;
Expand Down
Loading