feat: Add chatwoot:error
sdk event (#3998)
This commit is contained in:
parent
3b015d4dd8
commit
7ba24b90c4
12 changed files with 59 additions and 29 deletions
|
@ -23,8 +23,9 @@ import {
|
|||
removeUnreadClass,
|
||||
} from './bubbleHelpers';
|
||||
import { dispatchWindowEvent } from 'shared/helpers/CustomEventHelper';
|
||||
|
||||
const EVENT_NAME = 'chatwoot:ready';
|
||||
import { CHATWOOT_ERROR, CHATWOOT_READY } from '../widget/constants/sdkEvents';
|
||||
import { SET_USER_ERROR } from '../widget/constants/errorTypes';
|
||||
import { getUserCookieName } from './cookieHelpers';
|
||||
|
||||
export const IFrameHelper = {
|
||||
getUrl({ baseUrl, websiteToken }) {
|
||||
|
@ -129,7 +130,14 @@ export const IFrameHelper = {
|
|||
if (window.$chatwoot.user) {
|
||||
IFrameHelper.sendMessage('set-user', window.$chatwoot.user);
|
||||
}
|
||||
dispatchWindowEvent(EVENT_NAME);
|
||||
dispatchWindowEvent({ eventName: CHATWOOT_READY });
|
||||
},
|
||||
error: ({ errorType, data }) => {
|
||||
dispatchWindowEvent({ eventName: CHATWOOT_ERROR, data: data });
|
||||
|
||||
if (errorType === SET_USER_ERROR) {
|
||||
Cookies.remove(getUserCookieName());
|
||||
}
|
||||
},
|
||||
|
||||
setBubbleLabel(message) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue