update bugsnag instances

This commit is contained in:
feruz 2021-07-30 14:05:06 +03:00
parent c4e5f5b064
commit 656decf702
8 changed files with 117 additions and 49 deletions

2
App.js
View File

@ -1,5 +1,5 @@
// eslint-disable-next-line // eslint-disable-next-line
import bugsnag from './src/config/bugsnag'; import bugsnagInstance from './src/config/bugsnag';
import App from './src/index'; import App from './src/index';
if (__DEV__) { if (__DEV__) {

View File

@ -0,0 +1,67 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
* directory of this source tree.
*/
package app.esteem.mobile.android;
import android.content.Context;
import com.facebook.flipper.android.AndroidFlipperClient;
import com.facebook.flipper.android.utils.FlipperUtils;
import com.facebook.flipper.core.FlipperClient;
import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
import com.facebook.flipper.plugins.inspector.DescriptorMapping;
import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.modules.network.NetworkingModule;
import okhttp3.OkHttpClient;
public class ReactNativeFlipper {
public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
if (FlipperUtils.shouldEnableFlipper(context)) {
final FlipperClient client = AndroidFlipperClient.getInstance(context);
client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
client.addPlugin(new ReactFlipperPlugin());
client.addPlugin(new DatabasesFlipperPlugin(context));
client.addPlugin(new SharedPreferencesFlipperPlugin(context));
client.addPlugin(CrashReporterPlugin.getInstance());
NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
NetworkingModule.setCustomClientBuilder(
new NetworkingModule.CustomClientBuilder() {
@Override
public void apply(OkHttpClient.Builder builder) {
builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
}
});
client.addPlugin(networkFlipperPlugin);
client.start();
// Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
// Hence we run if after all native modules have been initialized
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
if (reactContext == null) {
reactInstanceManager.addReactInstanceEventListener(
new ReactInstanceManager.ReactInstanceEventListener() {
@Override
public void onReactContextInitialized(ReactContext reactContext) {
reactInstanceManager.removeReactInstanceEventListener(this);
reactContext.runOnNativeModulesQueueThread(
new Runnable() {
@Override
public void run() {
client.addPlugin(new FrescoFlipperPlugin());
}
});
}
});
} else {
client.addPlugin(new FrescoFlipperPlugin());
}
}
}
}

View File

@ -7,7 +7,7 @@ import ImageSize from 'react-native-image-size';
// Utils // Utils
import FastImage from 'react-native-fast-image'; import FastImage from 'react-native-fast-image';
import { getTimeFromNow } from '../../../utils/time'; import { getTimeFromNow } from '../../../utils/time';
import bugsnag from '../../../config/bugsnag'; //import bugsnagInstance from '../../../config/bugsnag';
// Components // Components
import { PostHeaderDescription } from '../../postElements'; import { PostHeaderDescription } from '../../postElements';

View File

@ -8,7 +8,7 @@ import { injectIntl } from 'react-intl';
import get from 'lodash/get'; import get from 'lodash/get';
// Services // Services
import bugsnag from '../config/bugsnag'; import bugsnagInstance from '../config/bugsnag';
import { purchaseOrder } from '../providers/ecency/ecency'; import { purchaseOrder } from '../providers/ecency/ecency';
// Utilities // Utilities
@ -77,7 +77,7 @@ class InAppPurchaseContainer extends Component {
} }
}) })
.catch((err) => .catch((err) =>
bugsnag.notify(err, (report) => { bugsnagInstance.notify(err, (report) => {
report.addMetadata('data', data); report.addMetadata('data', data);
}), }),
); );
@ -116,7 +116,7 @@ class InAppPurchaseContainer extends Component {
products.sort((a, b) => parseFloat(a.price) - parseFloat(b.price)).reverse(); products.sort((a, b) => parseFloat(a.price) - parseFloat(b.price)).reverse();
await this.setState({ productList: products }); await this.setState({ productList: products });
} catch (err) { } catch (err) {
bugsnag.notify(err); bugsnagInstance.notify(err);
Alert.alert( Alert.alert(
`InApp - Connection issue, try again or write to support@ecency.com `InApp - Connection issue, try again or write to support@ecency.com
${err.message.substr(0, 20)}`, ${err.message.substr(0, 20)}`,
@ -135,7 +135,7 @@ class InAppPurchaseContainer extends Component {
try { try {
RNIap.requestPurchase(sku, false); RNIap.requestPurchase(sku, false);
} catch (err) { } catch (err) {
bugsnag.notify(err, (report) => { bugsnagInstance.notify(err, (report) => {
report.addMetadata('sku', sku); report.addMetadata('sku', sku);
}); });
} }

View File

@ -23,7 +23,7 @@ import { getUser } from '../providers/ecency/ePoint';
// Utils // Utils
import { countDecimals } from '../utils/number'; import { countDecimals } from '../utils/number';
import bugsnag from '../config/bugsnag'; import bugsnagInstance from '../config/bugsnag';
/* /*
* Props Name Description Value * Props Name Description Value
@ -195,7 +195,7 @@ class TransferContainer extends Component {
}) })
.catch((err) => { .catch((err) => {
navigation.goBack(); navigation.goBack();
bugsnag.notify(err); bugsnagInstance.notify(err);
dispatch(toastNotification(intl.formatMessage({ id: 'alert.key_warning' }))); dispatch(toastNotification(intl.formatMessage({ id: 'alert.key_warning' })));
}); });
}; };

View File

@ -2,7 +2,7 @@ import api from '../../config/api';
import ecencyApi from '../../config/ecencyApi'; import ecencyApi from '../../config/ecencyApi';
import { upload } from '../../config/imageApi'; import { upload } from '../../config/imageApi';
import serverList from '../../config/serverListApi'; import serverList from '../../config/serverListApi';
import bugsnag from '../../config/bugsnag'; import bugsnagInstance from '../../config/bugsnag';
import { SERVER_LIST } from '../../constants/options/api'; import { SERVER_LIST } from '../../constants/options/api';
import { parsePost } from '../../utils/postParser'; import { parsePost } from '../../utils/postParser';
@ -11,7 +11,7 @@ export const getCurrencyRate = (currency) =>
.get(`/market-data/currency-rate/${currency}/hbd?fixed=1`) .get(`/market-data/currency-rate/${currency}/hbd?fixed=1`)
.then((resp) => resp.data) .then((resp) => resp.data)
.catch((err) => { .catch((err) => {
bugsnag.notify(err); bugsnagInstance.notify(err);
//TODO: save currency rate of offline values //TODO: save currency rate of offline values
return 1; return 1;
}); });
@ -21,7 +21,7 @@ export const getCurrencyTokenRate = (currency, token) =>
.get(`/market-data/currency-rate/${currency}/${token}`) .get(`/market-data/currency-rate/${currency}/${token}`)
.then((resp) => resp.data) .then((resp) => resp.data)
.catch((err) => { .catch((err) => {
bugsnag.notify(err); bugsnagInstance.notify(err);
return 0; return 0;
}); });
@ -35,7 +35,7 @@ export const getDrafts = async () => {
const res = await ecencyApi.post('/private-api/drafts'); const res = await ecencyApi.post('/private-api/drafts');
return res.data; return res.data;
}catch(error){ }catch(error){
bugsnag.notify(error); bugsnagInstance.notify(error);
throw error; throw error;
} }
} }
@ -51,7 +51,7 @@ export const deleteDraft = async (draftId:string) => {
const res = await ecencyApi.post(`/private-api/drafts-delete`, data); const res = await ecencyApi.post(`/private-api/drafts-delete`, data);
return res.data return res.data
}catch(error){ }catch(error){
bugsnag.notify(error); bugsnagInstance.notify(error);
throw error; throw error;
} }
} }
@ -73,7 +73,7 @@ export const addDraft = async (title:string, body:string, tags:string) => {
throw new Error('No drafts returned in response'); throw new Error('No drafts returned in response');
} }
} catch(error){ } catch(error){
bugsnag.notify(error); bugsnagInstance.notify(error);
throw error; throw error;
} }
} }
@ -95,7 +95,7 @@ export const updateDraft = async (draftId:string, title:string, body:string, tag
throw new Error("No data returned in response") throw new Error("No data returned in response")
} }
} catch(error){ } catch(error){
bugsnag.notify(error); bugsnagInstance.notify(error);
throw error; throw error;
} }
}; };
@ -121,7 +121,7 @@ export const addBookmark = async (author:string, permlink:string) => {
return response.data; return response.data;
} catch(error) { } catch(error) {
console.warn("Failed to add bookmark", error) console.warn("Failed to add bookmark", error)
bugsnag.notify(error) bugsnagInstance.notify(error)
throw error throw error
} }
} }
@ -136,7 +136,7 @@ export const getBookmarks = async () => {
return response.data; return response.data;
} catch(error) { } catch(error) {
console.warn("Failed to get saved bookmarks", error) console.warn("Failed to get saved bookmarks", error)
bugsnag.notify(error) bugsnagInstance.notify(error)
throw error throw error
} }
} }
@ -154,7 +154,7 @@ export const deleteBookmark = async (bookmarkId:string) => {
return response.data; return response.data;
} catch(error) { } catch(error) {
console.warn("Failed to delete bookmark", error) console.warn("Failed to delete bookmark", error)
bugsnag.notify(error) bugsnagInstance.notify(error)
throw error throw error
} }
} }
@ -184,7 +184,7 @@ export const getFavorites = async () => {
return response.data; return response.data;
} catch(error) { } catch(error) {
console.warn("Failed to get favorites", error); console.warn("Failed to get favorites", error);
bugsnag.notify(error); bugsnagInstance.notify(error);
throw error throw error
} }
} }
@ -201,7 +201,7 @@ export const checkFavorite = async (targetUsername:string) => {
return response.data || false; return response.data || false;
} catch(error) { } catch(error) {
console.warn("Failed to check favorite", error); console.warn("Failed to check favorite", error);
bugsnag.notify(error); bugsnagInstance.notify(error);
} }
} }
@ -217,7 +217,7 @@ export const addFavorite = async (targetUsername:string) => {
return response.data; return response.data;
} catch(error) { } catch(error) {
console.warn("Failed to add user favorites", error); console.warn("Failed to add user favorites", error);
bugsnag.notify(error); bugsnagInstance.notify(error);
throw error throw error
} }
} }
@ -235,7 +235,7 @@ export const deleteFavorite = async (targetUsername:string) => {
return response.data; return response.data;
} catch(error) { } catch(error) {
console.warn("Failed to add user favorites", error); console.warn("Failed to add user favorites", error);
bugsnag.notify(error); bugsnagInstance.notify(error);
throw error; throw error;
} }
} }
@ -258,7 +258,7 @@ export const getFragments = async () => {
return response.data; return response.data;
} catch(error) { } catch(error) {
console.warn("Failed to get fragments", error); console.warn("Failed to get fragments", error);
bugsnag.notify(error) bugsnagInstance.notify(error)
throw error; throw error;
} }
} }
@ -278,7 +278,7 @@ export const getFragments = async () => {
return response.data; return response.data;
} catch(error) { } catch(error) {
console.warn("Failed to add fragment", error); console.warn("Failed to add fragment", error);
bugsnag.notify(error) bugsnagInstance.notify(error)
throw error; throw error;
} }
} }
@ -297,7 +297,7 @@ export const getFragments = async () => {
return response.data; return response.data;
} catch(error) { } catch(error) {
console.warn("Failed to update fragment", error); console.warn("Failed to update fragment", error);
bugsnag.notify(error) bugsnagInstance.notify(error)
throw error; throw error;
} }
} }
@ -314,7 +314,7 @@ export const getFragments = async () => {
return response.data; return response.data;
} catch(error) { } catch(error) {
console.warn("Failed to delete fragment", error); console.warn("Failed to delete fragment", error);
bugsnag.notify(error) bugsnagInstance.notify(error)
throw error; throw error;
} }
} }
@ -332,7 +332,7 @@ export const getLeaderboard = async (duration:'day'|'week'|'month') => {
const response = await ecencyApi.get(`private-api/leaderboard/${duration}`) const response = await ecencyApi.get(`private-api/leaderboard/${duration}`)
return response.data; return response.data;
} catch(error) { } catch(error) {
bugsnag.notify(error) bugsnagInstance.notify(error)
} }
} }
@ -350,7 +350,7 @@ export const getNotifications = async (data:{
return response.data; return response.data;
}catch(error){ }catch(error){
console.warn("Failed to get notifications", error) console.warn("Failed to get notifications", error)
bugsnag.notify(error) bugsnagInstance.notify(error)
throw error; throw error;
} }
} }
@ -362,7 +362,7 @@ export const getNotifications = async (data:{
const response = await ecencyApi.post(`/private-api/notifications/unread`, data) const response = await ecencyApi.post(`/private-api/notifications/unread`, data)
return response.data ? response.data.count : 0; return response.data ? response.data.count : 0;
} catch(error) { } catch(error) {
bugsnag.notify(error); bugsnagInstance.notify(error);
return 0; return 0;
} }
} }
@ -373,7 +373,7 @@ export const getNotifications = async (data:{
const response = await ecencyApi.post((`/private-api/notifications/mark`), data); const response = await ecencyApi.post((`/private-api/notifications/mark`), data);
return response.data return response.data
}catch(error) { }catch(error) {
bugsnag.notify(error); bugsnagInstance.notify(error);
throw error throw error
} }
}; };
@ -387,7 +387,7 @@ export const setPushToken = (data) =>
resolve(res.data); resolve(res.data);
}) })
.catch((error) => { .catch((error) => {
bugsnag.notify(error); bugsnagInstance.notify(error);
reject(error); reject(error);
}); });
}); });
@ -410,7 +410,7 @@ export const search = async (data:{
return response.data; return response.data;
} catch(error) { } catch(error) {
console.warn("Search failed", error); console.warn("Search failed", error);
bugsnag.notify(error); bugsnagInstance.notify(error);
throw error; throw error;
} }
} }
@ -428,7 +428,7 @@ export const search = async (data:{
return response.data; return response.data;
} catch(error){ } catch(error){
console.warn("path search failed", error) console.warn("path search failed", error)
bugsnag.notify(error); bugsnagInstance.notify(error);
throw error throw error
} }
} }
@ -452,7 +452,7 @@ export const search = async (data:{
return response.data; return response.data;
} catch(error) { } catch(error) {
console.warn("account search failed", error) console.warn("account search failed", error)
bugsnag.notify(error); bugsnagInstance.notify(error);
throw error; throw error;
} }
} }
@ -476,7 +476,7 @@ export const search = async (data:{
return response.data; return response.data;
} catch(error) { } catch(error) {
console.warn("tag search failed", error) console.warn("tag search failed", error)
bugsnag.notify(error); bugsnagInstance.notify(error);
throw error throw error
} }
} }
@ -522,7 +522,7 @@ export const addSchedule = async (
return response.data; return response.data;
} catch(error) { } catch(error) {
console.warn("Failed to add post to schedule", error) console.warn("Failed to add post to schedule", error)
bugsnag.notify(error); bugsnagInstance.notify(error);
throw error; throw error;
} }
} }
@ -537,7 +537,7 @@ export const getSchedules = async () => {
return response.data; return response.data;
} catch(error){ } catch(error){
console.warn("Failed to get schedules") console.warn("Failed to get schedules")
bugsnag.notify(error) bugsnagInstance.notify(error)
throw error; throw error;
} }
} }
@ -554,7 +554,7 @@ export const deleteScheduledPost = async (id:string) => {
return response; return response;
}catch(error){ }catch(error){
console.warn("Failed to delete scheduled post") console.warn("Failed to delete scheduled post")
bugsnag.notify(error) bugsnagInstance.notify(error)
throw error; throw error;
} }
} }
@ -571,7 +571,7 @@ export const moveScheduledToDraft = async (id:string) => {
return response.data; return response.data;
} catch(error) { } catch(error) {
console.warn("Failed to move scheduled post to drafts") console.warn("Failed to move scheduled post to drafts")
bugsnag.notify(error) bugsnagInstance.notify(error)
throw error; throw error;
} }
} }
@ -590,7 +590,7 @@ export const getImages = async () => {
return response.data; return response.data;
} catch(error){ } catch(error){
console.warn('Failed to get images', error); console.warn('Failed to get images', error);
bugsnag.notify(error); bugsnagInstance.notify(error);
} }
} }
@ -601,7 +601,7 @@ export const addImage = async (url:string) => {
return response.data; return response.data;
} catch(error) { } catch(error) {
console.warn('Failed to add image', error); console.warn('Failed to add image', error);
bugsnag.notify(error); bugsnagInstance.notify(error);
throw error; throw error;
} }
} }
@ -613,7 +613,7 @@ export const deleteImage = async (id:string) => {
return response.data; return response.data;
} catch(error) { } catch(error) {
console.warn('Failed to delete image', error); console.warn('Failed to delete image', error);
bugsnag.notify(error); bugsnagInstance.notify(error);
throw error; throw error;
} }
} }
@ -651,7 +651,7 @@ export const getSCAccessToken = async (code:string) => {
return response.data; return response.data;
}catch(error){ }catch(error){
console.warn("failed to refresh token") console.warn("failed to refresh token")
bugsnag.notify(error); bugsnagInstance.notify(error);
throw error throw error
} }
} }
@ -673,7 +673,7 @@ export const getSCAccessToken = async (code:string) => {
}); });
} catch (error) { } catch (error) {
console.warn("Failed to get promoted enties") console.warn("Failed to get promoted enties")
bugsnag.notify(error); bugsnagInstance.notify(error);
return error; return error;
} }
}; };
@ -684,7 +684,7 @@ export const purchaseOrder = (data) =>
api api
.post('/purchase-order', data) .post('/purchase-order', data)
.then((resp) => resp.data) .then((resp) => resp.data)
.catch((error) => bugsnag.notify(error)); .catch((error) => bugsnagInstance.notify(error));
@ -692,7 +692,7 @@ export const getPostReblogs = (data) =>
api api
.get(`/post-reblogs/${data.author}/${data.permlink}`) .get(`/post-reblogs/${data.author}/${data.permlink}`)
.then((resp) => resp.data) .then((resp) => resp.data)
.catch((error) => bugsnag.notify(error)); .catch((error) => bugsnagInstance.notify(error));
/** /**
@ -713,7 +713,7 @@ export const signUp = async (username:string, email:string, referral?:string) =>
const response = await ecencyApi.post('/private-api/account-create', data); const response = await ecencyApi.post('/private-api/account-create', data);
return response.status === 202; return response.status === 202;
} catch (error) { } catch (error) {
bugsnag.notify(error); bugsnagInstance.notify(error);
throw error; throw error;
} }
}; };

View File

@ -170,6 +170,7 @@ class ApplicationScreen extends Component {
<ForegroundNotification remoteMessage={foregroundNotificationData} /> <ForegroundNotification remoteMessage={foregroundNotificationData} />
<AccountsBottomSheet /> <AccountsBottomSheet />
<ActionModal />
</View> </View>
); );
} }

View File

@ -5,7 +5,7 @@ import RNRestart from 'react-native-restart';
import { Icon } from '../../../components'; import { Icon } from '../../../components';
import bugsnag from '../../../config/bugsnag'; import bugsnagInstance from '../../../config/bugsnag';
class ErrorBoundary extends React.Component { class ErrorBoundary extends React.Component {
constructor(props) { constructor(props) {
@ -18,7 +18,7 @@ class ErrorBoundary extends React.Component {
} }
componentDidCatch(error, errorInfo) { componentDidCatch(error, errorInfo) {
bugsnag.notify(error, (report) => { bugsnagInstance.notify(error, (report) => {
report.addMetadata('errorBoundary', errorInfo); report.addMetadata('errorBoundary', errorInfo);
}); });
} }