11import { getCurrentHub } from '@sentry/core' ;
22import type { Integration } from '@sentry/types' ;
33import { isNodeEnv , logger } from '@sentry/utils' ;
4+ import { ACTOR_LABEL , CANCEL_BUTTON_LABEL , DEFAULT_THEME , EMAIL_LABEL , EMAIL_PLACEHOLDER , FORM_TITLE , MESSAGE_LABEL , MESSAGE_PLACEHOLDER , NAME_LABEL , NAME_PLACEHOLDER , SUBMIT_BUTTON_LABEL , SUCCESS_MESSAGE_TEXT } from './constants' ;
45
5- import type { FeedbackConfigurationWithDefaults , FeedbackFormData } from './types' ;
6+ import type { FeedbackConfigurationWithDefaults , FeedbackFormData , FeedbackTheme } from './types' ;
67import { handleFeedbackSubmit } from './util/handleFeedbackSubmit' ;
78import { Actor } from './widget/Actor' ;
89import { createActorStyles } from './widget/Actor.css' ;
@@ -25,20 +26,12 @@ function isBrowser(): boolean {
2526 return typeof window !== 'undefined' && ( ! isNodeEnv ( ) || isElectronNodeRenderer ( ) ) ;
2627}
2728
28- const THEME = {
29- light : {
30- background : '#ffffff' ,
31- foreground : '#2B2233' ,
32- success : '#268d75' ,
33- error : '#df3338' ,
34- } ,
35- dark : {
36- background : '#29232f' ,
37- foreground : '#EBE6EF' ,
38- success : '#2da98c' ,
39- error : '#f55459' ,
40- } ,
41- } ;
29+ interface FeedbackConfiguration extends Partial < Omit < FeedbackConfigurationWithDefaults , 'theme' > > {
30+ theme ?: {
31+ dark ?: Partial < FeedbackTheme > ;
32+ light ?: Partial < FeedbackTheme > ;
33+ }
34+ }
4235
4336/**
4437 * Feedback integration. When added as an integration to the SDK, it will
@@ -100,20 +93,23 @@ export class Feedback implements Integration {
10093 isEmailRequired = false ,
10194 isNameRequired = false ,
10295
103- buttonLabel = 'Report a Bug' ,
104- cancelButtonLabel = 'Cancel' ,
105- submitButtonLabel = 'Send Bug Report' ,
106- formTitle = 'Report a Bug' ,
107- emailPlaceholder
= '[email protected] ' , 108- emailLabel = 'Email' ,
109- messagePlaceholder = "What's the bug? What did you expect?" ,
110- messageLabel = 'Description' ,
111- namePlaceholder = 'Your Name' ,
112- nameLabel = 'Name' ,
113- successMessageText = 'Thank you for your report!' ,
96+ theme,
97+ colorScheme = 'system' ,
98+
99+ buttonLabel = ACTOR_LABEL ,
100+ cancelButtonLabel = CANCEL_BUTTON_LABEL ,
101+ submitButtonLabel = SUBMIT_BUTTON_LABEL ,
102+ formTitle = FORM_TITLE ,
103+ emailPlaceholder = EMAIL_PLACEHOLDER ,
104+ emailLabel = EMAIL_LABEL ,
105+ messagePlaceholder = MESSAGE_PLACEHOLDER ,
106+ messageLabel = MESSAGE_LABEL ,
107+ namePlaceholder = NAME_PLACEHOLDER ,
108+ nameLabel = NAME_LABEL ,
109+ successMessageText = SUCCESS_MESSAGE_TEXT ,
114110
115111 onOpenDialog,
116- } : Partial < FeedbackConfigurationWithDefaults > = { } ) {
112+ } : FeedbackConfiguration = { } ) {
117113 // Initializations
118114 this . name = Feedback . id ;
119115 this . _actor = null ;
@@ -133,6 +129,12 @@ export class Feedback implements Integration {
133129 showName,
134130 useSentryUser,
135131
132+ colorScheme,
133+ theme : {
134+ dark : Object . assign ( { } , DEFAULT_THEME . dark , theme && theme . dark ) ,
135+ light : Object . assign ( { } , DEFAULT_THEME . light , theme && theme . light ) ,
136+ } ,
137+
136138 buttonLabel,
137139 cancelButtonLabel,
138140 submitButtonLabel,
@@ -229,7 +231,6 @@ export class Feedback implements Integration {
229231 if ( this . _dialog ) {
230232 this . _dialog . open ( ) ;
231233 this . _isDialogOpen = true ;
232- console . log ( 'dialog already open' ) ;
233234 return ;
234235 }
235236
@@ -326,7 +327,7 @@ export class Feedback implements Integration {
326327 // Create the shadow root
327328 const shadow = this . _host . attachShadow ( { mode : 'open' } ) ;
328329
329- shadow . appendChild ( createMainStyles ( document , THEME ) ) ;
330+ shadow . appendChild ( createMainStyles ( document , this . options . colorScheme , this . options . theme ) ) ;
330331
331332 return shadow ;
332333 }
@@ -344,7 +345,7 @@ export class Feedback implements Integration {
344345 this . _shadow . appendChild ( createActorStyles ( document ) ) ;
345346
346347 // Create Actor component
347- this . _actor = Actor ( { options : this . options , theme : THEME , onClick : this . _handleActorClick } ) ;
348+ this . _actor = Actor ( { options : this . options , onClick : this . _handleActorClick } ) ;
348349
349350 this . _shadow . appendChild ( this . _actor . $el ) ;
350351 } catch ( err ) {
@@ -370,7 +371,6 @@ export class Feedback implements Integration {
370371 }
371372 this . showActor ( ) ;
372373 } ,
373- theme : THEME ,
374374 } ) ;
375375
376376 this . _shadow . appendChild ( success . $el ) ;
0 commit comments