Skip to content

Commit 8f037ac

Browse files
authored
fix(feedback): Ensure pluggable feedback CDN bundle is correctly built (#13081)
Fixes #13080 This was basically just wrong - we need stuff from `browser` package there, so we can't really build the final CDN bundle from the feedback-internal package. I moved this over and also adjusted tests to actually test this with pluggable CDN integrations as well.
1 parent e9897ab commit 8f037ac

File tree

8 files changed

+28
-27
lines changed

8 files changed

+28
-27
lines changed

dev-packages/browser-integration-tests/suites/feedback/captureFeedback/init.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import * as Sentry from '@sentry/browser';
2+
// Import this separately so that generatePlugin can handle it for CDN scenarios
3+
import { feedbackIntegration } from '@sentry/browser';
24

35
window.Sentry = Sentry;
46

57
Sentry.init({
68
dsn: 'https://[email protected]/1337',
79
integrations: [
8-
Sentry.feedbackIntegration({
10+
feedbackIntegration({
911
tags: { from: 'integration init' },
1012
}),
1113
],

dev-packages/browser-integration-tests/suites/feedback/captureFeedbackAndReplay/hasSampling/init.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import * as Sentry from '@sentry/browser';
2+
// Import this separately so that generatePlugin can handle it for CDN scenarios
3+
import { feedbackIntegration } from '@sentry/browser';
24

35
window.Sentry = Sentry;
46

@@ -12,6 +14,6 @@ Sentry.init({
1214
flushMaxDelay: 200,
1315
minReplayDuration: 0,
1416
}),
15-
Sentry.feedbackIntegration(),
17+
feedbackIntegration(),
1618
],
1719
});
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import * as Sentry from '@sentry/browser';
2+
// Import this separately so that generatePlugin can handle it for CDN scenarios
3+
import { feedbackIntegration } from '@sentry/browser';
24

35
window.Sentry = Sentry;
46

57
Sentry.init({
68
dsn: 'https://[email protected]/1337',
7-
integrations: [Sentry.browserTracingIntegration(), Sentry.feedbackIntegration()],
9+
integrations: [Sentry.browserTracingIntegration(), feedbackIntegration()],
810
tracePropagationTargets: ['http://example.com'],
911
tracesSampleRate: 1,
1012
});

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ const useLoader = bundleKey.startsWith('loader');
2424

2525
// These are imports that, when using CDN bundles, are not included in the main CDN bundle.
2626
// In this case, if we encounter this import, we want to add this CDN bundle file instead
27+
// IMPORTANT NOTE: In order for this to work, you need to import this from browser like this:
28+
// import { httpClientIntegration } from '@sentry/browser';
29+
// You cannot use e.g. Sentry.httpClientIntegration, as this will not be detected
2730
const IMPORTED_INTEGRATION_CDN_BUNDLE_PATHS: Record<string, string> = {
2831
httpClientIntegration: 'httpclient',
2932
captureConsoleIntegration: 'captureconsole',
@@ -34,6 +37,7 @@ const IMPORTED_INTEGRATION_CDN_BUNDLE_PATHS: Record<string, string> = {
3437
extraErrorDataIntegration: 'extraerrordata',
3538
reportingObserverIntegration: 'reportingobserver',
3639
sessionTimingIntegration: 'sessiontiming',
40+
feedbackIntegration: 'feedback',
3741
};
3842

3943
const BUNDLE_PATHS: Record<string, Record<string, string>> = {

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,11 @@ export function shouldSkipTracingTest(): boolean {
246246
}
247247

248248
/**
249-
* We can only test feedback tests in certain bundles/packages:
250-
* - NPM (ESM, CJS)
251-
* - CDN bundles that contain the Replay integration
252-
*
253-
* @returns `true` if we should skip the feedback test
249+
* Today we always run feedback tests, but this can be used to guard this if we ever need to.
254250
*/
255251
export function shouldSkipFeedbackTest(): boolean {
256-
const bundle = process.env.PW_BUNDLE as string | undefined;
257-
return bundle != null && !bundle.includes('feedback') && !bundle.includes('esm') && !bundle.includes('cjs');
252+
// We always run these, in bundles the pluggable integration is automatically added
253+
return false;
258254
}
259255

260256
/**

packages/browser/rollup.bundle.config.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ const builds = [];
44

55
const browserPluggableIntegrationFiles = ['contextlines', 'httpclient', 'reportingobserver', 'browserprofiling'];
66

7-
const corePluggableIntegrationFiles = [
7+
const reexportedPluggableIntegrationFiles = [
88
'captureconsole',
99
'debug',
1010
'dedupe',
1111
'extraerrordata',
1212
'rewriteframes',
1313
'sessiontiming',
14+
'feedback',
1415
];
1516

1617
browserPluggableIntegrationFiles.forEach(integrationName => {
@@ -24,7 +25,7 @@ browserPluggableIntegrationFiles.forEach(integrationName => {
2425
builds.push(...makeBundleConfigVariants(integrationsBundleConfig));
2526
});
2627

27-
corePluggableIntegrationFiles.forEach(integrationName => {
28+
reexportedPluggableIntegrationFiles.forEach(integrationName => {
2829
const integrationsBundleConfig = makeBaseBundleConfig({
2930
bundleType: 'addon',
3031
entrypoints: [`src/integrations-bundle/index.${integrationName}.ts`],
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { feedbackAsyncIntegration } from '../feedbackAsync';
2+
3+
export { getFeedback } from '@sentry-internal/feedback';
4+
5+
export { feedbackAsyncIntegration, feedbackAsyncIntegration as feedbackIntegration };
6+
7+
export { captureFeedback } from '@sentry/core';

packages/feedback/rollup.bundle.config.mjs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
11
import { makeBaseBundleConfig, makeBundleConfigVariants } from '@sentry-internal/rollup-utils';
22

33
export default [
4-
...makeBundleConfigVariants(
5-
makeBaseBundleConfig({
6-
bundleType: 'addon',
7-
entrypoints: ['src/index.ts'],
8-
jsVersion: 'es6',
9-
licenseTitle: '@sentry-internal/feedback',
10-
outputFileBase: () => 'bundles/feedback',
11-
sucrase: {
12-
// The feedback widget is using preact so we need different pragmas and jsx runtimes
13-
jsxPragma: 'h',
14-
jsxFragmentPragma: 'Fragment',
15-
jsxRuntime: 'classic',
16-
},
17-
}),
18-
),
4+
// The core `feedback` bundle is built in the browser package
5+
// Sub-bundles are built here
196
...makeBundleConfigVariants(
207
makeBaseBundleConfig({
218
bundleType: 'addon',

0 commit comments

Comments
 (0)