[common/components] feat: 접속 로그 저장 기능 작업
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { ENDPOINT } from "../config";
|
||||
import { getApiClient } from "./client";
|
||||
|
||||
export interface ConnectionLog {
|
||||
cntnSn: number;
|
||||
cntnDt: string;
|
||||
cntnId: string;
|
||||
cntnIp: string;
|
||||
cntnRgn: string;
|
||||
wbsrKnd: string;
|
||||
menuCd: number;
|
||||
siteId: string;
|
||||
urlPath: string;
|
||||
}
|
||||
|
||||
export interface ConnectionLogPayload {
|
||||
cntnId?: string;
|
||||
cntnIp?: string;
|
||||
cntnRgn?: string;
|
||||
wbsrKnd?: string;
|
||||
menuCd?: number | null;
|
||||
siteId?: string;
|
||||
urlPath: string;
|
||||
}
|
||||
|
||||
const client = getApiClient();
|
||||
|
||||
export const saveConnectionLog = async (payload: ConnectionLogPayload) => {
|
||||
const response = await client.post<ConnectionLog>(
|
||||
`${ENDPOINT.CMS_SERVICE.CONNECTION_LOG}`,
|
||||
payload,
|
||||
);
|
||||
return response.data;
|
||||
};
|
||||
@@ -1,4 +1,5 @@
|
||||
export * from "./client";
|
||||
export * from "./connection-log";
|
||||
export * from "./menu";
|
||||
export * from "./popup";
|
||||
export * from "./site";
|
||||
|
||||
@@ -6,6 +6,7 @@ export const ENDPOINT = {
|
||||
SITES: "/cms-service/api/v1/sites",
|
||||
POPUPS: "/cms-service/api/v1/popups",
|
||||
IPS: "/cms-service/api/v1/site-ips",
|
||||
CONNECTION_LOG: "/cms-service/api/v1/cntnlog",
|
||||
},
|
||||
USER_SERVICE: {
|
||||
USERS: "/user-service/api/v1/users",
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { useState, useEffect, useRef } from "react";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { ChevronRight } from "lucide-react";
|
||||
import { useDetectDevice } from "@frontend-opensource/use-react-hooks";
|
||||
import { getConfig } from "@common/config";
|
||||
import { getParentIds } from "./lib";
|
||||
import {
|
||||
@@ -24,9 +25,10 @@ import {
|
||||
import { ENDPOINT } from "../../config";
|
||||
import { cn, getCookie, setCookie } from "../../lib";
|
||||
import {
|
||||
getAnonymouseMenuList,
|
||||
getMenuList,
|
||||
getPreviewTreeMenuList,
|
||||
getAnonymouseMenuList,
|
||||
saveConnectionLog,
|
||||
type MenuItem,
|
||||
} from "../../api";
|
||||
|
||||
@@ -55,6 +57,7 @@ export function LNB({
|
||||
const [defaultOpenMenuIds, setDefaultOpenMenuIds] = useState<number[]>([]);
|
||||
const [currentMenuCode, setCurrentMenuCode] = useState<number | null>(null);
|
||||
const prevPathRef = useRef(currentPath);
|
||||
const { browser } = useDetectDevice();
|
||||
|
||||
const siteId = propSiteId ?? appSiteId;
|
||||
|
||||
@@ -125,6 +128,16 @@ export function LNB({
|
||||
}
|
||||
|
||||
if (matchedMenuCode) setCurrentMenuCode(matchedMenuCode);
|
||||
|
||||
// 접속 로그 저장
|
||||
saveConnectionLog({
|
||||
cntnId: userId,
|
||||
cntnRgn: navigator.language,
|
||||
wbsrKnd: browser,
|
||||
menuCd: matchedMenuCode,
|
||||
siteId,
|
||||
urlPath: currentPath,
|
||||
});
|
||||
}, [menuList, currentPath]);
|
||||
|
||||
function MenuItem({
|
||||
|
||||
Reference in New Issue
Block a user