-
Notifications
You must be signed in to change notification settings - Fork 0
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(@yourssu/logging-system): fix 10th lost-log #68
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -1,36 +1,32 @@ | ||||||||||
import { LogRequestList, LogResponse, LogType } from './types/LogType'; | ||||||||||
|
||||||||||
export const SetLocalStorageClear = () => { | ||||||||||
const list: any[] = []; | ||||||||||
const list: LogType[] = []; | ||||||||||
localStorage.setItem('yls-web', JSON.stringify(list)); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
이거 그냥 이렇게 해도 되지 않나요? |
||||||||||
}; | ||||||||||
|
||||||||||
export const SetLocalStorage = async ( | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PR의 내용과는 관계없습니다만, 이거 왜 예시) 일단 이 PR과 관계없으므로 resolve 되지 않아도 Approve는 가능합니다. |
||||||||||
logger: LogType, | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 PR만의 문제가 아닌 것 같긴 한데, 얘 이름이 logger인 이유를 모르겠네요. log 데이터 그 자체이므로 이름 수정이 필요합니다. |
||||||||||
putLog: (data: LogRequestList) => Promise<LogResponse> | ||||||||||
) => { | ||||||||||
if (window.localStorage.getItem('yls-web') == undefined) { | ||||||||||
const list: any[] = []; | ||||||||||
list.push(logger); | ||||||||||
localStorage.setItem('yls-web', JSON.stringify(list)); | ||||||||||
} else { | ||||||||||
const remainList: any[] = JSON.parse(localStorage.getItem('yls-web') as string) || []; | ||||||||||
if (remainList.length < 10) { | ||||||||||
const updateList = [...remainList, logger]; | ||||||||||
localStorage.setItem('yls-web', JSON.stringify(updateList)); | ||||||||||
} else { | ||||||||||
const req: LogRequestList = { | ||||||||||
logRequestList: remainList, | ||||||||||
}; | ||||||||||
const list: LogType[] = JSON.parse(localStorage.getItem('yls-web') as string) || []; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
list.push(logger); | ||||||||||
localStorage.setItem('yls-web', JSON.stringify(list)); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
if (list.length >= 10) { | ||||||||||
const req: LogRequestList = { | ||||||||||
logRequestList: list, | ||||||||||
}; | ||||||||||
|
||||||||||
SetLocalStorageClear(); | ||||||||||
|
||||||||||
try { | ||||||||||
const res = await putLog(req); | ||||||||||
if (res.success) { | ||||||||||
SetLocalStorageClear(); | ||||||||||
} | ||||||||||
} catch (e) { | ||||||||||
console.error('Failed to post log'); | ||||||||||
} | ||||||||||
try { | ||||||||||
await putLog(req); | ||||||||||
} catch (e) { | ||||||||||
console.error('Failed to post log'); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 오류는 프로덕션에는 안나면 좋겠네요. 어짜피 Network 탭에서 요청 상태를 확인 가능하니까요. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 혹시나 에러 로깅을 하고 싶으시다면
Suggested change
|
||||||||||
const remainList: LogType[] = JSON.parse(localStorage.getItem('yls-web') as string) || []; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||
remainList.unshift(...list); | ||||||||||
localStorage.setItem('yls-web', JSON.stringify(remainList)); | ||||||||||
Comment on lines
+28
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
이편이 깔끔하지 않을까요? |
||||||||||
} | ||||||||||
} | ||||||||||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이것도 네이밍이 미묘하네요.