Skip to content

Commit

Permalink
feat: add sentry exception handling for plain errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jainpawan21 committed Dec 5, 2024
1 parent 2aaf2b0 commit 69c3d1d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,7 @@
"pnpm-workspace.yaml",
"tsconfig.json",
"unreadRead",
"websockets"
"websockets",
"apps/dashboard/src/components/header-navigation/customer-support-button.tsx"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import { RiQuestionFill } from 'react-icons/ri';
import { HeaderButton } from './header-button';
import { PLAIN_SUPPORT_CHAT_APP_ID } from '@/config';
import { useAuth } from '@/context/auth/hooks';
import * as Sentry from '@sentry/react';

export const CustomerSupportButton = () => {
const [isFirstRender, setIsFirstRender] = useState(true);
const { currentOrganization, currentUser } = useAuth();
const { currentUser } = useAuth();

const isLiveChatVisible =
currentOrganization?.apiServiceLevel !== 'free' &&
currentUser?.servicesHashes?.plain &&
PLAIN_SUPPORT_CHAT_APP_ID !== undefined;
const isLiveChatVisible = currentUser?.servicesHashes?.plain && PLAIN_SUPPORT_CHAT_APP_ID !== undefined;

useBootIntercom();

Expand Down Expand Up @@ -115,7 +113,8 @@ export const CustomerSupportButton = () => {
],
});
} catch (error) {
console.error('error initializing plain chat', error);
console.error('Error initializing plain chat: ', error);
Sentry.captureException(error);
}
}
setIsFirstRender(false);
Expand All @@ -127,7 +126,8 @@ export const CustomerSupportButton = () => {
// @ts-ignore
window?.Plain?.open();
} catch (error) {
console.error('error opening plain chat', error);
console.error('Error opening plain chat: ', error);
Sentry.captureException(error);
}
}
};
Expand Down
7 changes: 5 additions & 2 deletions apps/web/src/components/layout/components/v2/HeaderNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Tooltip, Dropdown } from '@novu/design-system';
import { css } from '@novu/novui/css';
import { HStack } from '@novu/novui/jsx';
import { FeatureFlagsKeysEnum } from '@novu/shared';
import { captureException } from '@sentry/react';
import { IS_EE_AUTH_ENABLED, IS_NOVU_PROD_STAGING } from '../../../../config';
import { useBootIntercom, useFeatureFlag } from '../../../../hooks';
import useThemeChange from '../../../../hooks/useThemeChange';
Expand Down Expand Up @@ -76,7 +77,8 @@ export function HeaderNav() {
},
});
} catch (error) {
console.error('error initializing plain chat', error);
console.error('Error initializing plain chat: ', error);
captureException(error);
}
}
setIsFirstRender(false);
Expand All @@ -88,7 +90,8 @@ export function HeaderNav() {
// @ts-ignore
window?.Plain?.open();
} catch (error) {
console.error('error opening plain chat', error);
console.error('Error opening plain chat: ', error);
captureException(error);
}
}
};
Expand Down

0 comments on commit 69c3d1d

Please sign in to comment.