@@ -6,6 +6,8 @@ import { IdleTransaction } from '../idletransaction';
6
6
import { Span as SpanClass } from '../span' ;
7
7
import { SpanStatus } from '../spanstatus' ;
8
8
9
+ import { registerBackgroundTabDetection } from './tracing/backgroundtab' ;
10
+ import { registerErrorHandlers } from './tracing/errors' ;
9
11
import {
10
12
defaultRequestInstrumentionOptions ,
11
13
RequestInstrumentationClass ,
@@ -20,12 +22,6 @@ import {
20
22
} from './tracing/router' ;
21
23
22
24
/**
23
- * TODO: _setupErrorHandling
24
- * - This should be a integration that runs automatically
25
- * TODO: _setupBackgroundTabDetection
26
- * - This something that works automatically too
27
- * - This just cancels active pageload/navigation on scope
28
- * - Provide option to to extend to all transactions??
29
25
* TODO: Tracing._addPerformanceEntries
30
26
* - This is a beforeFinish() hook here
31
27
*/
@@ -43,6 +39,15 @@ export type BrowserTracingOptions = {
43
39
*/
44
40
maxTransactionDuration : number ;
45
41
42
+ /**
43
+ * Flag Transactions where tabs moved to background with "cancelled". Browser background tab timing is
44
+ * not suited towards doing precise measurements of operations. Background transaction can mess up your
45
+ * statistics in non deterministic ways that's why we by default recommend leaving this opition enabled.
46
+ *
47
+ * Default: true
48
+ */
49
+ markBackgroundTransactions : boolean ;
50
+
46
51
/**
47
52
* This is only if you want to debug in prod.
48
53
* writeAsBreadcrumbs: Instead of having console.log statements we log messages to breadcrumbs
@@ -120,6 +125,10 @@ export class BrowserTracing implements Integration {
120
125
121
126
BrowserTracing . _initRoutingInstrumentation ( hub ) ;
122
127
BrowserTracing . _initRequestInstrumentation ( ) ;
128
+ registerErrorHandlers ( ) ;
129
+ if ( BrowserTracing . options . markBackgroundTransactions ) {
130
+ registerBackgroundTabDetection ( ) ;
131
+ }
123
132
124
133
// This EventProcessor makes sure that the transaction is not longer than maxTransactionDuration
125
134
addGlobalEventProcessor ( ( event : Event ) => {
@@ -139,7 +148,7 @@ export class BrowserTracing implements Integration {
139
148
event . type === 'transaction' &&
140
149
isOutdatedTransaction
141
150
) {
142
- BrowserTracing . _log ( `[Tracing] Transaction: ${ SpanStatus . Cancelled } since it maxed out maxTransactionDuration` ) ;
151
+ BrowserTracing . log ( `[Tracing] Transaction: ${ SpanStatus . Cancelled } since it maxed out maxTransactionDuration` ) ;
143
152
if ( event . contexts && event . contexts . trace ) {
144
153
event . contexts . trace = {
145
154
...event . contexts . trace ,
@@ -205,7 +214,7 @@ export class BrowserTracing implements Integration {
205
214
if ( header ) {
206
215
const span = SpanClass . fromTraceparent ( header ) ;
207
216
if ( span ) {
208
- BrowserTracing . _log (
217
+ BrowserTracing . log (
209
218
`[Tracing] found 'sentry-meta' '<meta />' continuing trace with: trace_id: ${ span . traceId } span_id: ${
210
219
span . parentSpanId
211
220
} `,
@@ -225,7 +234,7 @@ export class BrowserTracing implements Integration {
225
234
/**
226
235
* Uses logger.log to log things in the SDK or as breadcrumbs if defined in options
227
236
*/
228
- private static _log ( ...args : any [ ] ) : void {
237
+ public static log ( ...args : any [ ] ) : void {
229
238
if ( BrowserTracing . options && BrowserTracing . options . debug && BrowserTracing . options . debug . writeAsBreadcrumbs ) {
230
239
const _getCurrentHub = BrowserTracing . _getCurrentHub ;
231
240
if ( _getCurrentHub ) {
0 commit comments