{"version":3,"file":"index.js","sources":["../../../src/constants.ts","../../../src/util/prepareFeedbackEvent.ts","../../../src/util/sendFeedbackRequest.ts","../../../src/sendFeedback.ts","../../../src/debug-build.ts","../../../src/util/mergeOptions.ts","../../../src/widget/Actor.css.ts","../../../src/widget/Dialog.css.ts","../../../src/widget/Main.css.ts","../../../src/widget/createShadowHost.ts","../../../src/util/handleFeedbackSubmit.ts","../../../src/util/setAttributesNS.ts","../../../src/widget/Icon.ts","../../../src/widget/util/createElement.ts","../../../src/widget/Actor.ts","../../../src/widget/SubmitButton.ts","../../../src/widget/Form.ts","../../../src/widget/Logo.ts","../../../src/widget/Dialog.ts","../../../src/widget/SuccessIcon.ts","../../../src/widget/SuccessMessage.ts","../../../src/widget/createWidget.ts","../../../src/integration.ts"],"sourcesContent":["import { GLOBAL_OBJ } from '@sentry/utils';\n\n// exporting a separate copy of `WINDOW` rather than exporting the one from `@sentry/browser`\n// prevents the browser package from being bundled in the CDN bundle, and avoids a\n// circular dependency between the browser and feedback packages\nexport const WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window;\n\nconst LIGHT_BACKGROUND = '#ffffff';\nconst INHERIT = 'inherit';\nconst SUBMIT_COLOR = 'rgba(108, 95, 199, 1)';\nconst LIGHT_THEME = {\n fontFamily: \"system-ui, 'Helvetica Neue', Arial, sans-serif\",\n fontSize: '14px',\n\n background: LIGHT_BACKGROUND,\n backgroundHover: '#f6f6f7',\n foreground: '#2b2233',\n border: '1.5px solid rgba(41, 35, 47, 0.13)',\n borderRadius: '12px',\n boxShadow: '0px 4px 24px 0px rgba(43, 34, 51, 0.12)',\n\n success: '#268d75',\n error: '#df3338',\n\n submitBackground: 'rgba(88, 74, 192, 1)',\n submitBackgroundHover: SUBMIT_COLOR,\n submitBorder: SUBMIT_COLOR,\n submitOutlineFocus: '#29232f',\n submitForeground: LIGHT_BACKGROUND,\n submitForegroundHover: LIGHT_BACKGROUND,\n\n cancelBackground: 'transparent',\n cancelBackgroundHover: 'var(--background-hover)',\n cancelBorder: 'var(--border)',\n cancelOutlineFocus: 'var(--input-outline-focus)',\n cancelForeground: 'var(--foreground)',\n cancelForegroundHover: 'var(--foreground)',\n\n inputBackground: INHERIT,\n inputForeground: INHERIT,\n inputBorder: 'var(--border)',\n inputOutlineFocus: SUBMIT_COLOR,\n\n formBorderRadius: '20px',\n formContentBorderRadius: '6px',\n};\n\nexport const DEFAULT_THEME = {\n light: LIGHT_THEME,\n dark: {\n ...LIGHT_THEME,\n\n background: '#29232f',\n backgroundHover: '#352f3b',\n foreground: '#ebe6ef',\n border: '1.5px solid rgba(235, 230, 239, 0.15)',\n\n success: '#2da98c',\n error: '#f55459',\n },\n};\n\nexport const ACTOR_LABEL = 'Report a Bug';\nexport const CANCEL_BUTTON_LABEL = 'Cancel';\nexport const SUBMIT_BUTTON_LABEL = 'Send Bug Report';\nexport const FORM_TITLE = 'Report a Bug';\nexport const EMAIL_PLACEHOLDER = 'your.email@example.org';\nexport const EMAIL_LABEL = 'Email';\nexport const MESSAGE_PLACEHOLDER = \"What's the bug? What did you expect?\";\nexport const MESSAGE_LABEL = 'Description';\nexport const NAME_PLACEHOLDER = 'Your Name';\nexport const NAME_LABEL = 'Name';\nexport const SUCCESS_MESSAGE_TEXT = 'Thank you for your report!';\n\nexport const FEEDBACK_WIDGET_SOURCE = 'widget';\nexport const FEEDBACK_API_SOURCE = 'api';\n","import type { Scope } from '@sentry/core';\nimport { getIsolationScope } from '@sentry/core';\nimport { prepareEvent } from '@sentry/core';\nimport type { Client, FeedbackEvent } from '@sentry/types';\n\ninterface PrepareFeedbackEventParams {\n client: Client;\n event: FeedbackEvent;\n scope: Scope;\n}\n/**\n * Prepare a feedback event & enrich it with the SDK metadata.\n */\nexport async function prepareFeedbackEvent({\n client,\n scope,\n event,\n}: PrepareFeedbackEventParams): Promise {\n const eventHint = {};\n if (client.emit) {\n client.emit('preprocessEvent', event, eventHint);\n }\n\n const preparedEvent = (await prepareEvent(\n client.getOptions(),\n event,\n eventHint,\n scope,\n client,\n getIsolationScope(),\n )) as FeedbackEvent | null;\n\n if (preparedEvent === null) {\n // Taken from baseclient's `_processEvent` method, where this is handled for errors/transactions\n client.recordDroppedEvent('event_processor', 'feedback', event);\n return null;\n }\n\n // This normally happens in browser client \"_prepareEvent\"\n // but since we do not use this private method from the client, but rather the plain import\n // we need to do this manually.\n preparedEvent.platform = preparedEvent.platform || 'javascript';\n\n return preparedEvent;\n}\n","import { createEventEnvelope, getClient, withScope } from '@sentry/core';\nimport type { FeedbackEvent, TransportMakeRequestResponse } from '@sentry/types';\n\nimport { FEEDBACK_API_SOURCE, FEEDBACK_WIDGET_SOURCE } from '../constants';\nimport type { SendFeedbackData, SendFeedbackOptions } from '../types';\nimport { prepareFeedbackEvent } from './prepareFeedbackEvent';\n\n/**\n * Send feedback using transport\n */\nexport async function sendFeedbackRequest(\n { feedback: { message, email, name, source, url } }: SendFeedbackData,\n { includeReplay = true }: SendFeedbackOptions = {},\n): Promise {\n const client = getClient();\n const transport = client && client.getTransport();\n const dsn = client && client.getDsn();\n\n if (!client || !transport || !dsn) {\n return;\n }\n\n const baseEvent: FeedbackEvent = {\n contexts: {\n feedback: {\n contact_email: email,\n name,\n message,\n url,\n source,\n },\n },\n type: 'feedback',\n };\n\n return withScope(async scope => {\n // No use for breadcrumbs in feedback\n scope.clearBreadcrumbs();\n\n if ([FEEDBACK_API_SOURCE, FEEDBACK_WIDGET_SOURCE].includes(String(source))) {\n scope.setLevel('info');\n }\n\n const feedbackEvent = await prepareFeedbackEvent({\n scope,\n client,\n event: baseEvent,\n });\n\n if (!feedbackEvent) {\n return;\n }\n\n if (client.emit) {\n client.emit('beforeSendFeedback', feedbackEvent, { includeReplay: Boolean(includeReplay) });\n }\n\n const envelope = createEventEnvelope(feedbackEvent, dsn, client.getOptions()._metadata, client.getOptions().tunnel);\n\n let response: void | TransportMakeRequestResponse;\n\n try {\n response = await transport.send(envelope);\n } catch (err) {\n const error = new Error('Unable to send Feedback');\n\n try {\n // In case browsers don't allow this property to be writable\n // @ts-expect-error This needs lib es2022 and newer\n error.cause = err;\n } catch {\n // nothing to do\n }\n throw error;\n }\n\n // TODO (v8): we can remove this guard once transport.send's type signature doesn't include void anymore\n if (!response) {\n return;\n }\n\n // Require valid status codes, otherwise can assume feedback was not sent successfully\n if (typeof response.statusCode === 'number' && (response.statusCode < 200 || response.statusCode >= 300)) {\n throw new Error('Unable to send Feedback');\n }\n\n return response;\n });\n}\n\n/*\n * For reference, the fully built event looks something like this:\n * {\n * \"type\": \"feedback\",\n * \"event_id\": \"d2132d31b39445f1938d7e21b6bf0ec4\",\n * \"timestamp\": 1597977777.6189718,\n * \"dist\": \"1.12\",\n * \"platform\": \"javascript\",\n * \"environment\": \"production\",\n * \"release\": 42,\n * \"tags\": {\"transaction\": \"/organizations/:orgId/performance/:eventSlug/\"},\n * \"sdk\": {\"name\": \"name\", \"version\": \"version\"},\n * \"user\": {\n * \"id\": \"123\",\n * \"username\": \"user\",\n * \"email\": \"user@site.com\",\n * \"ip_address\": \"192.168.11.12\",\n * },\n * \"request\": {\n * \"url\": None,\n * \"headers\": {\n * \"user-Agent\": \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Safari/605.1.15\"\n * },\n * },\n * \"contexts\": {\n * \"feedback\": {\n * \"message\": \"test message\",\n * \"contact_email\": \"test@example.com\",\n * \"type\": \"feedback\",\n * },\n * \"trace\": {\n * \"trace_id\": \"4C79F60C11214EB38604F4AE0781BFB2\",\n * \"span_id\": \"FA90FDEAD5F74052\",\n * \"type\": \"trace\",\n * },\n * \"replay\": {\n * \"replay_id\": \"e2d42047b1c5431c8cba85ee2a8ab25d\",\n * },\n * },\n * }\n */\n","import { getLocationHref } from '@sentry/utils';\n\nimport { FEEDBACK_API_SOURCE } from './constants';\nimport type { SendFeedbackOptions } from './types';\nimport { sendFeedbackRequest } from './util/sendFeedbackRequest';\n\ninterface SendFeedbackParams {\n message: string;\n name?: string;\n email?: string;\n url?: string;\n source?: string;\n}\n\n/**\n * Public API to send a Feedback item to Sentry\n */\nexport function sendFeedback(\n { name, email, message, source = FEEDBACK_API_SOURCE, url = getLocationHref() }: SendFeedbackParams,\n options: SendFeedbackOptions = {},\n): ReturnType {\n if (!message) {\n throw new Error('Unable to submit feedback with empty message');\n }\n\n return sendFeedbackRequest(\n {\n feedback: {\n name,\n email,\n message,\n url,\n source,\n },\n },\n options,\n );\n}\n","declare const __DEBUG_BUILD__: boolean;\n\n/**\n * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.\n *\n * ATTENTION: This constant must never cross package boundaries (i.e. be exported) to guarantee that it can be used for tree shaking.\n */\nexport const DEBUG_BUILD = __DEBUG_BUILD__;\n","import type { FeedbackInternalOptions, OptionalFeedbackConfiguration } from '../types';\n\n/**\n * Quick and dirty deep merge for the Feedback integration options\n */\nexport function mergeOptions(\n defaultOptions: FeedbackInternalOptions,\n optionOverrides: OptionalFeedbackConfiguration,\n): FeedbackInternalOptions {\n return {\n ...defaultOptions,\n ...optionOverrides,\n themeDark: {\n ...defaultOptions.themeDark,\n ...optionOverrides.themeDark,\n },\n themeLight: {\n ...defaultOptions.themeLight,\n ...optionOverrides.themeLight,\n },\n };\n}\n","/**\n * Creates