@@ -18,6 +18,8 @@ const INTERCOM_KEY = 'p57suhg7';
18
18
const BUGSNAG_KEY = '0d11ab5f4d97452cc83d3365c21b491c' ;
19
19
20
20
module . exports = function ( ) {
21
+ let intercomBlocked = false ;
22
+
21
23
metrics . configure ( {
22
24
stitch : {
23
25
appId : 'compass-metrics-irinb' ,
@@ -36,13 +38,32 @@ module.exports = function() {
36
38
} ) ;
37
39
38
40
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 ;
44
59
}
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
+ }
46
67
}
47
68
48
69
// create an app resource with name and version
@@ -142,7 +163,7 @@ module.exports = function() {
142
163
* such that when a link is clicked, the event is properly
143
164
* passed off to `app.router` and a web page actually opens.
144
165
*/
145
- if ( process . env . HADRON_PRODUCT !== 'mongodb-compass-community' ) {
166
+ if ( process . env . HADRON_PRODUCT !== 'mongodb-compass-community' && ! intercomBlocked ) {
146
167
intercom . configure ( ) ;
147
168
}
148
169
0 commit comments