Skip to content

Commit

Permalink
[fix] reduce noise from trackjs on reload (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
sijav authored Jun 20, 2024
1 parent 1e34d29 commit 3436648
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,19 @@
delete window._load_page_timeout
if (window.TrackJS && window.TrackJS.isInstalled()) {
window.TrackJS.track(new Error('It took more than ' + timeout / 1000 + 's to load the page'))
window.console = {
error: () => {},
info: () => {},
log: () => {},
warn: () => {},
assert: () => {},
debug: () => {},
trace: () => {}
}
window.TrackJS = {
isInstalled: () => false,
track: () => {}
}
}
window.setTimeout(function () {
window.location.reload()
Expand Down
5 changes: 5 additions & 0 deletions src/core/auth/AuthGuard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ export function AuthGuard({ children }: PropsWithChildren) {
(error: AxiosError | Error) => {
if ((error as AxiosError)?.code !== 'ERR_CANCELED') {
if (window.TrackJS?.isInstalled()) {
const data = (error as AxiosError)?.response?.data
if (data) {
window.TrackJS.console.info(data)
}
window.TrackJS.track(error)
}
postHog.capture(PostHogEvent.Error, {
Expand All @@ -198,6 +202,7 @@ export function AuthGuard({ children }: PropsWithChildren) {
}
if ('isAxiosError' in error && error.isAxiosError && error.code !== 'ERR_CANCELED') {
if (window.TrackJS?.isInstalled()) {
window.TrackJS.console.info(error.response?.data ?? 'no data from server')
window.TrackJS.track(error)
}
postHog.capture(PostHogEvent.NetworkError, {
Expand Down
4 changes: 4 additions & 0 deletions src/pages/panel/shared/utils/sendInventoryError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ export const sendInventoryError = ({
postHog: PostHog
}) => {
if (window.TrackJS?.isInstalled()) {
const data = error?.response?.data
if (data) {
window.TrackJS.console.info(data)
}
window.TrackJS.track(error)
}

Expand Down

0 comments on commit 3436648

Please sign in to comment.