@@ -123,11 +123,7 @@ Raven.prototype = {
123
123
} ) ;
124
124
}
125
125
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 ) ;
131
127
132
128
// "Script error." is hard coded into browsers for errors that it can't read.
133
129
// this is the result of a script being pulled in from an external domain and CORS.
@@ -156,15 +152,6 @@ Raven.prototype = {
156
152
}
157
153
this . _globalOptions . autoBreadcrumbs = autoBreadcrumbs ;
158
154
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
-
168
155
TraceKit . collectWindowErrors = ! ! this . _globalOptions . collectWindowErrors ;
169
156
170
157
// return for chaining
@@ -199,6 +186,27 @@ Raven.prototype = {
199
186
return this ;
200
187
} ,
201
188
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
+
202
210
/*
203
211
* Wrap code within a context so Raven can capture errors
204
212
* reliably across domains that is executed immediately.
0 commit comments