- refactored logic of logging;
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import * as Sentry from '@sentry/browser';
|
import logMsgWithSentry from '../../helpers/logMsgWithSentry';
|
||||||
|
|
||||||
const LOCAL_DEVELOPMENT = process.env.REACT_APP_LOCAL_DEVELOPMENT;
|
|
||||||
|
|
||||||
class ErrorBoundary extends Component {
|
class ErrorBoundary extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -14,16 +12,8 @@ class ErrorBoundary extends Component {
|
|||||||
|
|
||||||
static getDerivedStateFromError(error) {
|
static getDerivedStateFromError(error) {
|
||||||
try {
|
try {
|
||||||
if (LOCAL_DEVELOPMENT !== '1') {
|
logMsgWithSentry('', 0, {}, error);
|
||||||
Sentry.init({
|
|
||||||
dsn: "https://e7b2134f7d816f663bb83e51b106a694@o4508381921738752.ingest.de.sentry.io/4508381935501392",
|
|
||||||
environment: process.env.NODE_ENV || "development"
|
|
||||||
});
|
|
||||||
|
|
||||||
Sentry.captureException(error);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log('err')
|
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
return { builderError: true };
|
return { builderError: true };
|
||||||
|
|||||||
31
src/helpers/logMsgWithSentry.js
Normal file
31
src/helpers/logMsgWithSentry.js
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import * as Sentry from '@sentry/browser';
|
||||||
|
|
||||||
|
const LOCAL_DEVELOPMENT = process.env.REACT_APP_LOCAL_DEVELOPMENT;
|
||||||
|
|
||||||
|
const logMsgWithSentry = (endpoint = '', status = 0, resp = {}, error = null) => {
|
||||||
|
try {
|
||||||
|
if (LOCAL_DEVELOPMENT !== '1') {
|
||||||
|
Sentry.init({
|
||||||
|
dsn: 'https://e7b2134f7d816f663bb83e51b106a694@o4508381921738752.ingest.de.sentry.io/4508381935501392',
|
||||||
|
environment: process.env.NODE_ENV || 'development'
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!error) {
|
||||||
|
const newError = new Error(`Status ${status}`);
|
||||||
|
Sentry.captureException(`Error in endpoint: ${endpoint}`, {
|
||||||
|
level: 'error',
|
||||||
|
extra: {
|
||||||
|
originalError: newError,
|
||||||
|
details: resp
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Sentry.captureException(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default logMsgWithSentry;
|
||||||
@@ -1,33 +1,11 @@
|
|||||||
import { storeGet, storeSet } from '../store';
|
import { storeGet, storeSet } from '../store';
|
||||||
import * as Sentry from '@sentry/browser';
|
import logMsgWithSentry from '../helpers/logMsgWithSentry';
|
||||||
|
|
||||||
const LOCAL_DEVELOPMENT = process.env.REACT_APP_LOCAL_DEVELOPMENT;
|
|
||||||
|
|
||||||
export class NetworkService {
|
export class NetworkService {
|
||||||
static TOKEN_KEY
|
|
||||||
static REFRESH_TOKEN_KEY
|
|
||||||
|
|
||||||
static logApiError = (endpoint, status = 0, resp = {}) => {
|
static logApiError = (endpoint, status = 0, resp = {}) => {
|
||||||
if (status === 500) {
|
if (status === 500) {
|
||||||
if (LOCAL_DEVELOPMENT !== '1') {
|
logMsgWithSentry(endpoint, status, resp);
|
||||||
try {
|
|
||||||
Sentry.init({
|
|
||||||
dsn: 'https://e7b2134f7d816f663bb83e51b106a694@o4508381921738752.ingest.de.sentry.io/4508381935501392',
|
|
||||||
environment: process.env.NODE_ENV || 'development'
|
|
||||||
});
|
|
||||||
|
|
||||||
const error = new Error(`Status ${status}`);
|
|
||||||
Sentry.captureException(`Error in endpoint: ${endpoint}`, {
|
|
||||||
level: 'error',
|
|
||||||
extra: {
|
|
||||||
originalError: error,
|
|
||||||
details: resp
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (status === 403) {
|
} else if (status === 403) {
|
||||||
storeSet.main.token('');
|
storeSet.main.token('');
|
||||||
const { pathname } = window.location;
|
const { pathname } = window.location;
|
||||||
|
|||||||
Reference in New Issue
Block a user