Skip to content

Commit f71eb69

Browse files
committed
ref: Update export
1 parent 299e18c commit f71eb69

File tree

19 files changed

+129
-151
lines changed

19 files changed

+129
-151
lines changed

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@
9797
"karma-firefox-launcher": "^1.1.0",
9898
"lerna": "6.5.0-alpha.2",
9999
"madge": "4.0.2",
100-
"magic-string": "^0.27.0",
101100
"mocha": "^6.1.4",
102101
"nodemon": "^2.0.16",
103102
"npm-run-all": "^4.1.5",
@@ -108,7 +107,6 @@
108107
"rollup": "^2.67.1",
109108
"rollup-plugin-cleanup": "3.2.1",
110109
"rollup-plugin-license": "^2.6.1",
111-
"rollup-plugin-modify": "^3.0.0",
112110
"rollup-plugin-terser": "^7.0.2",
113111
"rollup-plugin-typescript2": "^0.31.2",
114112
"sinon": "^7.3.2",
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as Sentry from '@sentry/browser';
2+
3+
window.Sentry = Sentry;
4+
5+
Sentry.init({
6+
dsn: 'https://[email protected]/1337',
7+
sampleRate: 1,
8+
integrations: [new Sentry.Integrations.BrowserTracing()],
9+
});
10+
11+
// This should not fail
12+
Sentry.addTracingExtensions();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
</head>
6+
<body>
7+
<button onclick="console.log('Test log')">Click me</button>
8+
</body>
9+
</html>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { expect } from '@playwright/test';
2+
3+
import { sentryTest } from '../../../utils/fixtures';
4+
5+
sentryTest(
6+
'exports a shim Integrations.BrowserTracing integration for non-tracing bundles',
7+
async ({ getLocalTestPath, page }) => {
8+
const bundle = process.env.PW_BUNDLE;
9+
10+
if (!bundle || !bundle.startsWith('bundle_') || bundle.includes('tracing')) {
11+
sentryTest.skip();
12+
}
13+
14+
const consoleMessages: string[] = [];
15+
page.on('console', msg => consoleMessages.push(msg.text()));
16+
17+
let requestCount = 0;
18+
await page.route('https://dsn.ingest.sentry.io/**/*', route => {
19+
requestCount++;
20+
return route.fulfill({
21+
status: 200,
22+
contentType: 'application/json',
23+
body: JSON.stringify({ id: 'test-id' }),
24+
});
25+
});
26+
27+
const url = await getLocalTestPath({ testDir: __dirname });
28+
29+
await page.goto(url);
30+
31+
expect(requestCount).toBe(0);
32+
expect(consoleMessages).toEqual([
33+
'You are using new BrowserTracing() even though this bundle does not include tracing.',
34+
]);
35+
},
36+
);

packages/browser-integration-tests/suites/tracing/browserTracingShim/init.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@ window.Sentry = Sentry;
55
Sentry.init({
66
dsn: 'https://[email protected]/1337',
77
sampleRate: 1,
8-
integrations: [new Sentry.Integrations.BrowserTracing()],
8+
integrations: [new Sentry.BrowserTracing()],
99
});
10+
11+
// This should not fail
12+
Sentry.addTracingExtensions();

packages/browser/rollup.bundle.config.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ const builds = [];
55
['es5', 'es6'].forEach(jsVersion => {
66
const baseBundleConfig = makeBaseBundleConfig({
77
bundleType: 'standalone',
8-
entrypoints: ['src/index.ts'],
8+
entrypoints: ['src/index.bundle.ts'],
99
jsVersion,
1010
licenseTitle: '@sentry/browser',
11-
includeReplay: 'shim',
12-
includeBrowserTracing: 'shim',
1311
outputFileBase: () => `bundles/bundle${jsVersion === 'es5' ? '.es5' : ''}`,
1412
});
1513

@@ -19,12 +17,10 @@ const builds = [];
1917
// Full bundle incl. replay only available for es6
2018
const replayBaseBundleConfig = makeBaseBundleConfig({
2119
bundleType: 'standalone',
22-
entrypoints: ['src/index.ts'],
20+
entrypoints: ['src/index.bundle.replay.ts'],
2321
jsVersion: 'es6',
2422
licenseTitle: '@sentry/browser & @sentry/replay',
2523
outputFileBase: () => 'bundles/bundle.replay',
26-
includeReplay: true,
27-
includeBrowserTracing: 'shim',
2824
});
2925

3026
builds.push(...makeBundleConfigVariants(replayBaseBundleConfig));
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export * from './exports';
2+
3+
import { Integrations as CoreIntegrations } from '@sentry/core';
4+
import type { Integration } from '@sentry/types';
5+
6+
import { WINDOW } from './helpers';
7+
import * as BrowserIntegrations from './integrations';
8+
9+
let windowIntegrations = {};
10+
11+
// This block is needed to add compatibility with the integrations packages when used with a CDN
12+
if (WINDOW.Sentry && WINDOW.Sentry.Integrations) {
13+
windowIntegrations = WINDOW.Sentry.Integrations;
14+
}
15+
16+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
17+
const INTEGRATIONS: Record<string, new (...args: any[]) => Integration> = {
18+
...windowIntegrations,
19+
...CoreIntegrations,
20+
...BrowserIntegrations,
21+
};
22+
23+
export { INTEGRATIONS as Integrations };
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// This is exported so the loader does not fail when switching off Replay/Tracing
2+
import { addTracingExtensions, BrowserTracing } from '@sentry-internal/integration-shims';
3+
import { Replay } from '@sentry/replay';
4+
5+
import * as Sentry from './index.bundle.base';
6+
7+
// TODO (v8): Remove this as it was only needed for backwards compatibility
8+
Sentry.Integrations.Replay = Replay;
9+
10+
Sentry.Integrations.BrowserTracing = BrowserTracing;
11+
12+
export * from './index.bundle.base';
13+
export { BrowserTracing, addTracingExtensions, Replay };
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This is exported so the loader does not fail when switching off Replay/Tracing
2+
import { addTracingExtensions, BrowserTracing, Replay } from '@sentry-internal/integration-shims';
3+
4+
import * as Sentry from './index.bundle.base';
5+
6+
// TODO (v8): Remove this as it was only needed for backwards compatibility
7+
Sentry.Integrations.Replay = Replay;
8+
9+
Sentry.Integrations.BrowserTracing = BrowserTracing;
10+
11+
export * from './index.bundle.base';
12+
export { BrowserTracing, addTracingExtensions, Replay };

packages/browser/src/index.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,9 @@ const INTEGRATIONS = {
2020

2121
export { INTEGRATIONS as Integrations };
2222

23-
// DO NOT DELETE THESE COMMENTS!
24-
// We want to exclude Replay/Offline from CDN bundles, so we remove the block below with our
25-
// makeExcludeBlockPlugin Rollup plugin when generating bundles. Everything between
26-
// ROLLUP_EXCLUDE_*_FROM_BUNDLES_BEGIN and _END__ is removed for bundles.
27-
28-
// __ROLLUP_EXCLUDE_REPLAY_FROM_BUNDLES_BEGIN__
2923
export { Replay } from '@sentry/replay';
30-
// __ROLLUP_EXCLUDE_REPLAY_FROM_BUNDLES_END__
31-
32-
// __ROLLUP_EXCLUDE_BROWSER_TRACING_FROM_BUNDLES_BEGIN__
3324
export { BrowserTracing } from '@sentry-internal/tracing';
3425
export { addTracingExtensions } from '@sentry/core';
35-
// __ROLLUP_EXCLUDE_BROWSER_TRACING_FROM_BUNDLES_END__
36-
37-
// __ROLLUP_EXCLUDE_OFFLINE_FROM_BUNDLES_BEGIN__
3826
export { makeBrowserOfflineTransport } from './transports/offline';
39-
// __ROLLUP_EXCLUDE_OFFLINE_FROM_BUNDLES_END__
40-
41-
// __ROLLUP_EXCLUDE_BROWSER_PROFILING_FROM_BUNDLES_BEGIN__
4227
export { onProfilingStartRouteTransaction } from './profiling/hubextensions';
4328
export { BrowserProfilingIntegration } from './profiling/integration';
44-
// __ROLLUP_EXCLUDE_BROWSER_PROFILING_FROM_BUNDLES_END__

0 commit comments

Comments
 (0)