@@ -85,6 +85,13 @@ export interface BrowserTracingOptions {
85
85
// TODO: Should this be an option, or a static class variable and passed
86
86
// in and we use something like `BrowserTracing.addRoutingProcessor()`
87
87
routingInstrumentationProcessors : routingInstrumentationProcessor [ ] ;
88
+
89
+ /**
90
+ * Flag to enable default routing instrumentation.
91
+ *
92
+ * Default: true
93
+ */
94
+ defaultRoutingInstrumentation : boolean ;
88
95
}
89
96
90
97
/**
@@ -120,6 +127,7 @@ export class BrowserTracing implements Integration {
120
127
debug : {
121
128
writeAsBreadcrumbs : false ,
122
129
} ,
130
+ defaultRoutingInstrumentation : true ,
123
131
idleTimeout : DEFAULT_IDLE_TIMEOUT ,
124
132
routingInstrumentationProcessors : [ ] ,
125
133
startTransactionOnLocationChange : true ,
@@ -143,15 +151,17 @@ export class BrowserTracing implements Integration {
143
151
144
152
// TODO: is it fine that this is mutable operation? Could also do = [...routingInstr, setHeaderContext]?
145
153
BrowserTracing . options . routingInstrumentationProcessors . push ( setHeaderContext ) ;
146
- BrowserTracing . _initRoutingInstrumentation ( ) ;
154
+ if ( BrowserTracing . options . defaultRoutingInstrumentation ) {
155
+ BrowserTracing . _initRoutingInstrumentation ( ) ;
156
+ }
147
157
}
148
158
149
159
/** Start routing instrumentation */
150
160
private static _initRoutingInstrumentation ( ) : void {
151
161
const { startTransactionOnPageLoad, startTransactionOnLocationChange } = BrowserTracing . options ;
152
162
153
163
if ( startTransactionOnPageLoad ) {
154
- BrowserTracing . _activeTransaction = BrowserTracing . _createRouteTransaction ( 'pageload' ) ;
164
+ BrowserTracing . _activeTransaction = BrowserTracing . createRouteTransaction ( 'pageload' ) ;
155
165
}
156
166
157
167
let startingUrl : string | undefined = global . location . href ;
@@ -178,15 +188,18 @@ export class BrowserTracing implements Integration {
178
188
// are navigating to a new page.
179
189
BrowserTracing . _activeTransaction . finishIdleTransaction ( ) ;
180
190
}
181
- BrowserTracing . _activeTransaction = BrowserTracing . _createRouteTransaction ( 'navigation' ) ;
191
+ BrowserTracing . _activeTransaction = BrowserTracing . createRouteTransaction ( 'navigation' ) ;
182
192
}
183
193
} ,
184
194
type : 'history' ,
185
195
} ) ;
186
196
}
187
197
188
198
/** Create pageload/navigation idle transaction. */
189
- private static _createRouteTransaction ( op : 'pageload' | 'navigation' ) : IdleTransaction | undefined {
199
+ public static createRouteTransaction (
200
+ op : 'pageload' | 'navigation' ,
201
+ ctx ?: TransactionContext ,
202
+ ) : IdleTransaction | undefined {
190
203
if ( ! BrowserTracing . _getCurrentHub ) {
191
204
return undefined ;
192
205
}
@@ -199,7 +212,7 @@ export class BrowserTracing implements Integration {
199
212
return undefined ;
200
213
}
201
214
202
- let context : TransactionContext = { name, op } ;
215
+ let context : TransactionContext = { name, op, ... ctx } ;
203
216
if ( routingInstrumentationProcessors ) {
204
217
for ( const processor of routingInstrumentationProcessors ) {
205
218
context = processor ( context ) ;
0 commit comments