diff --git a/App.js b/App.js index effb20d2f..24cf3cf8c 100644 --- a/App.js +++ b/App.js @@ -1,5 +1,5 @@ // eslint-disable-next-line -import bugsnag from './src/config/bugsnag'; +import bugsnagInstance from './src/config/bugsnag'; import App from './src/index'; if (__DEV__) { diff --git a/android/app/src/debug/java/app/esteem/mobile/android/ReactNativeFlipper.java b/android/app/src/debug/java/app/esteem/mobile/android/ReactNativeFlipper.java new file mode 100644 index 000000000..2ccc1c781 --- /dev/null +++ b/android/app/src/debug/java/app/esteem/mobile/android/ReactNativeFlipper.java @@ -0,0 +1,67 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + *
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());
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/components/postCard/view/postCardView.js b/src/components/postCard/view/postCardView.js
index 7b57f6340..c6af4978d 100644
--- a/src/components/postCard/view/postCardView.js
+++ b/src/components/postCard/view/postCardView.js
@@ -7,7 +7,7 @@ import ImageSize from 'react-native-image-size';
// Utils
import FastImage from 'react-native-fast-image';
import { getTimeFromNow } from '../../../utils/time';
-import bugsnag from '../../../config/bugsnag';
+//import bugsnagInstance from '../../../config/bugsnag';
// Components
import { PostHeaderDescription } from '../../postElements';
diff --git a/src/containers/inAppPurchaseContainer.js b/src/containers/inAppPurchaseContainer.js
index 92cc3819b..a617ece6d 100644
--- a/src/containers/inAppPurchaseContainer.js
+++ b/src/containers/inAppPurchaseContainer.js
@@ -8,7 +8,7 @@ import { injectIntl } from 'react-intl';
import get from 'lodash/get';
// Services
-import bugsnag from '../config/bugsnag';
+import bugsnagInstance from '../config/bugsnag';
import { purchaseOrder } from '../providers/ecency/ecency';
// Utilities
@@ -77,7 +77,7 @@ class InAppPurchaseContainer extends Component {
}
})
.catch((err) =>
- bugsnag.notify(err, (report) => {
+ bugsnagInstance.notify(err, (report) => {
report.addMetadata('data', data);
}),
);
@@ -116,7 +116,7 @@ class InAppPurchaseContainer extends Component {
products.sort((a, b) => parseFloat(a.price) - parseFloat(b.price)).reverse();
await this.setState({ productList: products });
} catch (err) {
- bugsnag.notify(err);
+ bugsnagInstance.notify(err);
Alert.alert(
`InApp - Connection issue, try again or write to support@ecency.com
${err.message.substr(0, 20)}`,
@@ -135,7 +135,7 @@ class InAppPurchaseContainer extends Component {
try {
RNIap.requestPurchase(sku, false);
} catch (err) {
- bugsnag.notify(err, (report) => {
+ bugsnagInstance.notify(err, (report) => {
report.addMetadata('sku', sku);
});
}
diff --git a/src/containers/transferContainer.js b/src/containers/transferContainer.js
index 8b03c938e..de6afa615 100644
--- a/src/containers/transferContainer.js
+++ b/src/containers/transferContainer.js
@@ -23,7 +23,7 @@ import { getUser } from '../providers/ecency/ePoint';
// Utils
import { countDecimals } from '../utils/number';
-import bugsnag from '../config/bugsnag';
+import bugsnagInstance from '../config/bugsnag';
/*
* Props Name Description Value
@@ -195,7 +195,7 @@ class TransferContainer extends Component {
})
.catch((err) => {
navigation.goBack();
- bugsnag.notify(err);
+ bugsnagInstance.notify(err);
dispatch(toastNotification(intl.formatMessage({ id: 'alert.key_warning' })));
});
};
diff --git a/src/providers/ecency/ecency.ts b/src/providers/ecency/ecency.ts
index fb4516eaf..ebc02b9a3 100644
--- a/src/providers/ecency/ecency.ts
+++ b/src/providers/ecency/ecency.ts
@@ -2,7 +2,7 @@ import api from '../../config/api';
import ecencyApi from '../../config/ecencyApi';
import { upload } from '../../config/imageApi';
import serverList from '../../config/serverListApi';
-import bugsnag from '../../config/bugsnag';
+import bugsnagInstance from '../../config/bugsnag';
import { SERVER_LIST } from '../../constants/options/api';
import { parsePost } from '../../utils/postParser';
@@ -11,7 +11,7 @@ export const getCurrencyRate = (currency) =>
.get(`/market-data/currency-rate/${currency}/hbd?fixed=1`)
.then((resp) => resp.data)
.catch((err) => {
- bugsnag.notify(err);
+ bugsnagInstance.notify(err);
//TODO: save currency rate of offline values
return 1;
});
@@ -21,7 +21,7 @@ export const getCurrencyTokenRate = (currency, token) =>
.get(`/market-data/currency-rate/${currency}/${token}`)
.then((resp) => resp.data)
.catch((err) => {
- bugsnag.notify(err);
+ bugsnagInstance.notify(err);
return 0;
});
@@ -35,7 +35,7 @@ export const getDrafts = async () => {
const res = await ecencyApi.post('/private-api/drafts');
return res.data;
}catch(error){
- bugsnag.notify(error);
+ bugsnagInstance.notify(error);
throw error;
}
}
@@ -51,7 +51,7 @@ export const deleteDraft = async (draftId:string) => {
const res = await ecencyApi.post(`/private-api/drafts-delete`, data);
return res.data
}catch(error){
- bugsnag.notify(error);
+ bugsnagInstance.notify(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');
}
} catch(error){
- bugsnag.notify(error);
+ bugsnagInstance.notify(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")
}
} catch(error){
- bugsnag.notify(error);
+ bugsnagInstance.notify(error);
throw error;
}
};
@@ -121,7 +121,7 @@ export const addBookmark = async (author:string, permlink:string) => {
return response.data;
} catch(error) {
console.warn("Failed to add bookmark", error)
- bugsnag.notify(error)
+ bugsnagInstance.notify(error)
throw error
}
}
@@ -136,7 +136,7 @@ export const getBookmarks = async () => {
return response.data;
} catch(error) {
console.warn("Failed to get saved bookmarks", error)
- bugsnag.notify(error)
+ bugsnagInstance.notify(error)
throw error
}
}
@@ -154,7 +154,7 @@ export const deleteBookmark = async (bookmarkId:string) => {
return response.data;
} catch(error) {
console.warn("Failed to delete bookmark", error)
- bugsnag.notify(error)
+ bugsnagInstance.notify(error)
throw error
}
}
@@ -184,7 +184,7 @@ export const getFavorites = async () => {
return response.data;
} catch(error) {
console.warn("Failed to get favorites", error);
- bugsnag.notify(error);
+ bugsnagInstance.notify(error);
throw error
}
}
@@ -201,7 +201,7 @@ export const checkFavorite = async (targetUsername:string) => {
return response.data || false;
} catch(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;
} catch(error) {
console.warn("Failed to add user favorites", error);
- bugsnag.notify(error);
+ bugsnagInstance.notify(error);
throw error
}
}
@@ -235,7 +235,7 @@ export const deleteFavorite = async (targetUsername:string) => {
return response.data;
} catch(error) {
console.warn("Failed to add user favorites", error);
- bugsnag.notify(error);
+ bugsnagInstance.notify(error);
throw error;
}
}
@@ -258,7 +258,7 @@ export const getFragments = async () => {
return response.data;
} catch(error) {
console.warn("Failed to get fragments", error);
- bugsnag.notify(error)
+ bugsnagInstance.notify(error)
throw error;
}
}
@@ -278,7 +278,7 @@ export const getFragments = async () => {
return response.data;
} catch(error) {
console.warn("Failed to add fragment", error);
- bugsnag.notify(error)
+ bugsnagInstance.notify(error)
throw error;
}
}
@@ -297,7 +297,7 @@ export const getFragments = async () => {
return response.data;
} catch(error) {
console.warn("Failed to update fragment", error);
- bugsnag.notify(error)
+ bugsnagInstance.notify(error)
throw error;
}
}
@@ -314,7 +314,7 @@ export const getFragments = async () => {
return response.data;
} catch(error) {
console.warn("Failed to delete fragment", error);
- bugsnag.notify(error)
+ bugsnagInstance.notify(error)
throw error;
}
}
@@ -332,7 +332,7 @@ export const getLeaderboard = async (duration:'day'|'week'|'month') => {
const response = await ecencyApi.get(`private-api/leaderboard/${duration}`)
return response.data;
} catch(error) {
- bugsnag.notify(error)
+ bugsnagInstance.notify(error)
}
}
@@ -350,7 +350,7 @@ export const getNotifications = async (data:{
return response.data;
}catch(error){
console.warn("Failed to get notifications", error)
- bugsnag.notify(error)
+ bugsnagInstance.notify(error)
throw error;
}
}
@@ -362,7 +362,7 @@ export const getNotifications = async (data:{
const response = await ecencyApi.post(`/private-api/notifications/unread`, data)
return response.data ? response.data.count : 0;
} catch(error) {
- bugsnag.notify(error);
+ bugsnagInstance.notify(error);
return 0;
}
}
@@ -373,7 +373,7 @@ export const getNotifications = async (data:{
const response = await ecencyApi.post((`/private-api/notifications/mark`), data);
return response.data
}catch(error) {
- bugsnag.notify(error);
+ bugsnagInstance.notify(error);
throw error
}
};
@@ -387,7 +387,7 @@ export const setPushToken = (data) =>
resolve(res.data);
})
.catch((error) => {
- bugsnag.notify(error);
+ bugsnagInstance.notify(error);
reject(error);
});
});
@@ -410,7 +410,7 @@ export const search = async (data:{
return response.data;
} catch(error) {
console.warn("Search failed", error);
- bugsnag.notify(error);
+ bugsnagInstance.notify(error);
throw error;
}
}
@@ -428,7 +428,7 @@ export const search = async (data:{
return response.data;
} catch(error){
console.warn("path search failed", error)
- bugsnag.notify(error);
+ bugsnagInstance.notify(error);
throw error
}
}
@@ -452,7 +452,7 @@ export const search = async (data:{
return response.data;
} catch(error) {
console.warn("account search failed", error)
- bugsnag.notify(error);
+ bugsnagInstance.notify(error);
throw error;
}
}
@@ -476,7 +476,7 @@ export const search = async (data:{
return response.data;
} catch(error) {
console.warn("tag search failed", error)
- bugsnag.notify(error);
+ bugsnagInstance.notify(error);
throw error
}
}
@@ -522,7 +522,7 @@ export const addSchedule = async (
return response.data;
} catch(error) {
console.warn("Failed to add post to schedule", error)
- bugsnag.notify(error);
+ bugsnagInstance.notify(error);
throw error;
}
}
@@ -537,7 +537,7 @@ export const getSchedules = async () => {
return response.data;
} catch(error){
console.warn("Failed to get schedules")
- bugsnag.notify(error)
+ bugsnagInstance.notify(error)
throw error;
}
}
@@ -554,7 +554,7 @@ export const deleteScheduledPost = async (id:string) => {
return response;
}catch(error){
console.warn("Failed to delete scheduled post")
- bugsnag.notify(error)
+ bugsnagInstance.notify(error)
throw error;
}
}
@@ -571,7 +571,7 @@ export const moveScheduledToDraft = async (id:string) => {
return response.data;
} catch(error) {
console.warn("Failed to move scheduled post to drafts")
- bugsnag.notify(error)
+ bugsnagInstance.notify(error)
throw error;
}
}
@@ -590,7 +590,7 @@ export const getImages = async () => {
return response.data;
} catch(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;
} catch(error) {
console.warn('Failed to add image', error);
- bugsnag.notify(error);
+ bugsnagInstance.notify(error);
throw error;
}
}
@@ -613,7 +613,7 @@ export const deleteImage = async (id:string) => {
return response.data;
} catch(error) {
console.warn('Failed to delete image', error);
- bugsnag.notify(error);
+ bugsnagInstance.notify(error);
throw error;
}
}
@@ -651,7 +651,7 @@ export const getSCAccessToken = async (code:string) => {
return response.data;
}catch(error){
console.warn("failed to refresh token")
- bugsnag.notify(error);
+ bugsnagInstance.notify(error);
throw error
}
}
@@ -673,7 +673,7 @@ export const getSCAccessToken = async (code:string) => {
});
} catch (error) {
console.warn("Failed to get promoted enties")
- bugsnag.notify(error);
+ bugsnagInstance.notify(error);
return error;
}
};
@@ -684,7 +684,7 @@ export const purchaseOrder = (data) =>
api
.post('/purchase-order', data)
.then((resp) => resp.data)
- .catch((error) => bugsnag.notify(error));
+ .catch((error) => bugsnagInstance.notify(error));
@@ -692,7 +692,7 @@ export const getPostReblogs = (data) =>
api
.get(`/post-reblogs/${data.author}/${data.permlink}`)
.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);
return response.status === 202;
} catch (error) {
- bugsnag.notify(error);
+ bugsnagInstance.notify(error);
throw error;
}
};
diff --git a/src/screens/application/screen/applicationScreen.js b/src/screens/application/screen/applicationScreen.js
index e496087f4..db7755d72 100644
--- a/src/screens/application/screen/applicationScreen.js
+++ b/src/screens/application/screen/applicationScreen.js
@@ -170,6 +170,7 @@ class ApplicationScreen extends Component {