@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.
- package/CHANGELOG.md +5 -0
- package/FONTS_SETUP_GUIDE.md +521 -0
- package/Gemfile +1 -0
- package/Gemfile.lock +11 -0
- package/LICENSE +21 -0
- package/README.md +148 -0
- package/RNLuciq.podspec +21 -0
- package/android/build.gradle +88 -0
- package/android/gradle.properties +4 -0
- package/android/jacoco.gradle +52 -0
- package/android/native.gradle +7 -0
- package/android/proguard-rules.txt +1 -0
- package/android/sourcemaps.gradle +255 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/ai/luciq/reactlibrary/ArgsRegistry.java +278 -0
- package/android/src/main/java/ai/luciq/reactlibrary/Constants.java +20 -0
- package/android/src/main/java/ai/luciq/reactlibrary/RNLuciq.java +328 -0
- package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqAPMModule.java +392 -0
- package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqBugReportingModule.java +444 -0
- package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqCrashReportingModule.java +169 -0
- package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqFeatureRequestsModule.java +98 -0
- package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqNetworkLoggerModule.java +195 -0
- package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqReactnativeModule.java +1611 -0
- package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqReactnativePackage.java +41 -0
- package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqRepliesModule.java +298 -0
- package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqSessionReplayModule.java +213 -0
- package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqSurveysModule.java +237 -0
- package/android/src/main/java/ai/luciq/reactlibrary/utils/ArrayUtil.java +167 -0
- package/android/src/main/java/ai/luciq/reactlibrary/utils/EventEmitterModule.java +35 -0
- package/android/src/main/java/ai/luciq/reactlibrary/utils/LuciqUtil.java +58 -0
- package/android/src/main/java/ai/luciq/reactlibrary/utils/MainThreadHandler.java +13 -0
- package/android/src/main/java/ai/luciq/reactlibrary/utils/MapUtil.java +171 -0
- package/android/src/main/java/ai/luciq/reactlibrary/utils/RNTouchedViewExtractor.java +167 -0
- package/android/src/main/java/ai/luciq/reactlibrary/utils/ReportUtil.java +67 -0
- package/app.plugin.js +1 -0
- package/babel.config.js +3 -0
- package/bin/commands/MigrateCommand.d.ts +6 -0
- package/bin/commands/UploadEasUpdatesSourcemaps.d.ts +2 -0
- package/bin/commands/UploadSoFiles.d.ts +6 -0
- package/bin/commands/UploadSourcemaps.d.ts +2 -0
- package/bin/config/migration-config.json +125 -0
- package/bin/index.d.ts +2 -0
- package/bin/index.js +19179 -0
- package/bin/upload/index.d.ts +4 -0
- package/bin/upload/migrate.d.ts +14 -0
- package/bin/upload/uploadEasUpdatesSourcemaps.d.ts +21 -0
- package/bin/upload/uploadSoFiles.d.ts +21 -0
- package/bin/upload/uploadSourcemaps.d.ts +21 -0
- package/cli/commands/MigrateCommand.ts +32 -0
- package/cli/commands/UploadEasUpdatesSourcemaps.ts +34 -0
- package/cli/commands/UploadSoFiles.ts +38 -0
- package/cli/commands/UploadSourcemaps.ts +40 -0
- package/cli/config/migration-config.json +125 -0
- package/cli/index.ts +21 -0
- package/cli/upload/index.ts +4 -0
- package/cli/upload/migrate.ts +271 -0
- package/cli/upload/uploadEasUpdatesSourcemaps.ts +74 -0
- package/cli/upload/uploadSoFiles.ts +112 -0
- package/cli/upload/uploadSourcemaps.ts +73 -0
- package/dangerfile.ts +44 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +14 -0
- package/dist/models/FeatureFlag.d.ts +11 -0
- package/dist/models/FeatureFlag.js +1 -0
- package/dist/models/LuciqConfig.d.ts +42 -0
- package/dist/models/LuciqConfig.js +1 -0
- package/dist/models/NonFatalOptions.d.ts +15 -0
- package/dist/models/NonFatalOptions.js +1 -0
- package/dist/models/OverAirUpdate.d.ts +12 -0
- package/dist/models/OverAirUpdate.js +1 -0
- package/dist/models/Report.d.ts +70 -0
- package/dist/models/Report.js +109 -0
- package/dist/models/ReproConfig.d.ts +27 -0
- package/dist/models/ReproConfig.js +1 -0
- package/dist/models/SessionMetadata.d.ts +55 -0
- package/dist/models/SessionMetadata.js +1 -0
- package/dist/models/ThemeConfig.d.ts +27 -0
- package/dist/models/ThemeConfig.js +1 -0
- package/dist/models/W3cExternalTraceAttributes.d.ts +22 -0
- package/dist/models/W3cExternalTraceAttributes.js +1 -0
- package/dist/modules/APM.d.ts +77 -0
- package/dist/modules/APM.js +104 -0
- package/dist/modules/BugReporting.d.ts +138 -0
- package/dist/modules/BugReporting.js +202 -0
- package/dist/modules/CrashReporting.d.ts +19 -0
- package/dist/modules/CrashReporting.js +40 -0
- package/dist/modules/FeatureRequests.d.ts +20 -0
- package/dist/modules/FeatureRequests.js +28 -0
- package/dist/modules/Luciq.d.ts +362 -0
- package/dist/modules/Luciq.js +797 -0
- package/dist/modules/NetworkLogger.d.ts +52 -0
- package/dist/modules/NetworkLogger.js +208 -0
- package/dist/modules/Replies.d.ts +78 -0
- package/dist/modules/Replies.js +121 -0
- package/dist/modules/SessionReplay.d.ts +78 -0
- package/dist/modules/SessionReplay.js +98 -0
- package/dist/modules/Surveys.d.ts +75 -0
- package/dist/modules/Surveys.js +101 -0
- package/dist/native/NativeAPM.d.ts +18 -0
- package/dist/native/NativeAPM.js +4 -0
- package/dist/native/NativeBugReporting.d.ts +32 -0
- package/dist/native/NativeBugReporting.js +10 -0
- package/dist/native/NativeConstants.d.ts +182 -0
- package/dist/native/NativeConstants.js +1 -0
- package/dist/native/NativeCrashReporting.d.ts +18 -0
- package/dist/native/NativeCrashReporting.js +2 -0
- package/dist/native/NativeFeatureRequests.d.ts +8 -0
- package/dist/native/NativeFeatureRequests.js +2 -0
- package/dist/native/NativeLuciq.d.ts +86 -0
- package/dist/native/NativeLuciq.js +10 -0
- package/dist/native/NativeNetworkLogger.d.ts +21 -0
- package/dist/native/NativeNetworkLogger.js +14 -0
- package/dist/native/NativePackage.d.ts +21 -0
- package/dist/native/NativePackage.js +2 -0
- package/dist/native/NativeReplies.d.ts +21 -0
- package/dist/native/NativeReplies.js +8 -0
- package/dist/native/NativeSessionReplay.d.ts +16 -0
- package/dist/native/NativeSessionReplay.js +8 -0
- package/dist/native/NativeSurveys.d.ts +22 -0
- package/dist/native/NativeSurveys.js +9 -0
- package/dist/utils/AppStatesHandler.d.ts +3 -0
- package/dist/utils/AppStatesHandler.js +16 -0
- package/dist/utils/Enums.d.ts +244 -0
- package/dist/utils/Enums.js +266 -0
- package/dist/utils/FeatureFlags.d.ts +7 -0
- package/dist/utils/FeatureFlags.js +24 -0
- package/dist/utils/LuciqConstants.d.ts +14 -0
- package/dist/utils/LuciqConstants.js +15 -0
- package/dist/utils/LuciqUtils.d.ts +97 -0
- package/dist/utils/LuciqUtils.js +301 -0
- package/dist/utils/UnhandledRejectionTracking.d.ts +9 -0
- package/dist/utils/UnhandledRejectionTracking.js +99 -0
- package/dist/utils/XhrNetworkInterceptor.d.ts +39 -0
- package/dist/utils/XhrNetworkInterceptor.js +253 -0
- package/dist/utils/config.d.ts +5 -0
- package/dist/utils/config.js +6 -0
- package/dist/utils/logger.d.ts +10 -0
- package/dist/utils/logger.js +39 -0
- package/expo.d.ts +1 -0
- package/expo.js +1 -0
- package/ios/RNLuciq/ArgsRegistry.h +32 -0
- package/ios/RNLuciq/ArgsRegistry.m +276 -0
- package/ios/RNLuciq/LuciqAPMBridge.h +26 -0
- package/ios/RNLuciq/LuciqAPMBridge.m +99 -0
- package/ios/RNLuciq/LuciqBugReportingBridge.h +60 -0
- package/ios/RNLuciq/LuciqBugReportingBridge.m +241 -0
- package/ios/RNLuciq/LuciqCrashReportingBridge.h +18 -0
- package/ios/RNLuciq/LuciqCrashReportingBridge.m +68 -0
- package/ios/RNLuciq/LuciqFeatureRequestsBridge.h +30 -0
- package/ios/RNLuciq/LuciqFeatureRequestsBridge.m +61 -0
- package/ios/RNLuciq/LuciqNetworkLoggerBridge.h +44 -0
- package/ios/RNLuciq/LuciqNetworkLoggerBridge.m +206 -0
- package/ios/RNLuciq/LuciqReactBridge.h +151 -0
- package/ios/RNLuciq/LuciqReactBridge.m +548 -0
- package/ios/RNLuciq/LuciqRepliesBridge.h +40 -0
- package/ios/RNLuciq/LuciqRepliesBridge.m +80 -0
- package/ios/RNLuciq/LuciqSessionReplayBridge.h +32 -0
- package/ios/RNLuciq/LuciqSessionReplayBridge.m +107 -0
- package/ios/RNLuciq/LuciqSurveysBridge.h +46 -0
- package/ios/RNLuciq/LuciqSurveysBridge.m +107 -0
- package/ios/RNLuciq/RCTConvert+LuciqEnums.h +18 -0
- package/ios/RNLuciq/RCTConvert+LuciqEnums.m +127 -0
- package/ios/RNLuciq/RNLuciq.h +35 -0
- package/ios/RNLuciq/RNLuciq.m +107 -0
- package/ios/RNLuciq/Util/LCQAPM+PrivateAPIs.h +15 -0
- package/ios/RNLuciq/Util/LCQCrashReporting+CP.h +13 -0
- package/ios/RNLuciq/Util/LCQNetworkLogger+CP.h +68 -0
- package/ios/RNLuciq/Util/Luciq+CP.h +12 -0
- package/ios/RNLuciq.xcodeproj/project.pbxproj +352 -0
- package/ios/native.rb +12 -0
- package/ios/sourcemaps.sh +120 -0
- package/migrate.js +569 -0
- package/package.json +92 -0
- package/plugin/build/index.js +42078 -0
- package/plugin/src/index.ts +5 -0
- package/plugin/src/pluginProps.ts +6 -0
- package/plugin/src/withLuciq.ts +51 -0
- package/plugin/src/withLuciqAndroid.ts +99 -0
- package/plugin/src/withLuciqIOS.ts +109 -0
- package/plugin/tsconfig.json +7 -0
- package/react-native.config.js +16 -0
- package/scripts/customize-ios-endpoints.sh +28 -0
- package/scripts/dream-11-delete-unused-features.sh +62 -0
- package/scripts/find-token.js +58 -0
- package/scripts/find-token.sh +70 -0
- package/scripts/notify-github.sh +15 -0
- package/scripts/replace.js +58 -0
- package/scripts/snapshot-comment.md +15 -0
- package/scripts/snapshot-version.sh +11 -0
- package/src/index.ts +40 -0
- package/src/models/FeatureFlag.ts +12 -0
- package/src/models/LuciqConfig.ts +48 -0
- package/src/models/NonFatalOptions.ts +16 -0
- package/src/models/OverAirUpdate.ts +14 -0
- package/src/models/Report.ts +124 -0
- package/src/models/ReproConfig.ts +31 -0
- package/src/models/SessionMetadata.ts +57 -0
- package/src/models/ThemeConfig.ts +34 -0
- package/src/models/W3cExternalTraceAttributes.ts +22 -0
- package/src/modules/APM.ts +117 -0
- package/src/modules/BugReporting.ts +254 -0
- package/src/modules/CrashReporting.ts +54 -0
- package/src/modules/FeatureRequests.ts +32 -0
- package/src/modules/Luciq.ts +934 -0
- package/src/modules/NetworkLogger.ts +270 -0
- package/src/modules/Replies.ts +137 -0
- package/src/modules/SessionReplay.ts +111 -0
- package/src/modules/Surveys.ts +118 -0
- package/src/native/NativeAPM.ts +51 -0
- package/src/native/NativeBugReporting.ts +70 -0
- package/src/native/NativeConstants.ts +215 -0
- package/src/native/NativeCrashReporting.ts +29 -0
- package/src/native/NativeFeatureRequests.ts +12 -0
- package/src/native/NativeLuciq.ts +179 -0
- package/src/native/NativeNetworkLogger.ts +42 -0
- package/src/native/NativePackage.ts +25 -0
- package/src/native/NativeReplies.ts +34 -0
- package/src/native/NativeSessionReplay.ts +21 -0
- package/src/native/NativeSurveys.ts +34 -0
- package/src/promise.d.ts +11 -0
- package/src/utils/AppStatesHandler.ts +19 -0
- package/src/utils/Enums.ts +266 -0
- package/src/utils/FeatureFlags.ts +33 -0
- package/src/utils/LuciqConstants.ts +24 -0
- package/src/utils/LuciqUtils.ts +417 -0
- package/src/utils/UnhandledRejectionTracking.ts +118 -0
- package/src/utils/XhrNetworkInterceptor.ts +333 -0
- package/src/utils/config.ts +7 -0
- package/src/utils/logger.ts +54 -0
- package/tsconfig.json +32 -0
- package/tsconfig.test.json +4 -0
- package/tsconfig.upload.json +10 -0
- package/upload/index.d.ts +4 -0
- package/upload/index.js +17314 -0
- package/upload/migrate.d.ts +14 -0
- package/upload/package.json +5 -0
- package/upload/uploadEasUpdatesSourcemaps.d.ts +21 -0
- package/upload/uploadSoFiles.d.ts +21 -0
- 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
|
+
}
|