|
6 | 6 | import android.net.Uri;
|
7 | 7 | import android.os.Handler;
|
8 | 8 | import android.os.Looper;
|
| 9 | +import android.util.Log; |
9 | 10 | import android.view.View;
|
10 | 11 |
|
11 | 12 | import com.facebook.react.bridge.Arguments;
|
|
25 | 26 | import com.facebook.react.uimanager.NativeViewHierarchyManager;
|
26 | 27 | import com.facebook.react.uimanager.UIBlock;
|
27 | 28 | import com.facebook.react.uimanager.UIManagerModule;
|
| 29 | +import com.instabug.apm.APM; |
28 | 30 | import com.instabug.bug.BugReporting;
|
29 | 31 | import com.instabug.bug.instabugdisclaimer.Internal;
|
30 | 32 | import com.instabug.bug.invocation.InvocationMode;
|
|
38 | 40 | import com.instabug.library.Instabug;
|
39 | 41 | import com.instabug.library.InstabugState;
|
40 | 42 | import com.instabug.library.OnSdkDismissCallback;
|
| 43 | +import com.instabug.library.Platform; |
41 | 44 | import com.instabug.library.extendedbugreport.ExtendedBugReport;
|
42 | 45 | import com.instabug.library.invocation.InstabugInvocationEvent;
|
43 | 46 | import com.instabug.library.InstabugColorTheme;
|
@@ -236,23 +239,16 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
|
236 | 239 | private final String REPORT_DISCARD_DIALOG_POSITIVE_ACTION = "discardAlertAction";
|
237 | 240 | private final String REPORT_ADD_ATTACHMENT_HEADER = "addAttachmentButtonTitleStringName";
|
238 | 241 |
|
239 |
| - private Application androidApplication; |
240 |
| - private Instabug mInstabug; |
241 |
| - private InstabugInvocationEvent invocationEvent; |
242 | 242 | private InstabugCustomTextPlaceHolder placeHolders;
|
243 | 243 | private Report currentReport;
|
244 | 244 |
|
245 | 245 | /**
|
246 |
| - * Instantiates a new Rn instabug reactnative module. |
| 246 | + * Instantiates a new Rn Instabug ReactNative module. |
247 | 247 | *
|
248 | 248 | * @param reactContext the react context
|
249 |
| - * @param mInstabug the m instabug |
250 | 249 | */
|
251 |
| - public RNInstabugReactnativeModule(ReactApplicationContext reactContext, Application |
252 |
| - androidApplication, Instabug mInstabug) { |
| 250 | + public RNInstabugReactnativeModule(ReactApplicationContext reactContext) { |
253 | 251 | super(reactContext);
|
254 |
| - this.androidApplication = androidApplication; |
255 |
| - this.mInstabug = mInstabug; |
256 | 252 | //init placHolders
|
257 | 253 | placeHolders = new InstabugCustomTextPlaceHolder();
|
258 | 254 | }
|
@@ -283,13 +279,52 @@ public void run() {
|
283 | 279 | String key = stringArray[i];
|
284 | 280 | invocationEventsArray[i] = ArgsRegistry.getDeserializedValue(key, InstabugInvocationEvent.class);
|
285 | 281 | }
|
286 |
| - new Instabug.Builder(getCurrentActivity().getApplication(), token).setInvocationEvents(invocationEventsArray).build(); |
| 282 | + |
| 283 | + final Application application = (Application) getReactApplicationContext().getApplicationContext(); |
| 284 | + |
| 285 | + setCurrentPlatform(); |
| 286 | + setBaseUrlForDeprecationLogs(); |
| 287 | + |
| 288 | + new Instabug.Builder(application, token) |
| 289 | + .setInvocationEvents(invocationEventsArray) |
| 290 | + .build(); |
| 291 | + |
| 292 | + // Temporarily disabling APM hot launches |
| 293 | + APM.setHotAppLaunchEnabled(false); |
287 | 294 | } catch (Exception e) {
|
288 | 295 | e.printStackTrace();
|
289 | 296 | }
|
290 | 297 | }
|
291 | 298 | });
|
| 299 | + } |
| 300 | + |
| 301 | + private void setCurrentPlatform() { |
| 302 | + try { |
| 303 | + Method method = InstabugUtil.getMethod(Class.forName("com.instabug.library.Instabug"), "setCurrentPlatform", int.class); |
| 304 | + if (method != null) { |
| 305 | + Log.i("IB-CP-Bridge", "invoking setCurrentPlatform with platform: " + Platform.RN); |
| 306 | + method.invoke(null, Platform.RN); |
| 307 | + } else { |
| 308 | + Log.e("IB-CP-Bridge", "setCurrentPlatform was not found by reflection"); |
| 309 | + } |
| 310 | + } catch (Exception e) { |
| 311 | + e.printStackTrace(); |
| 312 | + } |
| 313 | + } |
292 | 314 |
|
| 315 | + private void setBaseUrlForDeprecationLogs() { |
| 316 | + try { |
| 317 | + Method method = InstabugUtil.getMethod(Class.forName("com.instabug.library.util.InstabugDeprecationLogger"), "setBaseUrl", String.class); |
| 318 | + if (method != null) { |
| 319 | + method.invoke(null, "https://docs.instabug.com/docs/react-native-sdk-migration-guide"); |
| 320 | + } |
| 321 | + } catch (ClassNotFoundException e) { |
| 322 | + e.printStackTrace(); |
| 323 | + } catch (IllegalAccessException e) { |
| 324 | + e.printStackTrace(); |
| 325 | + } catch (InvocationTargetException e) { |
| 326 | + e.printStackTrace(); |
| 327 | + } |
293 | 328 | }
|
294 | 329 |
|
295 | 330 | /**
|
@@ -1070,7 +1105,7 @@ public void getAllUserAttributes(final Callback userAttributesCallback) {
|
1070 | 1105 | public void run() {
|
1071 | 1106 | WritableMap writableMap = Arguments.createMap();
|
1072 | 1107 | try {
|
1073 |
| - HashMap<String, String> map = mInstabug.getAllUserAttributes(); |
| 1108 | + HashMap<String, String> map = Instabug.getAllUserAttributes(); |
1074 | 1109 | for (HashMap.Entry<String, String> entry : map.entrySet()) {
|
1075 | 1110 | writableMap.putString(entry.getKey(), entry.getValue());
|
1076 | 1111 | }
|
|
0 commit comments