message: fix(app): Grab intercom handler from window on every call
  Our support module was caching the intercom handler too early (before
  the window had a chance to load), resulting in all our intercom calls
  nooping. This change removes the caching so window.Intercom is always
  called correctly.
diff: // @flow
  // user support module
  -import noop from 'lodash/noop'
  -
  import {version} from './../package.json'
  import createLogger from './logger'
  @@ -15,10 +13,17 @@ const log = createLogger(__filename)
  // pulled in from environment at build time
  const INTERCOM_ID = process.env.OT_APP_INTERCOM_ID
  -// intercom handler (default noop)
  -let intercom = noop
  +// intercom user ID
  let userId
  +// intercom handler (default noop)
  +const intercom = (...args) => {
  + if (INTERCOM_ID && global.Intercom) {
  + log.debug('Sending to Intercom', {args})
  + global.Intercom(...args)
  + }
  +}
  +
  export function initializeSupport (): ThunkAction {
  return (_, getState) => {
  const config = getState().config.support
  @@ -32,9 +37,8 @@ export const supportMiddleware: Middleware = (store) => (next) => (action) => {
  if (action.type === 'robot:CONNECT_RESPONSE') {
  const state = store.getState()
  const robot = state.robot.connection.connectRequest.name
  - const data = {user_id: userId, 'Robot Name': robot}
  - log.debug('Updating intercom data', {data})
  - intercom('update', {data})
  +
  + intercom('update', {user_id: userId, 'Robot Name': robot})
  }
  return next(action)
  @@ -44,16 +48,12 @@ function initializeIntercom (config: SupportConfig) {
  if (INTERCOM_ID) {
  userId = config.userId
  - const data = {
  + intercom('boot', {
  app_id: INTERCOM_ID,
  user_id: userId,
  created_at: config.createdAt,
  name: config.name,
  'App Version': version
  - }
  -
  - log.debug('Initializing Intercom', {data})
  - intercom = global.Intercom || intercom
  - intercom('boot', data)
  + })
  }
  }
  