Skip to content
This repository has been archived by the owner on May 1, 2023. It is now read-only.

Freshchat.addEventListener is calling multiple times #21

Open
Naveen9453 opened this issue May 1, 2023 · 0 comments
Open

Freshchat.addEventListener is calling multiple times #21

Naveen9453 opened this issue May 1, 2023 · 0 comments

Comments

@Naveen9453
Copy link

Hello Team,
Freshchat.addEventListener event is calling multiple times.

Below is the code snippet :

useEffect(() => {
Freshchat.addEventListener(Freshchat.EVENT_USER_RESTORE_ID_GENERATED, () => {
Freshchat.getUser((user) => {
const restoreId = user.restoreId;
const externalId = user.externalId;
try {

        **callUpdateFCPRofile(externalId, restoreId);**
      
    } catch (e) {
      //
    }
    Freshchat.identifyUser(externalId, restoreId, (error) => {
      CommonBugFender('freshchat_event_identifyUser', error, BUSINESS_VERTICAL.NH);
    });
  });
});

}, [currentPatient?.mobileNumber]);

Here callUpdateFCPRofile(externalId, restoreId); method is calling multiple times due to which API is hitting multiple times. I checked with putting log observed that Freshchat.addEventListener is triggering multiple times when a new user initiating the chat (sending the first message).

Why it is triggering multiple times? it supposed to be triggered only one time.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant