From bc57872955e3c5cbd176ac22ba3a0bd2d8d7c4d6 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Thu, 23 May 2024 13:12:19 -0700 Subject: [PATCH 01/10] move OptionalFeedbackConfiguration & OverrideFeedbackConfiguration into @sentry/types --- packages/feedback/src/core/integration.ts | 3 ++- packages/feedback/src/core/types.ts | 19 ------------------- packages/feedback/src/util/mergeOptions.ts | 3 +-- packages/types/src/feedback/index.ts | 18 ++++++++++++++++++ packages/types/src/index.ts | 4 +++- 5 files changed, 24 insertions(+), 23 deletions(-) delete mode 100644 packages/feedback/src/core/types.ts diff --git a/packages/feedback/src/core/integration.ts b/packages/feedback/src/core/integration.ts index 203b98e0823a..0af799ab78ec 100644 --- a/packages/feedback/src/core/integration.ts +++ b/packages/feedback/src/core/integration.ts @@ -6,6 +6,8 @@ import type { FeedbackScreenshotIntegration, Integration, IntegrationFn, + OptionalFeedbackConfiguration, + OverrideFeedbackConfiguration, } from '@sentry/types'; import { isBrowser, logger } from '@sentry/utils'; import { @@ -33,7 +35,6 @@ import type { ActorComponent } from './components/Actor'; import { Actor } from './components/Actor'; import { createMainStyles } from './createMainStyles'; import { sendFeedback } from './sendFeedback'; -import type { OptionalFeedbackConfiguration, OverrideFeedbackConfiguration } from './types'; type Unsubscribe = () => void; diff --git a/packages/feedback/src/core/types.ts b/packages/feedback/src/core/types.ts deleted file mode 100644 index a85987301702..000000000000 --- a/packages/feedback/src/core/types.ts +++ /dev/null @@ -1,19 +0,0 @@ -import type { FeedbackInternalOptions } from '@sentry/types'; - -/** - * Partial configuration that overrides default configuration values - * - * This is the config that gets passed into the integration constructor - */ -export interface OptionalFeedbackConfiguration - extends Omit, 'themeLight' | 'themeDark'> { - themeLight?: Partial; - themeDark?: Partial; -} - -/** - * Partial configuration that overrides default configuration values - * - * This is the config that gets passed into the integration constructor - */ -export type OverrideFeedbackConfiguration = Omit, 'themeLight' | 'themeDark'>; diff --git a/packages/feedback/src/util/mergeOptions.ts b/packages/feedback/src/util/mergeOptions.ts index 8e7961fc9a21..692f32e5062c 100644 --- a/packages/feedback/src/util/mergeOptions.ts +++ b/packages/feedback/src/util/mergeOptions.ts @@ -1,5 +1,4 @@ -import type { FeedbackFormData, FeedbackInternalOptions } from '@sentry/types'; -import type { OptionalFeedbackConfiguration } from '../core/types'; +import type { FeedbackFormData, FeedbackInternalOptions, OptionalFeedbackConfiguration } from '@sentry/types'; /** * Quick and dirty deep merge for the Feedback integration options diff --git a/packages/types/src/feedback/index.ts b/packages/types/src/feedback/index.ts index aa34d1a574b7..9f8594973ed3 100644 --- a/packages/types/src/feedback/index.ts +++ b/packages/types/src/feedback/index.ts @@ -22,6 +22,24 @@ export interface FeedbackInternalOptions FeedbackTextConfiguration, FeedbackCallbacks {} +/** + * Partial configuration that overrides default configuration values + * + * This is the config that gets passed into the integration constructor + */ +export interface OptionalFeedbackConfiguration + extends Omit, 'themeLight' | 'themeDark'> { + themeLight?: Partial; + themeDark?: Partial; +} + +/** + * Partial configuration that overrides the constructor provided configuration values + * + * This is the config that gets passed into methods like attachTo and createWidget. + */ +export type OverrideFeedbackConfiguration = Omit, 'themeLight' | 'themeDark'>; + type HTMLElement = unknown; export interface FeedbackDialog { /** diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 1ed8ec1755a6..ffe3156921f7 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -73,15 +73,17 @@ export type { } from './profiling'; export type { ReplayEvent, ReplayRecordingData, ReplayRecordingMode } from './replay'; export type { + CreateDialogProps, FeedbackDialog, FeedbackEvent, FeedbackFormData, FeedbackInternalOptions, FeedbackModalIntegration, FeedbackScreenshotIntegration, + OptionalFeedbackConfiguration, + OverrideFeedbackConfiguration, SendFeedback, SendFeedbackParams, - CreateDialogProps, UserFeedback, } from './feedback'; export type { QueryParams, Request, SanitizedRequestData } from './request'; From a6c724989728cebefcc1f783c1abb050668931f0 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Thu, 23 May 2024 13:14:51 -0700 Subject: [PATCH 02/10] publish and use SendFeedbackOptions instead of rewriting it each time --- packages/core/src/feedback.ts | 7 ++----- packages/feedback/src/core/sendFeedback.ts | 11 ++++++++--- packages/types/src/feedback/index.ts | 10 ++++++++-- packages/types/src/feedback/sendFeedback.ts | 2 +- packages/types/src/index.ts | 1 + 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/packages/core/src/feedback.ts b/packages/core/src/feedback.ts index ae3abc7ca50f..c94a42d8a87c 100644 --- a/packages/core/src/feedback.ts +++ b/packages/core/src/feedback.ts @@ -1,14 +1,11 @@ -import type { EventHint, FeedbackEvent, SendFeedbackParams } from '@sentry/types'; +import type { FeedbackEvent, SendFeedbackOptions, SendFeedbackParams } from '@sentry/types'; import { dropUndefinedKeys } from '@sentry/utils'; import { getClient, getCurrentScope } from './currentScopes'; /** * Send user feedback to Sentry. */ -export function captureFeedback( - feedbackParams: SendFeedbackParams, - hint: EventHint & { includeReplay?: boolean } = {}, -): string { +export function captureFeedback(feedbackParams: SendFeedbackParams, hint: SendFeedbackOptions = {}): string { const { message, name, email, url, source, associatedEventId } = feedbackParams; const client = getClient(); diff --git a/packages/feedback/src/core/sendFeedback.ts b/packages/feedback/src/core/sendFeedback.ts index 3848eb9cbc33..70061b5fee49 100644 --- a/packages/feedback/src/core/sendFeedback.ts +++ b/packages/feedback/src/core/sendFeedback.ts @@ -1,7 +1,12 @@ import { captureFeedback } from '@sentry/core'; import { getClient } from '@sentry/core'; -import type { EventHint, SendFeedback, SendFeedbackParams, TransportMakeRequestResponse } from '@sentry/types'; -import type { Event } from '@sentry/types'; +import type { + Event, + SendFeedback, + SendFeedbackOptions, + SendFeedbackParams, + TransportMakeRequestResponse, +} from '@sentry/types'; import { getLocationHref } from '@sentry/utils'; import { FEEDBACK_API_SOURCE } from '../constants'; @@ -10,7 +15,7 @@ import { FEEDBACK_API_SOURCE } from '../constants'; */ export const sendFeedback: SendFeedback = ( options: SendFeedbackParams, - hint: EventHint & { includeReplay?: boolean } = { includeReplay: true }, + hint: SendFeedbackOptions = { includeReplay: true }, ): Promise => { if (!options.message) { throw new Error('Unable to submit feedback with empty message'); diff --git a/packages/types/src/feedback/index.ts b/packages/types/src/feedback/index.ts index 9f8594973ed3..20f07e521231 100644 --- a/packages/types/src/feedback/index.ts +++ b/packages/types/src/feedback/index.ts @@ -10,8 +10,14 @@ import type { export type { FeedbackFormData } from './form'; -import type { FeedbackEvent, SendFeedback, SendFeedbackParams, UserFeedback } from './sendFeedback'; -export type { FeedbackEvent, UserFeedback, SendFeedback, SendFeedbackParams }; +import type { + FeedbackEvent, + SendFeedback, + SendFeedbackOptions, + SendFeedbackParams, + UserFeedback, +} from './sendFeedback'; +export type { FeedbackEvent, SendFeedback, SendFeedbackOptions, SendFeedbackParams, UserFeedback }; /** * The integration's internal `options` member where every value should be set diff --git a/packages/types/src/feedback/sendFeedback.ts b/packages/types/src/feedback/sendFeedback.ts index a284e82f107b..ab1b9e62dcac 100644 --- a/packages/types/src/feedback/sendFeedback.ts +++ b/packages/types/src/feedback/sendFeedback.ts @@ -40,7 +40,7 @@ export interface SendFeedbackParams { associatedEventId?: string; } -interface SendFeedbackOptions extends EventHint { +export interface SendFeedbackOptions extends EventHint { /** * Should include replay with the feedback? */ diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index ffe3156921f7..bd4dca4a685a 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -83,6 +83,7 @@ export type { OptionalFeedbackConfiguration, OverrideFeedbackConfiguration, SendFeedback, + SendFeedbackOptions, SendFeedbackParams, UserFeedback, } from './feedback'; From 868c5500dff105af8732d0d843400c1e4c39988b Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Thu, 23 May 2024 14:15:30 -0700 Subject: [PATCH 03/10] feat(feedback): Allow passing `tags` field to and feedback config object --- packages/core/src/feedback.ts | 3 ++- packages/feedback/src/core/integration.ts | 8 +++++--- packages/feedback/src/core/sendFeedback.ts | 4 ++++ packages/feedback/src/modal/components/Form.tsx | 2 ++ packages/feedback/src/util/mergeOptions.ts | 4 ++++ packages/types/src/feedback/config.ts | 6 ++++++ packages/types/src/feedback/sendFeedback.ts | 6 ++++++ 7 files changed, 29 insertions(+), 4 deletions(-) diff --git a/packages/core/src/feedback.ts b/packages/core/src/feedback.ts index c94a42d8a87c..31169f24f4a9 100644 --- a/packages/core/src/feedback.ts +++ b/packages/core/src/feedback.ts @@ -6,7 +6,7 @@ import { getClient, getCurrentScope } from './currentScopes'; * Send user feedback to Sentry. */ export function captureFeedback(feedbackParams: SendFeedbackParams, hint: SendFeedbackOptions = {}): string { - const { message, name, email, url, source, associatedEventId } = feedbackParams; + const { message, name, email, url, source, associatedEventId, tags } = feedbackParams; const client = getClient(); @@ -23,6 +23,7 @@ export function captureFeedback(feedbackParams: SendFeedbackParams, hint: SendFe }, type: 'feedback', level: 'info', + tags, }; if (client) { diff --git a/packages/feedback/src/core/integration.ts b/packages/feedback/src/core/integration.ts index 0af799ab78ec..3d331a8511b4 100644 --- a/packages/feedback/src/core/integration.ts +++ b/packages/feedback/src/core/integration.ts @@ -65,8 +65,10 @@ export const buildFeedbackIntegration = ({ const feedbackIntegration = (({ // FeedbackGeneralConfiguration id = 'sentry-feedback', - showBranding = true, autoInject = true, + showBranding = true, + isEmailRequired = false, + isNameRequired = false, showEmail = true, showName = true, enableScreenshot = true, @@ -74,8 +76,7 @@ export const buildFeedbackIntegration = ({ email: 'email', name: 'username', }, - isNameRequired = false, - isEmailRequired = false, + tags, // FeedbackThemeConfiguration colorScheme = 'system', @@ -116,6 +117,7 @@ export const buildFeedbackIntegration = ({ showName, enableScreenshot, useSentryUser, + tags, colorScheme, themeDark, diff --git a/packages/feedback/src/core/sendFeedback.ts b/packages/feedback/src/core/sendFeedback.ts index 70061b5fee49..bebb1a74242a 100644 --- a/packages/feedback/src/core/sendFeedback.ts +++ b/packages/feedback/src/core/sendFeedback.ts @@ -1,5 +1,6 @@ import { captureFeedback } from '@sentry/core'; import { getClient } from '@sentry/core'; +import { getCurrentScope } from '@sentry/core'; import type { Event, SendFeedback, @@ -28,6 +29,9 @@ export const sendFeedback: SendFeedback = ( throw new Error('No client setup, cannot send feedback.'); } + if (options.tags) { + getCurrentScope().setTags(options.tags); + } const eventId = captureFeedback( { source: FEEDBACK_API_SOURCE, diff --git a/packages/feedback/src/modal/components/Form.tsx b/packages/feedback/src/modal/components/Form.tsx index 788512cb192b..c8815a7ef97d 100644 --- a/packages/feedback/src/modal/components/Form.tsx +++ b/packages/feedback/src/modal/components/Form.tsx @@ -46,6 +46,7 @@ export function Form({ screenshotInput, }: Props): VNode { const { + tags, addScreenshotButtonLabel, removeScreenshotButtonLabel, cancelButtonLabel, @@ -122,6 +123,7 @@ export function Form({ email: data.email, message: data.message, source: FEEDBACK_WIDGET_SOURCE, + tags, }, { attachments: data.attachments }, ); diff --git a/packages/feedback/src/util/mergeOptions.ts b/packages/feedback/src/util/mergeOptions.ts index 692f32e5062c..8b8b948042da 100644 --- a/packages/feedback/src/util/mergeOptions.ts +++ b/packages/feedback/src/util/mergeOptions.ts @@ -10,6 +10,10 @@ export function mergeOptions( return { ...defaultOptions, ...optionOverrides, + tags: { + ...defaultOptions.tags, + ...optionOverrides.tags, + }, onFormOpen: () => { optionOverrides.onFormOpen && optionOverrides.onFormOpen(); defaultOptions.onFormOpen && defaultOptions.onFormOpen(); diff --git a/packages/types/src/feedback/config.ts b/packages/types/src/feedback/config.ts index e6f92e65d52e..5b877e6e91e3 100644 --- a/packages/types/src/feedback/config.ts +++ b/packages/types/src/feedback/config.ts @@ -1,3 +1,4 @@ +import { Primitive } from '../misc'; import type { FeedbackFormData } from './form'; import type { FeedbackTheme } from './theme'; @@ -55,6 +56,11 @@ export interface FeedbackGeneralConfiguration { email: string; name: string; }; + + /** + * Set an object that will be merged sent as tags data with the event. + */ + tags?: { [key: string]: Primitive }; } /** diff --git a/packages/types/src/feedback/sendFeedback.ts b/packages/types/src/feedback/sendFeedback.ts index ab1b9e62dcac..a5af37601fde 100644 --- a/packages/types/src/feedback/sendFeedback.ts +++ b/packages/types/src/feedback/sendFeedback.ts @@ -1,4 +1,5 @@ import type { Event, EventHint } from '../event'; +import type { Primitive } from '../misc'; import type { User } from '../user'; /** @@ -38,6 +39,11 @@ export interface SendFeedbackParams { url?: string; source?: string; associatedEventId?: string; + + /** + * Set an object that will be merged sent as tags data with the event. + */ + tags?: { [key: string]: Primitive }; } export interface SendFeedbackOptions extends EventHint { From 314f7c565c06646ae98bc9faea3c283e54a833c0 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Thu, 23 May 2024 14:43:13 -0700 Subject: [PATCH 04/10] add missing type keyword --- packages/types/src/feedback/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/types/src/feedback/config.ts b/packages/types/src/feedback/config.ts index 5b877e6e91e3..2350545941be 100644 --- a/packages/types/src/feedback/config.ts +++ b/packages/types/src/feedback/config.ts @@ -1,4 +1,4 @@ -import { Primitive } from '../misc'; +import type { Primitive } from '../misc'; import type { FeedbackFormData } from './form'; import type { FeedbackTheme } from './theme'; From e41115cd3a9d4bf736f0292a1e5195627d9f1463 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Thu, 23 May 2024 15:15:09 -0700 Subject: [PATCH 05/10] update tests --- .../suites/feedback/captureFeedback/test.ts | 1 + .../suites/feedback/captureFeedbackAndReplay/hasSampling/test.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/dev-packages/browser-integration-tests/suites/feedback/captureFeedback/test.ts b/dev-packages/browser-integration-tests/suites/feedback/captureFeedback/test.ts index fede6aa2c0e2..70a03e45c1c2 100644 --- a/dev-packages/browser-integration-tests/suites/feedback/captureFeedback/test.ts +++ b/dev-packages/browser-integration-tests/suites/feedback/captureFeedback/test.ts @@ -59,6 +59,7 @@ sentryTest('should capture feedback', async ({ getLocalTestUrl, page }) => { }, }, level: 'info', + tags: {}, timestamp: expect.any(Number), event_id: expect.stringMatching(/\w{32}/), environment: 'production', diff --git a/dev-packages/browser-integration-tests/suites/feedback/captureFeedbackAndReplay/hasSampling/test.ts b/dev-packages/browser-integration-tests/suites/feedback/captureFeedbackAndReplay/hasSampling/test.ts index 4457d64ccd9e..5a88a429e53c 100644 --- a/dev-packages/browser-integration-tests/suites/feedback/captureFeedbackAndReplay/hasSampling/test.ts +++ b/dev-packages/browser-integration-tests/suites/feedback/captureFeedbackAndReplay/hasSampling/test.ts @@ -95,6 +95,7 @@ sentryTest('should capture feedback', async ({ forceFlushReplay, getLocalTestUrl }, }, level: 'info', + tags: {}, timestamp: expect.any(Number), event_id: expect.stringMatching(/\w{32}/), environment: 'production', From 2bb651361e74fce2a756dc5fdaa9ce74ad195084 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Tue, 28 May 2024 10:12:49 -0700 Subject: [PATCH 06/10] keep using EventHint, rename args to match type: "params", more specific guard before setTags --- packages/core/src/feedback.ts | 9 ++++++--- packages/feedback/src/core/sendFeedback.ts | 20 +++++++------------- packages/types/src/feedback/index.ts | 10 ++-------- packages/types/src/feedback/sendFeedback.ts | 12 ++++-------- packages/types/src/index.ts | 1 - 5 files changed, 19 insertions(+), 33 deletions(-) diff --git a/packages/core/src/feedback.ts b/packages/core/src/feedback.ts index 31169f24f4a9..fde8f103bae6 100644 --- a/packages/core/src/feedback.ts +++ b/packages/core/src/feedback.ts @@ -1,12 +1,15 @@ -import type { FeedbackEvent, SendFeedbackOptions, SendFeedbackParams } from '@sentry/types'; +import type { EventHint, FeedbackEvent, SendFeedbackParams } from '@sentry/types'; import { dropUndefinedKeys } from '@sentry/utils'; import { getClient, getCurrentScope } from './currentScopes'; /** * Send user feedback to Sentry. */ -export function captureFeedback(feedbackParams: SendFeedbackParams, hint: SendFeedbackOptions = {}): string { - const { message, name, email, url, source, associatedEventId, tags } = feedbackParams; +export function captureFeedback( + params: SendFeedbackParams, + hint: EventHint & { includeReplay?: boolean } = {}, +): string { + const { message, name, email, url, source, associatedEventId, tags } = params; const client = getClient(); diff --git a/packages/feedback/src/core/sendFeedback.ts b/packages/feedback/src/core/sendFeedback.ts index bebb1a74242a..2fa136b06897 100644 --- a/packages/feedback/src/core/sendFeedback.ts +++ b/packages/feedback/src/core/sendFeedback.ts @@ -1,13 +1,7 @@ import { captureFeedback } from '@sentry/core'; import { getClient } from '@sentry/core'; import { getCurrentScope } from '@sentry/core'; -import type { - Event, - SendFeedback, - SendFeedbackOptions, - SendFeedbackParams, - TransportMakeRequestResponse, -} from '@sentry/types'; +import type { Event, EventHint, SendFeedback, SendFeedbackParams, TransportMakeRequestResponse } from '@sentry/types'; import { getLocationHref } from '@sentry/utils'; import { FEEDBACK_API_SOURCE } from '../constants'; @@ -15,10 +9,10 @@ import { FEEDBACK_API_SOURCE } from '../constants'; * Public API to send a Feedback item to Sentry */ export const sendFeedback: SendFeedback = ( - options: SendFeedbackParams, - hint: SendFeedbackOptions = { includeReplay: true }, + params: SendFeedbackParams, + hint: EventHint & { includeReplay?: boolean } = { includeReplay: true }, ): Promise => { - if (!options.message) { + if (!params.message) { throw new Error('Unable to submit feedback with empty message'); } @@ -29,14 +23,14 @@ export const sendFeedback: SendFeedback = ( throw new Error('No client setup, cannot send feedback.'); } - if (options.tags) { - getCurrentScope().setTags(options.tags); + if (params.tags && Object.keys(params.tags).length) { + getCurrentScope().setTags(params.tags); } const eventId = captureFeedback( { source: FEEDBACK_API_SOURCE, url: getLocationHref(), - ...options, + ...params, }, hint, ); diff --git a/packages/types/src/feedback/index.ts b/packages/types/src/feedback/index.ts index 20f07e521231..4cb96fad96ab 100644 --- a/packages/types/src/feedback/index.ts +++ b/packages/types/src/feedback/index.ts @@ -10,14 +10,8 @@ import type { export type { FeedbackFormData } from './form'; -import type { - FeedbackEvent, - SendFeedback, - SendFeedbackOptions, - SendFeedbackParams, - UserFeedback, -} from './sendFeedback'; -export type { FeedbackEvent, SendFeedback, SendFeedbackOptions, SendFeedbackParams, UserFeedback }; +import type { FeedbackEvent, SendFeedback, SendFeedbackParams, UserFeedback } from './sendFeedback'; +export type { FeedbackEvent, SendFeedback, SendFeedbackParams, UserFeedback }; /** * The integration's internal `options` member where every value should be set diff --git a/packages/types/src/feedback/sendFeedback.ts b/packages/types/src/feedback/sendFeedback.ts index a5af37601fde..8f865b57038d 100644 --- a/packages/types/src/feedback/sendFeedback.ts +++ b/packages/types/src/feedback/sendFeedback.ts @@ -46,11 +46,7 @@ export interface SendFeedbackParams { tags?: { [key: string]: Primitive }; } -export interface SendFeedbackOptions extends EventHint { - /** - * Should include replay with the feedback? - */ - includeReplay?: boolean; -} - -export type SendFeedback = (params: SendFeedbackParams, options?: SendFeedbackOptions) => Promise; +export type SendFeedback = ( + params: SendFeedbackParams, + hint?: EventHint & { includeReplay?: boolean }, +) => Promise; diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index bd4dca4a685a..ffe3156921f7 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -83,7 +83,6 @@ export type { OptionalFeedbackConfiguration, OverrideFeedbackConfiguration, SendFeedback, - SendFeedbackOptions, SendFeedbackParams, UserFeedback, } from './feedback'; From bf2591fd7d039414e08be546dcdbeebe2b18fa53 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Tue, 28 May 2024 10:17:31 -0700 Subject: [PATCH 07/10] define OptionalFeedbackConfiguration in terms of OverrideFeedbackConfiguration --- packages/types/src/feedback/index.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/types/src/feedback/index.ts b/packages/types/src/feedback/index.ts index 4cb96fad96ab..d6ef2e95521c 100644 --- a/packages/types/src/feedback/index.ts +++ b/packages/types/src/feedback/index.ts @@ -22,24 +22,23 @@ export interface FeedbackInternalOptions FeedbackTextConfiguration, FeedbackCallbacks {} +/** + * Partial configuration that overrides the constructor provided configuration values + * + * This is the config that gets passed into methods like attachTo and createWidget. + */ +export type OverrideFeedbackConfiguration = Omit, 'themeLight' | 'themeDark'>; + /** * Partial configuration that overrides default configuration values * * This is the config that gets passed into the integration constructor */ -export interface OptionalFeedbackConfiguration - extends Omit, 'themeLight' | 'themeDark'> { +export interface OptionalFeedbackConfiguration extends OverrideFeedbackConfiguration { themeLight?: Partial; themeDark?: Partial; } -/** - * Partial configuration that overrides the constructor provided configuration values - * - * This is the config that gets passed into methods like attachTo and createWidget. - */ -export type OverrideFeedbackConfiguration = Omit, 'themeLight' | 'themeDark'>; - type HTMLElement = unknown; export interface FeedbackDialog { /** From d26b2dad569b15b03d51009be9b4c712a35a3472 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Tue, 11 Jun 2024 14:58:30 -0700 Subject: [PATCH 08/10] Do not export strange types --- packages/feedback/src/core/integration.ts | 3 +-- packages/feedback/src/core/types.ts | 19 +++++++++++++++++++ packages/feedback/src/util/mergeOptions.ts | 3 ++- packages/types/src/index.ts | 9 ++++----- 4 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 packages/feedback/src/core/types.ts diff --git a/packages/feedback/src/core/integration.ts b/packages/feedback/src/core/integration.ts index 3d331a8511b4..b7d7ae246f6f 100644 --- a/packages/feedback/src/core/integration.ts +++ b/packages/feedback/src/core/integration.ts @@ -6,8 +6,6 @@ import type { FeedbackScreenshotIntegration, Integration, IntegrationFn, - OptionalFeedbackConfiguration, - OverrideFeedbackConfiguration, } from '@sentry/types'; import { isBrowser, logger } from '@sentry/utils'; import { @@ -35,6 +33,7 @@ import type { ActorComponent } from './components/Actor'; import { Actor } from './components/Actor'; import { createMainStyles } from './createMainStyles'; import { sendFeedback } from './sendFeedback'; +import type { OptionalFeedbackConfiguration, OverrideFeedbackConfiguration } from './types'; type Unsubscribe = () => void; diff --git a/packages/feedback/src/core/types.ts b/packages/feedback/src/core/types.ts new file mode 100644 index 000000000000..a85987301702 --- /dev/null +++ b/packages/feedback/src/core/types.ts @@ -0,0 +1,19 @@ +import type { FeedbackInternalOptions } from '@sentry/types'; + +/** + * Partial configuration that overrides default configuration values + * + * This is the config that gets passed into the integration constructor + */ +export interface OptionalFeedbackConfiguration + extends Omit, 'themeLight' | 'themeDark'> { + themeLight?: Partial; + themeDark?: Partial; +} + +/** + * Partial configuration that overrides default configuration values + * + * This is the config that gets passed into the integration constructor + */ +export type OverrideFeedbackConfiguration = Omit, 'themeLight' | 'themeDark'>; diff --git a/packages/feedback/src/util/mergeOptions.ts b/packages/feedback/src/util/mergeOptions.ts index 8b8b948042da..0a30a893c777 100644 --- a/packages/feedback/src/util/mergeOptions.ts +++ b/packages/feedback/src/util/mergeOptions.ts @@ -1,4 +1,5 @@ -import type { FeedbackFormData, FeedbackInternalOptions, OptionalFeedbackConfiguration } from '@sentry/types'; +import type { FeedbackFormData, FeedbackInternalOptions } from '@sentry/types'; +import type { OptionalFeedbackConfiguration } from '../core/types'; /** * Quick and dirty deep merge for the Feedback integration options diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index ffe3156921f7..c90b7841f9ff 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -73,17 +73,15 @@ export type { } from './profiling'; export type { ReplayEvent, ReplayRecordingData, ReplayRecordingMode } from './replay'; export type { - CreateDialogProps, FeedbackDialog, FeedbackEvent, FeedbackFormData, FeedbackInternalOptions, FeedbackModalIntegration, FeedbackScreenshotIntegration, - OptionalFeedbackConfiguration, - OverrideFeedbackConfiguration, SendFeedback, SendFeedbackParams, + CreateDialogProps, UserFeedback, } from './feedback'; export type { QueryParams, Request, SanitizedRequestData } from './request'; @@ -123,11 +121,10 @@ export type { Stacktrace, StackParser, StackLineParser, StackLineParserFn } from export type { PropagationContext, TracePropagationTargets } from './tracing'; export type { StartSpanOptions } from './startSpanOptions'; export type { - CustomSamplingContext, - SamplingContext, TraceparentData, TransactionSource, } from './transaction'; +export type { CustomSamplingContext, SamplingContext } from './samplingcontext'; export type { DurationUnit, InformationUnit, @@ -167,6 +164,8 @@ export type { MetricsAggregator, MetricBucketItem, MetricInstance, + MetricData, + Metrics, } from './metrics'; export type { ParameterizedString } from './parameterize'; export type { ViewHierarchyData, ViewHierarchyWindow } from './view-hierarchy'; From f5fa3cde2a04b8b3433559c73643e5cd7893ea35 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Tue, 11 Jun 2024 14:59:48 -0700 Subject: [PATCH 09/10] rm extra exports --- packages/types/src/feedback/index.ts | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/packages/types/src/feedback/index.ts b/packages/types/src/feedback/index.ts index d6ef2e95521c..aa34d1a574b7 100644 --- a/packages/types/src/feedback/index.ts +++ b/packages/types/src/feedback/index.ts @@ -11,7 +11,7 @@ import type { export type { FeedbackFormData } from './form'; import type { FeedbackEvent, SendFeedback, SendFeedbackParams, UserFeedback } from './sendFeedback'; -export type { FeedbackEvent, SendFeedback, SendFeedbackParams, UserFeedback }; +export type { FeedbackEvent, UserFeedback, SendFeedback, SendFeedbackParams }; /** * The integration's internal `options` member where every value should be set @@ -22,23 +22,6 @@ export interface FeedbackInternalOptions FeedbackTextConfiguration, FeedbackCallbacks {} -/** - * Partial configuration that overrides the constructor provided configuration values - * - * This is the config that gets passed into methods like attachTo and createWidget. - */ -export type OverrideFeedbackConfiguration = Omit, 'themeLight' | 'themeDark'>; - -/** - * Partial configuration that overrides default configuration values - * - * This is the config that gets passed into the integration constructor - */ -export interface OptionalFeedbackConfiguration extends OverrideFeedbackConfiguration { - themeLight?: Partial; - themeDark?: Partial; -} - type HTMLElement = unknown; export interface FeedbackDialog { /** From 55c1365f151f449dc8011f1f611b248a78e3ab1b Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Mon, 17 Jun 2024 12:18:05 -0700 Subject: [PATCH 10/10] Add a quick integration test that passes tags along --- .../suites/feedback/captureFeedback/init.js | 6 +++++- .../suites/feedback/captureFeedback/test.ts | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dev-packages/browser-integration-tests/suites/feedback/captureFeedback/init.js b/dev-packages/browser-integration-tests/suites/feedback/captureFeedback/init.js index 6455e8d8851a..7d36dc233847 100644 --- a/dev-packages/browser-integration-tests/suites/feedback/captureFeedback/init.js +++ b/dev-packages/browser-integration-tests/suites/feedback/captureFeedback/init.js @@ -4,5 +4,9 @@ window.Sentry = Sentry; Sentry.init({ dsn: 'https://public@dsn.ingest.sentry.io/1337', - integrations: [Sentry.feedbackIntegration()], + integrations: [ + Sentry.feedbackIntegration({ + tags: { from: 'integration init' }, + }), + ], }); diff --git a/dev-packages/browser-integration-tests/suites/feedback/captureFeedback/test.ts b/dev-packages/browser-integration-tests/suites/feedback/captureFeedback/test.ts index 70a03e45c1c2..eb16cf1e1848 100644 --- a/dev-packages/browser-integration-tests/suites/feedback/captureFeedback/test.ts +++ b/dev-packages/browser-integration-tests/suites/feedback/captureFeedback/test.ts @@ -59,7 +59,9 @@ sentryTest('should capture feedback', async ({ getLocalTestUrl, page }) => { }, }, level: 'info', - tags: {}, + tags: { + from: 'integration init', + }, timestamp: expect.any(Number), event_id: expect.stringMatching(/\w{32}/), environment: 'production',