Skip to content

Commit cacd1b4

Browse files
[WEB-5559] improvement: chat support functionality and remove Intercom provider (#8217)
* [WEB-5559] improve: chat support functionality and remove Intercom provider - Added ChatSupportModal component for chat support integration. - Replaced IntercomProvider with ChatSupportModal in AppProvider. - Introduced useChatSupport hook to manage chat support state and actions. - Updated help commands to utilize chat support instead of Intercom. - Removed obsolete Intercom-related components and hooks. * refactor: lazy load ChatSupportModal in AppProvider
1 parent e650b19 commit cacd1b4

File tree

12 files changed

+97
-394
lines changed

12 files changed

+97
-394
lines changed

apps/web/app/provider.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ const PostHogProvider = lazy(function PostHogProvider() {
2525
return import("@/lib/posthog-provider");
2626
});
2727

28-
const IntercomProvider = lazy(function IntercomProvider() {
29-
return import("@/lib/intercom-provider");
28+
const ChatSupportModal = lazy(function ChatSupportModal() {
29+
return import("@/components/global/chat-support-modal");
3030
});
3131

3232
export interface IAppProvider {
@@ -50,11 +50,10 @@ export function AppProvider(props: IAppProvider) {
5050
<StoreWrapper>
5151
<InstanceWrapper>
5252
<Suspense>
53-
<IntercomProvider>
54-
<PostHogProvider>
55-
<SWRConfig value={WEB_SWR_CONFIG}>{children}</SWRConfig>
56-
</PostHogProvider>
57-
</IntercomProvider>
53+
<ChatSupportModal />
54+
<PostHogProvider>
55+
<SWRConfig value={WEB_SWR_CONFIG}>{children}</SWRConfig>
56+
</PostHogProvider>
5857
</Suspense>
5958
</InstanceWrapper>
6059
</StoreWrapper>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { useEffect } from "react";
2+
import { Intercom, shutdown, show } from "@intercom/messenger-js-sdk";
3+
import { observer } from "mobx-react";
4+
// custom events
5+
import { CHAT_SUPPORT_EVENTS } from "@/custom-events/chat-support";
6+
// store hooks
7+
import { useInstance } from "@/hooks/store/use-instance";
8+
import { useUser } from "@/hooks/store/user";
9+
10+
const ChatSupportModal = observer(function ChatSupportModal() {
11+
// store hooks
12+
const { data: user } = useUser();
13+
const { config } = useInstance();
14+
// derived values
15+
const intercomAppId = config?.intercom_app_id;
16+
const isEnabled = Boolean(user && config?.is_intercom_enabled && intercomAppId);
17+
18+
useEffect(() => {
19+
if (!isEnabled || !user || !intercomAppId) return;
20+
21+
Intercom({
22+
app_id: intercomAppId,
23+
user_id: user.id,
24+
name: `${user.first_name} ${user.last_name}`,
25+
email: user.email,
26+
hide_default_launcher: true,
27+
});
28+
29+
const handleOpenChatSupport = () => {
30+
show();
31+
};
32+
33+
window.addEventListener(CHAT_SUPPORT_EVENTS.open, handleOpenChatSupport);
34+
return () => {
35+
window.removeEventListener(CHAT_SUPPORT_EVENTS.open, handleOpenChatSupport);
36+
shutdown();
37+
};
38+
}, [user, intercomAppId, isEnabled]);
39+
40+
return null;
41+
});
42+
43+
export default ChatSupportModal;

apps/web/core/components/power-k/config/help-commands.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import { DiscordIcon } from "@plane/propel/icons";
55
import type { TPowerKCommandConfig } from "@/components/power-k/core/types";
66
// hooks
77
import { usePowerK } from "@/hooks/store/use-power-k";
8-
import { useTransient } from "@/hooks/store/use-transient";
8+
import { useChatSupport } from "@/hooks/use-chat-support";
99

1010
/**
1111
* Help commands - Help related commands
1212
*/
1313
export const usePowerKHelpCommands = (): TPowerKCommandConfig[] => {
1414
// store
1515
const { toggleShortcutsListModal } = usePowerK();
16-
const { toggleIntercom } = useTransient();
16+
const { isEnabled: isChatSupportEnabled, openChatSupport } = useChatSupport();
1717

1818
return [
1919
{
@@ -73,9 +73,9 @@ export const usePowerKHelpCommands = (): TPowerKCommandConfig[] => {
7373
group: "help",
7474
i18n_title: "power_k.help_actions.chat_with_us",
7575
icon: MessageSquare,
76-
action: () => toggleIntercom(true),
77-
isEnabled: () => true,
78-
isVisible: () => true,
76+
action: () => openChatSupport(),
77+
isEnabled: () => isChatSupportEnabled,
78+
isVisible: () => isChatSupportEnabled,
7979
closeOnSelect: true,
8080
},
8181
];

apps/web/core/components/workspace/sidebar/help-menu.tsx

Lines changed: 0 additions & 125 deletions
This file was deleted.

apps/web/core/components/workspace/sidebar/help-section.tsx

Lines changed: 0 additions & 147 deletions
This file was deleted.

0 commit comments

Comments
 (0)