Skip to content

Commit

Permalink
Merge pull request #24 from ecency/bugfix/sentry-catches
Browse files Browse the repository at this point in the history
bugfix/sentry-catches
  • Loading branch information
feruzm authored Sep 22, 2024
2 parents b04e9df + 874420a commit 9ca33d0
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 17 deletions.
2 changes: 1 addition & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const withSentry = withSentryConfig(config, {
// tunnelRoute: "/monitoring",

// Hides source maps from generated client bundles
hideSourceMaps: true,
hideSourceMaps: false,

// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ecency-vision-next",
"version": "4.0.0",
"version": "4.0.1",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
2 changes: 1 addition & 1 deletion public/sw.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/sw.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/api/mutations/create-reply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function useCreateReply(entry?: Entry | null, parent?: Entry, onSuccess?:
point: boolean;
options?: CommentOptions;
}) => {
if (!activeUser || !activeUser.data.__loaded || !entry) {
if (!activeUser || !entry) {
throw new Error("[Reply][Create] – no active user provided");
}

Expand Down
37 changes: 30 additions & 7 deletions src/api/mutations/notifications/update-notifications-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,43 @@ import * as ls from "@/utils/local-storage";
import { error, success } from "@/features/shared";
import i18next from "i18next";
import { formatError } from "@/api/operations";
import { getAccessToken } from "@/utils";
import { appAxios } from "@/api/axios";
import { apiBase } from "@/api/helper";
import { ApiNotificationSetting } from "@/entities";

export function useUpdateNotificationsSettings() {
const activeUser = useGlobalStore((state) => state.activeUser);
const queryClient = useQueryClient();

return useMutation({
mutationKey: ["notifications", "update-settings"],
mutationFn: ({ notifyTypes, isEnabled }: { notifyTypes: NotifyTypes[]; isEnabled: boolean }) =>
saveNotificationsSettings(
activeUser!.username,
notifyTypes,
isEnabled,
ls.get("fb-notifications-token")
),
mutationFn: async ({
notifyTypes,
isEnabled
}: {
notifyTypes: NotifyTypes[];
isEnabled: boolean;
}) => {
if (!activeUser?.username) {
throw new Error("[UpdateNotificationSettings] Attempted to update settings with anon user");
}

const token = ls.get("fb-notifications-token") ?? "";

const response = await appAxios.post<ApiNotificationSetting>(
apiBase(`/private-api/register-device`),
{
code: getAccessToken(activeUser.username),
username: activeUser.username,
token,
system: "web",
allows_notify: Number(isEnabled),
notify_types: notifyTypes
}
);
return response.data;
},
onError: (e) => error(...formatError(e)),
onSuccess: (settings) => {
queryClient.setQueryData(
Expand Down
4 changes: 2 additions & 2 deletions src/api/mutations/update-reply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export function useUpdateReply(entry?: Entry | null, onSuccess?: () => void) {
point: boolean;
options?: CommentOptions;
}) => {
if (!activeUser || !activeUser.data.__loaded || !entry) {
throw new Error("[Reply][Create] – no active user provided");
if (!activeUser || !entry) {
throw new Error("[Reply][Update] – no active user provided");
}

await comment(
Expand Down
2 changes: 1 addition & 1 deletion src/api/queries/get-discussions-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const getDiscussionsMapQuery = (entry: Entry | undefined, enabled: boolea
return {};
},
enabled: enabled && !!entry,
initialData: {}
refetchOnMount: true
});

export function addReplyToDiscussionsList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const DeckThreadItemBody = ({
});
renderVideos(renderAreaRef);
renderTweets(renderAreaRef);
}, [entry.parent_author, setRenderInitiated]);
}, [entry.parent_author]);

const renderContentBody = useCallback(() => {
if (entry.parent_author === "liketu.moments") {
Expand All @@ -83,7 +83,7 @@ export const DeckThreadItemBody = ({
if (!renderInitiated) {
renderBody();
}
}, [height, entry, onResize, renderBody, renderInitiated]);
}, [height, entry, renderBody, renderInitiated]);

return (
<div className="thread-item-body">
Expand Down
6 changes: 6 additions & 0 deletions src/core/global-store/modules/authentication-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { formatError } from "@/api/operations";
import { getAccountFullQuery } from "@/api/queries";
import { activeUserMaker } from "@/specs/test-helper";
import { ACTIVE_USER_COOKIE_NAME } from "@/consts";
import * as Sentry from "@sentry/nextjs";

const load = (): ActiveUser | null => {
const name = ls.get("active_user");
Expand Down Expand Up @@ -63,10 +64,15 @@ export const createAuthenticationActions = (
ls.set("active_user", name);
Cookies.set(ACTIVE_USER_COOKIE_NAME, name, { expires: 365 });
set({ activeUser: load() });

Sentry.setUser({
username: name
});
} else {
ls.remove("active_user");
Cookies.remove(ACTIVE_USER_COOKIE_NAME);
set({ activeUser: load() });
Sentry.setUser(null);
}
}
});

0 comments on commit 9ca33d0

Please sign in to comment.