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

feat: 백엔드 로그 전달 #30

Merged
merged 2 commits into from
Feb 25, 2024
Merged
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
8 changes: 4 additions & 4 deletions src/Logger.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { SetLocalStorage, SetLocalStorageClear } from './SetLocalStorage';
import { LogPayloadParams, ServiceNameType } from './types/LogType';
import { LogPayloadParams, LogType, ServiceNameType } from './types/LogType';
import CryptoJS from 'crypto-js';
import { postLog } from './apis/postLog';

const createRandomId = () => {
let randomId = '';
Expand Down Expand Up @@ -93,8 +94,7 @@ export const Logger = ({ userId, serviceName, name, message, path, tags }: LogPa
window.addEventListener('unload', async (event) => {
event.preventDefault();

const logList: any[] = JSON.parse(localStorage.getItem('yls-web') as string) || [];

// const res = await postLog(logList);
const logList: LogType[] = JSON.parse(localStorage.getItem('yls-web') as string) || [];
const res = await postLog(logList);
SetLocalStorageClear();
});
5 changes: 3 additions & 2 deletions src/apis/postLog.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { LogType } from '../types/LogType';
import customedAxios from './customedAxios';

export const postLog = async () => {
const res = await customedAxios.put('');
export const postLog = async (data: LogType[]) => {
const res = await customedAxios.put('/log/list', data);
return res.data;
};