Skip to content

Commit 55500be

Browse files
committed
feat(feedback): Create async bundles and code to resolve helper integrations
1 parent 1a715fc commit 55500be

11 files changed

+281
-236
lines changed

.size-limit.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,12 @@ module.exports = [
6262
limit: '37 KB',
6363
},
6464
{
65-
name: '@sentry/browser (incl. Feedback, Feedback Modal)',
65+
name: '@sentry/browser (incl. FeedbackAsync)',
6666
path: 'packages/browser/build/npm/esm/index.js',
67-
import: createImport('init', 'feedbackIntegration', 'feedbackModalIntegration'),
67+
import: createImport('init', 'feedbackAsyncIntegration'),
6868
gzip: true,
6969
limit: '37 KB',
7070
},
71-
{
72-
name: '@sentry/browser (incl. Feedback, Feedback Modal, Feedback Screenshot)',
73-
path: 'packages/browser/build/npm/esm/index.js',
74-
import: createImport('init', 'feedbackIntegration', 'feedbackModalIntegration', 'feedbackScreenshotIntegration'),
75-
gzip: true,
76-
limit: '40 KB',
77-
},
7871
{
7972
name: '@sentry/browser (incl. sendFeedback)',
8073
path: 'packages/browser/build/npm/esm/index.js',

packages/browser/src/feedback.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import {
2+
buildFeedbackIntegration,
3+
feedbackModalIntegration,
4+
feedbackScreenshotIntegration,
5+
getFeedback,
6+
sendFeedback,
7+
} from '@sentry-internal/feedback';
8+
import { lazyLoadIntegration } from './utils/lazyLoadIntegration';
9+
10+
// The full feedback widget, with everything pre-loaded
11+
const feedbackIntegration = buildFeedbackIntegration({
12+
lazyLoadIntegration,
13+
getModalIntegration: () => feedbackModalIntegration,
14+
getScreenshotIntegration: () => feedbackScreenshotIntegration,
15+
});
16+
17+
// This is for users who want to have a lazy-loaded feedback widget
18+
const feedbackAsyncIntegration = buildFeedbackIntegration({
19+
lazyLoadIntegration,
20+
getModalIntegration: null,
21+
getScreenshotIntegration: null,
22+
});
23+
24+
export { getFeedback, sendFeedback, feedbackIntegration, feedbackAsyncIntegration };

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ export * from './index.bundle.base';
44

55
export {
66
feedbackIntegration,
7-
feedbackModalIntegration,
8-
feedbackScreenshotIntegration,
97
getFeedback,
10-
} from '@sentry-internal/feedback';
8+
} from './feedback';
119

1210
export { browserTracingIntegrationShim as browserTracingIntegration, replayIntegrationShim as replayIntegration };

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ export {
1717

1818
export {
1919
feedbackIntegration,
20-
feedbackModalIntegration,
21-
feedbackScreenshotIntegration,
2220
getFeedback,
23-
} from '@sentry-internal/feedback';
21+
} from './feedback';
2422

2523
export {
2624
browserTracingIntegration,

packages/browser/src/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@ export type {
3131
export { replayCanvasIntegration } from '@sentry-internal/replay-canvas';
3232

3333
export {
34+
feedbackAsyncIntegration,
3435
feedbackIntegration,
35-
feedbackModalIntegration,
36-
feedbackScreenshotIntegration,
3736
getFeedback,
3837
sendFeedback,
39-
} from '@sentry-internal/feedback';
38+
} from './feedback';
4039

4140
export {
4241
defaultRequestInstrumentationOptions,

packages/feedback/rollup.npm.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { makeBaseNPMConfig, makeNPMConfigVariants } from '@sentry-internal/rollu
22

33
export default makeNPMConfigVariants(
44
makeBaseNPMConfig({
5+
entrypoints: ['src/index.ts'],
56
hasBundles: true,
67
packageSpecificConfig: {
78
output: {

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

Lines changed: 6 additions & 2 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,7 +25,11 @@ describe('getFeedback', () => {
2525
});
2626

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

3034
mockSdk({
3135
sentryOptions: {
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)