this.filters.forEach(filter => { SDK.Hooks.addFilter(filter, this[filter].bind(this)); }); this.actions.forEach(action => { SDK.Hooks.addAction(action, this[action].bind(this)); }); this.bootIntercom = this.bootIntercom.bind(this); this.onIntercomStoreUpdate = this.onIntercomStoreUpdate.bind(this); const intercomScript = ` var APP_ID = "${this.configuration.appId}"; (function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/' + APP_ID;var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})() `; DOMUtils.appendScript(global.document.head, intercomScript); }, pluginsLoadedCheck(promiseArray) { const promise = new Promise(resolve => { if (global.Intercom) { resolve(); } setTimeout(resolve, INTERCOM_LOAD_TIMEOUT); }); promiseArray.push(promise); return promiseArray; },
this.configuration = configuration; this.filters.forEach(filter => { SDK.Hooks.addFilter(filter, this[filter].bind(this)); }); this.actions.forEach(action => { SDK.Hooks.addAction(action, this[action].bind(this)); }); Actions.initialize(); if (AuthStore.getUser()) { Actions.identify(AuthStore.getUser().uid); } DOMUtils.appendScript(global.document.head, segmentScript); }, pluginsLoadedCheck(promiseArray) { const promise = new Promise(resolve => { global.analytics.ready(() => { resolve(); }); // Let's not block the application loading in case it takes a really // long time to ready-up analytics or the integrations. global.setTimeout(resolve, ANALYTICS_LOAD_TIMEOUT); }); promiseArray.push(promise);