From 66a5d4f3a44171c6040a6db13f7432323ffb24bb Mon Sep 17 00:00:00 2001 From: Chirag <103994754+chiragnotionforms@users.noreply.github.com> Date: Thu, 22 Dec 2022 16:24:01 +0530 Subject: [PATCH] Crisp fix (#42) --- resources/js/base.js | 23 +++++++++++-------- resources/js/middleware/check-auth.js | 2 +- .../js/pages/auth/components/RegisterForm.vue | 6 ++--- resources/js/plugins/vue-plugins.js | 5 ---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/resources/js/base.js b/resources/js/base.js index 89aad18..19f5aec 100644 --- a/resources/js/base.js +++ b/resources/js/base.js @@ -4,7 +4,11 @@ import debounce from 'debounce' export default { - computed: {}, + computed: { + $crisp () { + return window.$crisp + } + }, metaInfo () { const info = { @@ -39,49 +43,50 @@ export default { /** * Show an error message. */ - alertError (message, autoClose=10000) { + alertError (message, autoClose = 10000) { this.$notify( { title: 'Error', text: message, - type: 'error', + type: 'error' }, autoClose) }, /** * Show a success message. */ - alertSuccess (message, autoClose=10000) { + alertSuccess (message, autoClose = 10000) { this.$notify( { title: 'Success', text: message, - type: 'success', + type: 'success' }, autoClose) }, /** * Show a warning message. */ - alertWarning (message, autoClose=10000) { + alertWarning (message, autoClose = 10000) { this.$notify( { title: 'Warning', text: message, - type: 'warning', + type: 'warning' }, autoClose) }, /** * Show confirmation message. */ - alertConfirm (message, success, failure, autoClose= 10000) { + alertConfirm (message, success, failure = ()=>{}, autoClose = 10000) { this.$notify( { title: 'Confirm', text: message, type: 'confirm', - success, failure + success, + failure }, autoClose) }, diff --git a/resources/js/middleware/check-auth.js b/resources/js/middleware/check-auth.js index 4574063..396ebde 100644 --- a/resources/js/middleware/check-auth.js +++ b/resources/js/middleware/check-auth.js @@ -7,7 +7,7 @@ export function initCrisp (user) { window.$crisp.push(['set', 'user:email', user.email]) window.$crisp.push(['set', 'user:nickname', user.name]) window.$crisp.push(['set', 'session:data', [[ - ['pro-subscription', user.is_subscribed], + ['pro-subscription', user?.is_subscribed ?? false], ['id', user.id] ]]]) window.clearInterval(intervalId) diff --git a/resources/js/pages/auth/components/RegisterForm.vue b/resources/js/pages/auth/components/RegisterForm.vue index 8abe171..82933da 100644 --- a/resources/js/pages/auth/components/RegisterForm.vue +++ b/resources/js/pages/auth/components/RegisterForm.vue @@ -111,9 +111,9 @@ export default { // Track event this.$logEvent('register', { source: this.form.hear_about_us }) - initCrisp(data).then(() => { - this.$getCrisp().push(['set', 'session:event', [[['register', {}, 'blue']]]]) - }) + + initCrisp(data) + this.$crisp.push(['set', 'session:event', [[['register', {}, 'blue']]]]) // Redirect if(this.isQuick){ diff --git a/resources/js/plugins/vue-plugins.js b/resources/js/plugins/vue-plugins.js index bcec051..a6e0194 100644 --- a/resources/js/plugins/vue-plugins.js +++ b/resources/js/plugins/vue-plugins.js @@ -1,12 +1,7 @@ import Vue from 'vue' import PortalVue from 'portal-vue' - import Notifications from "vt-notifications" Vue.use(PortalVue) Vue.use(Notifications) - -Vue.prototype.$getCrisp = () => { - return window.$crisp -}