Skip to content

Commit

Permalink
feat: 유저 이탈시 백엔드에 로그 전달 (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
JjungminLee authored Feb 14, 2024
1 parent 0198af0 commit 685cf78
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/Logger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SetLocalStorage } from './SetLocalStorage';
import { SetLocalStorage, SetLocalStorageClear } from './SetLocalStorage';
import { LogPayloadParams, ServiceNameType } from './types/LogType';
import CryptoJS from 'crypto-js';

Expand Down Expand Up @@ -89,3 +89,12 @@ 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);
SetLocalStorageClear();
});
2 changes: 1 addition & 1 deletion src/SetLocalStorage.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { postLog } from './apis/postLog';
import { LogType } from './types/LogType';

const SetLocalStorageClear = () => {
export const SetLocalStorageClear = () => {
const list: any[] = [];
localStorage.setItem('yls-web', JSON.stringify(list));
};
Expand Down

0 comments on commit 685cf78

Please sign in to comment.