π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
feat: enable chatwoot oss
DarkPhoenix270495d086e9657e
diff --git a/packages/nc-gui/components/dashboard/MiniSidebar.vue b/packages/nc-gui/components/dashboard/MiniSidebar.vueindex eeb96c6882..5ceac0d70e 100644--- a/packages/nc-gui/components/dashboard/MiniSidebar.vue+++ b/packages/nc-gui/components/dashboard/MiniSidebar.vue@@ -272,7 +272,7 @@ useEventListener(document, 'keydown', async (e: KeyboardEvent) => {<DashboardSidebarFeed /></NcTooltip></DashboardMiniSidebarItemWrapper>- <DashboardMiniSidebarItemWrapper v-if="!appInfo.disableSupportChat && appInfo.ee">+ <DashboardMiniSidebarItemWrapper v-if="!appInfo.disableSupportChat"><NcTooltip :title="`${$t('labels.chatWithNocoDBSupport')}!`" placement="right" hide-on-click :arrow="false"><DashboardSidebarChatSupport /></NcTooltip>diff --git a/packages/nc-gui/components/dashboard/Sidebar/ChatSupport.vue b/packages/nc-gui/components/dashboard/Sidebar/ChatSupport.vueindex 7c3f5c658a..23ad832e2c 100644--- a/packages/nc-gui/components/dashboard/Sidebar/ChatSupport.vue+++ b/packages/nc-gui/components/dashboard/Sidebar/ChatSupport.vue@@ -1,3 +1,33 @@+<script setup lang="ts">+const { t } = useI18n()++const { isModalVisible } = useChatWoot()++const toggleVisibility = () => {+ // if chatwoot is not initialized, show a message+ if (!isModalVisible.value && !ncIsFunction(window.$chatwoot?.toggle)) {+ message.info({+ title: t('msg.info.supportChatUnavailable'),+ content: t('msg.info.supportChatUnavailableSubtitle'),+ })+ return+ }++ const toggleText = (isModalVisible.value ? 'hide' : 'show') as any+ window.$chatwoot.toggle(toggleText)+}+</script>+<template>- <NcSpanHidden />+ <div v-e="['c:nocodb:chat-support']" class="nc-mini-sidebar-btn-full-width" data-testid="nc-sidebar-chat-support">+ <div+ class="nc-mini-sidebar-btn relative"+ :class="{+ active: isModalVisible,+ }"+ @click="toggleVisibility"+ >+ <GeneralIcon icon="ncSupportAgent" class="h-4.5 w-4.5" />+ </div>+ </div></template>diff --git a/packages/nc-gui/composables/useProvideChatwoot.ts b/packages/nc-gui/composables/useProvideChatwoot.tsindex afb19d3715..b42cff1ce0 100644--- a/packages/nc-gui/composables/useProvideChatwoot.ts+++ b/packages/nc-gui/composables/useProvideChatwoot.ts@@ -1,5 +1,51 @@export const useProvideChatwoot = () => {- const chatwootInit = () => {}+ const { setUser, setConversationCustomAttributes } = useChatWoot()+ const { user, appInfo } = useGlobal()+ const router = useRouter()+ const route = router.currentRoute++ const chatwootReady = ref(false)++ const initUserCustomerAttributes = () => {+ if (!chatwootReady.value || ncIsPlaywright() || !user.value?.id || appInfo.value.disableSupportChat) {+ return+ }++ const baseId = route.value?.params?.baseId as string++ const userId = user.value?.id as string+ const identity_hash = (user.value as any)?.identity_hash as string++ // userId has to be string for chatwoot sdk+ setUser(userId, {+ email: user.value?.email,+ name: user.value?.display_name || '',+ identifier_hash: identity_hash,+ })+ setConversationCustomAttributes({+ user_id: String(userId),+ email: user.value?.email || '',+ base_id: baseId || '',+ })+ }++ const chatwootInit = async () => {+ if (ncIsIframe()) return+ chatwootReady.value = true+ initUserCustomerAttributes()+ }++ watch(+ [() => user.value?.email, () => user.value?.id, () => appInfo.value.disableSupportChat],+ () => {+ initUserCustomerAttributes()+ },+ { immediate: true },+ )++ router.afterEach(() => {+ initUserCustomerAttributes()+ })return {chatwootInit,diff --git a/packages/nocodb/src/services/app-hooks-listener.service.ts b/packages/nocodb/src/services/app-hooks-listener.service.tsindex fcd0e43dce..d9f70b5a6f 100644--- a/packages/nocodb/src/services/app-hooks-listener.service.ts+++ b/packages/nocodb/src/services/app-hooks-listener.service.ts@@ -245,6 +245,12 @@ export class AppHooksListenerService implements OnModuleInit, OnModuleDestroy {case AppEvents.SHARED_BASE_DELETE_LINK:break;case AppEvents.ATTACHMENT_UPLOAD:+ {+ this.telemetryService.sendEvent({+ evt_type: 'image:uploaded',+ type: data?.type,+ });+ }break;case AppEvents.APIS_CREATED:break;