2022-12-09 04:53:13 +00:00
|
|
|
import AnalyticsHelper from './AnalyticsHelper';
|
2021-09-07 17:41:01 +00:00
|
|
|
|
|
|
|
export const CHATWOOT_SET_USER = 'CHATWOOT_SET_USER';
|
|
|
|
export const CHATWOOT_RESET = 'CHATWOOT_RESET';
|
|
|
|
|
|
|
|
export const ANALYTICS_IDENTITY = 'ANALYTICS_IDENTITY';
|
|
|
|
export const ANALYTICS_RESET = 'ANALYTICS_RESET';
|
|
|
|
|
|
|
|
export const initializeAnalyticsEvents = () => {
|
|
|
|
window.bus.$on(ANALYTICS_IDENTITY, ({ user }) => {
|
2022-12-09 04:53:13 +00:00
|
|
|
AnalyticsHelper.identify(user);
|
2021-09-07 17:41:01 +00:00
|
|
|
});
|
2022-12-09 04:53:13 +00:00
|
|
|
window.bus.$on(ANALYTICS_RESET, () => {});
|
2021-09-07 17:41:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const initializeChatwootEvents = () => {
|
|
|
|
window.bus.$on(CHATWOOT_RESET, () => {
|
|
|
|
if (window.$chatwoot) {
|
|
|
|
window.$chatwoot.reset();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
window.bus.$on(CHATWOOT_SET_USER, ({ user }) => {
|
|
|
|
if (window.$chatwoot) {
|
|
|
|
window.$chatwoot.setUser(user.email, {
|
|
|
|
avatar_url: user.avatar_url,
|
|
|
|
email: user.email,
|
|
|
|
identifier_hash: user.hmac_identifier,
|
|
|
|
name: user.name,
|
|
|
|
});
|
|
|
|
window.$chatwoot.setCustomAttributes({
|
|
|
|
signedUpAt: user.created_at,
|
|
|
|
cloudCustomer: 'true',
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|