@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,392 @@
1
+
2
+ package ai.luciq.reactlibrary;
3
+
4
+ import android.os.SystemClock;
5
+ import android.util.Log;
6
+
7
+ import androidx.annotation.NonNull;
8
+ import androidx.annotation.Nullable;
9
+
10
+ import com.facebook.react.bridge.Promise;
11
+ import com.facebook.react.bridge.ReactApplicationContext;
12
+ import com.facebook.react.bridge.ReactMethod;
13
+ import com.facebook.react.bridge.ReadableMap;
14
+ import ai.luciq.apm.APM;
15
+ import ai.luciq.apm.networking.APMNetworkLogger;
16
+ import ai.luciq.apm.networkinterception.cp.APMCPNetworkLog;
17
+ import ai.luciq.reactlibrary.utils.EventEmitterModule;
18
+ import ai.luciq.reactlibrary.utils.MainThreadHandler;
19
+
20
+ import java.lang.reflect.Method;
21
+
22
+ import java.util.HashMap;
23
+
24
+ import javax.annotation.Nonnull;
25
+
26
+ import static ai.luciq.reactlibrary.utils.LuciqUtil.getMethod;
27
+
28
+ public class RNLuciqAPMModule extends EventEmitterModule {
29
+
30
+ public RNLuciqAPMModule(ReactApplicationContext reactApplicationContext) {
31
+ super(reactApplicationContext);
32
+ }
33
+
34
+
35
+ @Nonnull
36
+ @Override
37
+ public String getName() {
38
+ return "LCQAPM";
39
+ }
40
+
41
+ /**
42
+ * Pauses the current thread for 3 seconds.
43
+ */
44
+ @ReactMethod
45
+ public void LCQSleep() {
46
+ MainThreadHandler.runOnMainThread(new Runnable() {
47
+ @Override
48
+ public void run() {
49
+ SystemClock.sleep(3000);
50
+ }
51
+ });
52
+ }
53
+
54
+ /**
55
+ * Enables or disables APM.
56
+ *
57
+ * @param isEnabled boolean indicating enabled or disabled.
58
+ */
59
+ @ReactMethod
60
+ public void setEnabled(final boolean isEnabled) {
61
+ MainThreadHandler.runOnMainThread(new Runnable() {
62
+ @Override
63
+ public void run() {
64
+ try {
65
+ APM.setEnabled(isEnabled);
66
+ } catch (Exception e) {
67
+ e.printStackTrace();
68
+ }
69
+ }
70
+ });
71
+ }
72
+
73
+ /**
74
+ * Enables or disables app launch tracking.
75
+ *
76
+ * @param isEnabled boolean indicating enabled or disabled.
77
+ */
78
+ @ReactMethod
79
+ public void setAppLaunchEnabled(final boolean isEnabled) {
80
+ MainThreadHandler.runOnMainThread(new Runnable() {
81
+ @Override
82
+ public void run() {
83
+ try {
84
+ APM.setColdAppLaunchEnabled(isEnabled);
85
+ } catch (Exception e) {
86
+ e.printStackTrace();
87
+ }
88
+ }
89
+ });
90
+ }
91
+
92
+ /**
93
+ * This method is used to signal the end of the app launch process.
94
+ */
95
+ @ReactMethod
96
+ public void endAppLaunch() {
97
+ MainThreadHandler.runOnMainThread(new Runnable() {
98
+ @Override
99
+ public void run() {
100
+ try {
101
+ APM.endAppLaunch();
102
+ } catch (Exception e) {
103
+ e.printStackTrace();
104
+ }
105
+ }
106
+ });
107
+ }
108
+
109
+ /**
110
+ * Enables or disables auto UI tracing
111
+ *
112
+ * @param isEnabled boolean indicating enabled or disabled.
113
+ */
114
+ @ReactMethod
115
+ public void setAutoUITraceEnabled(final boolean isEnabled) {
116
+ MainThreadHandler.runOnMainThread(new Runnable() {
117
+ @Override
118
+ public void run() {
119
+ try {
120
+ APM.setAutoUITraceEnabled(isEnabled);
121
+ } catch (Exception e) {
122
+ e.printStackTrace();
123
+ }
124
+ }
125
+ });
126
+ }
127
+
128
+ /**
129
+ * Starts an AppFlow with the specified name.
130
+ * <br/>
131
+ * On starting two flows with the same name the older flow will end with force abandon end reason.
132
+ * AppFlow name cannot exceed 150 characters otherwise it's truncated,
133
+ * leading and trailing whitespaces are also ignored.
134
+ *
135
+ * @param name AppFlow name. It can not be empty string or null.
136
+ * Starts a new AppFlow, if APM is enabled, feature is enabled
137
+ * and Luciq SDK is initialised.
138
+ */
139
+ @ReactMethod
140
+ public void startFlow(@NonNull final String name) {
141
+ MainThreadHandler.runOnMainThread(new Runnable() {
142
+ @Override
143
+ public void run() {
144
+ try {
145
+ APM.startFlow(name);
146
+ } catch (Exception e) {
147
+ e.printStackTrace();
148
+ }
149
+ }
150
+ });
151
+ }
152
+
153
+ /**
154
+ * Sets custom attributes for AppFlow with a given name.
155
+ * <br/>
156
+ * Setting an attribute value to null will remove its corresponding key if it already exists.
157
+ * <br/>
158
+ * Attribute key name cannot exceed 30 characters.
159
+ * Leading and trailing whitespaces are also ignored.
160
+ * Does not accept empty strings or null.
161
+ * <br/>
162
+ * Attribute value name cannot exceed 60 characters,
163
+ * leading and trailing whitespaces are also ignored.
164
+ * Does not accept empty strings.
165
+ * <br/>
166
+ * If a trace is ended, attributes will not be added and existing ones will not be updated.
167
+ * <br/>
168
+ *
169
+ * @param name AppFlow name. It can not be empty string or null
170
+ * @param key AppFlow attribute key. It can not be empty string or null
171
+ * @param value AppFlow attribute value. It can not be empty string. Null to remove attribute
172
+ */
173
+ @ReactMethod
174
+ public void setFlowAttribute(@NonNull final String name, @NonNull final String key, final String value) {
175
+ MainThreadHandler.runOnMainThread(new Runnable() {
176
+ @Override
177
+ public void run() {
178
+ try {
179
+ APM.setFlowAttribute(name, key, value);
180
+ } catch (Exception e) {
181
+ e.printStackTrace();
182
+ }
183
+ }
184
+ });
185
+ }
186
+
187
+ /**
188
+ * Ends AppFlow with a given name.
189
+ *
190
+ * @param name AppFlow name to be ended. It can not be empty string or null
191
+ */
192
+ @ReactMethod
193
+ public void endFlow(@NonNull final String name) {
194
+ MainThreadHandler.runOnMainThread(new Runnable() {
195
+ @Override
196
+ public void run() {
197
+ try {
198
+ APM.endFlow(name);
199
+ } catch (Exception e) {
200
+ e.printStackTrace();
201
+ }
202
+ }
203
+ });
204
+ }
205
+
206
+ /**
207
+ * Starts a UI trace
208
+ *
209
+ * @param name string name of the UI trace.
210
+ */
211
+ @ReactMethod
212
+ public void startUITrace(final String name) {
213
+ MainThreadHandler.runOnMainThread(new Runnable() {
214
+ @Override
215
+ public void run() {
216
+ try {
217
+ APM.startUITrace(name);
218
+ } catch (Exception e) {
219
+ e.printStackTrace();
220
+ }
221
+ }
222
+ });
223
+ }
224
+
225
+ /**
226
+ * This method is used to terminate the currently active UI trace.
227
+ */
228
+ @ReactMethod
229
+ public void endUITrace() {
230
+ MainThreadHandler.runOnMainThread(new Runnable() {
231
+ @Override
232
+ public void run() {
233
+ try {
234
+ APM.endUITrace();
235
+ } catch (Exception e) {
236
+ e.printStackTrace();
237
+ }
238
+ }
239
+ });
240
+ }
241
+
242
+ /**
243
+ * The `networkLogAndroid` function logs network-related information using APMNetworkLogger in a React
244
+ * Native module.
245
+ *
246
+ * @param requestStartTime The `requestStartTime` parameter in the `networkLogAndroid` method
247
+ * represents the timestamp when the network request started. It is of type `double` and is passed as
248
+ * a parameter to log network-related information.
249
+ * @param requestDuration The `requestDuration` parameter in the `networkLogAndroid` method represents
250
+ * the duration of the network request in milliseconds. It indicates the time taken for the request to
251
+ * complete from the moment it was initiated until the response was received. This parameter helps in
252
+ * measuring the performance of network requests and identifying any potential
253
+ * @param requestHeaders requestHeaders is a string parameter that contains the headers of the network
254
+ * request. It typically includes information such as the content type, authorization token, and any
255
+ * other headers that were sent with the request.
256
+ * @param requestBody The `requestBody` parameter in the `networkLogAndroid` method represents the
257
+ * body of the HTTP request being logged. It contains the data that is sent as part of the request to
258
+ * the server. This could include form data, JSON payload, XML data, or any other content that is
259
+ * being transmitted
260
+ * @param requestBodySize The `requestBodySize` parameter in the `networkLogAndroid` method represents
261
+ * the size of the request body in bytes. It is a double value that indicates the size of the request
262
+ * body being sent in the network request. This parameter is used to log information related to the
263
+ * network request, including details
264
+ * @param requestMethod The `requestMethod` parameter in the `networkLogAndroid` method represents the
265
+ * HTTP method used in the network request, such as GET, POST, PUT, DELETE, etc. It indicates the type
266
+ * of operation that the client is requesting from the server.
267
+ * @param requestUrl The `requestUrl` parameter in the `networkLogAndroid` method represents the URL
268
+ * of the network request being logged. It typically contains the address of the server to which the
269
+ * request is being made, along with any additional path or query parameters required for the request.
270
+ * This URL is essential for identifying the
271
+ * @param requestContentType The `requestContentType` parameter in the `networkLogAndroid` method
272
+ * represents the content type of the request being made. This could be values like
273
+ * "application/json", "application/xml", "text/plain", etc., indicating the format of the data being
274
+ * sent in the request body. It helps in specifying
275
+ * @param responseHeaders The `responseHeaders` parameter in the `networkLogAndroid` method represents
276
+ * the headers of the response received from a network request. These headers typically include
277
+ * information such as content type, content length, server information, and any other metadata
278
+ * related to the response. The `responseHeaders` parameter is expected to
279
+ * @param responseBody The `responseBody` parameter in the `networkLogAndroid` method represents the
280
+ * body of the response received from a network request. It contains the data or content sent back by
281
+ * the server in response to the request made by the client. This could be in various formats such as
282
+ * JSON, XML, HTML
283
+ * @param responseBodySize The `responseBodySize` parameter in the `networkLogAndroid` method
284
+ * represents the size of the response body in bytes. It is a double value that indicates the size of
285
+ * the response body received from the network request. This parameter is used to log information
286
+ * related to the network request and response, including
287
+ * @param statusCode The `statusCode` parameter in the `networkLogAndroid` method represents the HTTP
288
+ * status code of the network request/response. It indicates the status of the HTTP response, such as
289
+ * success (200), redirection (3xx), client errors (4xx), or server errors (5xx). This parameter is
290
+ * @param responseContentType The `responseContentType` parameter in the `networkLogAndroid` method
291
+ * represents the content type of the response received from the network request. It indicates the
292
+ * format of the data in the response, such as JSON, XML, HTML, etc. This information is useful for
293
+ * understanding how to parse and handle the
294
+ * @param errorDomain The `errorDomain` parameter in the `networkLogAndroid` method is used to specify
295
+ * the domain of an error, if any occurred during the network request. If there was no error, this
296
+ * parameter will be `null`.
297
+ * @param w3cAttributes The `w3cAttributes` parameter in the `networkLogAndroid` method is a
298
+ * ReadableMap object that contains additional attributes related to W3C external trace. It may
299
+ * include the following key-value pairs:
300
+ * @param gqLCQueryName The `gqLCQueryName` parameter in the `networkLogAndroid` method represents the
301
+ * name of the GraphQL query being executed. It is a nullable parameter, meaning it can be null if no
302
+ * GraphQL query name is provided. This parameter is used to log information related to GraphQL
303
+ * queries in the network logging
304
+ * @param serverErrorMessage The `serverErrorMessage` parameter in the `networkLogAndroid` method is
305
+ * used to pass any error message received from the server during network communication. This message
306
+ * can provide additional details about any errors that occurred on the server side, helping in
307
+ * debugging and troubleshooting network-related issues.
308
+ */
309
+ @ReactMethod
310
+ private void networkLogAndroid(final double requestStartTime,
311
+ final double requestDuration,
312
+ final String requestHeaders,
313
+ final String requestBody,
314
+ final double requestBodySize,
315
+ final String requestMethod,
316
+ final String requestUrl,
317
+ final String requestContentType,
318
+ final String responseHeaders,
319
+ final String responseBody,
320
+ final double responseBodySize,
321
+ final double statusCode,
322
+ final String responseContentType,
323
+ @Nullable final String errorDomain,
324
+ @Nullable final ReadableMap w3cAttributes,
325
+ @Nullable final String gqLCQueryName,
326
+ @Nullable final String serverErrorMessage
327
+ ) {
328
+ try {
329
+ APMNetworkLogger networkLogger = new APMNetworkLogger();
330
+
331
+ final boolean hasError = errorDomain != null && !errorDomain.isEmpty();
332
+ final String errorMessage = hasError ? errorDomain : null;
333
+ Boolean isW3cHeaderFound=false;
334
+ Long partialId=null;
335
+ Long networkStartTimeInSeconds=null;
336
+
337
+
338
+ try {
339
+ if (!w3cAttributes.isNull("isW3cHeaderFound")) {
340
+ isW3cHeaderFound = w3cAttributes.getBoolean("isW3cHeaderFound");
341
+ }
342
+
343
+ if (!w3cAttributes.isNull("partialId")) {
344
+ partialId =(long) w3cAttributes.getDouble("partialId");
345
+ networkStartTimeInSeconds = (long) w3cAttributes.getDouble("networkStartTimeInSeconds");
346
+ }
347
+
348
+ } catch (Exception e) {
349
+ e.printStackTrace();
350
+ }
351
+ APMCPNetworkLog.W3CExternalTraceAttributes w3cExternalTraceAttributes =
352
+ new APMCPNetworkLog.W3CExternalTraceAttributes(
353
+ isW3cHeaderFound,
354
+ partialId,
355
+ networkStartTimeInSeconds,
356
+ w3cAttributes.getString("w3cGeneratedHeader"),
357
+ w3cAttributes.getString("w3cCaughtHeader")
358
+ );
359
+ try {
360
+ Method method = getMethod(Class.forName("ai.luciq.apm.networking.APMNetworkLogger"), "log", long.class, long.class, String.class, String.class, long.class, String.class, String.class, String.class, String.class, String.class, long.class, int.class, String.class, String.class, String.class, String.class, APMCPNetworkLog.W3CExternalTraceAttributes.class);
361
+ if (method != null) {
362
+ method.invoke(
363
+ networkLogger,
364
+ (long) requestStartTime * 1000,
365
+ (long) requestDuration,
366
+ requestHeaders,
367
+ requestBody,
368
+ (long) requestBodySize,
369
+ requestMethod,
370
+ requestUrl,
371
+ requestContentType,
372
+ responseHeaders,
373
+ responseBody,
374
+ (long)responseBodySize,
375
+ (int) statusCode,
376
+ responseContentType,
377
+ errorMessage,
378
+ gqLCQueryName,
379
+ serverErrorMessage,
380
+ w3cExternalTraceAttributes
381
+ );
382
+ } else {
383
+ Log.e("IB-CP-Bridge", "APMNetworkLogger.log was not found by reflection");
384
+ }
385
+ } catch (Throwable e) {
386
+ e.printStackTrace();
387
+ }
388
+ } catch(Throwable e) {
389
+ e.printStackTrace();
390
+ }
391
+ }
392
+ }