Skip to content

Commit 9b5710e

Browse files
committed
remove addon bundle, fix full bundle setup
1 parent 2cf1879 commit 9b5710e

File tree

8 files changed

+42
-43
lines changed

8 files changed

+42
-43
lines changed

packages/integration-tests/suites/replay/captureReplay/test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ import type { ReplayEvent } from '@sentry/types';
44

55
import { sentryTest } from '../../../utils/fixtures';
66
import { envelopeRequestParser } from '../../../utils/helpers';
7-
import { waitForReplayRequest } from '../../../utils/replayHelpers';
7+
import { shouldSkipReplayTest, waitForReplayRequest } from '../../../utils/replayHelpers';
88

99
sentryTest('should capture replays', async ({ getLocalTestPath, page }) => {
10-
// Replay bundles are es6 only
11-
if (process.env.PW_BUNDLE && process.env.PW_BUNDLE.startsWith('bundle_es5')) {
10+
if (shouldSkipReplayTest()) {
1211
sentryTest.skip();
1312
}
1413

packages/integration-tests/suites/replay/compression/test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ import { expect } from '@playwright/test';
22

33
import { sentryTest } from '../../../utils/fixtures';
44
import { getExpectedReplayEvent } from '../../../utils/replayEventTemplates';
5-
import { getFullRecordingSnapshots, getReplayEvent, waitForReplayRequest } from '../../../utils/replayHelpers';
5+
import {
6+
getFullRecordingSnapshots,
7+
getReplayEvent,
8+
shouldSkipReplayTest,
9+
waitForReplayRequest,
10+
} from '../../../utils/replayHelpers';
611

712
sentryTest('replay recording should be compressed by default', async ({ getLocalTestPath, page }) => {
8-
// Replay bundles are es6 only
9-
if (process.env.PW_BUNDLE && process.env.PW_BUNDLE.startsWith('bundle_es5')) {
13+
if (shouldSkipReplayTest()) {
1014
sentryTest.skip();
1115
}
1216

packages/integration-tests/suites/replay/customEvents/test.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,19 @@ import {
1010
expectedNavigationPerformanceSpan,
1111
getExpectedReplayEvent,
1212
} from '../../../utils/replayEventTemplates';
13-
import { getCustomRecordingEvents, getReplayEvent, waitForReplayRequest } from '../../../utils/replayHelpers';
13+
import {
14+
getCustomRecordingEvents,
15+
getReplayEvent,
16+
shouldSkipReplayTest,
17+
waitForReplayRequest,
18+
} from '../../../utils/replayHelpers';
1419

1520
sentryTest(
1621
'replay recording should contain default performance spans',
1722
async ({ getLocalTestPath, page, browserName }) => {
18-
// Replay bundles are es6 only and most performance entries are only available in chromium
19-
if ((process.env.PW_BUNDLE && process.env.PW_BUNDLE.startsWith('bundle_es5')) || browserName !== 'chromium') {
23+
// We only test this against the NPM package and replay bundles
24+
// and only on chromium as most performance entries are only available in chromium
25+
if (shouldSkipReplayTest() || browserName !== 'chromium') {
2026
sentryTest.skip();
2127
}
2228

@@ -68,8 +74,7 @@ sentryTest(
6874
sentryTest(
6975
'replay recording should contain a click breadcrumb when a button is clicked',
7076
async ({ getLocalTestPath, page }) => {
71-
// Replay bundles are es6 only
72-
if (process.env.PW_BUNDLE && process.env.PW_BUNDLE.startsWith('bundle_es5')) {
77+
if (shouldSkipReplayTest()) {
7378
sentryTest.skip();
7479
}
7580

packages/integration-tests/suites/replay/errorResponse/test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import { expect } from '@playwright/test';
22

33
import { sentryTest } from '../../../utils/fixtures';
4-
import { getReplaySnapshot, REPLAY_DEFAULT_FLUSH_MAX_DELAY, waitForReplayRequest } from '../../../utils/replayHelpers';
4+
import {
5+
getReplaySnapshot,
6+
REPLAY_DEFAULT_FLUSH_MAX_DELAY,
7+
shouldSkipReplayTest,
8+
waitForReplayRequest,
9+
} from '../../../utils/replayHelpers';
510

611
sentryTest('should stop recording after receiving an error response', async ({ getLocalTestPath, page }) => {
7-
// Currently bundle tests are not supported for replay
8-
if (process.env.PW_BUNDLE && process.env.PW_BUNDLE.startsWith('bundle_es5')) {
12+
if (shouldSkipReplayTest()) {
913
sentryTest.skip();
1014
}
11-
1215
let called = 0;
1316

1417
await page.route('https://dsn.ingest.sentry.io/**/*', route => {

packages/integration-tests/suites/replay/init.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import * as Sentry from '@sentry/browser';
2-
import { Replay } from '@sentry/replay';
32

43
window.Sentry = Sentry;
5-
window.Replay = new Replay({
4+
window.Replay = new Sentry.Replay({
65
flushMinDelay: 200,
76
flushMaxDelay: 200,
87
});

packages/integration-tests/suites/replay/sampling/test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { expect } from '@playwright/test';
22

33
import { sentryTest } from '../../../utils/fixtures';
4-
import { getReplaySnapshot } from '../../../utils/replayHelpers';
4+
import { getReplaySnapshot, shouldSkipReplayTest } from '../../../utils/replayHelpers';
55

66
sentryTest('should not send replays if both sample rates are 0', async ({ getLocalTestPath, page }) => {
7-
// Replay bundles are es6 only
8-
if (process.env.PW_BUNDLE && process.env.PW_BUNDLE.startsWith('bundle_es5')) {
7+
if (shouldSkipReplayTest()) {
98
sentryTest.skip();
109
}
1110

packages/integration-tests/utils/generatePlugin.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ const useCompiledModule = bundleKey === 'esm' || bundleKey === 'cjs';
1515

1616
// Bundles need to be injected into HTML before Sentry initialization.
1717
const useBundle = bundleKey && !useCompiledModule;
18-
// `true` if we use an SDK bundle that supports Replay ootb,
19-
// without the need to add the additional addon replay integration bundle
20-
const useFullReplayBundle = useBundle && bundleKey.includes('replay');
2118

2219
const BUNDLE_PATHS: Record<string, Record<string, string>> = {
2320
browser: {
@@ -48,12 +45,6 @@ const BUNDLE_PATHS: Record<string, Record<string, string>> = {
4845
bundle_es6: 'build/bundles/[INTEGRATION_NAME].js',
4946
bundle_es6_min: 'build/bundles/[INTEGRATION_NAME].min.js',
5047
},
51-
replay: {
52-
cjs: 'build/npm/cjs/index.js',
53-
esm: 'build/npm/esm/index.js',
54-
bundle_es6: 'build/bundles/replay.js',
55-
bundle_es6_min: 'build/bundles/replay.min.js',
56-
},
5748
};
5849

5950
/*
@@ -101,7 +92,6 @@ function generateSentryAlias(): Record<string, string> {
10192
class SentryScenarioGenerationPlugin {
10293
public requiresTracing: boolean = false;
10394
public requiredIntegrations: string[] = [];
104-
public requiresReplay = false;
10595

10696
private _name: string = 'SentryScenarioGenerationPlugin';
10797

@@ -114,7 +104,7 @@ class SentryScenarioGenerationPlugin {
114104
'@sentry/browser': 'Sentry',
115105
'@sentry/tracing': 'Sentry',
116106
'@sentry/integrations': 'Sentry.Integrations',
117-
'@sentry/replay': 'Sentry.Integrations',
107+
'@sentry/replay': 'Sentry',
118108
}
119109
: {};
120110

@@ -129,10 +119,6 @@ class SentryScenarioGenerationPlugin {
129119
this.requiresTracing = true;
130120
} else if (source === '@sentry/integrations') {
131121
this.requiredIntegrations.push(statement.specifiers[0].imported.name.toLowerCase());
132-
} else if (!useFullReplayBundle && source === '@sentry/replay') {
133-
console.log('injecting replay addon bundle');
134-
135-
this.requiresReplay = true;
136122
}
137123
},
138124
);
@@ -160,14 +146,6 @@ class SentryScenarioGenerationPlugin {
160146
data.assetTags.scripts.unshift(integrationObject);
161147
});
162148

163-
if (this.requiresReplay && BUNDLE_PATHS['replay'][bundleKey]) {
164-
const replayObject = createHtmlTagObject('script', {
165-
src: path.resolve(PACKAGES_DIR, 'replay', BUNDLE_PATHS['replay'][bundleKey]),
166-
});
167-
168-
data.assetTags.scripts.unshift(replayObject);
169-
}
170-
171149
data.assetTags.scripts.unshift(bundleObject);
172150
}
173151

packages/integration-tests/utils/replayHelpers.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,15 @@ const replayEnvelopeParser = (request: Request | null): unknown[] => {
177177

178178
return lines;
179179
};
180+
181+
/**
182+
* We can only test replay tests in certain bundles/packages:
183+
* - NPM (ESM, CJS)
184+
* - CDN bundles that contain the Replay integration
185+
*
186+
* @returns `true` if we should skip the replay test
187+
*/
188+
export function shouldSkipReplayTest(): boolean {
189+
const bundle = process.env.PW_BUNDLE as string | undefined;
190+
return bundle != null && !bundle.includes('replay') && !bundle.includes('esm') && !bundle.includes('cjs');
191+
}

0 commit comments

Comments
 (0)