File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -11,8 +11,9 @@ module Exceptionless {
1111 export class ExceptionlessClient {
1212 public config :Configuration ;
1313
14- constructor ( apiKey :string , serverUrl ?:string ) {
15- this . config = new Configuration ( apiKey , serverUrl ) ;
14+ constructor ( apiKey ?:string , serverUrl ?:string ) {
15+ var settings = this . getSettingsFromScriptTag ( ) || { } ;
16+ this . config = new Configuration ( apiKey || settings . apiKey , serverUrl || settings . serverUrl ) ;
1617 }
1718
1819 public createException ( exception :Error ) : EventBuilder {
@@ -171,6 +172,18 @@ module Exceptionless {
171172 }
172173 }
173174
175+ private getSettingsFromScriptTag ( ) : any {
176+ var scripts = document . getElementsByTagName ( 'script' ) ;
177+
178+ for ( var index = 0 ; index < scripts . length ; index ++ ) {
179+ if ( scripts [ index ] . src && scripts [ index ] . src . indexOf ( '/exceptionless' ) > - 1 ) {
180+ return Utils . parseQueryString ( scripts [ index ] . src . split ( '?' ) . pop ( ) ) ;
181+ }
182+ }
183+
184+ return null ;
185+ }
186+
174187 private static _instance :ExceptionlessClient = null ;
175188 public static get default ( ) {
176189 if ( ExceptionlessClient . _instance === null ) {
You can’t perform that action at this time.
0 commit comments