11import  {  BaseClient ,  Scope ,  SDK_VERSION  }  from  '@sentry/core' ; 
2- import  {  Event ,  EventHint  }  from  '@sentry/types' ; 
3- import  {  getGlobalObject ,  logger  }  from  '@sentry/utils' ; 
2+ import  {  Event ,  EventHint ,   Options ,   SeverityLevel ,   Transport  }  from  '@sentry/types' ; 
3+ import  {  getGlobalObject ,  logger ,   supportsFetch  }  from  '@sentry/utils' ; 
44
5- import  {  BrowserBackend ,   BrowserOptions  }  from  './backend ' ; 
5+ import  {  eventFromException ,   eventFromMessage  }  from  './eventbuilder ' ; 
66import  {  injectReportDialog ,  ReportDialogOptions  }  from  './helpers' ; 
77import  {  Breadcrumbs  }  from  './integrations' ; 
8+ import  {  FetchTransport ,  XHRTransport  }  from  './transports' ; 
9+ 
10+ /** 
11+  * Configuration options for the Sentry Browser SDK. 
12+  * @see  BrowserClient for more information. 
13+  */ 
14+ export  interface  BrowserOptions  extends  Options  { 
15+   /** 
16+    * A pattern for error URLs which should exclusively be sent to Sentry. 
17+    * This is the opposite of {@link  Options.denyUrls}. 
18+    * By default, all errors will be sent. 
19+    */ 
20+   allowUrls ?: Array < string  |  RegExp > ; 
21+ 
22+   /** 
23+    * A pattern for error URLs which should not be sent to Sentry. 
24+    * To allow certain errors instead, use {@link  Options.allowUrls}. 
25+    * By default, all errors will be sent. 
26+    */ 
27+   denyUrls ?: Array < string  |  RegExp > ; 
28+ 
29+   /** @deprecated  use {@link  Options.allowUrls} instead. */ 
30+   whitelistUrls ?: Array < string  |  RegExp > ; 
31+ 
32+   /** @deprecated  use {@link  Options.denyUrls} instead. */ 
33+   blacklistUrls ?: Array < string  |  RegExp > ; 
34+ } 
835
936/** 
1037 * The Sentry Browser SDK Client. 
1138 * 
1239 * @see  BrowserOptions for documentation on configuration options. 
1340 * @see  SentryClient for usage documentation. 
1441 */ 
15- export  class  BrowserClient  extends  BaseClient < BrowserBackend ,   BrowserOptions >  { 
42+ export  class  BrowserClient  extends  BaseClient < BrowserOptions >  { 
1643  /** 
1744   * Creates a new Browser SDK instance. 
1845   * 
@@ -31,7 +58,7 @@ export class BrowserClient extends BaseClient<BrowserBackend, BrowserOptions> {
3158      version : SDK_VERSION , 
3259    } ; 
3360
34-     super ( BrowserBackend ,   options ) ; 
61+     super ( options ) ; 
3562  } 
3663
3764  /** 
@@ -73,6 +100,47 @@ export class BrowserClient extends BaseClient<BrowserBackend, BrowserOptions> {
73100    if  ( integration )  { 
74101      integration . addSentryBreadcrumb ( event ) ; 
75102    } 
76-     super . _sendEvent ( event ) ; 
103+     super . sendEvent ( event ) ; 
104+   } 
105+ 
106+   /** 
107+    * @inheritDoc  
108+    */ 
109+   // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types 
110+   protected  _eventFromException ( exception : any ,  hint ?: EventHint ) : PromiseLike < Event >  { 
111+     return  eventFromException ( this . _options ,  exception ,  hint ) ; 
112+   } 
113+ 
114+   /** 
115+    * @inheritDoc  
116+    */ 
117+   protected  _eventFromMessage ( message : string ,  level : SeverityLevel  =  'info' ,  hint ?: EventHint ) : PromiseLike < Event >  { 
118+     return  eventFromMessage ( this . _options ,  message ,  level ,  hint ) ; 
119+   } 
120+ 
121+   /** 
122+    * @inheritDoc  
123+    */ 
124+   protected  _setupTransport ( ) : Transport  { 
125+     if  ( ! this . _options . dsn )  { 
126+       // We return the noop transport here in case there is no Dsn. 
127+       return  super . _setupTransport ( ) ; 
128+     } 
129+ 
130+     const  transportOptions  =  { 
131+       ...this . _options . transportOptions , 
132+       dsn : this . _options . dsn , 
133+       tunnel : this . _options . tunnel , 
134+       sendClientReports : this . _options . sendClientReports , 
135+       _metadata : this . _options . _metadata , 
136+     } ; 
137+ 
138+     if  ( this . _options . transport )  { 
139+       return  new  this . _options . transport ( transportOptions ) ; 
140+     } 
141+     if  ( supportsFetch ( ) )  { 
142+       return  new  FetchTransport ( transportOptions ) ; 
143+     } 
144+     return  new  XHRTransport ( transportOptions ) ; 
77145  } 
78146} 
0 commit comments