feat: Integrate LogRocket (#6494)

* feat: install logrocket

* feat: allow log rocket

* feat: enable vuex log-rocket

* feat: integrate vuex with log rocket

* feat: add log rocket identify

* fix: identify if log rocket is initialized

---------

Co-authored-by: Vishnu Narayanan <vishnu@chatwoot.com>
This commit is contained in:
Shivam Mishra
2023-02-21 08:42:45 +05:30
committed by GitHub
parent 26f164d6a0
commit 62de25960c
6 changed files with 43 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
import AnalyticsHelper from './AnalyticsHelper';
import LogRocket from 'logrocket';
import DashboardAudioNotificationHelper from './AudioAlerts/DashboardAudioNotificationHelper';
export const CHATWOOT_SET_USER = 'CHATWOOT_SET_USER';
@@ -10,6 +11,12 @@ export const ANALYTICS_RESET = 'ANALYTICS_RESET';
export const initializeAnalyticsEvents = () => {
window.bus.$on(ANALYTICS_IDENTITY, ({ user }) => {
AnalyticsHelper.identify(user);
if (window.logRocketProjectId) {
LogRocket.identify(user.id, {
email: user.email,
name: user.name,
});
}
});
window.bus.$on(ANALYTICS_RESET, () => {});
};

View File

@@ -42,6 +42,25 @@ import teams from './modules/teams';
import userNotificationSettings from './modules/userNotificationSettings';
import webhooks from './modules/webhooks';
import LogRocket from 'logrocket';
import createPlugin from 'logrocket-vuex';
const plugins = [];
if (window.logRocketProjectId) {
LogRocket.init(window.logRocketProjectId);
const logRocketPlugin = createPlugin(LogRocket, function(mutation) {
const eventsToIgnore = ['SET_CURRENT_USER', 'AUTHENTICATE', 'CLEAR_USER'];
if (eventsToIgnore.includes(mutation.type)) {
return null;
}
return mutation;
});
plugins.push(logRocketPlugin);
}
Vue.use(Vuex);
export default new Vuex.Store({
modules: {
@@ -86,4 +105,5 @@ export default new Vuex.Store({
userNotificationSettings,
webhooks,
},
plugins,
});