SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
import { useEffect, useState } from 'react';
import { useMutation } from 'react-query';
import { Button, Card, Modal } from 'antd';
import { useAppLocation } from 'lib/router/useAppLocation';
import { getCurrentLocation } from 'lib/router/navigation';
import { Typography } from '@signozhq/ui/typography';
import logEvent from 'api/common/logEvent';
import { createSubscription } from 'api/generated/services/subscriptions';
import type { CreateSubscription201 } from 'api/generated/services/sigNoz.schemas';
import { FeatureKeys } from 'constants/features';
import { useNotifications } from 'hooks/useNotifications';
import AuthZTooltip from 'lib/authz/components/AuthZTooltip/AuthZTooltip';
import { SubscriptionCreatePermission } from 'lib/authz/hooks/useAuthZ/permissions/subscription.permissions';
import {
ArrowUpRight,
Book,
CreditCard,
Github,
LifeBuoy,
MessageSquare,
Slack,
X,
} from '@signozhq/icons';
import { useAppContext } from 'providers/App/App';
import APIError from 'types/api/error';
import { getBaseUrl } from 'utils/basePath';
import { openInNewTab } from 'utils/navigation';
import './Support.styles.scss';
const { Title, Text } = Typography;
interface Channel {
key: any;
name?: string;
icon?: JSX.Element;
title?: string;
url: any;
btnText?: string;
}
const channelsMap = {
documentation: 'documentation',
github: 'github',
slack_community: 'slack_community',
chat: 'chat',
schedule_call: 'schedule_call',
slack_connect: 'slack_connect',
};
const supportChannels = [
{
key: 'documentation',
name: 'Documentation',
icon: <Book size={16} />,
title: 'Find answers in the documentation.',
url: 'https://signoz.io/docs/',
btnText: 'Visit docs',
isExternal: true,
},
{
key: 'github',
name: 'Github',
icon: <Github size={16} />,
title: 'Create an issue on GitHub to report bugs or request new features.',
url: 'https://github.com/SigNoz/signoz/issues',
btnText: 'Create issue',
isExternal: true,
},
{
key: 'slack_community',
name: 'Slack Community',
icon: <Slack size={16} />,
title: 'Get support from the SigNoz community on Slack.',
url: 'https://signoz.io/slack',
btnText: 'Join Slack',
isExternal: true,
},
{
key: 'chat',
name: 'Chat',
icon: <MessageSquare size={16} />,
title: 'Get quick support directly from the team.',
url: '',
btnText: 'Launch chat',
isExternal: false,
},
];
export default function Support(): JSX.Element {
const { notifications } = useNotifications();
const { trialInfo, featureFlags } = useAppContext();
const [isAddCreditCardModalOpen, setIsAddCreditCardModalOpen] =
useState(false);
const { pathname } = useAppLocation();
const handleChannelWithRedirects = (url: string): void => {
openInNewTab(url);
};
useEffect(() => {
const currentLocation = getCurrentLocation();
if (currentLocation?.state) {
const locationState = currentLocation.state as any;
if (locationState && locationState?.from) {
logEvent(`Support : From URL : ${locationState.from}`, {});
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const isPremiumChatSupportEnabled =
featureFlags?.find((flag) => flag.name === FeatureKeys.PREMIUM_SUPPORT)
?.active || false;
const showAddCreditCardModal =
!isPremiumChatSupportEnabled && !trialInfo?.trialConvertedToSubscription;
const handleBillingOnSuccess = (data: CreateSubscription201): void => {
if (data?.data?.redirectURL) {
const newTab = document.createElement('a');
newTab.href = data.data.redirectURL;
newTab.target = '_blank';
newTab.rel = 'noopener noreferrer';
newTab.click();
}
};
const handleBillingOnError = (error: APIError): void => {
notifications.error({
message: error.getErrorCode(),
description: error.getErrorMessage(),
});
};
const { mutate: updateCreditCard, isLoading: isLoadingBilling } = useMutation(
createSubscription,
{
onSuccess: (data) => {
handleBillingOnSuccess(data);
},
onError: handleBillingOnError,
},
);
const handleAddCreditCard = (): void => {
logEvent('Add Credit card modal: Clicked', {
source: `help & support`,
page: pathname,
});
updateCreditCard({
url: getBaseUrl(),
});
};
const handleChat = (): void => {
if (showAddCreditCardModal) {
logEvent('Disabled Chat Support: Clicked', {
source: `help & support`,
page: pathname,
});
setIsAddCreditCardModalOpen(true);
} else if (window.pylon) {
window.Pylon('show');
}
};
const handleChannelClick = (channel: Channel): void => {
logEvent(`Support : ${channel.name}`, {});
switch (channel.key) {
case channelsMap.documentation:
case channelsMap.github:
case channelsMap.slack_community:
handleChannelWithRedirects(channel.url);
break;
case channelsMap.chat:
handleChat();
break;
default:
handleChannelWithRedirects('https://signoz.io/slack');
break;
}
};
return (
<div className="support-page-container">
<header className="support-page-header">
<div className="support-page-header-title" data-testid="support-page-title">
<LifeBuoy size={16} />
Support
</div>
</header>
<div className="support-page-content">
<div className="support-page-content-description">
We are here to help in case of questions or issues. Pick the channel that
is most convenient for you.
</div>
<div className="support-channels">
{supportChannels.map((channel): JSX.Element => (
<Card className="support-channel" key={channel.key}>
<div className="support-channel-content">
<Title truncate={1} level={5} className="support-channel-title">
{channel.icon}
{channel.name}{' '}
</Title>
<Text> {channel.title} </Text>
</div>
<div className="support-channel-action">
<Button
className="periscope-btn secondary support-channel-btn"
type="default"
onClick={(): void => handleChannelClick(channel)}
>
<Text truncate={1}>{channel.btnText} </Text>
{channel.isExternal && <ArrowUpRight size={14} />}
</Button>
</div>
</Card>
))}
</div>
</div>
{/* Add Credit Card Modal */}
<Modal
className="add-credit-card-modal"
title={<span className="title">Add Credit Card for Chat Support</span>}
open={isAddCreditCardModalOpen}
closable
onCancel={(): void => setIsAddCreditCardModalOpen(false)}
destroyOnClose
footer={[
<Button
key="cancel"
onClick={(): void => setIsAddCreditCardModalOpen(false)}
className="cancel-btn"
icon={<X size={16} />}
>
Cancel
</Button>,
<AuthZTooltip
key="submit"
checks={[SubscriptionCreatePermission]}
withPortal={false}
>
<Button
type="primary"
icon={<CreditCard size={16} />}
size="middle"
loading={isLoadingBilling}
disabled={isLoadingBilling}
onClick={handleAddCreditCard}
className="add-credit-card-btn periscope-btn primary"
>
Add Credit Card
</Button>
</AuthZTooltip>,
]}
>
<Typography.Text className="add-credit-card-text">
You're currently on <span className="highlight-text">Trial plan</span>
. Add a credit card to access SigNoz chat support to your workspace.
</Typography.Text>
</Modal>
</div>
);
}