Copy the Chatwoot (v4.14.0) frontend runnable subset into frontend/ for customization: - app/javascript/ (Vue SPA: dashboard, widget, sdk, portal, superadmin) - app/views/ (ERB templates for vite-plugin-ruby entrypoint resolution) - app/helpers/, app/assets/ (Rails view helpers, static assets) - enterprise/ (Enterprise edition frontend overlay) - config/vite.json, vite.config.ts, bin/vite (Vite-Rails toolchain) - package.json, pnpm-lock.yaml, tailwind/postcss/eslint configs - Gemfile, Gemfile.lock (vite_rails gem for bin/vite binstub) Excluded Rails backend: controllers, models, services, jobs, mailers, policies, db, lib, spec, public, node_modules. Update references to the new frontend location: - .gitignore: exclude frontend build artifacts (node_modules, tmp, packs), keep frontend/bin/ and frontend/vendor/ via negation - backend/scripts/parity_frontend_smoke.sh: CHATWOOT_DIR default reference/chatwoot -> ../frontend - backend/scripts/parity_frontend_browser_smoke.mjs: same default update - AGENTS.md: add frontend section with Rails/Vite coupling notes - README: architecture tree includes frontend/
61 lines
1.8 KiB
JavaScript
61 lines
1.8 KiB
JavaScript
import {
|
|
ANALYTICS_IDENTITY,
|
|
CHATWOOT_RESET,
|
|
CHATWOOT_SET_USER,
|
|
} from '../constants/appEvents';
|
|
import AnalyticsHelper from './AnalyticsHelper';
|
|
import DashboardAudioNotificationHelper from './AudioAlerts/DashboardAudioNotificationHelper';
|
|
import { emitter } from 'shared/helpers/mitt';
|
|
|
|
export const initializeAnalyticsEvents = () => {
|
|
AnalyticsHelper.init();
|
|
emitter.on(ANALYTICS_IDENTITY, ({ user }) => {
|
|
AnalyticsHelper.identify(user);
|
|
});
|
|
};
|
|
|
|
export const initializeAudioAlerts = user => {
|
|
const { ui_settings: uiSettings } = user || {};
|
|
const {
|
|
always_play_audio_alert: alwaysPlayAudioAlert,
|
|
enable_audio_alerts: audioAlertType,
|
|
alert_if_unread_assigned_conversation_exist: alertIfUnreadConversationExist,
|
|
notification_tone: audioAlertTone,
|
|
// UI Settings can be undefined initially as we don't send the
|
|
// entire payload for the user during the signup process.
|
|
} = uiSettings || {};
|
|
|
|
DashboardAudioNotificationHelper.set({
|
|
currentUser: user,
|
|
audioAlertType: audioAlertType || 'none',
|
|
audioAlertTone: audioAlertTone || 'ding',
|
|
alwaysPlayAudioAlert: alwaysPlayAudioAlert || false,
|
|
alertIfUnreadConversationExist: alertIfUnreadConversationExist || false,
|
|
});
|
|
};
|
|
|
|
export const initializeChatwootEvents = () => {
|
|
emitter.on(CHATWOOT_RESET, () => {
|
|
if (window.$chatwoot) {
|
|
window.$chatwoot.reset();
|
|
}
|
|
});
|
|
emitter.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',
|
|
account_id: user.account_id,
|
|
});
|
|
}
|
|
|
|
initializeAudioAlerts(user);
|
|
});
|
|
};
|