From 3f85aa676c722d92b4d34cd4e368d857aa666e41 Mon Sep 17 00:00:00 2001 From: bicochan Date: Thu, 31 Jul 2025 12:45:01 +0900 Subject: [PATCH] =?UTF-8?q?[common/components]=20feat:=20=EC=A0=91?= =?UTF-8?q?=EC=86=8D=20=EB=A1=9C=EA=B7=B8=20=EC=A0=80=EC=9E=A5=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=9E=91=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/src/api/connection-log.ts | 34 +++++++++++++++++++ packages/common/components/src/api/index.ts | 1 + packages/common/components/src/config/api.ts | 1 + .../common/components/src/ui/lnb/index.tsx | 15 +++++++- 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 packages/common/components/src/api/connection-log.ts diff --git a/packages/common/components/src/api/connection-log.ts b/packages/common/components/src/api/connection-log.ts new file mode 100644 index 000000000..b421b7cb3 --- /dev/null +++ b/packages/common/components/src/api/connection-log.ts @@ -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( + `${ENDPOINT.CMS_SERVICE.CONNECTION_LOG}`, + payload, + ); + return response.data; +}; diff --git a/packages/common/components/src/api/index.ts b/packages/common/components/src/api/index.ts index 10d68732c..d569765c2 100644 --- a/packages/common/components/src/api/index.ts +++ b/packages/common/components/src/api/index.ts @@ -1,4 +1,5 @@ export * from "./client"; +export * from "./connection-log"; export * from "./menu"; export * from "./popup"; export * from "./site"; diff --git a/packages/common/components/src/config/api.ts b/packages/common/components/src/config/api.ts index 6772182fb..a12ff5887 100644 --- a/packages/common/components/src/config/api.ts +++ b/packages/common/components/src/config/api.ts @@ -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", diff --git a/packages/common/components/src/ui/lnb/index.tsx b/packages/common/components/src/ui/lnb/index.tsx index dee4356f6..8e3c2aebf 100644 --- a/packages/common/components/src/ui/lnb/index.tsx +++ b/packages/common/components/src/ui/lnb/index.tsx @@ -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([]); const [currentMenuCode, setCurrentMenuCode] = useState(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({