|
33 | 33 | import androidx.lifecycle.LiveData; |
34 | 34 |
|
35 | 35 | import com.android.volley.toolbox.ImageLoader; |
| 36 | +import com.automattic.android.tracks.crashlogging.JsException; |
| 37 | +import com.automattic.android.tracks.crashlogging.JsExceptionCallback; |
| 38 | +import com.automattic.android.tracks.crashlogging.JsExceptionStackTraceElement; |
36 | 39 | import com.facebook.react.bridge.ReadableMap; |
37 | 40 | import com.facebook.react.bridge.WritableNativeMap; |
38 | 41 | import com.google.android.material.dialog.MaterialAlertDialogBuilder; |
|
47 | 50 | import org.wordpress.android.editor.EditorThemeUpdateListener; |
48 | 51 | import org.wordpress.android.editor.LiveTextWatcher; |
49 | 52 | import org.wordpress.android.editor.R; |
50 | | -import org.wordpress.android.editor.savedinstance.SavedInstanceDatabase; |
51 | 53 | import org.wordpress.android.editor.WPGutenbergWebViewActivity; |
52 | 54 | import org.wordpress.android.editor.gutenberg.GutenbergDialogFragment.GutenbergDialogNegativeClickInterface; |
53 | 55 | import org.wordpress.android.editor.gutenberg.GutenbergDialogFragment.GutenbergDialogPositiveClickInterface; |
| 56 | +import org.wordpress.android.editor.savedinstance.SavedInstanceDatabase; |
54 | 57 | import org.wordpress.android.util.AppLog; |
55 | 58 | import org.wordpress.android.util.AppLog.T; |
56 | 59 | import org.wordpress.android.util.DateTimeUtils; |
|
62 | 65 | import org.wordpress.android.util.helpers.MediaFile; |
63 | 66 | import org.wordpress.android.util.helpers.MediaGallery; |
64 | 67 | import org.wordpress.aztec.IHistoryListener; |
| 68 | +import org.wordpress.mobile.ReactNativeGutenbergBridge.GutenbergBridgeJS2Parent.LogExceptionCallback; |
65 | 69 | import org.wordpress.mobile.ReactNativeGutenbergBridge.GutenbergEmbedWebViewActivity; |
| 70 | +import org.wordpress.mobile.WPAndroidGlue.GutenbergJsException; |
66 | 71 | import org.wordpress.mobile.WPAndroidGlue.Media; |
67 | 72 | import org.wordpress.mobile.WPAndroidGlue.MediaOption; |
68 | 73 | import org.wordpress.mobile.WPAndroidGlue.RequestExecutor; |
69 | 74 | import org.wordpress.mobile.WPAndroidGlue.ShowSuggestionsUtil; |
70 | 75 | import org.wordpress.mobile.WPAndroidGlue.UnsupportedBlock; |
71 | | -import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnBlockTypeImpressionsEventListener; |
72 | 76 | import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnBackHandlerEventListener; |
| 77 | +import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnBlockTypeImpressionsEventListener; |
73 | 78 | import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnConnectionStatusEventListener; |
74 | 79 | import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnContentInfoReceivedListener; |
75 | 80 | import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnCustomerSupportOptionsListener; |
|
80 | 85 | import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnGutenbergDidRequestPreviewListener; |
81 | 86 | import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnGutenbergDidRequestUnsupportedBlockFallbackListener; |
82 | 87 | import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnGutenbergDidSendButtonPressedActionListener; |
| 88 | +import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnLogExceptionListener; |
83 | 89 | import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnMediaLibraryButtonListener; |
84 | 90 | import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnReattachMediaUploadQueryListener; |
85 | 91 | import org.wordpress.mobile.WPAndroidGlue.WPAndroidGlueCode.OnSetFeaturedImageListener; |
|
88 | 94 | import java.util.Date; |
89 | 95 | import java.util.HashMap; |
90 | 96 | import java.util.HashSet; |
| 97 | +import java.util.List; |
91 | 98 | import java.util.Map; |
92 | 99 | import java.util.Set; |
93 | 100 | import java.util.concurrent.ConcurrentHashMap; |
| 101 | +import java.util.stream.Collectors; |
94 | 102 |
|
95 | 103 | import static org.wordpress.mobile.WPAndroidGlue.Media.createRNMediaUsingMimeType; |
96 | 104 |
|
@@ -517,6 +525,40 @@ public void onGotoCustomerSupportOptions() { |
517 | 525 | } |
518 | 526 | }, |
519 | 527 |
|
| 528 | + new OnLogExceptionListener() { |
| 529 | + @Override public void onLogException(GutenbergJsException exception, |
| 530 | + LogExceptionCallback logExceptionCallback) { |
| 531 | + List<JsExceptionStackTraceElement> stackTraceElements = exception.getStackTrace().stream().map( |
| 532 | + stackTrace -> { |
| 533 | + return new JsExceptionStackTraceElement( |
| 534 | + stackTrace.getFileName(), |
| 535 | + stackTrace.getLineNumber(), |
| 536 | + stackTrace.getColNumber(), |
| 537 | + stackTrace.getFunction() |
| 538 | + ); |
| 539 | + }).collect(Collectors.toList()); |
| 540 | + |
| 541 | + JsException jsException = new JsException( |
| 542 | + exception.getType(), |
| 543 | + exception.getMessage(), |
| 544 | + stackTraceElements, |
| 545 | + exception.getContext(), |
| 546 | + exception.getTags(), |
| 547 | + exception.isHandled(), |
| 548 | + exception.getHandledBy() |
| 549 | + ); |
| 550 | + |
| 551 | + JsExceptionCallback callback = new JsExceptionCallback() { |
| 552 | + @Override |
| 553 | + public void onReportSent(boolean success) { |
| 554 | + logExceptionCallback.onLogException(success); |
| 555 | + } |
| 556 | + }; |
| 557 | + |
| 558 | + mEditorFragmentListener.onLogJsException(jsException, callback); |
| 559 | + } |
| 560 | + }, |
| 561 | + |
520 | 562 | GutenbergUtils.isDarkMode(getActivity())); |
521 | 563 |
|
522 | 564 | // request dependency injection. Do this after setting min/max dimensions |
|
0 commit comments