如何在我的React应用程序中添加对讲脚本?

问题描述 投票:5回答:2

我正在使用redux-segment进行分析,并正在尝试实现对讲。我遇到的问题实际上是使其加载等。我正在尝试遵循此方法,但仍不确定在哪里输入应用程序ID等。Intercom segment。我想在抓住当前用户时在动作创建器中加载对讲机,但没有有关如何实际加载对讲机的文档。

import { EventTypes } from 'redux-segment';

export function currentUser() {

  const request = user.current(); //this correctly grabs current user.

  if(request == null) {
     //having trouble with this part. load intercom non user specific
  } else {
     load intercom user specific
  }

  return {
    type: CURRENT_USER,
    payload: request
  };
}
reactjs intercom
2个回答
3
投票

[您要做的是将脚本放入对讲机中,或者将其放入index.html中,也可以将其放入条目组件中,以加载其分析对象。

class MyComponent extends Component {
    constructor(props){
        super(props);
        // script to load analytics
    }
    ....
}

1
投票

接受的答案是正确的。详细信息:

class LandingPage extends Component {

  constructor(props) {
    super(props);

    // initialize intercom (don't forget to *update* when page changes)
    window.Intercom("boot", {
      app_id: "your_app_id"
    });
  }
}

https://app.intercom.io/a/apps/bhfx1oqj/messages/guide/identify_your_users/track_users

© www.soinside.com 2019 - 2024. All rights reserved.