@@ -123,11 +123,7 @@ Raven.prototype = {
123123 } ) ;
124124 }
125125
126- var uri = this . _parseDSN ( dsn ) ,
127- lastSlash = uri . path . lastIndexOf ( '/' ) ,
128- path = uri . path . substr ( 1 , lastSlash ) ;
129-
130- this . _dsn = dsn ;
126+ this . setDSN ( dsn ) ;
131127
132128 // "Script error." is hard coded into browsers for errors that it can't read.
133129 // this is the result of a script being pulled in from an external domain and CORS.
@@ -156,15 +152,6 @@ Raven.prototype = {
156152 }
157153 this . _globalOptions . autoBreadcrumbs = autoBreadcrumbs ;
158154
159- this . _globalKey = uri . user ;
160- this . _globalSecret = uri . pass && uri . pass . substr ( 1 ) ;
161- this . _globalProject = uri . path . substr ( lastSlash + 1 ) ;
162-
163- this . _globalServer = this . _getGlobalServer ( uri ) ;
164-
165- this . _globalEndpoint = this . _globalServer +
166- '/' + path + 'api/' + this . _globalProject + '/store/' ;
167-
168155 TraceKit . collectWindowErrors = ! ! this . _globalOptions . collectWindowErrors ;
169156
170157 // return for chaining
@@ -199,6 +186,27 @@ Raven.prototype = {
199186 return this ;
200187 } ,
201188
189+ /*
190+ * Set the DSN (can be called multiple time unlike config)
191+ *
192+ * @param {string } dsn The public Sentry DSN
193+ */
194+ setDSN : function ( dsn ) {
195+ var uri = this . _parseDSN ( dsn ) ,
196+ lastSlash = uri . path . lastIndexOf ( '/' ) ,
197+ path = uri . path . substr ( 1 , lastSlash ) ;
198+
199+ this . _dsn = dsn ;
200+ this . _globalKey = uri . user ;
201+ this . _globalSecret = uri . pass && uri . pass . substr ( 1 ) ;
202+ this . _globalProject = uri . path . substr ( lastSlash + 1 ) ;
203+
204+ this . _globalServer = this . _getGlobalServer ( uri ) ;
205+
206+ this . _globalEndpoint = this . _globalServer +
207+ '/' + path + 'api/' + this . _globalProject + '/store/' ;
208+ } ,
209+
202210 /*
203211 * Wrap code within a context so Raven can capture errors
204212 * reliably across domains that is executed immediately.
0 commit comments