@@ -21,6 +21,7 @@ import ConfigStore from 'app/stores/configStore';
2121import Main from 'app/main' ;
2222import ajaxCsrfSetup from 'app/utils/ajaxCsrfSetup' ;
2323import plugins from 'app/plugins' ;
24+ import { startApm } from 'app/utils/apm' ;
2425
2526// SDK INIT --------------------------------------------------------
2627Sentry . init ( {
@@ -43,8 +44,6 @@ Sentry.configureScope(scope => {
4344 if ( window . __SENTRY__VERSION ) {
4445 scope . setTag ( 'sentry_version' , window . __SENTRY__VERSION ) ;
4546 }
46- // TODO(daniel): Maybe we need to follows from
47- // This is the inital pageload span
4847 scope . setSpan (
4948 Sentry . getCurrentHub ( ) . startSpan ( {
5049 op : 'pageload' ,
@@ -53,50 +52,6 @@ Sentry.configureScope(scope => {
5352 ) ;
5453} ) ;
5554
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-
10055// Used for operational metrics to determine that the application js
10156// bundle was loaded by browser.
10257metric . mark ( 'sentry-app-init' ) ;
@@ -112,6 +67,19 @@ if (window.__initialData) {
11267 ConfigStore . loadInitialData ( window . __initialData ) ;
11368}
11469
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+
11583// these get exported to a global variable, which is important as its the only
11684// way we can call into scoped objects
11785
0 commit comments