@luciq/react-native 18.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (239) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/FONTS_SETUP_GUIDE.md +521 -0
  3. package/Gemfile +1 -0
  4. package/Gemfile.lock +11 -0
  5. package/LICENSE +21 -0
  6. package/README.md +148 -0
  7. package/RNLuciq.podspec +21 -0
  8. package/android/build.gradle +88 -0
  9. package/android/gradle.properties +4 -0
  10. package/android/jacoco.gradle +52 -0
  11. package/android/native.gradle +7 -0
  12. package/android/proguard-rules.txt +1 -0
  13. package/android/sourcemaps.gradle +255 -0
  14. package/android/src/main/AndroidManifest.xml +4 -0
  15. package/android/src/main/java/ai/luciq/reactlibrary/ArgsRegistry.java +278 -0
  16. package/android/src/main/java/ai/luciq/reactlibrary/Constants.java +20 -0
  17. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciq.java +328 -0
  18. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqAPMModule.java +392 -0
  19. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqBugReportingModule.java +444 -0
  20. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqCrashReportingModule.java +169 -0
  21. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqFeatureRequestsModule.java +98 -0
  22. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqNetworkLoggerModule.java +195 -0
  23. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqReactnativeModule.java +1611 -0
  24. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqReactnativePackage.java +41 -0
  25. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqRepliesModule.java +298 -0
  26. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqSessionReplayModule.java +213 -0
  27. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqSurveysModule.java +237 -0
  28. package/android/src/main/java/ai/luciq/reactlibrary/utils/ArrayUtil.java +167 -0
  29. package/android/src/main/java/ai/luciq/reactlibrary/utils/EventEmitterModule.java +35 -0
  30. package/android/src/main/java/ai/luciq/reactlibrary/utils/LuciqUtil.java +58 -0
  31. package/android/src/main/java/ai/luciq/reactlibrary/utils/MainThreadHandler.java +13 -0
  32. package/android/src/main/java/ai/luciq/reactlibrary/utils/MapUtil.java +171 -0
  33. package/android/src/main/java/ai/luciq/reactlibrary/utils/RNTouchedViewExtractor.java +167 -0
  34. package/android/src/main/java/ai/luciq/reactlibrary/utils/ReportUtil.java +67 -0
  35. package/app.plugin.js +1 -0
  36. package/babel.config.js +3 -0
  37. package/bin/commands/MigrateCommand.d.ts +6 -0
  38. package/bin/commands/UploadEasUpdatesSourcemaps.d.ts +2 -0
  39. package/bin/commands/UploadSoFiles.d.ts +6 -0
  40. package/bin/commands/UploadSourcemaps.d.ts +2 -0
  41. package/bin/config/migration-config.json +125 -0
  42. package/bin/index.d.ts +2 -0
  43. package/bin/index.js +19179 -0
  44. package/bin/upload/index.d.ts +4 -0
  45. package/bin/upload/migrate.d.ts +14 -0
  46. package/bin/upload/uploadEasUpdatesSourcemaps.d.ts +21 -0
  47. package/bin/upload/uploadSoFiles.d.ts +21 -0
  48. package/bin/upload/uploadSourcemaps.d.ts +21 -0
  49. package/cli/commands/MigrateCommand.ts +32 -0
  50. package/cli/commands/UploadEasUpdatesSourcemaps.ts +34 -0
  51. package/cli/commands/UploadSoFiles.ts +38 -0
  52. package/cli/commands/UploadSourcemaps.ts +40 -0
  53. package/cli/config/migration-config.json +125 -0
  54. package/cli/index.ts +21 -0
  55. package/cli/upload/index.ts +4 -0
  56. package/cli/upload/migrate.ts +271 -0
  57. package/cli/upload/uploadEasUpdatesSourcemaps.ts +74 -0
  58. package/cli/upload/uploadSoFiles.ts +112 -0
  59. package/cli/upload/uploadSourcemaps.ts +73 -0
  60. package/dangerfile.ts +44 -0
  61. package/dist/index.d.ts +19 -0
  62. package/dist/index.js +14 -0
  63. package/dist/models/FeatureFlag.d.ts +11 -0
  64. package/dist/models/FeatureFlag.js +1 -0
  65. package/dist/models/LuciqConfig.d.ts +42 -0
  66. package/dist/models/LuciqConfig.js +1 -0
  67. package/dist/models/NonFatalOptions.d.ts +15 -0
  68. package/dist/models/NonFatalOptions.js +1 -0
  69. package/dist/models/OverAirUpdate.d.ts +12 -0
  70. package/dist/models/OverAirUpdate.js +1 -0
  71. package/dist/models/Report.d.ts +70 -0
  72. package/dist/models/Report.js +109 -0
  73. package/dist/models/ReproConfig.d.ts +27 -0
  74. package/dist/models/ReproConfig.js +1 -0
  75. package/dist/models/SessionMetadata.d.ts +55 -0
  76. package/dist/models/SessionMetadata.js +1 -0
  77. package/dist/models/ThemeConfig.d.ts +27 -0
  78. package/dist/models/ThemeConfig.js +1 -0
  79. package/dist/models/W3cExternalTraceAttributes.d.ts +22 -0
  80. package/dist/models/W3cExternalTraceAttributes.js +1 -0
  81. package/dist/modules/APM.d.ts +77 -0
  82. package/dist/modules/APM.js +104 -0
  83. package/dist/modules/BugReporting.d.ts +138 -0
  84. package/dist/modules/BugReporting.js +202 -0
  85. package/dist/modules/CrashReporting.d.ts +19 -0
  86. package/dist/modules/CrashReporting.js +40 -0
  87. package/dist/modules/FeatureRequests.d.ts +20 -0
  88. package/dist/modules/FeatureRequests.js +28 -0
  89. package/dist/modules/Luciq.d.ts +362 -0
  90. package/dist/modules/Luciq.js +797 -0
  91. package/dist/modules/NetworkLogger.d.ts +52 -0
  92. package/dist/modules/NetworkLogger.js +208 -0
  93. package/dist/modules/Replies.d.ts +78 -0
  94. package/dist/modules/Replies.js +121 -0
  95. package/dist/modules/SessionReplay.d.ts +78 -0
  96. package/dist/modules/SessionReplay.js +98 -0
  97. package/dist/modules/Surveys.d.ts +75 -0
  98. package/dist/modules/Surveys.js +101 -0
  99. package/dist/native/NativeAPM.d.ts +18 -0
  100. package/dist/native/NativeAPM.js +4 -0
  101. package/dist/native/NativeBugReporting.d.ts +32 -0
  102. package/dist/native/NativeBugReporting.js +10 -0
  103. package/dist/native/NativeConstants.d.ts +182 -0
  104. package/dist/native/NativeConstants.js +1 -0
  105. package/dist/native/NativeCrashReporting.d.ts +18 -0
  106. package/dist/native/NativeCrashReporting.js +2 -0
  107. package/dist/native/NativeFeatureRequests.d.ts +8 -0
  108. package/dist/native/NativeFeatureRequests.js +2 -0
  109. package/dist/native/NativeLuciq.d.ts +86 -0
  110. package/dist/native/NativeLuciq.js +10 -0
  111. package/dist/native/NativeNetworkLogger.d.ts +21 -0
  112. package/dist/native/NativeNetworkLogger.js +14 -0
  113. package/dist/native/NativePackage.d.ts +21 -0
  114. package/dist/native/NativePackage.js +2 -0
  115. package/dist/native/NativeReplies.d.ts +21 -0
  116. package/dist/native/NativeReplies.js +8 -0
  117. package/dist/native/NativeSessionReplay.d.ts +16 -0
  118. package/dist/native/NativeSessionReplay.js +8 -0
  119. package/dist/native/NativeSurveys.d.ts +22 -0
  120. package/dist/native/NativeSurveys.js +9 -0
  121. package/dist/utils/AppStatesHandler.d.ts +3 -0
  122. package/dist/utils/AppStatesHandler.js +16 -0
  123. package/dist/utils/Enums.d.ts +244 -0
  124. package/dist/utils/Enums.js +266 -0
  125. package/dist/utils/FeatureFlags.d.ts +7 -0
  126. package/dist/utils/FeatureFlags.js +24 -0
  127. package/dist/utils/LuciqConstants.d.ts +14 -0
  128. package/dist/utils/LuciqConstants.js +15 -0
  129. package/dist/utils/LuciqUtils.d.ts +97 -0
  130. package/dist/utils/LuciqUtils.js +301 -0
  131. package/dist/utils/UnhandledRejectionTracking.d.ts +9 -0
  132. package/dist/utils/UnhandledRejectionTracking.js +99 -0
  133. package/dist/utils/XhrNetworkInterceptor.d.ts +39 -0
  134. package/dist/utils/XhrNetworkInterceptor.js +253 -0
  135. package/dist/utils/config.d.ts +5 -0
  136. package/dist/utils/config.js +6 -0
  137. package/dist/utils/logger.d.ts +10 -0
  138. package/dist/utils/logger.js +39 -0
  139. package/expo.d.ts +1 -0
  140. package/expo.js +1 -0
  141. package/ios/RNLuciq/ArgsRegistry.h +32 -0
  142. package/ios/RNLuciq/ArgsRegistry.m +276 -0
  143. package/ios/RNLuciq/LuciqAPMBridge.h +26 -0
  144. package/ios/RNLuciq/LuciqAPMBridge.m +99 -0
  145. package/ios/RNLuciq/LuciqBugReportingBridge.h +60 -0
  146. package/ios/RNLuciq/LuciqBugReportingBridge.m +241 -0
  147. package/ios/RNLuciq/LuciqCrashReportingBridge.h +18 -0
  148. package/ios/RNLuciq/LuciqCrashReportingBridge.m +68 -0
  149. package/ios/RNLuciq/LuciqFeatureRequestsBridge.h +30 -0
  150. package/ios/RNLuciq/LuciqFeatureRequestsBridge.m +61 -0
  151. package/ios/RNLuciq/LuciqNetworkLoggerBridge.h +44 -0
  152. package/ios/RNLuciq/LuciqNetworkLoggerBridge.m +206 -0
  153. package/ios/RNLuciq/LuciqReactBridge.h +151 -0
  154. package/ios/RNLuciq/LuciqReactBridge.m +548 -0
  155. package/ios/RNLuciq/LuciqRepliesBridge.h +40 -0
  156. package/ios/RNLuciq/LuciqRepliesBridge.m +80 -0
  157. package/ios/RNLuciq/LuciqSessionReplayBridge.h +32 -0
  158. package/ios/RNLuciq/LuciqSessionReplayBridge.m +107 -0
  159. package/ios/RNLuciq/LuciqSurveysBridge.h +46 -0
  160. package/ios/RNLuciq/LuciqSurveysBridge.m +107 -0
  161. package/ios/RNLuciq/RCTConvert+LuciqEnums.h +18 -0
  162. package/ios/RNLuciq/RCTConvert+LuciqEnums.m +127 -0
  163. package/ios/RNLuciq/RNLuciq.h +35 -0
  164. package/ios/RNLuciq/RNLuciq.m +107 -0
  165. package/ios/RNLuciq/Util/LCQAPM+PrivateAPIs.h +15 -0
  166. package/ios/RNLuciq/Util/LCQCrashReporting+CP.h +13 -0
  167. package/ios/RNLuciq/Util/LCQNetworkLogger+CP.h +68 -0
  168. package/ios/RNLuciq/Util/Luciq+CP.h +12 -0
  169. package/ios/RNLuciq.xcodeproj/project.pbxproj +352 -0
  170. package/ios/native.rb +12 -0
  171. package/ios/sourcemaps.sh +120 -0
  172. package/migrate.js +569 -0
  173. package/package.json +92 -0
  174. package/plugin/build/index.js +42078 -0
  175. package/plugin/src/index.ts +5 -0
  176. package/plugin/src/pluginProps.ts +6 -0
  177. package/plugin/src/withLuciq.ts +51 -0
  178. package/plugin/src/withLuciqAndroid.ts +99 -0
  179. package/plugin/src/withLuciqIOS.ts +109 -0
  180. package/plugin/tsconfig.json +7 -0
  181. package/react-native.config.js +16 -0
  182. package/scripts/customize-ios-endpoints.sh +28 -0
  183. package/scripts/dream-11-delete-unused-features.sh +62 -0
  184. package/scripts/find-token.js +58 -0
  185. package/scripts/find-token.sh +70 -0
  186. package/scripts/notify-github.sh +15 -0
  187. package/scripts/replace.js +58 -0
  188. package/scripts/snapshot-comment.md +15 -0
  189. package/scripts/snapshot-version.sh +11 -0
  190. package/src/index.ts +40 -0
  191. package/src/models/FeatureFlag.ts +12 -0
  192. package/src/models/LuciqConfig.ts +48 -0
  193. package/src/models/NonFatalOptions.ts +16 -0
  194. package/src/models/OverAirUpdate.ts +14 -0
  195. package/src/models/Report.ts +124 -0
  196. package/src/models/ReproConfig.ts +31 -0
  197. package/src/models/SessionMetadata.ts +57 -0
  198. package/src/models/ThemeConfig.ts +34 -0
  199. package/src/models/W3cExternalTraceAttributes.ts +22 -0
  200. package/src/modules/APM.ts +117 -0
  201. package/src/modules/BugReporting.ts +254 -0
  202. package/src/modules/CrashReporting.ts +54 -0
  203. package/src/modules/FeatureRequests.ts +32 -0
  204. package/src/modules/Luciq.ts +934 -0
  205. package/src/modules/NetworkLogger.ts +270 -0
  206. package/src/modules/Replies.ts +137 -0
  207. package/src/modules/SessionReplay.ts +111 -0
  208. package/src/modules/Surveys.ts +118 -0
  209. package/src/native/NativeAPM.ts +51 -0
  210. package/src/native/NativeBugReporting.ts +70 -0
  211. package/src/native/NativeConstants.ts +215 -0
  212. package/src/native/NativeCrashReporting.ts +29 -0
  213. package/src/native/NativeFeatureRequests.ts +12 -0
  214. package/src/native/NativeLuciq.ts +179 -0
  215. package/src/native/NativeNetworkLogger.ts +42 -0
  216. package/src/native/NativePackage.ts +25 -0
  217. package/src/native/NativeReplies.ts +34 -0
  218. package/src/native/NativeSessionReplay.ts +21 -0
  219. package/src/native/NativeSurveys.ts +34 -0
  220. package/src/promise.d.ts +11 -0
  221. package/src/utils/AppStatesHandler.ts +19 -0
  222. package/src/utils/Enums.ts +266 -0
  223. package/src/utils/FeatureFlags.ts +33 -0
  224. package/src/utils/LuciqConstants.ts +24 -0
  225. package/src/utils/LuciqUtils.ts +417 -0
  226. package/src/utils/UnhandledRejectionTracking.ts +118 -0
  227. package/src/utils/XhrNetworkInterceptor.ts +333 -0
  228. package/src/utils/config.ts +7 -0
  229. package/src/utils/logger.ts +54 -0
  230. package/tsconfig.json +32 -0
  231. package/tsconfig.test.json +4 -0
  232. package/tsconfig.upload.json +10 -0
  233. package/upload/index.d.ts +4 -0
  234. package/upload/index.js +17314 -0
  235. package/upload/migrate.d.ts +14 -0
  236. package/upload/package.json +5 -0
  237. package/upload/uploadEasUpdatesSourcemaps.d.ts +21 -0
  238. package/upload/uploadSoFiles.d.ts +21 -0
  239. package/upload/uploadSourcemaps.d.ts +21 -0
@@ -0,0 +1,444 @@
1
+ package ai.luciq.reactlibrary;
2
+
3
+ import android.annotation.SuppressLint;
4
+ import android.annotation.TargetApi;
5
+ import androidx.annotation.Nullable;
6
+
7
+ import com.facebook.react.bridge.Arguments;
8
+ import com.facebook.react.bridge.Callback;
9
+ import com.facebook.react.bridge.ReactApplicationContext;
10
+ import com.facebook.react.bridge.ReactMethod;
11
+ import com.facebook.react.bridge.ReadableArray;
12
+ import com.facebook.react.bridge.WritableMap;
13
+ import ai.luciq.bug.BugReporting;
14
+ import ai.luciq.bug.invocation.Option;
15
+ import ai.luciq.library.Feature;
16
+ import ai.luciq.library.OnSdkDismissCallback;
17
+ import ai.luciq.library.extendedbugreport.ExtendedBugReport;
18
+ import ai.luciq.library.invocation.LuciqInvocationEvent;
19
+ import ai.luciq.library.invocation.OnInvokeCallback;
20
+ import ai.luciq.library.invocation.util.LuciqFloatingButtonEdge;
21
+ import ai.luciq.library.invocation.util.LuciqVideoRecordingButtonPosition;
22
+ import ai.luciq.reactlibrary.utils.ArrayUtil;
23
+ import ai.luciq.reactlibrary.utils.EventEmitterModule;
24
+ import ai.luciq.reactlibrary.utils.MainThreadHandler;
25
+ import ai.luciq.bug.userConsent.ActionType;
26
+
27
+ import java.util.ArrayList;
28
+
29
+ import javax.annotation.Nonnull;
30
+
31
+ public class RNLuciqBugReportingModule extends EventEmitterModule {
32
+ public RNLuciqBugReportingModule(ReactApplicationContext reactContext) {
33
+ super(reactContext);
34
+ }
35
+
36
+ @Nonnull
37
+ @Override
38
+ public String getName() {
39
+ return "LCQBugReporting";
40
+ }
41
+
42
+ @ReactMethod
43
+ public void addListener(String event) {
44
+ super.addListener(event);
45
+ }
46
+
47
+ @ReactMethod
48
+ public void removeListeners(Integer count) {
49
+ super.removeListeners(count);
50
+ }
51
+
52
+ /**
53
+ * Enable or disable all BugReporting related features.
54
+ * @param isEnabled boolean indicating enabled or disabled.
55
+ */
56
+ @ReactMethod
57
+ public void setEnabled(final boolean isEnabled) {
58
+ MainThreadHandler.runOnMainThread(new Runnable() {
59
+ @Override
60
+ public void run() {
61
+ try {
62
+ if (isEnabled) {
63
+ BugReporting.setState(Feature.State.ENABLED);
64
+ } else {
65
+ BugReporting.setState(Feature.State.DISABLED);
66
+ }
67
+ } catch (Exception e) {
68
+ e.printStackTrace();
69
+ }
70
+ }
71
+ });
72
+
73
+ }
74
+
75
+
76
+ /**
77
+ * Enable/Disable screen recording
78
+ *
79
+ * @param autoScreenRecordingEnabled boolean for enable/disable
80
+ * screen recording on crash feature
81
+ */
82
+ @TargetApi(21)
83
+ @ReactMethod
84
+ public void setAutoScreenRecordingEnabled(final boolean autoScreenRecordingEnabled) {
85
+ MainThreadHandler.runOnMainThread(new Runnable() {
86
+ @Override
87
+ public void run() {
88
+ try {
89
+ BugReporting.setAutoScreenRecordingEnabled(autoScreenRecordingEnabled);
90
+ } catch (Exception e) {
91
+ e.printStackTrace();
92
+ }
93
+ }
94
+ });
95
+ }
96
+
97
+ /**
98
+ * Sets whether the extended bug report mode should be disabled,
99
+ * enabled with required fields, or enabled with optional fields.
100
+ *
101
+ * @param extendedBugReportMode
102
+ */
103
+ @ReactMethod
104
+ public void setExtendedBugReportMode(final String extendedBugReportMode) {
105
+ MainThreadHandler.runOnMainThread(new Runnable() {
106
+ @Override
107
+ public void run() {
108
+ try {
109
+ final ExtendedBugReport.State parsedState = ArgsRegistry.extendedBugReportStates.get(extendedBugReportMode);
110
+ if (parsedState == null) return;
111
+ BugReporting.setExtendedBugReportState(parsedState);
112
+ } catch (Exception e) {
113
+ e.printStackTrace();
114
+ }
115
+ }
116
+ });
117
+ }
118
+
119
+ /**
120
+ * Enables or disables view hierarchy in the dashboard.
121
+ * @param isEnabled boolean indicating enabled or disabled.
122
+ */
123
+ @ReactMethod
124
+ public void setViewHierarchyEnabled(final boolean isEnabled) {
125
+ MainThreadHandler.runOnMainThread(new Runnable() {
126
+ @Override
127
+ public void run() {
128
+ try {
129
+ if (isEnabled) {
130
+ BugReporting.setViewHierarchyState(Feature.State.ENABLED);
131
+ } else {
132
+ BugReporting.setViewHierarchyState(Feature.State.DISABLED);
133
+ }
134
+ } catch (Exception e) {
135
+ e.printStackTrace();
136
+ }
137
+ }
138
+ });
139
+ }
140
+
141
+ /**
142
+ * Sets the default corner at which the video recording floating button will be shown
143
+ *
144
+ * @param corner corner to stick the video recording floating button to
145
+ */
146
+ @ReactMethod
147
+ public void setVideoRecordingFloatingButtonPosition(final String corner) {
148
+ MainThreadHandler.runOnMainThread(new Runnable() {
149
+ @Override
150
+ public void run() {
151
+ try {
152
+ final LuciqVideoRecordingButtonPosition parsedPosition = ArgsRegistry.recordButtonPositions.get(corner);
153
+ if (parsedPosition == null) return;
154
+ BugReporting.setVideoRecordingFloatingButtonPosition(parsedPosition);
155
+ } catch (Exception e) {
156
+ e.printStackTrace();
157
+ }
158
+ }
159
+ });
160
+ }
161
+
162
+ /**
163
+ * Sets whether attachments in bug reporting and in-app messaging are enabled or not.
164
+ *
165
+ * @param screenshot A boolean to enable or disable screenshot attachments.
166
+ * @param {boolean} extraScreenShot A boolean to enable or disable extra screenshot attachments.
167
+ * @param {boolean} galleryImage A boolean to enable or disable gallery image attachments.
168
+ * @param {boolean} screenRecording A boolean to enable or disable screen recording attachments.
169
+ */
170
+ @ReactMethod
171
+ public void setEnabledAttachmentTypes(final boolean screenshot, final boolean extraScreenshot, final boolean
172
+ galleryImage, final boolean screenRecording) {
173
+ MainThreadHandler.runOnMainThread(new Runnable() {
174
+ @Override
175
+ public void run() {
176
+ try {
177
+ BugReporting.setAttachmentTypesEnabled(screenshot, extraScreenshot, galleryImage,
178
+ screenRecording);
179
+ } catch (Exception e) {
180
+ e.printStackTrace();
181
+ }
182
+ }
183
+ });
184
+ }
185
+
186
+ /**
187
+ * Sets the event used to invoke Luciq SDK
188
+ *
189
+ * @param invocationEventValues the invocation event value
190
+ * @see LuciqInvocationEvent
191
+ */
192
+ @ReactMethod
193
+ public void setInvocationEvents(final ReadableArray invocationEventValues) {
194
+ MainThreadHandler.runOnMainThread(new Runnable() {
195
+ @Override
196
+ public void run() {
197
+ try {
198
+ final ArrayList<String> keys = ArrayUtil.parseReadableArrayOfStrings(invocationEventValues);
199
+ final ArrayList<LuciqInvocationEvent> parsedInvocationEvents = ArgsRegistry.invocationEvents.getAll(keys);
200
+ BugReporting.setInvocationEvents(parsedInvocationEvents.toArray(new LuciqInvocationEvent[0]));
201
+ } catch (Exception e) {
202
+ e.printStackTrace();
203
+ }
204
+ }
205
+ });
206
+ }
207
+
208
+ /**
209
+ * Sets the options for the features in the SDK
210
+ *
211
+ * @param optionValues the invocation option value
212
+ */
213
+ @ReactMethod
214
+ public void setOptions(final ReadableArray optionValues) {
215
+ MainThreadHandler.runOnMainThread(new Runnable() {
216
+ @SuppressLint("WrongConstant")
217
+ @Override
218
+ public void run() {
219
+ try {
220
+ final ArrayList<String> keys = ArrayUtil.parseReadableArrayOfStrings(optionValues);
221
+ final ArrayList<Integer> options = ArgsRegistry.invocationOptions.getAll(keys);
222
+
223
+ for (int i = 0; i < options.size(); i++) {
224
+ BugReporting.setOptions(options.get(i));
225
+ }
226
+
227
+ } catch (Exception e) {
228
+ e.printStackTrace();
229
+ }
230
+ }
231
+ });
232
+ }
233
+
234
+ /**
235
+ * Sets a block of code to be executed just before the SDK's UI is presented.
236
+ * This block is executed on the UI thread. Could be used for performing any
237
+ * UI changes before the SDK's UI is shown.
238
+ *
239
+ * @param onInvokeHandler - A callback that gets executed before
240
+ * invoking the SDK
241
+ */
242
+ @ReactMethod
243
+ public void setOnInvokeHandler(final Callback onInvokeHandler) {
244
+ MainThreadHandler.runOnMainThread(new Runnable() {
245
+ @Override
246
+ public void run() {
247
+ try {
248
+ BugReporting.setOnInvokeCallback(new OnInvokeCallback() {
249
+ @Override
250
+ public void onInvoke() {
251
+ sendEvent(Constants.LCQ_PRE_INVOCATION_HANDLER, null);
252
+ }
253
+ });
254
+ } catch (java.lang.Exception exception) {
255
+ exception.printStackTrace();
256
+ }
257
+ }
258
+ });
259
+ }
260
+
261
+ /**
262
+ * Sets the position of the Luciq floating button on the screen.
263
+ * @param floatingButtonEdge left or right edge of the screen.
264
+ * @param floatingButtonOffset integer offset from the left or right edge of the screen.
265
+ */
266
+ @ReactMethod
267
+ public void setFloatingButtonEdge(final String floatingButtonEdge, final int floatingButtonOffset) {
268
+ MainThreadHandler.runOnMainThread(new Runnable() {
269
+ @Override
270
+ public void run() {
271
+ final LuciqFloatingButtonEdge parsedEdge = ArgsRegistry.floatingButtonEdges
272
+ .getOrDefault(floatingButtonEdge, LuciqFloatingButtonEdge.RIGHT);
273
+ BugReporting.setFloatingButtonOffset(floatingButtonOffset);
274
+ BugReporting.setFloatingButtonEdge(parsedEdge);
275
+ }
276
+ });
277
+ }
278
+
279
+ /**
280
+ * Sets a block of code to be executed right after the SDK's UI is dismissed.
281
+ * This block is executed on the UI thread. Could be used for performing any
282
+ * UI changes after the SDK's UI is dismissed.
283
+ *
284
+ * @param handler - A callback to get executed after
285
+ * dismissing the SDK.
286
+ */
287
+ @ReactMethod
288
+ public void setOnSDKDismissedHandler(final Callback handler) {
289
+ MainThreadHandler.runOnMainThread(new Runnable() {
290
+ @Override
291
+ public void run() {
292
+ try {
293
+ BugReporting.setOnDismissCallback(new OnSdkDismissCallback() {
294
+ @Override
295
+ public void call(DismissType dismissType, ReportType reportType) {
296
+ WritableMap params = Arguments.createMap();
297
+ params.putString("dismissType", dismissType.toString());
298
+ params.putString("reportType", reportType.toString());
299
+ sendEvent(Constants.LCQ_POST_INVOCATION_HANDLER, params);
300
+ }
301
+ });
302
+ } catch (java.lang.Exception exception) {
303
+ exception.printStackTrace();
304
+ }
305
+ }
306
+ });
307
+ }
308
+
309
+ /**
310
+ * Sets the threshold value of the shake gesture for android devices.
311
+ * Default for android is an integer value equals 350.
312
+ * you could increase the shaking difficulty level by
313
+ * increasing the `350` value and vice versa.
314
+ *
315
+ * @param androidThreshold Threshold for android devices.
316
+ */
317
+ @ReactMethod
318
+ public void setShakingThresholdForAndroid(final int androidThreshold) {
319
+ MainThreadHandler.runOnMainThread(new Runnable() {
320
+ @Override
321
+ public void run() {
322
+ try {
323
+ BugReporting.setShakingThreshold(androidThreshold);
324
+ } catch (Exception e) {
325
+ e.printStackTrace();
326
+ }
327
+ }
328
+ });
329
+ }
330
+
331
+ /**
332
+ * Sets the enabled report types to be shown in the prompt. Bug or Feedback or both.
333
+ * @param types
334
+ * @see BugReporting.ReportType
335
+ */
336
+ @ReactMethod
337
+ public void setReportTypes(final ReadableArray types) {
338
+ MainThreadHandler.runOnMainThread(new Runnable() {
339
+ @SuppressLint("WrongConstant")
340
+ @Override
341
+ public void run() {
342
+ try {
343
+ final ArrayList<String> keys = ArrayUtil.parseReadableArrayOfStrings(types);
344
+ final ArrayList<Integer> types = ArgsRegistry.reportTypes.getAll(keys);
345
+
346
+ final int[] typesInts = new int[types.size()];
347
+ for (int i = 0; i < types.size(); i++) {
348
+ typesInts[i] = types.get(i);
349
+ }
350
+
351
+ BugReporting.setReportTypes(typesInts);
352
+ } catch (Exception e) {
353
+ e.printStackTrace();
354
+ }
355
+ }
356
+ });
357
+ }
358
+
359
+ /**
360
+ * Shows a bug or feedback report with optional options.
361
+ * @param reportType Bug or Feedback.
362
+ * @param options array of options
363
+ * @see BugReporting.ReportType
364
+ * @see Option
365
+ */
366
+ @ReactMethod
367
+ public void show(final String reportType, final ReadableArray options) {
368
+ MainThreadHandler.runOnMainThread(new Runnable() {
369
+ @Override
370
+ public void run() {
371
+ final Integer parsedReportType = ArgsRegistry.reportTypes.get(reportType);
372
+ if (parsedReportType == null) return;
373
+ BugReporting.show(parsedReportType);
374
+ setOptions(options);
375
+ }
376
+ });
377
+ }
378
+
379
+ /**
380
+ * Adds a disclaimer text within the bug reporting form, which can include hyperlinked text.
381
+ * @param text String text.
382
+ */
383
+ @ReactMethod
384
+ public void setDisclaimerText(final String text){
385
+ MainThreadHandler.runOnMainThread(new Runnable() {
386
+ @Override
387
+ public void run() {
388
+ BugReporting.setDisclaimerText(text);
389
+ }
390
+ });
391
+ }
392
+ /**
393
+ * Sets a minimum number of characters as a requirement for the comments field in the different report types.
394
+ * @param limit int number of characters.
395
+ * @param reportTypes (Optional) Array of reportType. If it's not passed, the limit will apply to all report types.
396
+ */
397
+ @ReactMethod
398
+ public void setCommentMinimumCharacterCount(final int limit, final ReadableArray reportTypes){
399
+ MainThreadHandler.runOnMainThread(new Runnable() {
400
+ @SuppressLint("WrongConstant")
401
+ @Override
402
+ public void run() {
403
+ try {
404
+ final ArrayList<String> keys = ArrayUtil.parseReadableArrayOfStrings(reportTypes);
405
+ final ArrayList<Integer> types = ArgsRegistry.reportTypes.getAll(keys);
406
+
407
+ final int[] typesInts = new int[types.size()];
408
+ for (int i = 0; i < types.size(); i++) {
409
+ typesInts[i] = types.get(i);
410
+ }
411
+
412
+ BugReporting.setCommentMinimumCharacterCountForBugReportType(limit, typesInts); } catch (Exception e) {
413
+ e.printStackTrace();
414
+ }
415
+ }
416
+ });
417
+ }
418
+
419
+ /**
420
+ * Adds a user consent item to the bug reporting
421
+ * @param key A unique identifier string for the consent item.
422
+ * @param description The text shown to the user describing the consent item.
423
+ * @param mandatory Whether the user must agree to this item before submitting a report.
424
+ * @param checked Whether the consent checkbox is pre-selected.
425
+ * @param actionType A string representing the action type to map to SDK behavior.
426
+ */
427
+ @ReactMethod
428
+ public void addUserConsent(String key, String description, boolean mandatory, boolean checked, @Nullable String actionType) {
429
+ MainThreadHandler.runOnMainThread(new Runnable() {
430
+ @Override
431
+ public void run() {
432
+ try {
433
+ String mappedActionType = ArgsRegistry.userConsentActionType.get(actionType);
434
+ BugReporting.addUserConsent(key, description, mandatory, checked, mappedActionType);
435
+ } catch (Exception e) {
436
+ e.printStackTrace();
437
+ }
438
+ }
439
+ });
440
+
441
+ }
442
+
443
+
444
+ }
@@ -0,0 +1,169 @@
1
+ package ai.luciq.reactlibrary;
2
+
3
+ import static ai.luciq.reactlibrary.utils.LuciqUtil.getMethod;
4
+
5
+ import androidx.annotation.NonNull;
6
+
7
+ import com.facebook.react.bridge.Promise;
8
+ import com.facebook.react.bridge.ReactApplicationContext;
9
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
10
+ import com.facebook.react.bridge.ReactMethod;
11
+ import com.facebook.react.bridge.ReadableMap;
12
+ import ai.luciq.crash.CrashReporting;
13
+ import ai.luciq.crash.models.LuciqNonFatalException;
14
+ import ai.luciq.library.Feature;
15
+ import ai.luciq.reactlibrary.utils.MainThreadHandler;
16
+
17
+ import org.json.JSONObject;
18
+
19
+ import java.lang.reflect.InvocationTargetException;
20
+ import java.lang.reflect.Method;
21
+ import java.util.HashMap;
22
+ import java.util.Map;
23
+
24
+ import javax.annotation.Nonnull;
25
+ import javax.annotation.Nullable;
26
+
27
+ public class RNLuciqCrashReportingModule extends ReactContextBaseJavaModule {
28
+
29
+ public RNLuciqCrashReportingModule(ReactApplicationContext reactApplicationContext) {
30
+ super(reactApplicationContext);
31
+ }
32
+
33
+ @Nonnull
34
+ @Override
35
+ public String getName() {
36
+ return "LCQCrashReporting";
37
+ }
38
+
39
+ /**
40
+ * Sets whether crash reporting feature is Enabled or Disabled
41
+ *
42
+ * @param isEnabled Exception object to be sent to Luciq's servers
43
+ */
44
+ @ReactMethod
45
+ public void setEnabled(final boolean isEnabled) {
46
+ MainThreadHandler.runOnMainThread(new Runnable() {
47
+ @Override
48
+ public void run() {
49
+ try {
50
+ if (isEnabled) {
51
+ CrashReporting.setState(Feature.State.ENABLED);
52
+ } else {
53
+ CrashReporting.setState(Feature.State.DISABLED);
54
+ }
55
+ } catch (Exception e) {
56
+ e.printStackTrace();
57
+ }
58
+ }
59
+ });
60
+ }
61
+
62
+ /**
63
+ * Send unhandled JS error object
64
+ *
65
+ * @param exceptionObject Exception object to be sent to Luciq's servers
66
+ * @param promise This makes sure that the RN side crashes the app only after the Android SDK
67
+ * finishes processing/handling the crash.
68
+ */
69
+ @ReactMethod
70
+ public void sendJSCrash(final String exceptionObject, final Promise promise) {
71
+ try {
72
+ JSONObject jsonObject = new JSONObject(exceptionObject);
73
+ sendJSCrashByReflection(jsonObject, false, new Runnable() {
74
+ @Override
75
+ public void run() {
76
+ promise.resolve(null);
77
+ }
78
+ });
79
+ } catch (Exception e) {
80
+ e.printStackTrace();
81
+ }
82
+ }
83
+
84
+ /**
85
+ * Send handled JS error object
86
+ *
87
+ * @param exceptionObject Exception object to be sent to Luciq's servers
88
+ * @param userAttributes (Optional) extra user attributes attached to the crash
89
+ * @param fingerprint (Optional) key used to customize how crashes are grouped together
90
+ * @param level different severity levels for errors
91
+ */
92
+ @ReactMethod
93
+ public void sendHandledJSCrash(final String exceptionObject, @Nullable final ReadableMap userAttributes, @Nullable final String fingerprint, @Nullable final String level) {
94
+ try {
95
+ final JSONObject jsonObject = new JSONObject(exceptionObject);
96
+ MainThreadHandler.runOnMainThread(new Runnable() {
97
+ @Override
98
+ public void run() {
99
+ try {
100
+ Method method = getMethod(Class.forName("ai.luciq.crash.CrashReporting"), "reportException", JSONObject.class, boolean.class,
101
+ Map.class, JSONObject.class, LuciqNonFatalException.Level.class);
102
+ if (method != null) {
103
+ LuciqNonFatalException.Level nonFatalExceptionLevel = ArgsRegistry.nonFatalExceptionLevel.getOrDefault(level, LuciqNonFatalException.Level.ERROR);
104
+ Map<String, Object> userAttributesMap = userAttributes == null ? null : userAttributes.toHashMap();
105
+ JSONObject fingerprintObj = fingerprint == null ? null : CrashReporting.getFingerprintObject(fingerprint);
106
+
107
+ method.invoke(null, jsonObject, true, userAttributesMap, fingerprintObj, nonFatalExceptionLevel);
108
+
109
+ RNLuciqReactnativeModule.clearCurrentReport();
110
+ }
111
+ } catch (ClassNotFoundException | IllegalAccessException |
112
+ InvocationTargetException e) {
113
+ e.printStackTrace();
114
+ }
115
+ }
116
+ });
117
+ } catch (Throwable e) {
118
+ e.printStackTrace();
119
+ }
120
+ }
121
+
122
+ private void sendJSCrashByReflection(final JSONObject exceptionObject, final boolean isHandled, @Nullable final Runnable onComplete) {
123
+ MainThreadHandler.runOnMainThread(new Runnable() {
124
+ @Override
125
+ public void run() {
126
+ try {
127
+ Method method = getMethod(Class.forName("ai.luciq.crash.CrashReporting"), "reportException", JSONObject.class, boolean.class);
128
+ if (method != null) {
129
+ method.invoke(null, exceptionObject, isHandled);
130
+ RNLuciqReactnativeModule.clearCurrentReport();
131
+ }
132
+ } catch (ClassNotFoundException e) {
133
+ e.printStackTrace();
134
+ } catch (IllegalAccessException e) {
135
+ e.printStackTrace();
136
+ } catch (InvocationTargetException e) {
137
+ e.printStackTrace();
138
+ } finally {
139
+ if (onComplete != null) {
140
+ onComplete.run();
141
+ }
142
+ }
143
+ }
144
+ });
145
+ }
146
+
147
+ /**
148
+ * Enables and disables capturing native C++ NDK crash reporting.
149
+ *
150
+ * @param isEnabled boolean indicating enabled or disabled.
151
+ */
152
+ @ReactMethod
153
+ public void setNDKCrashesEnabled(final boolean isEnabled) {
154
+ MainThreadHandler.runOnMainThread(new Runnable() {
155
+ @Override
156
+ public void run() {
157
+ try {
158
+ if (isEnabled) {
159
+ CrashReporting.setNDKCrashesState(Feature.State.ENABLED);
160
+ } else {
161
+ CrashReporting.setNDKCrashesState(Feature.State.DISABLED);
162
+ }
163
+ } catch (Exception e) {
164
+ e.printStackTrace();
165
+ }
166
+ }
167
+ });
168
+ }
169
+ }