From 42f58bf10caa12ca6390075d51238c17a2257051 Mon Sep 17 00:00:00 2001 From: optrader Date: Mon, 15 Dec 2025 09:39:00 +0900 Subject: [PATCH] =?UTF-8?q?[251215]=20fix:=20FeaturedBrandsPanel=20Log?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ๐Ÿ• ์ปค๋ฐ‹ ์‹œ๊ฐ„: 2025. 12. 15. 09:38:59 ๐Ÿ“Š ๋ณ€๊ฒฝ ํ†ต๊ณ„: โ€ข ์ด ํŒŒ์ผ: 3๊ฐœ โ€ข ์ถ”๊ฐ€: +30์ค„ ๐Ÿ“ ์ถ”๊ฐ€๋œ ํŒŒ์ผ: + com.twin.app.shoptime/src/api/logServerClient.js ๐Ÿ“ ์ˆ˜์ •๋œ ํŒŒ์ผ: ~ com.twin.app.shoptime/src/api/TLogEvent.js ~ com.twin.app.shoptime/src/views/FeaturedBrandsPanel/FeaturedBrandsPanel.jsx ๐Ÿ”ง ์ฃผ์š” ๋ณ€๊ฒฝ ๋‚ด์šฉ: โ€ข API ์„œ๋น„์Šค ๋ ˆ์ด์–ด ๊ฐœ์„  โ€ข ์†Œ๊ทœ๋ชจ ๊ธฐ๋Šฅ ๊ฐœ์„  --- com.twin.app.shoptime/src/api/TLogEvent.js | 18 ++++ .../src/api/logServerClient.js | 85 +++++++++++++++++++ .../FeaturedBrandsPanel.jsx | 12 +++ 3 files changed, 115 insertions(+) create mode 100644 com.twin.app.shoptime/src/api/logServerClient.js diff --git a/com.twin.app.shoptime/src/api/TLogEvent.js b/com.twin.app.shoptime/src/api/TLogEvent.js index 79ada808..99f66416 100644 --- a/com.twin.app.shoptime/src/api/TLogEvent.js +++ b/com.twin.app.shoptime/src/api/TLogEvent.js @@ -2,6 +2,7 @@ import axios from "axios"; import { createQueryString } from "../utils/helperMethods"; import { getUrl } from "./apiConfig"; +import { DEBUG_LOG_MODE, sendToLogServer } from "./logServerClient"; export const TLogEvent = ( dispatch, @@ -68,6 +69,23 @@ export const TLogEvent = ( prodCd, }; } + + // ===== DEBUG_LOG_MODE: ๋กœ๊ทธ์„œ๋ฒ„๋กœ ๋ฐ์ดํ„ฐ ์ „์†ก ===== + if (DEBUG_LOG_MODE) { + sendToLogServer({ + deviceId: dvcId, + cntryCd, + platCd, + prodCd, + appVersion, + deviceLang, + logModel: model, + apiUrl: url, + httpMethod: type, + totalLogFlag, + }); + } + let axiosInstance; switch (type) { diff --git a/com.twin.app.shoptime/src/api/logServerClient.js b/com.twin.app.shoptime/src/api/logServerClient.js new file mode 100644 index 00000000..f0310421 --- /dev/null +++ b/com.twin.app.shoptime/src/api/logServerClient.js @@ -0,0 +1,85 @@ +import axios from 'axios'; + +// ===== DEBUG_LOG_MODE ===== +// true: ๋กœ๊ทธ์„œ๋ฒ„๋กœ ๋ฐ์ดํ„ฐ ์ „์†ก +// false: ๋กœ๊ทธ์„œ๋ฒ„ ์ „์†ก ์•ˆํ•จ +export const DEBUG_LOG_MODE = false; + +// ===== ๋กœ๊ทธ์„œ๋ฒ„ ๊ธฐ๋ณธ ์„ค์ • ===== +const LOG_SERVER_URL = 'http://api.optsoft.store:55003/api/logs/realtime'; + +/** + * TLogEvent์—์„œ ๋ณด๋‚ธ ๋ฐ์ดํ„ฐ๋ฅผ ๋กœ๊ทธ์„œ๋ฒ„๋กœ ์ „์†ก + * + * @param {Object} logData - TLogEvent์—์„œ ๋ณด๋‚ธ ๋กœ๊ทธ ๋ฐ์ดํ„ฐ (params + ์ถ”๊ฐ€ ์ •๋ณด) + * @param {string} logData.deviceId - ๋””๋ฐ”์ด์Šค ID + * @param {string} logData.cntryCd - ๊ตญ๊ฐ€ ์ฝ”๋“œ (๋˜๋Š” countryCode) + * @param {string} logData.platCd - ํ”Œ๋žซํผ ์ฝ”๋“œ + * @param {string} logData.prodCd - ์ œํ’ˆ ์ฝ”๋“œ + * @param {string} logData.appVersion - ์•ฑ ๋ฒ„์ „ + * @param {Object} logData.logModel - TLogEvent๊ฐ€ axios๋กœ ๋ณด๋‚ผ ๋ชจ๋ธ ๊ฐ์ฒด + * @param {string} logData.apiUrl - API ์—”๋“œํฌ์ธํŠธ + * @param {string} logData.httpMethod - HTTP ๋ฉ”์„œ๋“œ (get, post) + * + * @returns {Promise} + */ +export async function sendToLogServer(logData) { + if (!DEBUG_LOG_MODE) { + return; + } + + try { + // TLogEvent์—์„œ ์ „๋‹ฌ๋œ messageId ์‚ฌ์šฉ, ์—†์œผ๋ฉด null + const messageId = (logData.logModel && logData.logModel.messageId) || null; + + // ๋กœ๊ทธ์„œ๋ฒ„์— ์ „์†กํ•  ๋ฐ์ดํ„ฐ ๊ตฌ์„ฑ + const logPayload = { + // ===== ํ•„์ˆ˜ ํ•„๋“œ ===== + deviceId: logData.deviceId || logData.dvcId || 'unknown', + messageId: messageId, + logCreateTime: new Date().toISOString(), + + // ===== ๋กœ๊ทธ ๊ธฐ๋ณธ ์ •๋ณด ===== + eventType: 'api_call', + apiUrl: logData.apiUrl || 'unknown', + httpMethod: logData.httpMethod || 'POST', + + // ===== ๋””๋ฐ”์ด์Šค & ์•ฑ ์ •๋ณด ===== + countryCode: logData.countryCode || logData.cntryCd || 'unknown', + platformCode: logData.platformCode || logData.platCd || 'unknown', + platformVersion: logData.platformVersion || logData.prodCd || 'unknown', + appVersion: logData.appVersion || 'unknown', + deviceLang: logData.deviceLang || 'unknown', + + // ===== ๋กœ๊ทธ ํƒ€์ž…๋ณ„ ๋ฐ์ดํ„ฐ ===== + logTpNo: logData.logTpNo || logData.logType || 'unknown', + entryMenu: logData.entryMenu || 'unknown', + nowMenu: logData.nowMenu || 'unknown', + + // ===== TLogEvent ์›๋ณธ ๋ฐ์ดํ„ฐ (model) ===== + ...(logData.logModel || {}), + }; + + // console.log('[logServerClient] Sending log to server - Full Payload:', logPayload); + // console.log('[logServerClient] Input logData:', logData); + + // ๋กœ๊ทธ์„œ๋ฒ„๋กœ ์ „์†ก (๋น„๋™๊ธฐ, ์‘๋‹ต ๋Œ€๊ธฐ ์•ˆํ•จ) + axios.post(LOG_SERVER_URL, logPayload, { + timeout: 5000, // 5์ดˆ ํƒ€์ž„์•„์›ƒ + headers: { + 'Content-Type': 'application/json', + }, + }).then((response) => { + // ์„ฑ๊ณต ์‹œ ์กฐ์šฉํ•˜๊ฒŒ ์ฒ˜๋ฆฌ + }).catch((error) => { + // ๋กœ๊ทธ์„œ๋ฒ„ ์ „์†ก ์‹คํŒจ ์‹œ๋งŒ ์˜ค๋ฅ˜ ๋กœ๊ทธ ์ถœ๋ ฅ + console.error('[logServerClient] Failed to send log to server:', { + url: LOG_SERVER_URL, + error: error.message, + messageId: messageId, + }); + }); + } catch (error) { + // ํ•จ์ˆ˜ ์ž์ฒด์˜ ์˜ค๋ฅ˜๋Š” ๋ฌด์‹œ (์กฐ์šฉํ•˜๊ฒŒ ์ฒ˜๋ฆฌ) + } +} diff --git a/com.twin.app.shoptime/src/views/FeaturedBrandsPanel/FeaturedBrandsPanel.jsx b/com.twin.app.shoptime/src/views/FeaturedBrandsPanel/FeaturedBrandsPanel.jsx index f6b48392..5475bc6d 100644 --- a/com.twin.app.shoptime/src/views/FeaturedBrandsPanel/FeaturedBrandsPanel.jsx +++ b/com.twin.app.shoptime/src/views/FeaturedBrandsPanel/FeaturedBrandsPanel.jsx @@ -1054,6 +1054,18 @@ const FeaturedBrandsPanel = ({ isOnTop, panelInfo, spotlightId }) => { } }, [isLogGNBSent, isInitialFocusOccurred, selectedPatnrId, selectedPatncNm]); + // effect: partners log for NBCU (patnrId=21) + useEffect(() => { + if (selectedPatnrId === 21 && selectedPatncNm) { + dispatch( + sendLogPartners({ + patncNm: selectedPatncNm, + patnrId: selectedPatnrId, + }) + ); + } + }, [selectedPatnrId, selectedPatncNm]); + // effect: unmount useEffect(() => { return () => {