Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop -> Main #159

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/app/auth/validation/complete/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,30 @@ import { useRouter, useSearchParams } from "next/navigation";

import LottieClient from "@shared/components/Lottie";
import { Button } from "@shared/components/ui/button";

import useIsLogin from "@shared/hooks/useIsLogin";

import { Mixpanel } from "@shared/utils/mixpanel";

import { SIGNUP_COMPLETED } from "@auth/constants/auth";
import lottieJson from "public/assets/Problem_Complete.json";
import FewLogo from "public/enterlogo.svg";

export default function ValidationCompletePage() {
const searchParams = useSearchParams();
const router = useRouter();
const memberEmail = searchParams.get("member_email");

const isLogin = useIsLogin();

// useAuth(auth_token ? auth_token : "");

// useEffect(function setMixpanel() {
// if (memberEmail) {
// console.log(memberEmail);
// }
// }, []);

return (
<div className="flex h-auto flex-col items-center">
<LottieClient animationData={lottieJson} />
Expand All @@ -32,7 +45,6 @@ export default function ValidationCompletePage() {
Mixpanel.identify({ id: memberEmail });
Mixpanel.people.set({ peoples: { $email: memberEmail } });
}

router.push("/");
}}
>
Expand Down
10 changes: 5 additions & 5 deletions src/app/workbook/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ export default function WorkbookPage() {
// usePathname 로 workbook id 받기
const pathname = usePathname();
const workbookId = getWorkbookId(pathname);
useTrackMixpanel({
eventKey: EVENT_NAME.WORKBOOK_APPEAR,
property: { id: workbookId },
dep: pathname,
});
// useTrackMixpanel({
// eventKey: EVENT_NAME.WORKBOOK_APPEAR,
// property: { id: workbookId },
// dep: pathname,
// });

const { data: workbookInfo, isLoading } = useQuery({
...getWorkbookQueryOptions(workbookId),
Expand Down
10 changes: 4 additions & 6 deletions src/article/components/ArticleBottomButton/indext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import { useParams, useRouter } from "next/navigation";
import { HTMLAttributes } from "react";

import { Button } from "@shared/components/ui/button";
import { EVENT_NAME } from "@shared/constants/mixpanel";
import { useProblemIdsViewModel } from "@shared/models/useProblemIdsViewModel";
import { Mixpanel } from "@shared/utils/mixpanel";

interface ArticleBottomButtonProps extends HTMLAttributes<HTMLButtonElement> {}
export default function ArticleBottomButton({
Expand All @@ -18,10 +16,10 @@ export default function ArticleBottomButton({
const { getCurrentProblemId } = useProblemIdsViewModel();
const onClickGoProblem = () => {
push(`/problem/${getCurrentProblemId()}`);
Mixpanel.track({
name: EVENT_NAME.ARTICLE_PROBLEMBUTTON_TAPPED,
property: { id: articleId },
});
// Mixpanel.track({
// name: EVENT_NAME.ARTICLE_PROBLEMBUTTON_TAPPED,
// property: { id: articleId },
// });
};
return (
<Button
Expand Down
26 changes: 12 additions & 14 deletions src/article/components/ArticleTitle/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import { setCookie } from "cookies-next";

import TitleSection from "@shared/components/TitleSection";
import { IS_EXIST_PROBLEMS } from "@shared/constants/middlewareConstant";
import { EVENT_NAME } from "@shared/constants/mixpanel";
import { useProblemIdsViewModel } from "@shared/models/useProblemIdsViewModel";
import { Mixpanel } from "@shared/utils/mixpanel";

import { ARTICLE_INFO_TYPE } from "@article/constants/articleCase";
import { getArticleQueryOptions } from "@article/remotes/getArticleQueryOptions";
Expand Down Expand Up @@ -66,18 +64,18 @@ export default function ArticleTitle() {
[articleInfo],
);

useEffect(
function trackMixpanel() {
if (!isFirstRender.current) {
isFirstRender.current = true;
Mixpanel.track({
name: EVENT_NAME.ARTICLE_APPREAR,
property: { id: articleId },
});
}
},
[articleInfo],
);
// useEffect(
// function trackMixpanel() {
// if (!isFirstRender.current) {
// isFirstRender.current = true;
// Mixpanel.track({
// name: EVENT_NAME.ARTICLE_APPREAR,
// property: { id: articleId },
// });
// }
// },
// [articleInfo],
// );

if (isLoading || isError || !articleInfo)
return <ArticleSkeleton.TitleSkeleton />;
Expand Down
3 changes: 1 addition & 2 deletions src/auth/hooks/useLogout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { deleteCookie } from "cookies-next";
import { ApiResponse } from "@api/fewFetch";

import { COOKIES } from "@shared/constants/token";
import { Mixpanel } from "@shared/utils/mixpanel";

import { logOutMutaionOption } from "@auth/remotes/logoutMembersQueryOption";

Expand All @@ -23,7 +22,7 @@ export const useLogout = () => {
// 쿠키 삭제 및 로그인 페이지로 이동
deleteCookie(COOKIES.REFRESH_TOKEN);
deleteCookie(COOKIES.ACCESS_TOKEN);
Mixpanel.reset();
// Mixpanel.reset();
router.push("/");
window.location.reload();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/components/MainHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { cn } from "@shared/utils/cn";
import DropDownMenuWrapper from "../DropdownMenuWrapper";
import FewLogo from "public/assets/icon/fewlogo.svg";
export default function MainHeader() {
useTrackMixpanel({ eventKey: EVENT_NAME.MAIN_APPEAR });
// useTrackMixpanel({ eventKey: EVENT_NAME.MAIN_APPEAR });
const [toggleMenu, setToggleMenu] = useState(false);

const handleToggleMenu = () => {
Expand Down
13 changes: 5 additions & 8 deletions src/problem/components/ProblemTitle/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import { useMutationState, useQuery } from "@tanstack/react-query";

import { ApiResponse } from "@api/fewFetch";

import { EVENT_NAME } from "@shared/constants/mixpanel";
import useTrackMixpanel from "@shared/hooks/useTrackMixpanel";

import ProblemSkeleton from "../ProblemSkeleton";
import { PROBLEM_TITLE_INFO } from "@problem/constants/problemInfo";
import { QUERY_KEY } from "@problem/remotes/api";
Expand All @@ -30,11 +27,11 @@ export default function ProblemTitle() {
},
select: (mutation) => mutation.state.data as ApiResponse<AnswerCheckInfo>,
});
useTrackMixpanel({
eventKey: EVENT_NAME.PROBLEM_APPEAR,
property: { id: problemId },
dep: problemId,
});
// useTrackMixpanel({
// eventKey: EVENT_NAME.PROBLEM_APPEAR,
// property: { id: problemId },
// dep: problemId,
// });
if (isLoading || isError || !problemInfo)
return <ProblemSkeleton.TitleSkeleton />;

Expand Down
72 changes: 34 additions & 38 deletions src/shared/middlewares/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,40 @@ type authMiddlewareProps = {
};

export const AuthMiddleware = async ({ req, nextUrl }: authMiddlewareProps) => {
try {
const { searchParams } = nextUrl;
const auth_token = searchParams.get(AUTH_TOKEN);
if (auth_token) {
const response: ApiResponse<tokenResponse> = await fewFetch().post(
API_ROUTE.TOKEN(auth_token),
);

const authData = response.data;

if (authData?.message === "알 수 없는 오류가 발생했어요.") {
nextUrl.searchParams.delete(AUTH_TOKEN);
const response = NextResponse.redirect(nextUrl);

// response.cookies.set(COOKIES.ACCESS_TOKEN, "false");
response.cookies.set(ISLOGIN, "false");

return NextResponse.redirect(nextUrl);
}
if (authData?.data?.accessToken) {
const accessToken = authData.data.accessToken;
const memberEmail = tokenParse(accessToken).memberEmail;

nextUrl.searchParams.delete(AUTH_TOKEN);
nextUrl.searchParams.set("member_email", memberEmail);

const response = NextResponse.redirect(nextUrl);

response.cookies.set(COOKIES.ACCESS_TOKEN, authData?.data?.accessToken);
response.cookies.set(
COOKIES.REFRESH_TOKEN,
authData?.data?.refreshToken,
);

return response;
}
const { searchParams } = nextUrl;
const auth_token = searchParams.get(AUTH_TOKEN);
if (auth_token) {
const response: ApiResponse<tokenResponse> = await fewFetch().post(
API_ROUTE.TOKEN(auth_token),
);

const authData = response.data;

if (authData?.message === "알 수 없는 오류가 발생했어요.") {
nextUrl.searchParams.delete(AUTH_TOKEN);
const response = NextResponse.redirect(nextUrl);

response.cookies.set(ISLOGIN, "false");

return NextResponse.redirect(nextUrl);
}
if (authData?.data?.accessToken) {
const accessToken = authData.data.accessToken;
const memberEmail = tokenParse(accessToken).memberEmail;

nextUrl.searchParams.delete(AUTH_TOKEN);
nextUrl.searchParams.set("member_email", memberEmail);

const response = NextResponse.redirect(nextUrl);

response.cookies.set(COOKIES.ACCESS_TOKEN, authData?.data?.accessToken, {
maxAge: 24 * 60 * 60, // 30 days
});
response.cookies.set(COOKIES.REFRESH_TOKEN, authData?.data?.refreshToken, {
maxAge: 24 * 60 * 60, // 30 days
});

return response;
}
} catch {
return undefined;
}
};
Loading