From 55500bea66e7825ac3cf770b57b8ade4747a0fa3 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Mon, 15 Apr 2024 21:22:01 -0700 Subject: [PATCH 01/16] feat(feedback): Create async bundles and code to resolve helper integrations --- .size-limit.js | 11 +- packages/browser/src/feedback.ts | 24 + packages/browser/src/index.bundle.feedback.ts | 4 +- .../index.bundle.tracing.replay.feedback.ts | 4 +- packages/browser/src/index.ts | 5 +- packages/feedback/rollup.npm.config.mjs | 1 + .../feedback/src/core/getFeedback.test.ts | 8 +- packages/feedback/src/core/getFeedback.ts | 8 +- packages/feedback/src/core/integration.ts | 435 +++++++++--------- packages/feedback/src/index.bundle.ts | 9 +- packages/feedback/src/index.ts | 8 +- 11 files changed, 281 insertions(+), 236 deletions(-) create mode 100644 packages/browser/src/feedback.ts diff --git a/.size-limit.js b/.size-limit.js index 6e005fd7c3e7..94510d1f0ddf 100644 --- a/.size-limit.js +++ b/.size-limit.js @@ -62,19 +62,12 @@ module.exports = [ limit: '37 KB', }, { - name: '@sentry/browser (incl. Feedback, Feedback Modal)', + name: '@sentry/browser (incl. FeedbackAsync)', path: 'packages/browser/build/npm/esm/index.js', - import: createImport('init', 'feedbackIntegration', 'feedbackModalIntegration'), + import: createImport('init', 'feedbackAsyncIntegration'), gzip: true, limit: '37 KB', }, - { - name: '@sentry/browser (incl. Feedback, Feedback Modal, Feedback Screenshot)', - path: 'packages/browser/build/npm/esm/index.js', - import: createImport('init', 'feedbackIntegration', 'feedbackModalIntegration', 'feedbackScreenshotIntegration'), - gzip: true, - limit: '40 KB', - }, { name: '@sentry/browser (incl. sendFeedback)', path: 'packages/browser/build/npm/esm/index.js', diff --git a/packages/browser/src/feedback.ts b/packages/browser/src/feedback.ts new file mode 100644 index 000000000000..2eae09ec73e1 --- /dev/null +++ b/packages/browser/src/feedback.ts @@ -0,0 +1,24 @@ +import { + buildFeedbackIntegration, + feedbackModalIntegration, + feedbackScreenshotIntegration, + getFeedback, + sendFeedback, +} from '@sentry-internal/feedback'; +import { lazyLoadIntegration } from './utils/lazyLoadIntegration'; + +// The full feedback widget, with everything pre-loaded +const feedbackIntegration = buildFeedbackIntegration({ + lazyLoadIntegration, + getModalIntegration: () => feedbackModalIntegration, + getScreenshotIntegration: () => feedbackScreenshotIntegration, +}); + +// This is for users who want to have a lazy-loaded feedback widget +const feedbackAsyncIntegration = buildFeedbackIntegration({ + lazyLoadIntegration, + getModalIntegration: null, + getScreenshotIntegration: null, +}); + +export { getFeedback, sendFeedback, feedbackIntegration, feedbackAsyncIntegration }; diff --git a/packages/browser/src/index.bundle.feedback.ts b/packages/browser/src/index.bundle.feedback.ts index 850da7bf1e26..7c937cdcce30 100644 --- a/packages/browser/src/index.bundle.feedback.ts +++ b/packages/browser/src/index.bundle.feedback.ts @@ -4,9 +4,7 @@ export * from './index.bundle.base'; export { feedbackIntegration, - feedbackModalIntegration, - feedbackScreenshotIntegration, getFeedback, -} from '@sentry-internal/feedback'; +} from './feedback'; export { browserTracingIntegrationShim as browserTracingIntegration, replayIntegrationShim as replayIntegration }; diff --git a/packages/browser/src/index.bundle.tracing.replay.feedback.ts b/packages/browser/src/index.bundle.tracing.replay.feedback.ts index 4c9c1e716534..caf98081a159 100644 --- a/packages/browser/src/index.bundle.tracing.replay.feedback.ts +++ b/packages/browser/src/index.bundle.tracing.replay.feedback.ts @@ -17,10 +17,8 @@ export { export { feedbackIntegration, - feedbackModalIntegration, - feedbackScreenshotIntegration, getFeedback, -} from '@sentry-internal/feedback'; +} from './feedback'; export { browserTracingIntegration, diff --git a/packages/browser/src/index.ts b/packages/browser/src/index.ts index 455214f60816..0727ddf7a594 100644 --- a/packages/browser/src/index.ts +++ b/packages/browser/src/index.ts @@ -31,12 +31,11 @@ export type { export { replayCanvasIntegration } from '@sentry-internal/replay-canvas'; export { + feedbackAsyncIntegration, feedbackIntegration, - feedbackModalIntegration, - feedbackScreenshotIntegration, getFeedback, sendFeedback, -} from '@sentry-internal/feedback'; +} from './feedback'; export { defaultRequestInstrumentationOptions, diff --git a/packages/feedback/rollup.npm.config.mjs b/packages/feedback/rollup.npm.config.mjs index cdc5fcf7ad1c..e4d856165ad0 100644 --- a/packages/feedback/rollup.npm.config.mjs +++ b/packages/feedback/rollup.npm.config.mjs @@ -2,6 +2,7 @@ import { makeBaseNPMConfig, makeNPMConfigVariants } from '@sentry-internal/rollu export default makeNPMConfigVariants( makeBaseNPMConfig({ + entrypoints: ['src/index.ts'], hasBundles: true, packageSpecificConfig: { output: { diff --git a/packages/feedback/src/core/getFeedback.test.ts b/packages/feedback/src/core/getFeedback.test.ts index f0cc7b70d0bc..f6ed89d550a1 100644 --- a/packages/feedback/src/core/getFeedback.test.ts +++ b/packages/feedback/src/core/getFeedback.test.ts @@ -1,6 +1,6 @@ import { getCurrentScope } from '@sentry/core'; import { getFeedback } from './getFeedback'; -import { feedbackIntegration } from './integration'; +import { buildFeedbackIntegration } from './integration'; import { mockSdk } from './mockSdk'; describe('getFeedback', () => { @@ -25,7 +25,11 @@ describe('getFeedback', () => { }); it('works with a client with Feedback', () => { - const feedback = feedbackIntegration(); + const feedback = buildFeedbackIntegration({ + lazyLoadIntegration: jest.fn(), + getModalIntegration: jest.fn(), + getScreenshotIntegration: jest.fn(), + }); mockSdk({ sentryOptions: { diff --git a/packages/feedback/src/core/getFeedback.ts b/packages/feedback/src/core/getFeedback.ts index f729d308971c..120c9ccd1d43 100644 --- a/packages/feedback/src/core/getFeedback.ts +++ b/packages/feedback/src/core/getFeedback.ts @@ -1,10 +1,12 @@ import { getClient } from '@sentry/core'; -import type { feedbackIntegration } from './integration'; +import type { buildFeedbackIntegration } from './integration'; + +type FeedbackIntegration = ReturnType; /** * This is a small utility to get a type-safe instance of the Feedback integration. */ -export function getFeedback(): ReturnType | undefined { +export function getFeedback(): ReturnType | undefined { const client = getClient(); - return client && client.getIntegrationByName>('Feedback'); + return client && client.getIntegrationByName('Feedback'); } diff --git a/packages/feedback/src/core/integration.ts b/packages/feedback/src/core/integration.ts index b4a513ab3b9f..a208c3c97cbe 100644 --- a/packages/feedback/src/core/integration.ts +++ b/packages/feedback/src/core/integration.ts @@ -4,6 +4,7 @@ import type { FeedbackInternalOptions, FeedbackModalIntegration, FeedbackScreenshotIntegration, + Integration, IntegrationFn, } from '@sentry/types'; import { isBrowser, logger } from '@sentry/utils'; @@ -23,7 +24,6 @@ import { SUBMIT_BUTTON_LABEL, SUCCESS_MESSAGE_TEXT, } from '../constants'; -import { feedbackModalIntegration } from '../modal/integration'; import { DEBUG_BUILD } from '../util/debug-build'; import { isScreenshotSupported } from '../util/isScreenshotSupported'; import { mergeOptions } from '../util/mergeOptions'; @@ -37,238 +37,257 @@ type Unsubscribe = () => void; /** * Allow users to capture user feedback and send it to Sentry. */ -export const feedbackIntegration = (({ - // FeedbackGeneralConfiguration - id = 'sentry-feedback', - showBranding = true, - autoInject = true, - showEmail = true, - showName = true, - showScreenshot = false, - useSentryUser = { - email: 'email', - name: 'username', - }, - isNameRequired = false, - isEmailRequired = false, - // FeedbackThemeConfiguration - colorScheme = 'system', - themeLight, - themeDark, - - // FeedbackTextConfiguration - buttonLabel = ACTOR_LABEL, - cancelButtonLabel = CANCEL_BUTTON_LABEL, - submitButtonLabel = SUBMIT_BUTTON_LABEL, - formTitle = FORM_TITLE, - emailLabel = EMAIL_LABEL, - emailPlaceholder = EMAIL_PLACEHOLDER, - messageLabel = MESSAGE_LABEL, - messagePlaceholder = MESSAGE_PLACEHOLDER, - nameLabel = NAME_LABEL, - namePlaceholder = NAME_PLACEHOLDER, - successMessageText = SUCCESS_MESSAGE_TEXT, - isRequiredText = IS_REQUIRED_TEXT, - - // FeedbackCallbacks - onFormOpen, - onFormClose, - onSubmitSuccess, - onSubmitError, - onFormSubmitted, -}: OptionalFeedbackConfiguration = {}) => { - const _options = { - id, - autoInject, - showBranding, - isEmailRequired, - isNameRequired, - showEmail, - showName, - showScreenshot, - useSentryUser, - - colorScheme, - themeDark: { - ...DEFAULT_THEME.dark, - ...themeDark, - }, - themeLight: { - ...DEFAULT_THEME.light, - ...themeLight, +interface BuilderOptions { + // The type here should be `keyof typeof LazyLoadableIntegrations`, but that'll cause a cicrular + // dependency with @sentry/core + // eslint-disable-next-line @typescript-eslint/no-explicit-any + lazyLoadIntegration: (name: any) => Promise; + getModalIntegration: null | (() => IntegrationFn); + getScreenshotIntegration: null | (() => IntegrationFn); +} +export const buildFeedbackIntegration = ({ + lazyLoadIntegration, + getModalIntegration, + getScreenshotIntegration, +}: BuilderOptions): IntegrationFn => { + const feedbackIntegration = (({ + // FeedbackGeneralConfiguration + id = 'sentry-feedback', + showBranding = true, + autoInject = true, + showEmail = true, + showName = true, + showScreenshot = true, + useSentryUser = { + email: 'email', + name: 'username', }, + isNameRequired = false, + isEmailRequired = false, - buttonLabel, - cancelButtonLabel, - submitButtonLabel, - formTitle, - emailLabel, - emailPlaceholder, - messageLabel, - messagePlaceholder, - nameLabel, - namePlaceholder, - successMessageText, - isRequiredText, + // FeedbackThemeConfiguration + colorScheme = 'system', + themeLight, + themeDark, - onFormClose, + // FeedbackTextConfiguration + buttonLabel = ACTOR_LABEL, + cancelButtonLabel = CANCEL_BUTTON_LABEL, + submitButtonLabel = SUBMIT_BUTTON_LABEL, + formTitle = FORM_TITLE, + emailLabel = EMAIL_LABEL, + emailPlaceholder = EMAIL_PLACEHOLDER, + messageLabel = MESSAGE_LABEL, + messagePlaceholder = MESSAGE_PLACEHOLDER, + nameLabel = NAME_LABEL, + namePlaceholder = NAME_PLACEHOLDER, + successMessageText = SUCCESS_MESSAGE_TEXT, + isRequiredText = IS_REQUIRED_TEXT, + + // FeedbackCallbacks onFormOpen, - onSubmitError, + onFormClose, onSubmitSuccess, + onSubmitError, onFormSubmitted, - }; + }: OptionalFeedbackConfiguration) => { + const _options = { + id, + autoInject, + showBranding, + isEmailRequired, + isNameRequired, + showEmail, + showName, + showScreenshot, + useSentryUser, - let _shadow: ShadowRoot | null = null; - let _subscriptions: Unsubscribe[] = []; + colorScheme, + themeDark: { + ...DEFAULT_THEME.dark, + ...themeDark, + }, + themeLight: { + ...DEFAULT_THEME.light, + ...themeLight, + }, - /** - * Get the shadow root where we will append css - */ - const _createShadow = (options: FeedbackInternalOptions): ShadowRoot => { - if (!_shadow) { - const host = DOCUMENT.createElement('div'); - host.id = String(options.id); - DOCUMENT.body.appendChild(host); + buttonLabel, + cancelButtonLabel, + submitButtonLabel, + formTitle, + emailLabel, + emailPlaceholder, + messageLabel, + messagePlaceholder, + nameLabel, + namePlaceholder, + successMessageText, + isRequiredText, - _shadow = host.attachShadow({ mode: 'open' }); - _shadow.appendChild(createMainStyles(options.colorScheme, options)); - } - return _shadow as ShadowRoot; - }; + onFormClose, + onFormOpen, + onSubmitError, + onSubmitSuccess, + onFormSubmitted, + }; - const _loadAndRenderDialog = async (options: FeedbackInternalOptions): Promise => { - const client = getClient(); // TODO: getClient() - if (!client) { - throw new Error('Sentry Client is not initialized correctly'); - } - const modalIntegration: FeedbackModalIntegration = feedbackModalIntegration(); - client.addIntegration(modalIntegration); - const screenshotIntegration = client.getIntegrationByName('FeedbackScreenshot'); - const screenshotIsSupported = isScreenshotSupported(); + let _shadow: ShadowRoot | null = null; + let _subscriptions: Unsubscribe[] = []; - // START TEMP: Error messages - if (!modalIntegration && showScreenshot && !screenshotIntegration) { - throw new Error('Async loading of Feedback Modal & Screenshot integrations is not yet implemented'); - } else if (!modalIntegration) { - throw new Error('Async loading of Feedback Modal is not yet implemented'); - } else if (showScreenshot && !screenshotIntegration) { - throw new Error('Async loading of Feedback Screenshot integration is not yet implemented'); - } - // END TEMP + /** + * Get the shadow root where we will append css + */ + const _createShadow = (options: FeedbackInternalOptions): ShadowRoot => { + if (!_shadow) { + const host = DOCUMENT.createElement('div'); + host.id = String(options.id); + DOCUMENT.body.appendChild(host); - if (!modalIntegration) { - // TODO: load modalIntegration - throw new Error('Not implemented yet'); - } + _shadow = host.attachShadow({ mode: 'open' }); + _shadow.appendChild(createMainStyles(options.colorScheme, options)); + } + return _shadow as ShadowRoot; + }; - if (showScreenshot && !screenshotIntegration && screenshotIsSupported) { - // TODO: load screenshotIntegration - throw new Error('Not implemented yet'); - } + const _findIntegration = async ( + integrationName: string, + getter: null | (() => IntegrationFn), + functionMethodName: 'feedbackModalIntegration' | 'feedbackScreenshotIntegration', + ): Promise => { + const client = getClient(); + const existing = client && client.getIntegrationByName(integrationName); + if (existing) { + return existing as I; + } + const integrationFn = (getter && getter()) || (await lazyLoadIntegration(functionMethodName)); + const integration = integrationFn(); + client && client.addIntegration(integration); + return integration as I; + }; - return modalIntegration.createDialog({ - options, - screenshotIntegration: screenshotIsSupported ? screenshotIntegration : undefined, - sendFeedback, - shadow: _createShadow(options), - }); - }; + const _loadAndRenderDialog = async (options: FeedbackInternalOptions): Promise => { + const [modalIntegration, screenshotIntegration] = await Promise.all([ + _findIntegration('FeedbackModal', getModalIntegration, 'feedbackModalIntegration'), + showScreenshot && isScreenshotSupported() + ? _findIntegration( + 'FeedbackScreenshot', + getScreenshotIntegration, + 'feedbackScreenshotIntegration', + ) + : undefined, + ]); + if (!modalIntegration || (showScreenshot && !screenshotIntegration)) { + // trouble! + throw new Error('Missing feedback helper integration!'); + } - const attachTo = (el: Element | string, optionOverrides: OverrideFeedbackConfiguration = {}): Unsubscribe => { - const mergedOptions = mergeOptions(_options, optionOverrides); + return modalIntegration.createDialog({ + options, + screenshotIntegration: showScreenshot ? screenshotIntegration : undefined, + sendFeedback, + shadow: _createShadow(options), + }); + }; - const targetEl = - typeof el === 'string' ? DOCUMENT.querySelector(el) : typeof el.addEventListener === 'function' ? el : null; + const attachTo = (el: Element | string, optionOverrides: OverrideFeedbackConfiguration = {}): Unsubscribe => { + const mergedOptions = mergeOptions(_options, optionOverrides); - if (!targetEl) { - DEBUG_BUILD && logger.error('[Feedback] Unable to attach to target element'); - throw new Error('Unable to attach to target element'); - } + const targetEl = + typeof el === 'string' ? DOCUMENT.querySelector(el) : typeof el.addEventListener === 'function' ? el : null; - let dialog: FeedbackDialog | null = null; - const handleClick = async (): Promise => { - if (!dialog) { - dialog = await _loadAndRenderDialog({ - ...mergedOptions, - onFormClose: () => { - dialog && dialog.close(); - mergedOptions.onFormClose && mergedOptions.onFormClose(); - }, - onFormSubmitted: () => { - dialog && dialog.removeFromDom(); - mergedOptions.onFormSubmitted && mergedOptions.onFormSubmitted(); - }, - }); + if (!targetEl) { + DEBUG_BUILD && logger.error('[Feedback] Unable to attach to target element'); + throw new Error('Unable to attach to target element'); } - dialog.appendToDom(); - dialog.open(); - }; - targetEl.addEventListener('click', handleClick); - const unsubscribe = (): void => { - _subscriptions = _subscriptions.filter(sub => sub !== unsubscribe); - dialog && dialog.removeFromDom(); - dialog = null; - targetEl.removeEventListener('click', handleClick); + + let dialog: FeedbackDialog | null = null; + const handleClick = async (): Promise => { + if (!dialog) { + dialog = await _loadAndRenderDialog({ + ...mergedOptions, + onFormClose: () => { + dialog && dialog.close(); + mergedOptions.onFormClose && mergedOptions.onFormClose(); + }, + onFormSubmitted: () => { + dialog && dialog.removeFromDom(); + mergedOptions.onFormSubmitted && mergedOptions.onFormSubmitted(); + }, + }); + } + dialog.appendToDom(); + dialog.open(); + }; + targetEl.addEventListener('click', handleClick); + const unsubscribe = (): void => { + _subscriptions = _subscriptions.filter(sub => sub !== unsubscribe); + dialog && dialog.removeFromDom(); + dialog = null; + targetEl.removeEventListener('click', handleClick); + }; + _subscriptions.push(unsubscribe); + return unsubscribe; }; - _subscriptions.push(unsubscribe); - return unsubscribe; - }; - const autoInjectActor = (): void => { - const shadow = _createShadow(_options); - const actor = Actor({ buttonLabel: _options.buttonLabel, shadow }); - const mergedOptions = mergeOptions(_options, { - onFormOpen() { - actor.removeFromDom(); - }, - onFormClose() { - actor.appendToDom(); - }, - onFormSubmitted() { - actor.appendToDom(); - }, - }); - attachTo(actor.el, mergedOptions); + const autoInjectActor = (): void => { + const shadow = _createShadow(_options); + const actor = Actor({ buttonLabel: _options.buttonLabel, shadow }); + const mergedOptions = mergeOptions(_options, { + onFormOpen() { + actor.removeFromDom(); + }, + onFormClose() { + actor.appendToDom(); + }, + onFormSubmitted() { + actor.appendToDom(); + }, + }); + attachTo(actor.el, mergedOptions); - actor.appendToDom(); - }; + actor.appendToDom(); + }; - return { - name: 'Feedback', - setupOnce() { - if (!isBrowser() || !_options.autoInject) { - return; - } + return { + name: 'Feedback', + setupOnce() { + if (!isBrowser() || !_options.autoInject) { + return; + } - autoInjectActor(); - }, + autoInjectActor(); + }, - /** - * Adds click listener to the element to open a feedback dialog - * - * The returned function can be used to remove the click listener - */ - attachTo, + /** + * Adds click listener to the element to open a feedback dialog + * + * The returned function can be used to remove the click listener + */ + attachTo, - /** - * Creates a new widget. Accepts partial options to override any options passed to constructor. - */ - async createWidget(optionOverrides: OverrideFeedbackConfiguration = {}): Promise { - return _loadAndRenderDialog(mergeOptions(_options, optionOverrides)); - }, + /** + * Creates a new widget. Accepts partial options to override any options passed to constructor. + */ + async createWidget(optionOverrides: OverrideFeedbackConfiguration = {}): Promise { + return _loadAndRenderDialog(mergeOptions(_options, optionOverrides)); + }, - /** - * Removes the Feedback integration (including host, shadow DOM, and all widgets) - */ - remove(): void { - if (_shadow) { - _shadow.parentElement && _shadow.parentElement.remove(); - _shadow = null; - } - // Remove any lingering subscriptions - _subscriptions.forEach(sub => sub()); - _subscriptions = []; - }, - }; -}) satisfies IntegrationFn; + /** + * Removes the Feedback integration (including host, shadow DOM, and all widgets) + */ + remove(): void { + if (_shadow) { + _shadow.parentElement && _shadow.parentElement.remove(); + _shadow = null; + } + // Remove any lingering subscriptions + _subscriptions.forEach(sub => sub()); + _subscriptions = []; + }, + }; + }) satisfies IntegrationFn; + + return feedbackIntegration; +}; diff --git a/packages/feedback/src/index.bundle.ts b/packages/feedback/src/index.bundle.ts index a384487e935b..3093f5cc374e 100644 --- a/packages/feedback/src/index.bundle.ts +++ b/packages/feedback/src/index.bundle.ts @@ -1,6 +1,9 @@ // This file is used as entry point to generate the integration CDN bundle for the core feedback integration -// For now this includes the modal as well, but not feedback + +// TODO: Move sendFeedback into @sentry/core export { sendFeedback } from './core/sendFeedback'; -export { feedbackIntegration } from './core/integration'; -export { feedbackModalIntegration } from './modal/integration'; + +export { buildFeedbackIntegration } from './core/integration'; export { getFeedback } from './core/getFeedback'; +export { feedbackModalIntegration } from './modal/integration'; +export { feedbackScreenshotIntegration } from './screenshot/integration'; diff --git a/packages/feedback/src/index.ts b/packages/feedback/src/index.ts index 245469a7f3d6..279c82df115a 100644 --- a/packages/feedback/src/index.ts +++ b/packages/feedback/src/index.ts @@ -1,5 +1,9 @@ +// This file is used as entry point to generate the npm package with the core feedback integration + +// TODO: Move sendFeedback into @sentry/core export { sendFeedback } from './core/sendFeedback'; -export { feedbackIntegration } from './core/integration'; -export { feedbackModalIntegration } from './modal/integration'; + +export { buildFeedbackIntegration } from './core/integration'; export { getFeedback } from './core/getFeedback'; +export { feedbackModalIntegration } from './modal/integration'; export { feedbackScreenshotIntegration } from './screenshot/integration'; From 5c5130a087f85060b13c96768547127bcdac8fdd Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Thu, 18 Apr 2024 09:51:56 -0700 Subject: [PATCH 02/16] poke integration exports to see if tree-shaking is affected --- packages/browser/src/feedback.ts | 8 ++------ packages/browser/src/index.ts | 4 +++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/browser/src/feedback.ts b/packages/browser/src/feedback.ts index 2eae09ec73e1..578e87de2bb6 100644 --- a/packages/browser/src/feedback.ts +++ b/packages/browser/src/feedback.ts @@ -2,23 +2,19 @@ import { buildFeedbackIntegration, feedbackModalIntegration, feedbackScreenshotIntegration, - getFeedback, - sendFeedback, } from '@sentry-internal/feedback'; import { lazyLoadIntegration } from './utils/lazyLoadIntegration'; // The full feedback widget, with everything pre-loaded -const feedbackIntegration = buildFeedbackIntegration({ +export const feedbackIntegration = buildFeedbackIntegration({ lazyLoadIntegration, getModalIntegration: () => feedbackModalIntegration, getScreenshotIntegration: () => feedbackScreenshotIntegration, }); // This is for users who want to have a lazy-loaded feedback widget -const feedbackAsyncIntegration = buildFeedbackIntegration({ +export const feedbackAsyncIntegration = buildFeedbackIntegration({ lazyLoadIntegration, getModalIntegration: null, getScreenshotIntegration: null, }); - -export { getFeedback, sendFeedback, feedbackIntegration, feedbackAsyncIntegration }; diff --git a/packages/browser/src/index.ts b/packages/browser/src/index.ts index 0727ddf7a594..a67315126024 100644 --- a/packages/browser/src/index.ts +++ b/packages/browser/src/index.ts @@ -33,9 +33,11 @@ export { replayCanvasIntegration } from '@sentry-internal/replay-canvas'; export { feedbackAsyncIntegration, feedbackIntegration, +} from './feedback'; +export { getFeedback, sendFeedback, -} from './feedback'; +} from '@sentry-internal/feedback'; export { defaultRequestInstrumentationOptions, From 75d246a1b11a899008e56727cfb6506a0510c534 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Fri, 19 Apr 2024 09:58:30 -0700 Subject: [PATCH 03/16] poke for bundle-size results --- packages/browser/src/feedback.ts | 7 ------- packages/browser/src/feedbackAsync.ts | 9 +++++++++ packages/browser/src/index.ts | 6 ++---- 3 files changed, 11 insertions(+), 11 deletions(-) create mode 100644 packages/browser/src/feedbackAsync.ts diff --git a/packages/browser/src/feedback.ts b/packages/browser/src/feedback.ts index 578e87de2bb6..20f3be3f4fbe 100644 --- a/packages/browser/src/feedback.ts +++ b/packages/browser/src/feedback.ts @@ -11,10 +11,3 @@ export const feedbackIntegration = buildFeedbackIntegration({ getModalIntegration: () => feedbackModalIntegration, getScreenshotIntegration: () => feedbackScreenshotIntegration, }); - -// This is for users who want to have a lazy-loaded feedback widget -export const feedbackAsyncIntegration = buildFeedbackIntegration({ - lazyLoadIntegration, - getModalIntegration: null, - getScreenshotIntegration: null, -}); diff --git a/packages/browser/src/feedbackAsync.ts b/packages/browser/src/feedbackAsync.ts new file mode 100644 index 000000000000..4a2e9f664e6a --- /dev/null +++ b/packages/browser/src/feedbackAsync.ts @@ -0,0 +1,9 @@ +import { buildFeedbackIntegration } from '@sentry-internal/feedback'; +import { lazyLoadIntegration } from './utils/lazyLoadIntegration'; + +// This is for users who want to have a lazy-loaded feedback widget +export const feedbackAsyncIntegration = buildFeedbackIntegration({ + lazyLoadIntegration, + getModalIntegration: null, + getScreenshotIntegration: null, +}); diff --git a/packages/browser/src/index.ts b/packages/browser/src/index.ts index a67315126024..d5e905ff568c 100644 --- a/packages/browser/src/index.ts +++ b/packages/browser/src/index.ts @@ -30,10 +30,8 @@ export type { export { replayCanvasIntegration } from '@sentry-internal/replay-canvas'; -export { - feedbackAsyncIntegration, - feedbackIntegration, -} from './feedback'; +export { feedbackIntegration } from './feedback'; +export { feedbackAsyncIntegration } from './feedbackAsync'; export { getFeedback, sendFeedback, From 7ee8631c8bf7c41d7672b2baa54ef6133e052d66 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Fri, 19 Apr 2024 10:18:15 -0700 Subject: [PATCH 04/16] fix imports and adjust size limits --- .size-limit.js | 6 +++--- packages/browser/src/index.bundle.feedback.ts | 6 ++---- .../browser/src/index.bundle.tracing.replay.feedback.ts | 6 ++---- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/.size-limit.js b/.size-limit.js index 94510d1f0ddf..5a34c0925cdb 100644 --- a/.size-limit.js +++ b/.size-limit.js @@ -52,21 +52,21 @@ module.exports = [ path: 'packages/browser/build/npm/esm/index.js', import: createImport('init', 'browserTracingIntegration', 'replayIntegration', 'feedbackIntegration'), gzip: true, - limit: '83 KB', + limit: '86 KB', }, { name: '@sentry/browser (incl. Feedback)', path: 'packages/browser/build/npm/esm/index.js', import: createImport('init', 'feedbackIntegration'), gzip: true, - limit: '37 KB', + limit: '40 KB', }, { name: '@sentry/browser (incl. FeedbackAsync)', path: 'packages/browser/build/npm/esm/index.js', import: createImport('init', 'feedbackAsyncIntegration'), gzip: true, - limit: '37 KB', + limit: '33 KB', }, { name: '@sentry/browser (incl. sendFeedback)', diff --git a/packages/browser/src/index.bundle.feedback.ts b/packages/browser/src/index.bundle.feedback.ts index 7c937cdcce30..eacbd0fb89c4 100644 --- a/packages/browser/src/index.bundle.feedback.ts +++ b/packages/browser/src/index.bundle.feedback.ts @@ -2,9 +2,7 @@ import { browserTracingIntegrationShim, replayIntegrationShim } from '@sentry-in export * from './index.bundle.base'; -export { - feedbackIntegration, - getFeedback, -} from './feedback'; +export { feedbackIntegration } from './feedback'; +export { getFeedback } from '@sentry-internal/feedback'; export { browserTracingIntegrationShim as browserTracingIntegration, replayIntegrationShim as replayIntegration }; diff --git a/packages/browser/src/index.bundle.tracing.replay.feedback.ts b/packages/browser/src/index.bundle.tracing.replay.feedback.ts index caf98081a159..8e31dba14027 100644 --- a/packages/browser/src/index.bundle.tracing.replay.feedback.ts +++ b/packages/browser/src/index.bundle.tracing.replay.feedback.ts @@ -15,10 +15,8 @@ export { setMeasurement, } from '@sentry/core'; -export { - feedbackIntegration, - getFeedback, -} from './feedback'; +export { feedbackIntegration } from './feedback'; +export { getFeedback } from '@sentry-internal/feedback'; export { browserTracingIntegration, From 238cb5cd8bc39dcd3e8b2d205b0b7ec28b8df3a5 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Fri, 19 Apr 2024 10:24:03 -0700 Subject: [PATCH 05/16] cleanup some extra lines --- packages/feedback/rollup.npm.config.mjs | 1 - packages/feedback/src/index.bundle.ts | 2 -- packages/feedback/src/index.ts | 2 -- 3 files changed, 5 deletions(-) diff --git a/packages/feedback/rollup.npm.config.mjs b/packages/feedback/rollup.npm.config.mjs index e4d856165ad0..cdc5fcf7ad1c 100644 --- a/packages/feedback/rollup.npm.config.mjs +++ b/packages/feedback/rollup.npm.config.mjs @@ -2,7 +2,6 @@ import { makeBaseNPMConfig, makeNPMConfigVariants } from '@sentry-internal/rollu export default makeNPMConfigVariants( makeBaseNPMConfig({ - entrypoints: ['src/index.ts'], hasBundles: true, packageSpecificConfig: { output: { diff --git a/packages/feedback/src/index.bundle.ts b/packages/feedback/src/index.bundle.ts index 3093f5cc374e..ff7657c185ab 100644 --- a/packages/feedback/src/index.bundle.ts +++ b/packages/feedback/src/index.bundle.ts @@ -1,8 +1,6 @@ // This file is used as entry point to generate the integration CDN bundle for the core feedback integration -// TODO: Move sendFeedback into @sentry/core export { sendFeedback } from './core/sendFeedback'; - export { buildFeedbackIntegration } from './core/integration'; export { getFeedback } from './core/getFeedback'; export { feedbackModalIntegration } from './modal/integration'; diff --git a/packages/feedback/src/index.ts b/packages/feedback/src/index.ts index 279c82df115a..08986cf09bf6 100644 --- a/packages/feedback/src/index.ts +++ b/packages/feedback/src/index.ts @@ -1,8 +1,6 @@ // This file is used as entry point to generate the npm package with the core feedback integration -// TODO: Move sendFeedback into @sentry/core export { sendFeedback } from './core/sendFeedback'; - export { buildFeedbackIntegration } from './core/integration'; export { getFeedback } from './core/getFeedback'; export { feedbackModalIntegration } from './modal/integration'; From 08297f16400679070315295390a4c62487777236 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Fri, 19 Apr 2024 10:37:10 -0700 Subject: [PATCH 06/16] make injected integration getters optional --- .size-limit.js | 14 +++++++------- packages/browser/src/feedbackAsync.ts | 2 -- packages/feedback/src/core/getFeedback.test.ts | 2 -- packages/feedback/src/core/integration.ts | 9 ++++----- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/.size-limit.js b/.size-limit.js index 5a34c0925cdb..666afdd49c86 100644 --- a/.size-limit.js +++ b/.size-limit.js @@ -68,13 +68,6 @@ module.exports = [ gzip: true, limit: '33 KB', }, - { - name: '@sentry/browser (incl. sendFeedback)', - path: 'packages/browser/build/npm/esm/index.js', - import: createImport('init', 'sendFeedback'), - gzip: true, - limit: '30 KB', - }, // React SDK (ESM) { name: '@sentry/react', @@ -160,6 +153,13 @@ module.exports = [ brotli: false, limit: '220 KB', }, + { + name: 'CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed', + path: createCDNPath('bundle.tracing.replay.feedback.min.js'), + gzip: false, + brotli: false, + limit: '241 KB', + }, // Next.js SDK (ESM) { name: '@sentry/nextjs (client)', diff --git a/packages/browser/src/feedbackAsync.ts b/packages/browser/src/feedbackAsync.ts index 4a2e9f664e6a..a4b518597357 100644 --- a/packages/browser/src/feedbackAsync.ts +++ b/packages/browser/src/feedbackAsync.ts @@ -4,6 +4,4 @@ import { lazyLoadIntegration } from './utils/lazyLoadIntegration'; // This is for users who want to have a lazy-loaded feedback widget export const feedbackAsyncIntegration = buildFeedbackIntegration({ lazyLoadIntegration, - getModalIntegration: null, - getScreenshotIntegration: null, }); diff --git a/packages/feedback/src/core/getFeedback.test.ts b/packages/feedback/src/core/getFeedback.test.ts index f6ed89d550a1..ef60f36557b6 100644 --- a/packages/feedback/src/core/getFeedback.test.ts +++ b/packages/feedback/src/core/getFeedback.test.ts @@ -27,8 +27,6 @@ describe('getFeedback', () => { it('works with a client with Feedback', () => { const feedback = buildFeedbackIntegration({ lazyLoadIntegration: jest.fn(), - getModalIntegration: jest.fn(), - getScreenshotIntegration: jest.fn(), }); mockSdk({ diff --git a/packages/feedback/src/core/integration.ts b/packages/feedback/src/core/integration.ts index a208c3c97cbe..d22f64292941 100644 --- a/packages/feedback/src/core/integration.ts +++ b/packages/feedback/src/core/integration.ts @@ -41,10 +41,9 @@ type Unsubscribe = () => void; interface BuilderOptions { // The type here should be `keyof typeof LazyLoadableIntegrations`, but that'll cause a cicrular // dependency with @sentry/core - // eslint-disable-next-line @typescript-eslint/no-explicit-any - lazyLoadIntegration: (name: any) => Promise; - getModalIntegration: null | (() => IntegrationFn); - getScreenshotIntegration: null | (() => IntegrationFn); + lazyLoadIntegration: (name: 'feedbackModalIntegration' | 'feedbackScreenshotIntegration') => Promise; + getModalIntegration?: null | (() => IntegrationFn); + getScreenshotIntegration?: null | (() => IntegrationFn); } export const buildFeedbackIntegration = ({ lazyLoadIntegration, @@ -153,7 +152,7 @@ export const buildFeedbackIntegration = ({ const _findIntegration = async ( integrationName: string, - getter: null | (() => IntegrationFn), + getter: undefined | null | (() => IntegrationFn), functionMethodName: 'feedbackModalIntegration' | 'feedbackScreenshotIntegration', ): Promise => { const client = getClient(); From d29f87a8bb961f9af21c8ef919b6edf5357b0edf Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Fri, 19 Apr 2024 10:41:08 -0700 Subject: [PATCH 07/16] keep the size check for sendFeedback --- .size-limit.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.size-limit.js b/.size-limit.js index 666afdd49c86..ff89fe2d1a00 100644 --- a/.size-limit.js +++ b/.size-limit.js @@ -54,6 +54,13 @@ module.exports = [ gzip: true, limit: '86 KB', }, + { + name: '@sentry/browser (incl. sendFeedback)', + path: 'packages/browser/build/npm/esm/index.js', + import: createImport('init', 'sendFeedback'), + gzip: true, + limit: '40 KB', + }, { name: '@sentry/browser (incl. Feedback)', path: 'packages/browser/build/npm/esm/index.js', From d4e42dc6002380b98276bd7c7dba675da75118d5 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Fri, 19 Apr 2024 10:42:18 -0700 Subject: [PATCH 08/16] fix size limits --- .size-limit.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.size-limit.js b/.size-limit.js index ff89fe2d1a00..23ad7b0974ed 100644 --- a/.size-limit.js +++ b/.size-limit.js @@ -55,18 +55,18 @@ module.exports = [ limit: '86 KB', }, { - name: '@sentry/browser (incl. sendFeedback)', + name: '@sentry/browser (incl. Feedback)', path: 'packages/browser/build/npm/esm/index.js', - import: createImport('init', 'sendFeedback'), + import: createImport('init', 'feedbackIntegration'), gzip: true, limit: '40 KB', }, { - name: '@sentry/browser (incl. Feedback)', + name: '@sentry/browser (incl. sendFeedback)', path: 'packages/browser/build/npm/esm/index.js', - import: createImport('init', 'feedbackIntegration'), + import: createImport('init', 'sendFeedback'), gzip: true, - limit: '40 KB', + limit: '28 KB', }, { name: '@sentry/browser (incl. FeedbackAsync)', @@ -165,7 +165,7 @@ module.exports = [ path: createCDNPath('bundle.tracing.replay.feedback.min.js'), gzip: false, brotli: false, - limit: '241 KB', + limit: '261 KB', }, // Next.js SDK (ESM) { From f59555fd2eb2c560328ea6f1b496472eaa0e3b97 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Fri, 19 Apr 2024 10:46:31 -0700 Subject: [PATCH 09/16] only need one index file --- packages/feedback/rollup.bundle.config.mjs | 2 +- packages/feedback/src/index.bundle.ts | 7 ------- packages/feedback/src/index.ts | 2 +- 3 files changed, 2 insertions(+), 9 deletions(-) delete mode 100644 packages/feedback/src/index.bundle.ts diff --git a/packages/feedback/rollup.bundle.config.mjs b/packages/feedback/rollup.bundle.config.mjs index 6bdaefed8748..4d5620c4c040 100644 --- a/packages/feedback/rollup.bundle.config.mjs +++ b/packages/feedback/rollup.bundle.config.mjs @@ -4,7 +4,7 @@ export default [ ...makeBundleConfigVariants( makeBaseBundleConfig({ bundleType: 'addon', - entrypoints: ['src/index.bundle.ts'], + entrypoints: ['src/index.ts'], jsVersion: 'es6', licenseTitle: '@sentry-internal/feedback', outputFileBase: () => 'bundles/feedback', diff --git a/packages/feedback/src/index.bundle.ts b/packages/feedback/src/index.bundle.ts deleted file mode 100644 index ff7657c185ab..000000000000 --- a/packages/feedback/src/index.bundle.ts +++ /dev/null @@ -1,7 +0,0 @@ -// This file is used as entry point to generate the integration CDN bundle for the core feedback integration - -export { sendFeedback } from './core/sendFeedback'; -export { buildFeedbackIntegration } from './core/integration'; -export { getFeedback } from './core/getFeedback'; -export { feedbackModalIntegration } from './modal/integration'; -export { feedbackScreenshotIntegration } from './screenshot/integration'; diff --git a/packages/feedback/src/index.ts b/packages/feedback/src/index.ts index 08986cf09bf6..2f95cf86fd1f 100644 --- a/packages/feedback/src/index.ts +++ b/packages/feedback/src/index.ts @@ -1,4 +1,4 @@ -// This file is used as entry point to generate the npm package with the core feedback integration +// This file is used as entry point to generate the npm package and CDN bundles. export { sendFeedback } from './core/sendFeedback'; export { buildFeedbackIntegration } from './core/integration'; From 6e25a73cdb2451f1ee76a6877d79c546ecca98eb Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Fri, 19 Apr 2024 11:58:43 -0700 Subject: [PATCH 10/16] reset showScreenshot default and add todo comments for when async laoding fails --- packages/feedback/src/core/integration.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/feedback/src/core/integration.ts b/packages/feedback/src/core/integration.ts index d22f64292941..1c4c35dc8e8c 100644 --- a/packages/feedback/src/core/integration.ts +++ b/packages/feedback/src/core/integration.ts @@ -57,7 +57,7 @@ export const buildFeedbackIntegration = ({ autoInject = true, showEmail = true, showName = true, - showScreenshot = true, + showScreenshot = false, useSentryUser = { email: 'email', name: 'username', @@ -178,7 +178,8 @@ export const buildFeedbackIntegration = ({ : undefined, ]); if (!modalIntegration || (showScreenshot && !screenshotIntegration)) { - // trouble! + // TODO: Let the end-user retry async loading + // Include more verbose logs so developers can understand the options (like preloading). throw new Error('Missing feedback helper integration!'); } From 6200b0177e2d2aae66579ec5cd5fed3dda0bec6a Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Fri, 19 Apr 2024 12:40:06 -0700 Subject: [PATCH 11/16] fix unit test --- packages/feedback/src/core/getFeedback.test.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/feedback/src/core/getFeedback.test.ts b/packages/feedback/src/core/getFeedback.test.ts index ef60f36557b6..58c5c0f8e88f 100644 --- a/packages/feedback/src/core/getFeedback.test.ts +++ b/packages/feedback/src/core/getFeedback.test.ts @@ -25,18 +25,19 @@ describe('getFeedback', () => { }); it('works with a client with Feedback', () => { - const feedback = buildFeedbackIntegration({ + const feedbackIntegration = buildFeedbackIntegration({ lazyLoadIntegration: jest.fn(), }); + const configuredIntegration = feedbackIntegration({}); mockSdk({ sentryOptions: { - integrations: [feedback], + integrations: [configuredIntegration], }, }); const actual = getFeedback(); expect(actual).toBeDefined(); - expect(actual === feedback).toBe(true); + expect(actual === configuredIntegration).toBe(true); }); }); From c5daa22f99ff82b386d326ac0ab344c911349029 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Fri, 19 Apr 2024 13:10:58 -0700 Subject: [PATCH 12/16] keep the default options obj --- packages/feedback/src/core/integration.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/feedback/src/core/integration.ts b/packages/feedback/src/core/integration.ts index 1c4c35dc8e8c..34f88886ece7 100644 --- a/packages/feedback/src/core/integration.ts +++ b/packages/feedback/src/core/integration.ts @@ -90,7 +90,7 @@ export const buildFeedbackIntegration = ({ onSubmitSuccess, onSubmitError, onFormSubmitted, - }: OptionalFeedbackConfiguration) => { + }: OptionalFeedbackConfiguration = {}) => { const _options = { id, autoInject, From b8c60ec009c0e1cc17321ba36ee3f84babfb2051 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Fri, 19 Apr 2024 13:41:00 -0700 Subject: [PATCH 13/16] cleanup shim exports --- packages/browser/src/index.bundle.replay.ts | 14 +------ .../src/index.bundle.tracing.replay.ts | 12 +----- packages/browser/src/index.bundle.tracing.ts | 14 +------ packages/browser/src/index.bundle.ts | 4 -- .../test/unit/index.bundle.replay.test.ts | 8 +--- .../browser/test/unit/index.bundle.test.ts | 9 +---- .../unit/index.bundle.tracing.replay.test.ts | 8 +--- .../test/unit/index.bundle.tracing.test.ts | 9 +---- packages/integration-shims/src/Feedback.ts | 38 +------------------ packages/integration-shims/src/index.ts | 6 +-- 10 files changed, 12 insertions(+), 110 deletions(-) diff --git a/packages/browser/src/index.bundle.replay.ts b/packages/browser/src/index.bundle.replay.ts index 3a26a2db77ac..c2d267a5227d 100644 --- a/packages/browser/src/index.bundle.replay.ts +++ b/packages/browser/src/index.bundle.replay.ts @@ -1,17 +1,7 @@ -import { - browserTracingIntegrationShim, - feedbackIntegrationShim, - feedbackModalIntegrationShim, - feedbackScreenshotIntegrationShim, -} from '@sentry-internal/integration-shims'; +import { browserTracingIntegrationShim, feedbackIntegrationShim } from '@sentry-internal/integration-shims'; export * from './index.bundle.base'; export { replayIntegration } from '@sentry-internal/replay'; -export { - browserTracingIntegrationShim as browserTracingIntegration, - feedbackIntegrationShim as feedbackIntegration, - feedbackModalIntegrationShim as feedbackModalIntegration, - feedbackScreenshotIntegrationShim as feedbackScreenshotIntegration, -}; +export { browserTracingIntegrationShim as browserTracingIntegration, feedbackIntegrationShim as feedbackIntegration }; diff --git a/packages/browser/src/index.bundle.tracing.replay.ts b/packages/browser/src/index.bundle.tracing.replay.ts index 1b986f9e794a..f103fa297ace 100644 --- a/packages/browser/src/index.bundle.tracing.replay.ts +++ b/packages/browser/src/index.bundle.tracing.replay.ts @@ -1,8 +1,4 @@ -import { - feedbackIntegrationShim, - feedbackModalIntegrationShim, - feedbackScreenshotIntegrationShim, -} from '@sentry-internal/integration-shims'; +import { feedbackIntegrationShim } from '@sentry-internal/integration-shims'; import { registerSpanErrorInstrumentation } from '@sentry/core'; registerSpanErrorInstrumentation(); @@ -26,10 +22,6 @@ export { startBrowserTracingPageLoadSpan, } from './tracing/browserTracingIntegration'; -export { - feedbackIntegrationShim as feedbackIntegration, - feedbackModalIntegrationShim as feedbackModalIntegration, - feedbackScreenshotIntegrationShim as feedbackScreenshotIntegration, -}; +export { feedbackIntegrationShim as feedbackIntegration }; export { replayIntegration } from '@sentry-internal/replay'; diff --git a/packages/browser/src/index.bundle.tracing.ts b/packages/browser/src/index.bundle.tracing.ts index f956bc4db1f6..9af45dfa8572 100644 --- a/packages/browser/src/index.bundle.tracing.ts +++ b/packages/browser/src/index.bundle.tracing.ts @@ -1,9 +1,4 @@ -import { - feedbackIntegrationShim, - feedbackModalIntegrationShim, - feedbackScreenshotIntegrationShim, - replayIntegrationShim, -} from '@sentry-internal/integration-shims'; +import { feedbackIntegrationShim, replayIntegrationShim } from '@sentry-internal/integration-shims'; import { registerSpanErrorInstrumentation } from '@sentry/core'; registerSpanErrorInstrumentation(); @@ -27,9 +22,4 @@ export { startBrowserTracingPageLoadSpan, } from './tracing/browserTracingIntegration'; -export { - feedbackIntegrationShim as feedbackIntegration, - feedbackModalIntegrationShim as feedbackModalIntegration, - feedbackScreenshotIntegrationShim as feedbackScreenshotIntegration, - replayIntegrationShim as replayIntegration, -}; +export { feedbackIntegrationShim as feedbackIntegration, replayIntegrationShim as replayIntegration }; diff --git a/packages/browser/src/index.bundle.ts b/packages/browser/src/index.bundle.ts index 9433e3605c3b..f24e98b4f6db 100644 --- a/packages/browser/src/index.bundle.ts +++ b/packages/browser/src/index.bundle.ts @@ -1,8 +1,6 @@ import { browserTracingIntegrationShim, feedbackIntegrationShim, - feedbackModalIntegrationShim, - feedbackScreenshotIntegrationShim, replayIntegrationShim, } from '@sentry-internal/integration-shims'; @@ -11,7 +9,5 @@ export * from './index.bundle.base'; export { browserTracingIntegrationShim as browserTracingIntegration, feedbackIntegrationShim as feedbackIntegration, - feedbackModalIntegrationShim as feedbackModalIntegration, - feedbackScreenshotIntegrationShim as feedbackScreenshotIntegration, replayIntegrationShim as replayIntegration, }; diff --git a/packages/browser/test/unit/index.bundle.replay.test.ts b/packages/browser/test/unit/index.bundle.replay.test.ts index 4e3d4e344734..3fec5d2bb6ab 100644 --- a/packages/browser/test/unit/index.bundle.replay.test.ts +++ b/packages/browser/test/unit/index.bundle.replay.test.ts @@ -1,8 +1,4 @@ -import { - feedbackIntegrationShim, - feedbackModalIntegrationShim, - feedbackScreenshotIntegrationShim, -} from '@sentry-internal/integration-shims'; +import { feedbackIntegrationShim } from '@sentry-internal/integration-shims'; import { replayIntegration } from '@sentry/browser'; import * as ReplayBundle from '../../src/index.bundle.replay'; @@ -11,7 +7,5 @@ describe('index.bundle.replay', () => { it('has correct exports', () => { expect(ReplayBundle.replayIntegration).toBe(replayIntegration); expect(ReplayBundle.feedbackIntegration).toBe(feedbackIntegrationShim); - expect(ReplayBundle.feedbackModalIntegration).toBe(feedbackModalIntegrationShim); - expect(ReplayBundle.feedbackScreenshotIntegration).toBe(feedbackScreenshotIntegrationShim); }); }); diff --git a/packages/browser/test/unit/index.bundle.test.ts b/packages/browser/test/unit/index.bundle.test.ts index f02e2528f802..1d459ddfd731 100644 --- a/packages/browser/test/unit/index.bundle.test.ts +++ b/packages/browser/test/unit/index.bundle.test.ts @@ -1,9 +1,4 @@ -import { - feedbackIntegrationShim, - feedbackModalIntegrationShim, - feedbackScreenshotIntegrationShim, - replayIntegrationShim, -} from '@sentry-internal/integration-shims'; +import { feedbackIntegrationShim, replayIntegrationShim } from '@sentry-internal/integration-shims'; import * as Bundle from '../../src/index.bundle'; @@ -11,7 +6,5 @@ describe('index.bundle', () => { it('has correct exports', () => { expect(Bundle.replayIntegration).toBe(replayIntegrationShim); expect(Bundle.feedbackIntegration).toBe(feedbackIntegrationShim); - expect(Bundle.feedbackModalIntegration).toBe(feedbackModalIntegrationShim); - expect(Bundle.feedbackScreenshotIntegration).toBe(feedbackScreenshotIntegrationShim); }); }); diff --git a/packages/browser/test/unit/index.bundle.tracing.replay.test.ts b/packages/browser/test/unit/index.bundle.tracing.replay.test.ts index f0228e575e68..5f5f1e649951 100644 --- a/packages/browser/test/unit/index.bundle.tracing.replay.test.ts +++ b/packages/browser/test/unit/index.bundle.tracing.replay.test.ts @@ -1,8 +1,4 @@ -import { - feedbackIntegrationShim, - feedbackModalIntegrationShim, - feedbackScreenshotIntegrationShim, -} from '@sentry-internal/integration-shims'; +import { feedbackIntegrationShim } from '@sentry-internal/integration-shims'; import { browserTracingIntegration, replayIntegration } from '../../src'; import * as TracingReplayBundle from '../../src/index.bundle.tracing.replay'; @@ -14,7 +10,5 @@ describe('index.bundle.tracing.replay', () => { expect(TracingReplayBundle.browserTracingIntegration).toBe(browserTracingIntegration); expect(TracingReplayBundle.feedbackIntegration).toBe(feedbackIntegrationShim); - expect(TracingReplayBundle.feedbackModalIntegration).toBe(feedbackModalIntegrationShim); - expect(TracingReplayBundle.feedbackScreenshotIntegration).toBe(feedbackScreenshotIntegrationShim); }); }); diff --git a/packages/browser/test/unit/index.bundle.tracing.test.ts b/packages/browser/test/unit/index.bundle.tracing.test.ts index 67a530b0e376..065654e054b9 100644 --- a/packages/browser/test/unit/index.bundle.tracing.test.ts +++ b/packages/browser/test/unit/index.bundle.tracing.test.ts @@ -1,9 +1,4 @@ -import { - feedbackIntegrationShim, - feedbackModalIntegrationShim, - feedbackScreenshotIntegrationShim, - replayIntegrationShim, -} from '@sentry-internal/integration-shims'; +import { feedbackIntegrationShim, replayIntegrationShim } from '@sentry-internal/integration-shims'; import { browserTracingIntegration } from '../../src'; import * as TracingBundle from '../../src/index.bundle.tracing'; @@ -13,7 +8,5 @@ describe('index.bundle.tracing', () => { expect(TracingBundle.replayIntegration).toBe(replayIntegrationShim); expect(TracingBundle.browserTracingIntegration).toBe(browserTracingIntegration); expect(TracingBundle.feedbackIntegration).toBe(feedbackIntegrationShim); - expect(TracingBundle.feedbackModalIntegration).toBe(feedbackModalIntegrationShim); - expect(TracingBundle.feedbackScreenshotIntegration).toBe(feedbackScreenshotIntegrationShim); }); }); diff --git a/packages/integration-shims/src/Feedback.ts b/packages/integration-shims/src/Feedback.ts index b0bb3f564779..189dc074cd1e 100644 --- a/packages/integration-shims/src/Feedback.ts +++ b/packages/integration-shims/src/Feedback.ts @@ -2,23 +2,11 @@ import type { Integration } from '@sentry/types'; import { consoleSandbox } from '@sentry/utils'; import { FAKE_FUNCTION } from './common'; -const FEEDBACK_INTEGRATION_METHODS = [ - 'openDialog', - 'closeDialog', - 'attachTo', - 'createWidget', - 'removeWidget', - 'getWidget', - 'remove', -] as const; +const FEEDBACK_INTEGRATION_METHODS = ['attachTo', 'createWidget', 'remove'] as const; type FeedbackSpecificMethods = Record<(typeof FEEDBACK_INTEGRATION_METHODS)[number], () => void>; -type FeedbackModalSpecificMethods = { createDialog: () => void }; -type FeedbackScreenshotSpecificMethods = { createInput: () => void }; interface FeedbackIntegration extends Integration, FeedbackSpecificMethods {} -interface FeedbackModalIntegration extends Integration, FeedbackModalSpecificMethods {} -interface FeedbackScreenshotIntegration extends Integration, FeedbackScreenshotSpecificMethods {} /** * This is a shim for the Feedback integration. @@ -39,27 +27,3 @@ export function feedbackIntegrationShim(_options: unknown): FeedbackIntegration }, {} as FeedbackSpecificMethods) as FeedbackSpecificMethods), }; } - -/** - * This is a shim for the FeedbackModal integration. - * It is needed in order for the CDN bundles to continue working when users add/remove feedback - * from it, without changing their config. This is necessary for the loader mechanism. - */ -export function feedbackModalIntegrationShim(): FeedbackModalIntegration { - return { - name: 'FeedbackModal', - createDialog: FAKE_FUNCTION, - }; -} - -/** - * This is a shim for the FeedbackScreenshot integration. - * It is needed in order for the CDN bundles to continue working when users add/remove feedback - * from it, without changing their config. This is necessary for the loader mechanism. - */ -export function feedbackScreenshotIntegrationShim(): FeedbackScreenshotIntegration { - return { - name: 'FeedbackScreenshot', - createInput: FAKE_FUNCTION, - }; -} diff --git a/packages/integration-shims/src/index.ts b/packages/integration-shims/src/index.ts index 2d1186017d4e..510b26ddbb76 100644 --- a/packages/integration-shims/src/index.ts +++ b/packages/integration-shims/src/index.ts @@ -1,7 +1,3 @@ -export { - feedbackIntegrationShim, - feedbackModalIntegrationShim, - feedbackScreenshotIntegrationShim, -} from './Feedback'; +export { feedbackIntegrationShim } from './Feedback'; export { replayIntegrationShim } from './Replay'; export { browserTracingIntegrationShim } from './BrowserTracing'; From 0fbf66405efe14474554c724bbca05a3be1d6dc3 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Fri, 19 Apr 2024 13:56:33 -0700 Subject: [PATCH 14/16] only exporting the "built" integration --- packages/browser/test/unit/index.bundle.feedback.test.ts | 4 +--- .../test/unit/index.bundle.tracing.replay.feedback.test.ts | 4 ---- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/packages/browser/test/unit/index.bundle.feedback.test.ts b/packages/browser/test/unit/index.bundle.feedback.test.ts index c403144d4306..9ee0e8f87786 100644 --- a/packages/browser/test/unit/index.bundle.feedback.test.ts +++ b/packages/browser/test/unit/index.bundle.feedback.test.ts @@ -1,5 +1,5 @@ import { replayIntegrationShim } from '@sentry-internal/integration-shims'; -import { feedbackIntegration, feedbackModalIntegration, feedbackScreenshotIntegration } from '@sentry/browser'; +import { feedbackIntegration } from '@sentry/browser'; import * as FeedbackBundle from '../../src/index.bundle.feedback'; @@ -7,7 +7,5 @@ describe('index.bundle.feedback', () => { it('has correct exports', () => { expect(FeedbackBundle.replayIntegration).toBe(replayIntegrationShim); expect(FeedbackBundle.feedbackIntegration).toBe(feedbackIntegration); - expect(FeedbackBundle.feedbackModalIntegration).toBe(feedbackModalIntegration); - expect(FeedbackBundle.feedbackScreenshotIntegration).toBe(feedbackScreenshotIntegration); }); }); diff --git a/packages/browser/test/unit/index.bundle.tracing.replay.feedback.test.ts b/packages/browser/test/unit/index.bundle.tracing.replay.feedback.test.ts index 847f610ca702..ebec9794d3de 100644 --- a/packages/browser/test/unit/index.bundle.tracing.replay.feedback.test.ts +++ b/packages/browser/test/unit/index.bundle.tracing.replay.feedback.test.ts @@ -1,8 +1,6 @@ import { browserTracingIntegration, feedbackIntegration, - feedbackModalIntegration, - feedbackScreenshotIntegration, replayIntegration, } from '../../src'; import * as TracingReplayFeedbackBundle from '../../src/index.bundle.tracing.replay.feedback'; @@ -12,7 +10,5 @@ describe('index.bundle.tracing.replay.feedback', () => { expect(TracingReplayFeedbackBundle.replayIntegration).toBe(replayIntegration); expect(TracingReplayFeedbackBundle.browserTracingIntegration).toBe(browserTracingIntegration); expect(TracingReplayFeedbackBundle.feedbackIntegration).toBe(feedbackIntegration); - expect(TracingReplayFeedbackBundle.feedbackModalIntegration).toBe(feedbackModalIntegration); - expect(TracingReplayFeedbackBundle.feedbackScreenshotIntegration).toBe(feedbackScreenshotIntegration); }); }); From 4997f25d4e4959b2fa4cb9b4c63fb85b4d76126b Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Fri, 19 Apr 2024 14:03:36 -0700 Subject: [PATCH 15/16] formatting --- .../test/unit/index.bundle.tracing.replay.feedback.test.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/browser/test/unit/index.bundle.tracing.replay.feedback.test.ts b/packages/browser/test/unit/index.bundle.tracing.replay.feedback.test.ts index ebec9794d3de..72418b639241 100644 --- a/packages/browser/test/unit/index.bundle.tracing.replay.feedback.test.ts +++ b/packages/browser/test/unit/index.bundle.tracing.replay.feedback.test.ts @@ -1,8 +1,4 @@ -import { - browserTracingIntegration, - feedbackIntegration, - replayIntegration, -} from '../../src'; +import { browserTracingIntegration, feedbackIntegration, replayIntegration } from '../../src'; import * as TracingReplayFeedbackBundle from '../../src/index.bundle.tracing.replay.feedback'; describe('index.bundle.tracing.replay.feedback', () => { From 780a9366bc3c0faa35aa615d2382912d7d7c9f62 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Fri, 19 Apr 2024 15:35:24 -0700 Subject: [PATCH 16/16] fix import path for tests --- packages/browser/test/unit/index.bundle.feedback.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/browser/test/unit/index.bundle.feedback.test.ts b/packages/browser/test/unit/index.bundle.feedback.test.ts index 9ee0e8f87786..bd231a95fe05 100644 --- a/packages/browser/test/unit/index.bundle.feedback.test.ts +++ b/packages/browser/test/unit/index.bundle.feedback.test.ts @@ -1,10 +1,11 @@ -import { replayIntegrationShim } from '@sentry-internal/integration-shims'; -import { feedbackIntegration } from '@sentry/browser'; +import { browserTracingIntegrationShim, replayIntegrationShim } from '@sentry-internal/integration-shims'; +import { feedbackIntegration } from '../../src'; import * as FeedbackBundle from '../../src/index.bundle.feedback'; describe('index.bundle.feedback', () => { it('has correct exports', () => { + expect(FeedbackBundle.browserTracingIntegration).toBe(browserTracingIntegrationShim); expect(FeedbackBundle.replayIntegration).toBe(replayIntegrationShim); expect(FeedbackBundle.feedbackIntegration).toBe(feedbackIntegration); });