Skip to content

Commit 9bad704

Browse files
committed
update tests
1 parent 48df7c2 commit 9bad704

File tree

9 files changed

+22
-21
lines changed

9 files changed

+22
-21
lines changed
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
import { getCanvasManager } from '@sentry-internal/rrweb';
21
import * as Sentry from '@sentry/browser';
32

43
window.Sentry = Sentry;
54
window.Replay = new Sentry.Replay({
65
flushMinDelay: 50,
76
flushMaxDelay: 50,
87
minReplayDuration: 0,
9-
_experiments: {
10-
canvas: {
11-
manager: getCanvasManager,
12-
},
13-
},
148
});
159

1610
Sentry.init({
@@ -20,5 +14,5 @@ Sentry.init({
2014
replaysOnErrorSampleRate: 0.0,
2115
debug: true,
2216

23-
integrations: [window.Replay],
17+
integrations: [window.Replay, new Sentry.ReplayCanvas()],
2418
});

dev-packages/browser-integration-tests/suites/replay/canvas/withCanvasIntegrationFirst/test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { expect } from '@playwright/test';
2+
import type { ReplayCanvasIntegrationOptions } from '@sentry-internal/replay-canvas';
23

34
import { sentryTest } from '../../../../utils/fixtures';
45
import { getReplaySnapshot, shouldSkipReplayTest } from '../../../../utils/replayHelpers';
@@ -21,8 +22,8 @@ sentryTest('sets up canvas when adding ReplayCanvas integration first', async ({
2122
await page.goto(url);
2223

2324
const replay = await getReplaySnapshot(page);
24-
const canvasOptions = replay._options._experiments?.canvas;
25-
expect(canvasOptions.fps).toBe(4);
26-
expect(canvasOptions.quality).toBe(0.6);
25+
const canvasOptions = replay._integrations.canvas as ReplayCanvasIntegrationOptions;
26+
expect(canvasOptions.sampling.canvas).toBe(2);
27+
expect(canvasOptions.dataURLOptions.quality).toBe(0.4);
2728
expect(replay._hasCanvas).toBe(true);
2829
});

dev-packages/browser-integration-tests/suites/replay/canvas/withCanvasIntegrationSecond/test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { expect } from '@playwright/test';
2+
import type { ReplayCanvasIntegrationOptions } from '@sentry-internal/replay-canvas';
23

34
import { sentryTest } from '../../../../utils/fixtures';
45
import { getReplaySnapshot, shouldSkipReplayTest } from '../../../../utils/replayHelpers';
@@ -21,8 +22,8 @@ sentryTest('sets up canvas when adding ReplayCanvas integration after Replay', a
2122
await page.goto(url);
2223

2324
const replay = await getReplaySnapshot(page);
24-
const canvasOptions = replay._options._experiments?.canvas;
25-
expect(canvasOptions.fps).toBe(4);
26-
expect(canvasOptions.quality).toBe(0.6);
25+
const canvasOptions = replay._integrations.canvas as ReplayCanvasIntegrationOptions;
26+
expect(canvasOptions.sampling.canvas).toBe(2);
27+
expect(canvasOptions.dataURLOptions.quality).toBe(0.4);
2728
expect(replay._hasCanvas).toBe(true);
2829
});

dev-packages/browser-integration-tests/suites/replay/canvas/withoutCanvasIntegration/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ sentryTest('does not setup up canvas without ReplayCanvas integration', async ({
2121
await page.goto(url);
2222

2323
const replay = await getReplaySnapshot(page);
24-
const canvasOptions = replay._options._experiments?.canvas;
24+
const canvasOptions = replay._integrations.canvas;
2525
expect(canvasOptions).toBe(undefined);
2626
expect(replay._hasCanvas).toBe(false);
2727
});

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ export function getReplaySnapshot(page: Page): Promise<{
174174
_isEnabled: boolean;
175175
_context: InternalEventContext;
176176
_options: ReplayPluginOptions;
177+
_integrations: Record<string, unknown>;
177178
_hasCanvas: boolean;
178179
session: Session | undefined;
179180
recordingMode: ReplayRecordingMode;
@@ -187,8 +188,9 @@ export function getReplaySnapshot(page: Page): Promise<{
187188
_isEnabled: replay.isEnabled(),
188189
_context: replay.getContext(),
189190
_options: replay.getOptions(),
191+
_integrations: replay.getIntegrations(),
190192
// We cannot pass the function through as this is serialized
191-
_hasCanvas: typeof replay.getOptions()._experiments.canvas?.manager === 'function',
193+
_hasCanvas: typeof replay.getIntegrations().canvas?.getCanvasManager === 'function',
192194
session: replay.session,
193195
recordingMode: replay.recordingMode,
194196
};

packages/replay-canvas/src/canvas.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ interface ReplayCanvasOptions {
66
quality: 'low' | 'medium' | 'high';
77
}
88

9-
interface ReplayCanvasIntegrationOptions {
9+
export interface ReplayCanvasIntegrationOptions {
1010
recordCanvas: true;
1111
getCanvasManager: (options: ConstructorParameters<typeof CanvasManager>[0]) => CanvasManagerInterface;
1212
sampling: {

packages/replay-canvas/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { ReplayCanvas } from './canvas';
2+
export type { ReplayCanvasIntegrationOptions } from './canvas';

packages/replay/src/replay.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ export class ReplayContainer implements ReplayContainerInterface {
228228
return this._options;
229229
}
230230

231+
/** Get the replay integrations. [test only] */
232+
public getIntegrations(): Record<string, Record<string, unknown>> {
233+
return { ...this._integrations };
234+
}
235+
231236
/**
232237
* Initializes the plugin based on sampling configuration. Should not be
233238
* called outside of constructor.

packages/replay/src/types/replay.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type { SKIPPED, THROTTLED } from '../util/throttle';
1414
import type { AllPerformanceEntry, AllPerformanceEntryData, ReplayPerformanceEntry } from './performance';
1515
import type { ReplayFrameEvent } from './replayFrame';
1616
import type { ReplayNetworkRequestOrResponse } from './request';
17-
import type { CanvasManagerInterface, GetCanvasManagerOptions, ReplayEventWithTime, RrwebRecordOptions } from './rrweb';
17+
import type { ReplayEventWithTime, RrwebRecordOptions } from './rrweb';
1818

1919
export type RecordingEvent = ReplayFrameEvent | ReplayEventWithTime;
2020
export type RecordingOptions = RrwebRecordOptions;
@@ -232,10 +232,6 @@ export interface ReplayPluginOptions extends ReplayNetworkOptions {
232232
_experiments: Partial<{
233233
captureExceptions: boolean;
234234
traceInternals: boolean;
235-
canvas: {
236-
quality?: 'low' | 'medium' | 'high';
237-
manager: (options: GetCanvasManagerOptions) => CanvasManagerInterface;
238-
};
239235
}>;
240236
}
241237

@@ -506,6 +502,7 @@ export interface ReplayContainer {
506502
updateUserActivity(): void;
507503
addUpdate(cb: AddUpdateCallback): void;
508504
getOptions(): ReplayPluginOptions;
505+
getIntegrations(): Record<string, Record<string, unknown>>;
509506
getSessionId(): string | undefined;
510507
checkAndHandleExpiredSession(): boolean | void;
511508
setInitialState(): void;

0 commit comments

Comments
 (0)