mirror of
https://github.com/ktds-dg0501/kt-event-marketing-fe.git
synced 2025-12-06 08:16:23 +00:00
- 이벤트 기간 계산 함수에 상세 디버그 로그 추가 - 차트 데이터 생성 함수에 필터링 과정 로그 추가 - Timeline dataPoints 구조 확인을 위한 콘솔 출력 추가 - ROI 필드 매핑 검증을 위한 로그 추가
68 lines
1.8 KiB
TypeScript
68 lines
1.8 KiB
TypeScript
import axios, { AxiosInstance, AxiosError, InternalAxiosRequestConfig } from 'axios';
|
|
|
|
const ANALYTICS_HOST =
|
|
process.env.NEXT_PUBLIC_ANALYTICS_HOST || 'http://localhost:8086';
|
|
|
|
export const analyticsClient: AxiosInstance = axios.create({
|
|
baseURL: ANALYTICS_HOST,
|
|
timeout: 30000,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
});
|
|
|
|
// Request interceptor - JWT 토큰 추가
|
|
analyticsClient.interceptors.request.use(
|
|
(config: InternalAxiosRequestConfig) => {
|
|
console.log('🚀 Analytics API Request:', {
|
|
method: config.method?.toUpperCase(),
|
|
url: config.url,
|
|
baseURL: config.baseURL,
|
|
params: config.params,
|
|
});
|
|
|
|
const token = localStorage.getItem('accessToken');
|
|
if (token && config.headers) {
|
|
config.headers.Authorization = `Bearer ${token}`;
|
|
console.log('🔑 Token added to analytics request');
|
|
}
|
|
return config;
|
|
},
|
|
(error: AxiosError) => {
|
|
console.error('❌ Analytics Request Error:', error);
|
|
return Promise.reject(error);
|
|
}
|
|
);
|
|
|
|
// Response interceptor - 에러 처리
|
|
analyticsClient.interceptors.response.use(
|
|
(response) => {
|
|
console.log('✅ Analytics API Response:', {
|
|
status: response.status,
|
|
url: response.config.url,
|
|
data: response.data,
|
|
});
|
|
return response;
|
|
},
|
|
(error: AxiosError) => {
|
|
console.error('❌ Analytics API Error:', {
|
|
message: error.message,
|
|
status: error.response?.status,
|
|
statusText: error.response?.statusText,
|
|
url: error.config?.url,
|
|
data: error.response?.data,
|
|
});
|
|
|
|
if (error.response?.status === 401) {
|
|
console.warn('🔒 401 Unauthorized - Redirecting to login');
|
|
localStorage.removeItem('accessToken');
|
|
if (typeof window !== 'undefined') {
|
|
window.location.href = '/login';
|
|
}
|
|
}
|
|
return Promise.reject(error);
|
|
}
|
|
);
|
|
|
|
export default analyticsClient;
|