Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit fff7ba9

Browse files
feat: report errors to rollbar
1 parent dfc1de6 commit fff7ba9

File tree

4 files changed

+43
-3
lines changed

4 files changed

+43
-3
lines changed

src/renderer/components/Favorite/FavoriteCookbook.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { useMutation } from '@apollo/client';
22
import { useToast } from '@codiga/components';
3+
import { useRollbar } from '@rollbar/react';
4+
import { LogArgument } from 'rollbar';
5+
36
import useQueryVariables from '../../hooks/useQueryVariables';
47
import {
58
SUBSCRIBE_TO_COOKBOOK,
@@ -11,6 +14,7 @@ import {
1114
GET_USER_SUBSCRIBED_COOKBOOKS,
1215
} from '../../graphql/queries';
1316
import Favorite, { FavoriteProps } from './Favorite';
17+
import { useUser } from '../UserContext';
1418

1519
type FavoriteCookbookProps = Pick<FavoriteProps, 'isSubscribed'> & {
1620
cookbookId: number;
@@ -21,6 +25,8 @@ export default function FavoriteCookbook({
2125
cookbookId,
2226
}: FavoriteCookbookProps) {
2327
const toast = useToast();
28+
const rollbar = useRollbar();
29+
const { id: userId } = useUser();
2430

2531
const [favoriteCookbook] = useMutation(SUBSCRIBE_TO_COOKBOOK);
2632
const [unfavoriteCookbook] = useMutation(UNSUBSCRIBE_TO_COOKBOOK);
@@ -56,6 +62,11 @@ export default function FavoriteCookbook({
5662
refetchQueries,
5763
});
5864
} catch (err) {
65+
rollbar.error('Error favoriting cookbook', err as LogArgument, {
66+
cookbookId,
67+
isSubscribed,
68+
userId,
69+
});
5970
toast({
6071
status: 'error',
6172
description: 'An error occurred. Please try again.',
@@ -72,6 +83,11 @@ export default function FavoriteCookbook({
7283
refetchQueries,
7384
});
7485
} catch (err) {
86+
rollbar.error('Error unfavoriting cookbook', err as LogArgument, {
87+
cookbookId,
88+
isSubscribed,
89+
userId,
90+
});
7591
toast({
7692
status: 'error',
7793
description: 'An error occurred. Please try again.',

src/renderer/components/Favorite/FavoriteSnippet.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { useMutation } from '@apollo/client';
22
import { useToast } from '@codiga/components';
3+
import { useRollbar } from '@rollbar/react';
4+
import { LogArgument } from 'rollbar';
5+
36
import useQueryVariables from '../../hooks/useQueryVariables';
47
import {
58
SUBSCRIBE_TO_RECIPE,
@@ -12,6 +15,7 @@ import {
1215
GET_USER_SUBSCRIBED_RECIPES,
1316
} from '../../graphql/queries';
1417
import Favorite, { FavoriteProps } from './Favorite';
18+
import { useUser } from '../UserContext';
1519

1620
type FavoriteRecipeProps = Pick<FavoriteProps, 'isSubscribed'> & {
1721
recipeId: number;
@@ -22,6 +26,8 @@ export default function FavoriteSnippet({
2226
recipeId,
2327
}: FavoriteRecipeProps) {
2428
const toast = useToast();
29+
const rollbar = useRollbar();
30+
const { id: userId } = useUser();
2531

2632
const [favoriteRecipe] = useMutation(SUBSCRIBE_TO_RECIPE);
2733
const [unfavoriteRecipe] = useMutation(UNSUBSCRIBE_TO_RECIPE);
@@ -63,6 +69,11 @@ export default function FavoriteSnippet({
6369
refetchQueries,
6470
});
6571
} catch (err) {
72+
rollbar.error('Error favoriting snippet', err as LogArgument, {
73+
recipeId,
74+
isSubscribed,
75+
userId,
76+
});
6677
toast({
6778
status: 'error',
6879
description: 'An error occurred. Please try again.',
@@ -79,6 +90,11 @@ export default function FavoriteSnippet({
7990
refetchQueries,
8091
});
8192
} catch (err) {
93+
rollbar.error('Error unfavoriting snippet', err as LogArgument, {
94+
recipeId,
95+
isSubscribed,
96+
userId,
97+
});
8298
toast({
8399
status: 'error',
84100
description: 'An error occurred. Please try again.',

src/renderer/components/Login/Login.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import {
1414
import { TextField, useToast } from '@codiga/components';
1515
import { useLazyQuery } from '@apollo/client';
1616
import { useForm } from 'react-hook-form';
17+
import { useRollbar } from '@rollbar/react';
18+
import { LogArgument } from 'rollbar';
1719

1820
import { APP_URL, TOKEN } from '../../lib/config';
1921
import { CHECK_USER } from '../../graphql/queries';
@@ -26,6 +28,7 @@ type LoginProps = {
2628

2729
export default function Login({ isOpen, closeModal }: LoginProps) {
2830
const toast = useToast();
31+
const rollbar = useRollbar();
2932
const { setUser } = useUser();
3033

3134
const {
@@ -62,6 +65,7 @@ export default function Login({ isOpen, closeModal }: LoginProps) {
6265
});
6366
}
6467
} catch (err) {
68+
rollbar.error('Error logging in', err as LogArgument);
6569
// network errors while fetching are placed here
6670
toast({
6771
status: 'error',

src/renderer/components/Votes/Votes.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export default function Votes({
3131
...props
3232
}: VotesProps) {
3333
const toast = useToast();
34-
const { id: userId } = useUser();
3534
const rollbar = useRollbar();
35+
const { id: userId } = useUser();
3636

3737
const ref = useRef(null);
3838
const isInView = useInView(ref);
@@ -69,7 +69,9 @@ export default function Votes({
6969
});
7070
} catch (err) {
7171
rollbar.error('Error upvoting', err as LogArgument, {
72-
hello: 'world',
72+
userId,
73+
entityId,
74+
entityType,
7375
});
7476
toast({
7577
status: 'error',
@@ -92,7 +94,9 @@ export default function Votes({
9294
});
9395
} catch (err) {
9496
rollbar.error('Error downvoting', err as LogArgument, {
95-
hello: 'world',
97+
userId,
98+
entityId,
99+
entityType,
96100
});
97101
toast({
98102
status: 'error',

0 commit comments

Comments
 (0)