@@ -21,6 +21,7 @@ import ConfigStore from 'app/stores/configStore';
21
21
import Main from 'app/main' ;
22
22
import ajaxCsrfSetup from 'app/utils/ajaxCsrfSetup' ;
23
23
import plugins from 'app/plugins' ;
24
+ import { startApm } from 'app/utils/apm' ;
24
25
25
26
// SDK INIT --------------------------------------------------------
26
27
Sentry . init ( {
@@ -43,8 +44,6 @@ Sentry.configureScope(scope => {
43
44
if ( window . __SENTRY__VERSION ) {
44
45
scope . setTag ( 'sentry_version' , window . __SENTRY__VERSION ) ;
45
46
}
46
- // TODO(daniel): Maybe we need to follows from
47
- // This is the inital pageload span
48
47
scope . setSpan (
49
48
Sentry . getCurrentHub ( ) . startSpan ( {
50
49
op : 'pageload' ,
@@ -53,50 +52,6 @@ Sentry.configureScope(scope => {
53
52
) ;
54
53
} ) ;
55
54
56
- // APM --------------------------------------------------------------
57
- let flushTransactionTimeout = undefined ;
58
- let firstPageLoad = true ;
59
-
60
- function trackTrace ( ) {
61
- // We do set the transaction name in the router but we want to start it here
62
- // since in the App component where we set the transaction name, it's called multiple
63
- // times. This would result in losing the start of the transaction.
64
- let transactionSpan ;
65
- const hub = Sentry . getCurrentHub ( ) ;
66
- hub . configureScope ( scope => {
67
- if ( firstPageLoad ) {
68
- transactionSpan = scope . getSpan ( ) ;
69
- firstPageLoad = false ;
70
- } else {
71
- const prevTransactionSpan = scope . getSpan ( ) ;
72
- // If there is a transaction we set the name to the route
73
- if ( prevTransactionSpan && prevTransactionSpan . timestamp === undefined ) {
74
- hub . finishSpan ( prevTransactionSpan ) ;
75
- }
76
- transactionSpan = hub . startSpan ( {
77
- op : 'navigation' ,
78
- sampled : true ,
79
- } ) ;
80
- }
81
- scope . setSpan ( transactionSpan ) ;
82
- } ) ;
83
-
84
- if ( flushTransactionTimeout ) {
85
- clearTimeout ( flushTransactionTimeout ) ;
86
- }
87
-
88
- flushTransactionTimeout = setTimeout ( ( ) => {
89
- hub . finishSpan ( transactionSpan ) ;
90
- } , 5000 ) ;
91
- }
92
-
93
- trackTrace ( ) ;
94
- Router . browserHistory . listen ( ( ) => {
95
- trackTrace ( ) ;
96
- } ) ;
97
-
98
- // -----------------------------------------------------------------
99
-
100
55
// Used for operational metrics to determine that the application js
101
56
// bundle was loaded by browser.
102
57
metric . mark ( 'sentry-app-init' ) ;
@@ -112,6 +67,19 @@ if (window.__initialData) {
112
67
ConfigStore . loadInitialData ( window . __initialData ) ;
113
68
}
114
69
70
+ // APM -------------------------------------------------------------
71
+ const config = ConfigStore . getConfig ( ) ;
72
+ // This is just a simple gatekeeper to not enable apm for whole sentry.io at first
73
+ if (
74
+ config &&
75
+ config . userIdentity &&
76
+ config . userIdentity . email &&
77
+ config . userIdentity . email . includes ( 'sentry' )
78
+ ) {
79
+ startApm ( ) ;
80
+ }
81
+ // -----------------------------------------------------------------
82
+
115
83
// these get exported to a global variable, which is important as its the only
116
84
// way we can call into scoped objects
117
85
0 commit comments