Skip to content

Commit a6e7324

Browse files
authored
feat(feedback): Create async bundles and code to resolve helper integrations (#11621)
1 parent 7eb000c commit a6e7324

24 files changed

+301
-377
lines changed

.size-limit.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,35 +52,28 @@ module.exports = [
5252
path: 'packages/browser/build/npm/esm/index.js',
5353
import: createImport('init', 'browserTracingIntegration', 'replayIntegration', 'feedbackIntegration'),
5454
gzip: true,
55-
limit: '83 KB',
55+
limit: '86 KB',
5656
},
5757
{
5858
name: '@sentry/browser (incl. Feedback)',
5959
path: 'packages/browser/build/npm/esm/index.js',
6060
import: createImport('init', 'feedbackIntegration'),
6161
gzip: true,
62-
limit: '37 KB',
63-
},
64-
{
65-
name: '@sentry/browser (incl. Feedback, Feedback Modal)',
66-
path: 'packages/browser/build/npm/esm/index.js',
67-
import: createImport('init', 'feedbackIntegration', 'feedbackModalIntegration'),
68-
gzip: true,
69-
limit: '37 KB',
62+
limit: '40 KB',
7063
},
7164
{
72-
name: '@sentry/browser (incl. Feedback, Feedback Modal, Feedback Screenshot)',
65+
name: '@sentry/browser (incl. sendFeedback)',
7366
path: 'packages/browser/build/npm/esm/index.js',
74-
import: createImport('init', 'feedbackIntegration', 'feedbackModalIntegration', 'feedbackScreenshotIntegration'),
67+
import: createImport('init', 'sendFeedback'),
7568
gzip: true,
76-
limit: '40 KB',
69+
limit: '28 KB',
7770
},
7871
{
79-
name: '@sentry/browser (incl. sendFeedback)',
72+
name: '@sentry/browser (incl. FeedbackAsync)',
8073
path: 'packages/browser/build/npm/esm/index.js',
81-
import: createImport('init', 'sendFeedback'),
74+
import: createImport('init', 'feedbackAsyncIntegration'),
8275
gzip: true,
83-
limit: '30 KB',
76+
limit: '33 KB',
8477
},
8578
// React SDK (ESM)
8679
{
@@ -167,6 +160,13 @@ module.exports = [
167160
brotli: false,
168161
limit: '220 KB',
169162
},
163+
{
164+
name: 'CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed',
165+
path: createCDNPath('bundle.tracing.replay.feedback.min.js'),
166+
gzip: false,
167+
brotli: false,
168+
limit: '261 KB',
169+
},
170170
// Next.js SDK (ESM)
171171
{
172172
name: '@sentry/nextjs (client)',

packages/browser/src/feedback.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import {
2+
buildFeedbackIntegration,
3+
feedbackModalIntegration,
4+
feedbackScreenshotIntegration,
5+
} from '@sentry-internal/feedback';
6+
import { lazyLoadIntegration } from './utils/lazyLoadIntegration';
7+
8+
// The full feedback widget, with everything pre-loaded
9+
export const feedbackIntegration = buildFeedbackIntegration({
10+
lazyLoadIntegration,
11+
getModalIntegration: () => feedbackModalIntegration,
12+
getScreenshotIntegration: () => feedbackScreenshotIntegration,
13+
});

packages/browser/src/feedbackAsync.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { buildFeedbackIntegration } from '@sentry-internal/feedback';
2+
import { lazyLoadIntegration } from './utils/lazyLoadIntegration';
3+
4+
// This is for users who want to have a lazy-loaded feedback widget
5+
export const feedbackAsyncIntegration = buildFeedbackIntegration({
6+
lazyLoadIntegration,
7+
});

packages/browser/src/index.bundle.feedback.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ import { browserTracingIntegrationShim, replayIntegrationShim } from '@sentry-in
22

33
export * from './index.bundle.base';
44

5-
export {
6-
feedbackIntegration,
7-
feedbackModalIntegration,
8-
feedbackScreenshotIntegration,
9-
getFeedback,
10-
} from '@sentry-internal/feedback';
5+
export { feedbackIntegration } from './feedback';
6+
export { getFeedback } from '@sentry-internal/feedback';
117

128
export { browserTracingIntegrationShim as browserTracingIntegration, replayIntegrationShim as replayIntegration };
Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
1-
import {
2-
browserTracingIntegrationShim,
3-
feedbackIntegrationShim,
4-
feedbackModalIntegrationShim,
5-
feedbackScreenshotIntegrationShim,
6-
} from '@sentry-internal/integration-shims';
1+
import { browserTracingIntegrationShim, feedbackIntegrationShim } from '@sentry-internal/integration-shims';
72

83
export * from './index.bundle.base';
94

105
export { replayIntegration } from '@sentry-internal/replay';
116

12-
export {
13-
browserTracingIntegrationShim as browserTracingIntegration,
14-
feedbackIntegrationShim as feedbackIntegration,
15-
feedbackModalIntegrationShim as feedbackModalIntegration,
16-
feedbackScreenshotIntegrationShim as feedbackScreenshotIntegration,
17-
};
7+
export { browserTracingIntegrationShim as browserTracingIntegration, feedbackIntegrationShim as feedbackIntegration };

packages/browser/src/index.bundle.tracing.replay.feedback.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,8 @@ export {
1515
setMeasurement,
1616
} from '@sentry/core';
1717

18-
export {
19-
feedbackIntegration,
20-
feedbackModalIntegration,
21-
feedbackScreenshotIntegration,
22-
getFeedback,
23-
} from '@sentry-internal/feedback';
18+
export { feedbackIntegration } from './feedback';
19+
export { getFeedback } from '@sentry-internal/feedback';
2420

2521
export {
2622
browserTracingIntegration,

packages/browser/src/index.bundle.tracing.replay.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import {
2-
feedbackIntegrationShim,
3-
feedbackModalIntegrationShim,
4-
feedbackScreenshotIntegrationShim,
5-
} from '@sentry-internal/integration-shims';
1+
import { feedbackIntegrationShim } from '@sentry-internal/integration-shims';
62
import { registerSpanErrorInstrumentation } from '@sentry/core';
73

84
registerSpanErrorInstrumentation();
@@ -26,10 +22,6 @@ export {
2622
startBrowserTracingPageLoadSpan,
2723
} from './tracing/browserTracingIntegration';
2824

29-
export {
30-
feedbackIntegrationShim as feedbackIntegration,
31-
feedbackModalIntegrationShim as feedbackModalIntegration,
32-
feedbackScreenshotIntegrationShim as feedbackScreenshotIntegration,
33-
};
25+
export { feedbackIntegrationShim as feedbackIntegration };
3426

3527
export { replayIntegration } from '@sentry-internal/replay';

packages/browser/src/index.bundle.tracing.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import {
2-
feedbackIntegrationShim,
3-
feedbackModalIntegrationShim,
4-
feedbackScreenshotIntegrationShim,
5-
replayIntegrationShim,
6-
} from '@sentry-internal/integration-shims';
1+
import { feedbackIntegrationShim, replayIntegrationShim } from '@sentry-internal/integration-shims';
72
import { registerSpanErrorInstrumentation } from '@sentry/core';
83

94
registerSpanErrorInstrumentation();
@@ -27,9 +22,4 @@ export {
2722
startBrowserTracingPageLoadSpan,
2823
} from './tracing/browserTracingIntegration';
2924

30-
export {
31-
feedbackIntegrationShim as feedbackIntegration,
32-
feedbackModalIntegrationShim as feedbackModalIntegration,
33-
feedbackScreenshotIntegrationShim as feedbackScreenshotIntegration,
34-
replayIntegrationShim as replayIntegration,
35-
};
25+
export { feedbackIntegrationShim as feedbackIntegration, replayIntegrationShim as replayIntegration };

packages/browser/src/index.bundle.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import {
22
browserTracingIntegrationShim,
33
feedbackIntegrationShim,
4-
feedbackModalIntegrationShim,
5-
feedbackScreenshotIntegrationShim,
64
replayIntegrationShim,
75
} from '@sentry-internal/integration-shims';
86

@@ -11,7 +9,5 @@ export * from './index.bundle.base';
119
export {
1210
browserTracingIntegrationShim as browserTracingIntegration,
1311
feedbackIntegrationShim as feedbackIntegration,
14-
feedbackModalIntegrationShim as feedbackModalIntegration,
15-
feedbackScreenshotIntegrationShim as feedbackScreenshotIntegration,
1612
replayIntegrationShim as replayIntegration,
1713
};

packages/browser/src/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,9 @@ export type {
3030

3131
export { replayCanvasIntegration } from '@sentry-internal/replay-canvas';
3232

33+
export { feedbackIntegration } from './feedback';
34+
export { feedbackAsyncIntegration } from './feedbackAsync';
3335
export {
34-
feedbackIntegration,
35-
feedbackModalIntegration,
36-
feedbackScreenshotIntegration,
3736
getFeedback,
3837
sendFeedback,
3938
} from '@sentry-internal/feedback';
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import { replayIntegrationShim } from '@sentry-internal/integration-shims';
2-
import { feedbackIntegration, feedbackModalIntegration, feedbackScreenshotIntegration } from '@sentry/browser';
1+
import { browserTracingIntegrationShim, replayIntegrationShim } from '@sentry-internal/integration-shims';
2+
import { feedbackIntegration } from '../../src';
33

44
import * as FeedbackBundle from '../../src/index.bundle.feedback';
55

66
describe('index.bundle.feedback', () => {
77
it('has correct exports', () => {
8+
expect(FeedbackBundle.browserTracingIntegration).toBe(browserTracingIntegrationShim);
89
expect(FeedbackBundle.replayIntegration).toBe(replayIntegrationShim);
910
expect(FeedbackBundle.feedbackIntegration).toBe(feedbackIntegration);
10-
expect(FeedbackBundle.feedbackModalIntegration).toBe(feedbackModalIntegration);
11-
expect(FeedbackBundle.feedbackScreenshotIntegration).toBe(feedbackScreenshotIntegration);
1211
});
1312
});
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import {
2-
feedbackIntegrationShim,
3-
feedbackModalIntegrationShim,
4-
feedbackScreenshotIntegrationShim,
5-
} from '@sentry-internal/integration-shims';
1+
import { feedbackIntegrationShim } from '@sentry-internal/integration-shims';
62
import { replayIntegration } from '@sentry/browser';
73

84
import * as ReplayBundle from '../../src/index.bundle.replay';
@@ -11,7 +7,5 @@ describe('index.bundle.replay', () => {
117
it('has correct exports', () => {
128
expect(ReplayBundle.replayIntegration).toBe(replayIntegration);
139
expect(ReplayBundle.feedbackIntegration).toBe(feedbackIntegrationShim);
14-
expect(ReplayBundle.feedbackModalIntegration).toBe(feedbackModalIntegrationShim);
15-
expect(ReplayBundle.feedbackScreenshotIntegration).toBe(feedbackScreenshotIntegrationShim);
1610
});
1711
});
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
import {
2-
feedbackIntegrationShim,
3-
feedbackModalIntegrationShim,
4-
feedbackScreenshotIntegrationShim,
5-
replayIntegrationShim,
6-
} from '@sentry-internal/integration-shims';
1+
import { feedbackIntegrationShim, replayIntegrationShim } from '@sentry-internal/integration-shims';
72

83
import * as Bundle from '../../src/index.bundle';
94

105
describe('index.bundle', () => {
116
it('has correct exports', () => {
127
expect(Bundle.replayIntegration).toBe(replayIntegrationShim);
138
expect(Bundle.feedbackIntegration).toBe(feedbackIntegrationShim);
14-
expect(Bundle.feedbackModalIntegration).toBe(feedbackModalIntegrationShim);
15-
expect(Bundle.feedbackScreenshotIntegration).toBe(feedbackScreenshotIntegrationShim);
169
});
1710
});
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
1-
import {
2-
browserTracingIntegration,
3-
feedbackIntegration,
4-
feedbackModalIntegration,
5-
feedbackScreenshotIntegration,
6-
replayIntegration,
7-
} from '../../src';
1+
import { browserTracingIntegration, feedbackIntegration, replayIntegration } from '../../src';
82
import * as TracingReplayFeedbackBundle from '../../src/index.bundle.tracing.replay.feedback';
93

104
describe('index.bundle.tracing.replay.feedback', () => {
115
it('has correct exports', () => {
126
expect(TracingReplayFeedbackBundle.replayIntegration).toBe(replayIntegration);
137
expect(TracingReplayFeedbackBundle.browserTracingIntegration).toBe(browserTracingIntegration);
148
expect(TracingReplayFeedbackBundle.feedbackIntegration).toBe(feedbackIntegration);
15-
expect(TracingReplayFeedbackBundle.feedbackModalIntegration).toBe(feedbackModalIntegration);
16-
expect(TracingReplayFeedbackBundle.feedbackScreenshotIntegration).toBe(feedbackScreenshotIntegration);
179
});
1810
});
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import {
2-
feedbackIntegrationShim,
3-
feedbackModalIntegrationShim,
4-
feedbackScreenshotIntegrationShim,
5-
} from '@sentry-internal/integration-shims';
1+
import { feedbackIntegrationShim } from '@sentry-internal/integration-shims';
62

73
import { browserTracingIntegration, replayIntegration } from '../../src';
84
import * as TracingReplayBundle from '../../src/index.bundle.tracing.replay';
@@ -14,7 +10,5 @@ describe('index.bundle.tracing.replay', () => {
1410
expect(TracingReplayBundle.browserTracingIntegration).toBe(browserTracingIntegration);
1511

1612
expect(TracingReplayBundle.feedbackIntegration).toBe(feedbackIntegrationShim);
17-
expect(TracingReplayBundle.feedbackModalIntegration).toBe(feedbackModalIntegrationShim);
18-
expect(TracingReplayBundle.feedbackScreenshotIntegration).toBe(feedbackScreenshotIntegrationShim);
1913
});
2014
});
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import {
2-
feedbackIntegrationShim,
3-
feedbackModalIntegrationShim,
4-
feedbackScreenshotIntegrationShim,
5-
replayIntegrationShim,
6-
} from '@sentry-internal/integration-shims';
1+
import { feedbackIntegrationShim, replayIntegrationShim } from '@sentry-internal/integration-shims';
72

83
import { browserTracingIntegration } from '../../src';
94
import * as TracingBundle from '../../src/index.bundle.tracing';
@@ -13,7 +8,5 @@ describe('index.bundle.tracing', () => {
138
expect(TracingBundle.replayIntegration).toBe(replayIntegrationShim);
149
expect(TracingBundle.browserTracingIntegration).toBe(browserTracingIntegration);
1510
expect(TracingBundle.feedbackIntegration).toBe(feedbackIntegrationShim);
16-
expect(TracingBundle.feedbackModalIntegration).toBe(feedbackModalIntegrationShim);
17-
expect(TracingBundle.feedbackScreenshotIntegration).toBe(feedbackScreenshotIntegrationShim);
1811
});
1912
});

packages/feedback/rollup.bundle.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default [
44
...makeBundleConfigVariants(
55
makeBaseBundleConfig({
66
bundleType: 'addon',
7-
entrypoints: ['src/index.bundle.ts'],
7+
entrypoints: ['src/index.ts'],
88
jsVersion: 'es6',
99
licenseTitle: '@sentry-internal/feedback',
1010
outputFileBase: () => 'bundles/feedback',

packages/feedback/src/core/getFeedback.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { getCurrentScope } from '@sentry/core';
22
import { getFeedback } from './getFeedback';
3-
import { feedbackIntegration } from './integration';
3+
import { buildFeedbackIntegration } from './integration';
44
import { mockSdk } from './mockSdk';
55

66
describe('getFeedback', () => {
@@ -25,16 +25,19 @@ describe('getFeedback', () => {
2525
});
2626

2727
it('works with a client with Feedback', () => {
28-
const feedback = feedbackIntegration();
28+
const feedbackIntegration = buildFeedbackIntegration({
29+
lazyLoadIntegration: jest.fn(),
30+
});
2931

32+
const configuredIntegration = feedbackIntegration({});
3033
mockSdk({
3134
sentryOptions: {
32-
integrations: [feedback],
35+
integrations: [configuredIntegration],
3336
},
3437
});
3538

3639
const actual = getFeedback();
3740
expect(actual).toBeDefined();
38-
expect(actual === feedback).toBe(true);
41+
expect(actual === configuredIntegration).toBe(true);
3942
});
4043
});
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { getClient } from '@sentry/core';
2-
import type { feedbackIntegration } from './integration';
2+
import type { buildFeedbackIntegration } from './integration';
3+
4+
type FeedbackIntegration = ReturnType<typeof buildFeedbackIntegration>;
35

46
/**
57
* This is a small utility to get a type-safe instance of the Feedback integration.
68
*/
7-
export function getFeedback(): ReturnType<typeof feedbackIntegration> | undefined {
9+
export function getFeedback(): ReturnType<FeedbackIntegration> | undefined {
810
const client = getClient();
9-
return client && client.getIntegrationByName<ReturnType<typeof feedbackIntegration>>('Feedback');
11+
return client && client.getIntegrationByName('Feedback');
1012
}

0 commit comments

Comments
 (0)