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

Freshchat.addEventListener is calling multiple times #21

@Naveen9453

Description

@Naveen9453

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions