Skip to content
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

ref(v7/replay): Deprecate @sentry/replay exports #11242

Merged
merged 6 commits into from
Mar 22, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from '@playwright/test';
import type { Replay } from '@sentry/replay';
import type { InternalReplay } from '@sentry/replay';
import type { ReplayContainer } from '@sentry/replay/build/npm/types/types';

import { sentryTest } from '../../../utils/fixtures';
Expand Down Expand Up @@ -68,7 +68,8 @@ sentryTest(
expect(
await page.evaluate(() => {
// eslint-disable-next-line deprecation/deprecation
const replayIntegration = (window as unknown as Window & { Replay: InstanceType<typeof Replay> }).Replay;
const replayIntegration = (window as unknown as Window & { Replay: InstanceType<typeof InternalReplay> })
.Replay;
// @ts-expect-error private
const replay = replayIntegration._replay;
replayIntegration.startBuffering();
Expand All @@ -89,7 +90,7 @@ sentryTest(
reqPromise0,
page.evaluate(async () => {
// eslint-disable-next-line deprecation/deprecation
const replayIntegration = (window as unknown as Window & { Replay: Replay }).Replay;
const replayIntegration = (window as unknown as Window & { Replay: InternalReplay }).Replay;
await replayIntegration.flush();
}),
]);
Expand Down Expand Up @@ -213,7 +214,8 @@ sentryTest(
expect(
await page.evaluate(() => {
// eslint-disable-next-line deprecation/deprecation
const replayIntegration = (window as unknown as Window & { Replay: InstanceType<typeof Replay> }).Replay;
const replayIntegration = (window as unknown as Window & { Replay: InstanceType<typeof InternalReplay> })
.Replay;
// @ts-expect-error private
const replay = replayIntegration._replay;
replayIntegration.startBuffering();
Expand All @@ -234,7 +236,7 @@ sentryTest(
reqPromise0,
page.evaluate(async () => {
// eslint-disable-next-line deprecation/deprecation
const replayIntegration = (window as unknown as Window & { Replay: Replay }).Replay;
const replayIntegration = (window as unknown as Window & { Replay: InternalReplay }).Replay;
await replayIntegration.flush({ continueRecording: false });
}),
]);
Expand Down Expand Up @@ -329,7 +331,8 @@ sentryTest(
expect(
await page.evaluate(() => {
// eslint-disable-next-line deprecation/deprecation
const replayIntegration = (window as unknown as Window & { Replay: InstanceType<typeof Replay> }).Replay;
const replayIntegration = (window as unknown as Window & { Replay: InstanceType<typeof InternalReplay> })
.Replay;
const replay = replayIntegration['_replay'];
replayIntegration.startBuffering();
return replay.isEnabled();
Expand All @@ -348,7 +351,7 @@ sentryTest(

await page.evaluate(async () => {
// eslint-disable-next-line deprecation/deprecation
const replayIntegration = (window as unknown as Window & { Replay: Replay }).Replay;
const replayIntegration = (window as unknown as Window & { Replay: InternalReplay }).Replay;
replayIntegration['_replay'].getOptions().errorSampleRate = 1.0;
});

Expand Down
8 changes: 4 additions & 4 deletions packages/browser/src/index.bundle.replay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import {
browserTracingIntegration,
feedbackIntegration,
} from '@sentry-internal/integration-shims';
import { Replay, replayIntegration } from '@sentry/replay';
import { InternalReplay, internalReplayIntegration } from '@sentry/replay';

import * as Sentry from './index.bundle.base';

// TODO (v8): Remove this as it was only needed for backwards compatibility
// eslint-disable-next-line deprecation/deprecation
Sentry.Integrations.Replay = Replay;
Sentry.Integrations.Replay = InternalReplay;

// eslint-disable-next-line deprecation/deprecation
Sentry.Integrations.BrowserTracing = BrowserTracing;
Expand All @@ -24,8 +24,8 @@ export {
browserTracingIntegration,
addTracingExtensions,
// eslint-disable-next-line deprecation/deprecation
Replay,
replayIntegration,
InternalReplay as Replay,
internalReplayIntegration as replayIntegration,
// eslint-disable-next-line deprecation/deprecation
Feedback,
feedbackIntegration,
Expand Down
8 changes: 4 additions & 4 deletions packages/browser/src/index.bundle.tracing.replay.feedback.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Feedback, feedbackIntegration } from '@sentry-internal/feedback';
import { BrowserTracing, Span, addExtensionMethods } from '@sentry-internal/tracing';
import { Replay, replayIntegration } from '@sentry/replay';
import { InternalReplay, internalReplayIntegration } from '@sentry/replay';
import { bundleBrowserTracingIntegration as browserTracingIntegration } from './helpers';

import * as Sentry from './index.bundle.base';
Expand All @@ -9,7 +9,7 @@ import * as Sentry from './index.bundle.base';
// We want replay to be available under Sentry.Replay, to be consistent
// with the NPM package version.
// eslint-disable-next-line deprecation/deprecation
Sentry.Integrations.Replay = Replay;
Sentry.Integrations.Replay = InternalReplay;

// eslint-disable-next-line deprecation/deprecation
Sentry.Integrations.BrowserTracing = BrowserTracing;
Expand All @@ -21,9 +21,9 @@ export {
// eslint-disable-next-line deprecation/deprecation
Feedback,
// eslint-disable-next-line deprecation/deprecation
Replay,
InternalReplay as Replay,
feedbackIntegration,
replayIntegration,
internalReplayIntegration as replayIntegration,
// eslint-disable-next-line deprecation/deprecation
BrowserTracing,
browserTracingIntegration,
Expand Down
8 changes: 4 additions & 4 deletions packages/browser/src/index.bundle.tracing.replay.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Feedback, feedbackIntegration } from '@sentry-internal/integration-shims';
import { BrowserTracing, Span, addExtensionMethods } from '@sentry-internal/tracing';
import { Replay, replayIntegration } from '@sentry/replay';
import { InternalReplay, internalReplayIntegration } from '@sentry/replay';
import { bundleBrowserTracingIntegration as browserTracingIntegration } from './helpers';

import * as Sentry from './index.bundle.base';
Expand All @@ -9,7 +9,7 @@ import * as Sentry from './index.bundle.base';
// We want replay to be available under Sentry.Replay, to be consistent
// with the NPM package version.
// eslint-disable-next-line deprecation/deprecation
Sentry.Integrations.Replay = Replay;
Sentry.Integrations.Replay = InternalReplay;

// eslint-disable-next-line deprecation/deprecation
Sentry.Integrations.BrowserTracing = BrowserTracing;
Expand All @@ -21,8 +21,8 @@ export {
// eslint-disable-next-line deprecation/deprecation
Feedback,
// eslint-disable-next-line deprecation/deprecation
Replay,
replayIntegration,
InternalReplay as Replay,
internalReplayIntegration as replayIntegration,
feedbackIntegration,
// eslint-disable-next-line deprecation/deprecation
BrowserTracing,
Expand Down
24 changes: 12 additions & 12 deletions packages/browser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ export { INTEGRATIONS as Integrations };

export {
// eslint-disable-next-line deprecation/deprecation
Replay,
replayIntegration,
getReplay,
InternalReplay as Replay,
internalReplayIntegration as replayIntegration,
internalGetReplay as getReplay,
} from '@sentry/replay';
export type {
ReplayEventType,
ReplayEventWithTime,
ReplayBreadcrumbFrame,
ReplayBreadcrumbFrameEvent,
ReplayOptionFrameEvent,
ReplayFrame,
ReplayFrameEvent,
ReplaySpanFrame,
ReplaySpanFrameEvent,
InternalReplayEventType as ReplayEventType,
InternalReplayEventWithTime as ReplayEventWithTime,
InternalReplayBreadcrumbFrame as ReplayBreadcrumbFrame,
InternalReplayBreadcrumbFrameEvent as ReplayBreadcrumbFrameEvent,
InternalReplayOptionFrameEvent as ReplayOptionFrameEvent,
InternalReplayFrame as ReplayFrame,
InternalReplayFrameEvent as ReplayFrameEvent,
InternalReplaySpanFrame as ReplaySpanFrame,
InternalReplaySpanFrameEvent as ReplaySpanFrameEvent,
} from '@sentry/replay';

export {
Expand Down
6 changes: 3 additions & 3 deletions packages/replay-canvas/src/canvas.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { CanvasManager } from '@sentry-internal/rrweb';
import { convertIntegrationFnToClass, defineIntegration } from '@sentry/core';
import type { CanvasManagerInterface, CanvasManagerOptions } from '@sentry/replay';
import type { InternalCanvasManagerInterface, InternalCanvasManagerOptions } from '@sentry/replay';
import type { Integration, IntegrationClass, IntegrationFn } from '@sentry/types';

interface ReplayCanvasOptions {
enableManualSnapshot?: boolean;
quality: 'low' | 'medium' | 'high';
}

type GetCanvasManager = (options: CanvasManagerOptions) => CanvasManagerInterface;
type GetCanvasManager = (options: InternalCanvasManagerOptions) => InternalCanvasManagerInterface;
export interface ReplayCanvasIntegrationOptions {
enableManualSnapshot?: boolean;
recordCanvas: true;
Expand Down Expand Up @@ -74,7 +74,7 @@ export const _replayCanvasIntegration = ((options: Partial<ReplayCanvasOptions>
return {
enableManualSnapshot,
recordCanvas: true,
getCanvasManager: (options: CanvasManagerOptions) => {
getCanvasManager: (options: InternalCanvasManagerOptions) => {
const manager = new CanvasManager({
...options,
enableManualSnapshot,
Expand Down
109 changes: 96 additions & 13 deletions packages/replay/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,108 @@
export {
// eslint-disable-next-line deprecation/deprecation
Replay,
replayIntegration,
} from './integration';
// eslint-disable-next-line deprecation/deprecation
import { Replay as InternalReplay, replayIntegration as internalReplayIntegration } from './integration';
import type {
CanvasManagerInterface as InternalCanvasManagerInterface,
CanvasManagerOptions as InternalCanvasManagerOptions,
ReplayBreadcrumbFrame as InternalReplayBreadcrumbFrame,
ReplayBreadcrumbFrameEvent as InternalReplayBreadcrumbFrameEvent,
ReplayConfiguration as InternalReplayConfiguration,
ReplayEventType as InternalReplayEventType,
ReplayEventWithTime as InternalReplayEventWithTime,
ReplayFrame as InternalReplayFrame,
ReplayFrameEvent as InternalReplayFrameEvent,
ReplayOptionFrameEvent as InternalReplayOptionFrameEvent,
ReplaySpanFrame as InternalReplaySpanFrame,
ReplaySpanFrameEvent as InternalReplaySpanFrameEvent,
} from './types';
import { getReplay as internalGetReplay } from './util/getReplay';

/** @deprecated Use the export from `@sentry/replay` or from framework-specific SDKs like `@sentry/react` or `@sentry/vue` */
const getReplay = internalGetReplay;

/** @deprecated Use the export from `@sentry/replay` or from framework-specific SDKs like `@sentry/react` or `@sentry/vue` */
const replayIntegration = internalReplayIntegration;

/** @deprecated Use the export from `@sentry/replay` or from framework-specific SDKs like `@sentry/react` or `@sentry/vue` */
// eslint-disable-next-line deprecation/deprecation
class Replay extends InternalReplay {}

// eslint-disable-next-line deprecation/deprecation
export { replayIntegration, getReplay, Replay, internalReplayIntegration, internalGetReplay, InternalReplay };

/** @deprecated Use the export from `@sentry/replay` or from framework-specific SDKs like `@sentry/react` or `@sentry/vue` */
type ReplayConfiguration = InternalReplayConfiguration;

/** @deprecated Use the export from `@sentry/replay` or from framework-specific SDKs like `@sentry/react` or `@sentry/vue` */
type ReplayEventType = InternalReplayEventType;

/** @deprecated Use the export from `@sentry/replay` or from framework-specific SDKs like `@sentry/react` or `@sentry/vue` */
type ReplayEventWithTime = InternalReplayEventWithTime;

/** @deprecated Use the export from `@sentry/replay` or from framework-specific SDKs like `@sentry/react` or `@sentry/vue` */
type ReplayBreadcrumbFrame = InternalReplayBreadcrumbFrame;

/** @deprecated Use the export from `@sentry/replay` or from framework-specific SDKs like `@sentry/react` or `@sentry/vue` */
type ReplayBreadcrumbFrameEvent = InternalReplayBreadcrumbFrameEvent;

/** @deprecated Use the export from `@sentry/replay` or from framework-specific SDKs like `@sentry/react` or `@sentry/vue` */
type ReplayOptionFrameEvent = InternalReplayOptionFrameEvent;

/** @deprecated Use the export from `@sentry/replay` or from framework-specific SDKs like `@sentry/react` or `@sentry/vue` */
type ReplayFrame = InternalReplayFrame;

/** @deprecated Use the export from `@sentry/replay` or from framework-specific SDKs like `@sentry/react` or `@sentry/vue` */
type ReplayFrameEvent = InternalReplayFrameEvent;

/** @deprecated Use the export from `@sentry/replay` or from framework-specific SDKs like `@sentry/react` or `@sentry/vue` */
type ReplaySpanFrame = InternalReplaySpanFrame;

/** @deprecated Use the export from `@sentry/replay` or from framework-specific SDKs like `@sentry/react` or `@sentry/vue` */
type ReplaySpanFrameEvent = InternalReplaySpanFrameEvent;

/** @deprecated Use the export from `@sentry/replay` or from framework-specific SDKs like `@sentry/react` or `@sentry/vue` */
type CanvasManagerInterface = InternalCanvasManagerInterface;

/** @deprecated Use the export from `@sentry/replay` or from framework-specific SDKs like `@sentry/react` or `@sentry/vue` */
type CanvasManagerOptions = InternalCanvasManagerOptions;

export type {
// eslint-disable-next-line deprecation/deprecation
CanvasManagerInterface,
// eslint-disable-next-line deprecation/deprecation
CanvasManagerOptions,
// eslint-disable-next-line deprecation/deprecation
ReplayBreadcrumbFrame,
// eslint-disable-next-line deprecation/deprecation
ReplayBreadcrumbFrameEvent,
// eslint-disable-next-line deprecation/deprecation
ReplayConfiguration,
// eslint-disable-next-line deprecation/deprecation
ReplayEventType,
// eslint-disable-next-line deprecation/deprecation
ReplayEventWithTime,
ReplayBreadcrumbFrame,
ReplayBreadcrumbFrameEvent,
ReplayOptionFrameEvent,
// eslint-disable-next-line deprecation/deprecation
ReplayFrame,
// eslint-disable-next-line deprecation/deprecation
ReplayFrameEvent,
// eslint-disable-next-line deprecation/deprecation
ReplayOptionFrameEvent,
// eslint-disable-next-line deprecation/deprecation
ReplaySpanFrame,
// eslint-disable-next-line deprecation/deprecation
ReplaySpanFrameEvent,
CanvasManagerInterface,
CanvasManagerOptions,
} from './types';

export { getReplay } from './util/getReplay';
InternalCanvasManagerInterface,
InternalCanvasManagerOptions,
InternalReplayBreadcrumbFrame,
InternalReplayBreadcrumbFrameEvent,
InternalReplayConfiguration,
InternalReplayEventType,
InternalReplayEventWithTime,
InternalReplayFrame,
InternalReplayFrameEvent,
InternalReplayOptionFrameEvent,
InternalReplaySpanFrame,
InternalReplaySpanFrameEvent,
};

// TODO (v8): Remove deprecated types
export * from './types/deprecated';
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as SentryCore from '@sentry/core';
import type { Transport } from '@sentry/types';
import * as SentryUtils from '@sentry/utils';

// eslint-disable-next-line deprecation/deprecation
import type { Replay } from '../../src';
import type { ReplayContainer } from '../../src/replay';
import { clearSession } from '../../src/session/clearSession';
Expand Down
1 change: 1 addition & 0 deletions packages/replay/test/integration/stop.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as SentryUtils from '@sentry/utils';

// eslint-disable-next-line deprecation/deprecation
import type { Replay } from '../../src';
import { WINDOW } from '../../src/constants';
import type { ReplayContainer } from '../../src/replay';
Expand Down
1 change: 1 addition & 0 deletions packages/replay/test/mocks/mockSdk.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Envelope, Transport, TransportMakeRequestResponse } from '@sentry/types';

// eslint-disable-next-line deprecation/deprecation
import type { Replay as ReplayIntegration } from '../../src';
import type { ReplayContainer } from '../../src/replay';
import type { ReplayConfiguration } from '../../src/types';
Expand Down
5 changes: 5 additions & 0 deletions packages/replay/test/utils/getTestEvent.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line deprecation/deprecation
import type { ReplayEventType, ReplayEventWithTime } from '../../src';
import { ReplayEventTypeFullSnapshot, ReplayEventTypeIncrementalSnapshot } from '../../src/types';

Expand All @@ -8,7 +9,9 @@ export function getTestEvent({
}: {
timestamp: number;
data?: any;
// eslint-disable-next-line deprecation/deprecation
type: ReplayEventType;
// eslint-disable-next-line deprecation/deprecation
}): ReplayEventWithTime {
return {
data: data || {},
Expand All @@ -17,10 +20,12 @@ export function getTestEvent({
};
}

// eslint-disable-next-line deprecation/deprecation
export function getTestEventCheckout({ timestamp, data }: { timestamp: number; data?: any }): ReplayEventWithTime {
return getTestEvent({ timestamp, data, type: ReplayEventTypeFullSnapshot });
}

// eslint-disable-next-line deprecation/deprecation
export function getTestEventIncremental({ timestamp, data }: { timestamp: number; data?: any }): ReplayEventWithTime {
return getTestEvent({ timestamp, data, type: ReplayEventTypeIncrementalSnapshot });
}