@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,41 @@
1
+ package ai.luciq.reactlibrary;
2
+
3
+ import androidx.annotation.NonNull;
4
+
5
+ import com.facebook.react.ReactPackage;
6
+ import com.facebook.react.bridge.NativeModule;
7
+ import com.facebook.react.bridge.ReactApplicationContext;
8
+ import com.facebook.react.uimanager.ViewManager;
9
+
10
+ import java.util.ArrayList;
11
+ import java.util.Collections;
12
+ import java.util.List;
13
+
14
+ public class RNLuciqReactnativePackage implements ReactPackage {
15
+
16
+ private static final String TAG = RNLuciqReactnativePackage.class.getSimpleName();
17
+
18
+ public RNLuciqReactnativePackage() {}
19
+
20
+ @NonNull
21
+ @Override
22
+ public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
23
+ List<NativeModule> modules = new ArrayList<>();
24
+ modules.add(new RNLuciqReactnativeModule(reactContext));
25
+ modules.add(new RNLuciqBugReportingModule(reactContext));
26
+ modules.add(new RNLuciqCrashReportingModule(reactContext));
27
+ modules.add(new RNLuciqSurveysModule(reactContext));
28
+ modules.add(new RNLuciqFeatureRequestsModule(reactContext));
29
+ modules.add(new RNLuciqRepliesModule(reactContext));
30
+ modules.add(new RNLuciqAPMModule(reactContext));
31
+ modules.add(new RNLuciqSessionReplayModule(reactContext));
32
+ modules.add(new RNLuciqNetworkLoggerModule(reactContext));
33
+ return modules;
34
+ }
35
+
36
+ @NonNull
37
+ @Override
38
+ public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
39
+ return Collections.emptyList();
40
+ }
41
+ }
@@ -0,0 +1,298 @@
1
+ package ai.luciq.reactlibrary;
2
+
3
+ import com.facebook.react.bridge.Callback;
4
+ import com.facebook.react.bridge.Promise;
5
+ import com.facebook.react.bridge.ReactApplicationContext;
6
+ import com.facebook.react.bridge.ReactMethod;
7
+ import com.facebook.react.bridge.ReadableMap;
8
+ import com.facebook.react.bridge.ReadableType;
9
+ import com.facebook.react.bridge.ReadableMapKeySetIterator;
10
+ import ai.luciq.chat.Replies;
11
+ import ai.luciq.library.Feature;
12
+ import ai.luciq.reactlibrary.utils.EventEmitterModule;
13
+ import ai.luciq.reactlibrary.utils.MainThreadHandler;
14
+
15
+ import javax.annotation.Nonnull;
16
+ import java.util.HashMap;
17
+ import java.util.Map;
18
+
19
+ public class RNLuciqRepliesModule extends EventEmitterModule {
20
+
21
+ public RNLuciqRepliesModule(ReactApplicationContext reactApplicationContext) {
22
+ super(reactApplicationContext);
23
+ }
24
+
25
+ @Nonnull
26
+ @Override
27
+ public String getName() {
28
+ return "LCQReplies";
29
+ }
30
+
31
+ @ReactMethod
32
+ public void addListener(String event) {
33
+ super.addListener(event);
34
+ }
35
+
36
+ @ReactMethod
37
+ public void removeListeners(Integer count) {
38
+ super.removeListeners(count);
39
+ }
40
+
41
+ @ReactMethod
42
+ public void setEnabled(final boolean isEnabled) {
43
+ MainThreadHandler.runOnMainThread(new Runnable() {
44
+ @Override
45
+ public void run() {
46
+ try {
47
+ if (isEnabled) {
48
+ Replies.setState(Feature.State.ENABLED);
49
+ } else {
50
+ Replies.setState(Feature.State.DISABLED);
51
+ }
52
+ } catch (Exception e) {
53
+ e.printStackTrace();
54
+ }
55
+ }
56
+ });
57
+ }
58
+
59
+ @ReactMethod
60
+ public void hasChats(final Promise promise) {
61
+ MainThreadHandler.runOnMainThread(new Runnable() {
62
+ @Override
63
+ public void run() {
64
+ boolean hasChats = Replies.hasChats();
65
+ promise.resolve(hasChats);
66
+ }
67
+ });
68
+ }
69
+
70
+ @ReactMethod
71
+ public void show() {
72
+ MainThreadHandler.runOnMainThread(new Runnable() {
73
+ @Override
74
+ public void run() {
75
+ Replies.show();
76
+ }
77
+ });
78
+ }
79
+
80
+ /**
81
+ * Set whether new in app notification received will play a small sound notification
82
+ * or not (Default is {@code false})
83
+ *
84
+ * @param shouldPlaySound desired state of conversation sounds
85
+ * @since 4.1.0
86
+ */
87
+ @ReactMethod
88
+ public void setInAppNotificationSound(final boolean shouldPlaySound) {
89
+ MainThreadHandler.runOnMainThread(new Runnable() {
90
+ @Override
91
+ public void run() {
92
+ try {
93
+ Replies.setInAppNotificationSound(shouldPlaySound);
94
+ } catch (Exception e) {
95
+ e.printStackTrace();
96
+ }
97
+ }
98
+ });
99
+ }
100
+
101
+ /**
102
+ * Get current unread count of messages for this user
103
+ *
104
+ * @return number of messages that are unread for this user
105
+ */
106
+ @ReactMethod
107
+ public void getUnreadRepliesCount(final Promise promise) {
108
+ MainThreadHandler.runOnMainThread(new Runnable() {
109
+ @Override
110
+ public void run() {
111
+ int unreadMessages = 0;
112
+ try {
113
+ unreadMessages = Replies.getUnreadRepliesCount();
114
+ } catch (Exception e) {
115
+ e.printStackTrace();
116
+ }
117
+
118
+ promise.resolve(unreadMessages);
119
+ }
120
+ });
121
+ }
122
+
123
+ /**
124
+ * Enabled/disable push notifications
125
+ *
126
+ * @param isEnabled whether chat push notifications is enabled or not
127
+ */
128
+ @ReactMethod
129
+ public void setPushNotificationsEnabled(final boolean isEnabled) {
130
+ MainThreadHandler.runOnMainThread(new Runnable() {
131
+ @Override
132
+ public void run() {
133
+ try {
134
+ if (isEnabled) {
135
+ Replies.setPushNotificationState(Feature.State.ENABLED);
136
+ } else {
137
+ Replies.setPushNotificationState(Feature.State.DISABLED);
138
+ }
139
+ } catch (Exception e) {
140
+ e.printStackTrace();
141
+ }
142
+ }
143
+ });
144
+ }
145
+
146
+ /**
147
+ * Enabled/disable chat notification
148
+ *
149
+ * @param isChatNotificationEnable whether chat notification is reburied or not
150
+ */
151
+ @ReactMethod
152
+ public void setInAppNotificationEnabled(final boolean isChatNotificationEnable) {
153
+ MainThreadHandler.runOnMainThread(new Runnable() {
154
+ @Override
155
+ public void run() {
156
+ try {
157
+ Replies.setInAppNotificationEnabled(isChatNotificationEnable);
158
+ } catch (Exception e) {
159
+ e.printStackTrace();
160
+ }
161
+ }
162
+ });
163
+ }
164
+
165
+ /**
166
+ * Set the GCM registration token to Luciq
167
+ *
168
+ * @param token the GCM registration token
169
+ */
170
+ @ReactMethod
171
+ public void setPushNotificationRegistrationToken(final String token) {
172
+ MainThreadHandler.runOnMainThread(new Runnable() {
173
+ @Override
174
+ public void run() {
175
+ try {
176
+ Replies.setPushNotificationRegistrationToken(token);
177
+ } catch (Exception e) {
178
+ e.printStackTrace();
179
+ }
180
+ }
181
+ });
182
+ }
183
+
184
+ /**
185
+ * Show in-app Messaging's notifications
186
+ *
187
+ * @param data the data bundle related to Luciq
188
+ */
189
+ @ReactMethod
190
+ public void showNotification(final ReadableMap data) {
191
+ MainThreadHandler.runOnMainThread(new Runnable() {
192
+ @Override
193
+ public void run() {
194
+ try {
195
+ Map<String, String> map = new HashMap<>();
196
+ ReadableMapKeySetIterator iterator = data.keySetIterator();
197
+
198
+ while (iterator.hasNextKey()) {
199
+ String key = iterator.nextKey();
200
+ ReadableType type = data.getType(key);
201
+
202
+ switch(type) {
203
+ case String:
204
+ String value = data.getString(key);
205
+ map.put(key, value);
206
+ break;
207
+ }
208
+ }
209
+ if (Replies.isLuciqNotification(map)) {
210
+ Replies.showNotification(map);
211
+ }
212
+ } catch (Exception e) {
213
+ e.printStackTrace();
214
+ }
215
+ }
216
+ });
217
+ }
218
+
219
+ /**
220
+ * Set the push notification's icon that will be shown with Luciq notifications
221
+ *
222
+ * @param notificationIcon the notification icon resource ID
223
+ */
224
+ @ReactMethod
225
+ public void setNotificationIcon(final int notificationIcon) {
226
+ MainThreadHandler.runOnMainThread(new Runnable() {
227
+ @Override
228
+ public void run() {
229
+ try {
230
+ Replies.setNotificationIcon(notificationIcon);
231
+ } catch (Exception e) {
232
+ e.printStackTrace();
233
+ }
234
+ }
235
+ });
236
+ }
237
+
238
+
239
+ /**
240
+ * Set a notification channel id to a notification channel that notifications
241
+ * can be posted to.
242
+ *
243
+ * @param pushNotificationChannelId an id to a notification channel that notifications
244
+ */
245
+ @ReactMethod
246
+ public void setPushNotificationChannelId(final String pushNotificationChannelId) {
247
+ MainThreadHandler.runOnMainThread(new Runnable() {
248
+ @Override
249
+ public void run() {
250
+ try {
251
+ Replies.setPushNotificationChannelId(pushNotificationChannelId);
252
+ } catch (Exception e) {
253
+ e.printStackTrace();
254
+ }
255
+ }
256
+ });
257
+ }
258
+
259
+ /**
260
+ * Set whether new system notification received will play the default sound from
261
+ * RingtoneManager or not (Default is {@code false})
262
+ *
263
+ * @param shouldPlaySound desired state of conversation sounds
264
+ */
265
+ @ReactMethod
266
+ public void setSystemReplyNotificationSoundEnabled(final boolean shouldPlaySound) {
267
+ MainThreadHandler.runOnMainThread(new Runnable() {
268
+ @Override
269
+ public void run() {
270
+ try {
271
+ Replies.setSystemReplyNotificationSoundEnabled(shouldPlaySound);
272
+ } catch (Exception e) {
273
+ e.printStackTrace();
274
+ }
275
+ }
276
+ });
277
+ }
278
+
279
+ @ReactMethod
280
+ public void setOnNewReplyReceivedHandler(final Callback onNewReplyReceivedCallback) {
281
+ MainThreadHandler.runOnMainThread(new Runnable() {
282
+ @Override
283
+ public void run() {
284
+ try {
285
+ Runnable onNewReplyReceivedRunnable = new Runnable() {
286
+ @Override
287
+ public void run() {
288
+ sendEvent(Constants.LCQ_ON_NEW_REPLY_RECEIVED_CALLBACK, null);
289
+ }
290
+ };
291
+ Replies.setOnNewReplyReceivedCallback(onNewReplyReceivedRunnable);
292
+ } catch (java.lang.Exception exception) {
293
+ exception.printStackTrace();
294
+ }
295
+ }
296
+ });
297
+ }
298
+ }
@@ -0,0 +1,213 @@
1
+ package ai.luciq.reactlibrary;
2
+
3
+
4
+ import androidx.annotation.NonNull;
5
+ import androidx.annotation.Nullable;
6
+
7
+ import com.facebook.react.bridge.Arguments;
8
+ import com.facebook.react.bridge.Promise;
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.ReadableMap;
13
+ import com.facebook.react.bridge.WritableArray;
14
+ import com.facebook.react.bridge.WritableMap;
15
+ import ai.luciq.library.OnSessionReplayLinkReady;
16
+ import ai.luciq.library.SessionSyncListener;
17
+ import ai.luciq.library.sessionreplay.SessionReplay;
18
+ import ai.luciq.library.sessionreplay.model.SessionMetadata;
19
+ import ai.luciq.reactlibrary.utils.EventEmitterModule;
20
+ import ai.luciq.reactlibrary.utils.MainThreadHandler;
21
+ import java.util.ArrayList;
22
+ import java.util.List;
23
+ import java.util.concurrent.CountDownLatch;
24
+
25
+ import javax.annotation.Nonnull;
26
+
27
+ public class RNLuciqSessionReplayModule extends EventEmitterModule {
28
+
29
+ public RNLuciqSessionReplayModule(ReactApplicationContext reactApplicationContext) {
30
+ super(reactApplicationContext);
31
+ }
32
+
33
+ @ReactMethod
34
+ public void addListener(String event) {
35
+ super.addListener(event);
36
+ }
37
+
38
+ @ReactMethod
39
+ public void removeListeners(Integer count) {
40
+ super.removeListeners(count);
41
+ }
42
+
43
+ @Nonnull
44
+ @Override
45
+ public String getName() {
46
+ return "LCQSessionReplay";
47
+ }
48
+
49
+ @ReactMethod
50
+ public void setEnabled(final boolean isEnabled) {
51
+ MainThreadHandler.runOnMainThread(new Runnable() {
52
+ @Override
53
+ public void run() {
54
+ try {
55
+ SessionReplay.setEnabled(isEnabled);
56
+ } catch (Exception e) {
57
+ e.printStackTrace();
58
+ }
59
+ }
60
+ });
61
+ }
62
+
63
+ @ReactMethod
64
+ public void setNetworkLogsEnabled(final boolean isEnabled) {
65
+ MainThreadHandler.runOnMainThread(new Runnable() {
66
+ @Override
67
+ public void run() {
68
+ try {
69
+ SessionReplay.setNetworkLogsEnabled(isEnabled);
70
+ } catch (Exception e) {
71
+ e.printStackTrace();
72
+ }
73
+ }
74
+ });
75
+ }
76
+
77
+
78
+ @ReactMethod
79
+ public void setLuciqLogsEnabled(final boolean isEnabled) {
80
+ MainThreadHandler.runOnMainThread(new Runnable() {
81
+ @Override
82
+ public void run() {
83
+ try {
84
+ SessionReplay.setLuciqLogsEnabled(isEnabled);
85
+ } catch (Exception e) {
86
+ e.printStackTrace();
87
+ }
88
+ }
89
+ });
90
+ }
91
+
92
+ @ReactMethod
93
+ public void setUserStepsEnabled(final boolean isEnabled) {
94
+ MainThreadHandler.runOnMainThread(new Runnable() {
95
+ @Override
96
+ public void run() {
97
+ try {
98
+ SessionReplay.setUserStepsEnabled(isEnabled);
99
+ } catch (Exception e) {
100
+ e.printStackTrace();
101
+ }
102
+ }
103
+ });
104
+ }
105
+
106
+ @ReactMethod
107
+ public void getSessionReplayLink(final Promise promise) {
108
+ MainThreadHandler.runOnMainThread(new Runnable() {
109
+ @Override
110
+ public void run() {
111
+ SessionReplay.getSessionReplayLink(new OnSessionReplayLinkReady() {
112
+ @Override
113
+ public void onSessionReplayLinkReady(@Nullable String link) {
114
+
115
+ promise.resolve(link);
116
+ }
117
+ });
118
+ }
119
+ });
120
+
121
+ }
122
+
123
+ public ReadableMap getSessionMetadataMap(SessionMetadata sessionMetadata){
124
+ WritableMap params = Arguments.createMap();
125
+ params.putString("appVersion",sessionMetadata.getAppVersion());
126
+ params.putString("OS",sessionMetadata.getOs());
127
+ params.putString("device",sessionMetadata.getDevice());
128
+ params.putDouble("sessionDurationInSeconds",(double)sessionMetadata.getSessionDurationInSeconds());
129
+ params.putBoolean("hasLinkToAppReview",sessionMetadata.getLinkedToReview());
130
+ params.putArray("networkLogs",getNetworkLogsArray(sessionMetadata.getNetworkLogs()));
131
+
132
+ String launchType = sessionMetadata.getLaunchType();
133
+ Long launchDuration = sessionMetadata.getLaunchDuration();
134
+
135
+ if (launchType != null) {
136
+ params.putString("launchType",ArgsRegistry.launchTypeReversed.get(sessionMetadata.getLaunchType()) );
137
+ } else {
138
+ params.putString("launchType",ArgsRegistry.launchType.get("unknown"));
139
+ }
140
+
141
+ if (launchDuration != null) {
142
+ params.putDouble("launchDuration", (double)launchDuration);
143
+ } else {
144
+ params.putDouble("launchDuration", 0.0);
145
+ }
146
+
147
+ return params;
148
+ }
149
+
150
+ public ReadableArray getNetworkLogsArray(List<SessionMetadata.NetworkLog> networkLogList ) {
151
+ WritableArray networkLogs = Arguments.createArray();
152
+
153
+ if (networkLogList != null) {
154
+ for (SessionMetadata.NetworkLog log : networkLogList) {
155
+ WritableMap networkLog = Arguments.createMap();
156
+ networkLog.putString("url", log.getUrl());
157
+ networkLog.putDouble("duration", log.getDuration());
158
+ networkLog.putInt("statusCode", log.getStatusCode());
159
+
160
+ networkLogs.pushMap(networkLog);
161
+ }
162
+ }
163
+
164
+ return networkLogs;
165
+ }
166
+
167
+ private boolean shouldSync = true;
168
+ private CountDownLatch latch;
169
+ @ReactMethod
170
+ public void setSyncCallback() {
171
+ MainThreadHandler.runOnMainThread(new Runnable() {
172
+ @Override
173
+ public void run() {
174
+ try {
175
+ SessionReplay.setSyncCallback(new SessionSyncListener() {
176
+ @Override
177
+ public boolean onSessionReadyToSync(@NonNull SessionMetadata sessionMetadata) {
178
+
179
+ sendEvent(Constants.LCQ_SESSION_REPLAY_ON_SYNC_CALLBACK_INVOCATION,getSessionMetadataMap(sessionMetadata));
180
+
181
+ latch = new CountDownLatch(1);
182
+
183
+ try {
184
+ latch.await();
185
+ } catch (InterruptedException e) {
186
+ e.printStackTrace();
187
+ return true;
188
+ }
189
+
190
+ return shouldSync;
191
+ }
192
+ });
193
+ }
194
+ catch(Exception e){
195
+ e.printStackTrace();
196
+ }
197
+
198
+ }
199
+ });
200
+ }
201
+
202
+ @ReactMethod
203
+ public void evaluateSync(boolean result) {
204
+ shouldSync = result;
205
+
206
+ if (latch != null) {
207
+ latch.countDown();
208
+ }
209
+ }
210
+
211
+
212
+
213
+ }