@@ -18,6 +18,8 @@ const INTERCOM_KEY = 'p57suhg7';
1818const BUGSNAG_KEY = '0d11ab5f4d97452cc83d3365c21b491c' ;
1919
2020module . exports = function ( ) {
21+ let intercomBlocked = false ;
22+
2123 metrics . configure ( {
2224 stitch : {
2325 appId : 'compass-metrics-irinb' ,
@@ -36,13 +38,32 @@ module.exports = function() {
3638 } ) ;
3739
3840 if ( process . env . HADRON_PRODUCT !== 'mongodb-compass-community' ) {
39- metrics . configure ( {
40- intercom : {
41- appId : INTERCOM_KEY ,
42- enabled : app . preferences . trackUsageStatistics ,
43- panelEnabled : app . preferences . enableFeedbackPanel
41+ const request = new XMLHttpRequest ( ) ;
42+ request . onreadystatechange = ( ) => {
43+ try {
44+ if ( request . readyState === XMLHttpRequest . DONE ) {
45+ if ( request . status < 400 ) {
46+ metrics . configure ( {
47+ intercom : {
48+ appId : INTERCOM_KEY ,
49+ enabled : app . preferences . trackUsageStatistics ,
50+ panelEnabled : app . preferences . enableFeedbackPanel
51+ }
52+ } ) ;
53+ } else {
54+ intercomBlocked = true ;
55+ }
56+ }
57+ } catch ( e ) {
58+ intercomBlocked = true ;
4459 }
45- } ) ;
60+ } ;
61+ try {
62+ request . open ( 'GET' , format ( 'https://widget.intercom.io/widget/%s' , INTERCOM_KEY ) , true ) ;
63+ request . send ( ) ;
64+ } catch ( e ) {
65+ intercomBlocked = true ;
66+ }
4667 }
4768
4869 // create an app resource with name and version
@@ -142,7 +163,7 @@ module.exports = function() {
142163 * such that when a link is clicked, the event is properly
143164 * passed off to `app.router` and a web page actually opens.
144165 */
145- if ( process . env . HADRON_PRODUCT !== 'mongodb-compass-community' ) {
166+ if ( process . env . HADRON_PRODUCT !== 'mongodb-compass-community' && ! intercomBlocked ) {
146167 intercom . configure ( ) ;
147168 }
148169
0 commit comments