diff --git a/.env.example b/.env.example index 149d1f6e6..39d5c06ec 100644 --- a/.env.example +++ b/.env.example @@ -169,6 +169,9 @@ USE_INBOX_AVATAR_FOR_BOT=true ## Sentry # SENTRY_DSN= +## LogRocket +# LOG_ROCKET_PROJECT_ID=xxxxx/some-project + ## Scout ## https://scoutapm.com/docs/ruby/configuration # SCOUT_KEY=YOURKEY diff --git a/app/javascript/dashboard/helper/scriptHelpers.js b/app/javascript/dashboard/helper/scriptHelpers.js index 3aa0f5379..90b872363 100644 --- a/app/javascript/dashboard/helper/scriptHelpers.js +++ b/app/javascript/dashboard/helper/scriptHelpers.js @@ -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, () => {}); }; diff --git a/app/javascript/dashboard/store/index.js b/app/javascript/dashboard/store/index.js index 632c14d2c..e2d34f50d 100755 --- a/app/javascript/dashboard/store/index.js +++ b/app/javascript/dashboard/store/index.js @@ -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, }); diff --git a/app/views/layouts/vueapp.html.erb b/app/views/layouts/vueapp.html.erb index 4c0c62a49..eba020c8b 100644 --- a/app/views/layouts/vueapp.html.erb +++ b/app/views/layouts/vueapp.html.erb @@ -51,6 +51,7 @@ browser_name: '<%= browser.name %>', } window.errorLoggingConfig = '<%= ENV.fetch('SENTRY_DSN', '')%>' + window.logRocketProjectId = '<%= ENV.fetch('LOG_ROCKET_PROJECT_ID', '')%>' <% if @global_config['ANALYTICS_TOKEN'].present? %>