@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,1611 @@
|
|
|
1
|
+
package ai.luciq.reactlibrary;
|
|
2
|
+
|
|
3
|
+
import static ai.luciq.apm.configuration.cp.APMFeature.APM_NETWORK_PLUGIN_INSTALLED;
|
|
4
|
+
import static ai.luciq.apm.configuration.cp.APMFeature.CP_NATIVE_INTERCEPTION_ENABLED;
|
|
5
|
+
import static ai.luciq.reactlibrary.utils.LuciqUtil.getMethod;
|
|
6
|
+
|
|
7
|
+
import android.app.Application;
|
|
8
|
+
import android.graphics.Bitmap;
|
|
9
|
+
import android.graphics.Color;
|
|
10
|
+
import android.graphics.Typeface;
|
|
11
|
+
import android.net.Uri;
|
|
12
|
+
import android.os.Build;
|
|
13
|
+
import android.util.Log;
|
|
14
|
+
import android.view.View;
|
|
15
|
+
|
|
16
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
17
|
+
|
|
18
|
+
import androidx.annotation.NonNull;
|
|
19
|
+
import androidx.annotation.UiThread;
|
|
20
|
+
|
|
21
|
+
import com.facebook.react.bridge.Arguments;
|
|
22
|
+
import com.facebook.react.bridge.Callback;
|
|
23
|
+
import com.facebook.react.bridge.Promise;
|
|
24
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
25
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
26
|
+
import com.facebook.react.bridge.ReadableArray;
|
|
27
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
28
|
+
import com.facebook.react.bridge.UIManager;
|
|
29
|
+
import com.facebook.react.bridge.WritableArray;
|
|
30
|
+
import com.facebook.react.bridge.WritableMap;
|
|
31
|
+
import com.facebook.react.bridge.WritableNativeArray;
|
|
32
|
+
import com.facebook.react.bridge.WritableNativeMap;
|
|
33
|
+
import com.facebook.react.uimanager.UIManagerHelper;
|
|
34
|
+
import com.facebook.react.uimanager.UIManagerModule;
|
|
35
|
+
import ai.luciq.apm.InternalAPM;
|
|
36
|
+
import ai.luciq.apm.configuration.cp.APMFeature;
|
|
37
|
+
import ai.luciq.library.Feature;
|
|
38
|
+
import ai.luciq.library.Luciq;
|
|
39
|
+
import ai.luciq.library.LuciqColorTheme;
|
|
40
|
+
import ai.luciq.library.LuciqCustomTextPlaceHolder;
|
|
41
|
+
import ai.luciq.library.IssueType;
|
|
42
|
+
import ai.luciq.library.LogLevel;
|
|
43
|
+
import ai.luciq.library.ReproConfigurations;
|
|
44
|
+
import ai.luciq.library.core.InstabugCore;
|
|
45
|
+
import ai.luciq.library.internal.crossplatform.CoreFeature;
|
|
46
|
+
import ai.luciq.library.internal.crossplatform.CoreFeaturesState;
|
|
47
|
+
import ai.luciq.library.internal.crossplatform.FeaturesStateListener;
|
|
48
|
+
import ai.luciq.library.internal.crossplatform.InternalCore;
|
|
49
|
+
import ai.luciq.library.featuresflags.model.LuciqFeatureFlag;
|
|
50
|
+
import ai.luciq.library.internal.crossplatform.InternalCore;
|
|
51
|
+
import ai.luciq.library.internal.crossplatform.OnFeaturesUpdatedListener;
|
|
52
|
+
import ai.luciq.library.internal.module.LuciqLocale;
|
|
53
|
+
import ai.luciq.library.invocation.LuciqInvocationEvent;
|
|
54
|
+
import ai.luciq.library.logging.LuciqLog;
|
|
55
|
+
import ai.luciq.library.model.LuciqTheme;
|
|
56
|
+
import ai.luciq.library.model.NetworkLog;
|
|
57
|
+
import ai.luciq.library.model.Report;
|
|
58
|
+
import ai.luciq.library.ui.onboarding.WelcomeMessage;
|
|
59
|
+
import ai.luciq.library.util.LuciqSDKLogger;
|
|
60
|
+
import ai.luciq.reactlibrary.utils.ArrayUtil;
|
|
61
|
+
import ai.luciq.reactlibrary.utils.EventEmitterModule;
|
|
62
|
+
import ai.luciq.reactlibrary.utils.MainThreadHandler;
|
|
63
|
+
|
|
64
|
+
import ai.luciq.reactlibrary.utils.RNTouchedViewExtractor;
|
|
65
|
+
|
|
66
|
+
import org.json.JSONException;
|
|
67
|
+
import org.json.JSONObject;
|
|
68
|
+
import org.json.JSONTokener;
|
|
69
|
+
|
|
70
|
+
import java.io.File;
|
|
71
|
+
import java.lang.reflect.Method;
|
|
72
|
+
import java.util.ArrayList;
|
|
73
|
+
import java.util.Arrays;
|
|
74
|
+
import java.util.HashMap;
|
|
75
|
+
import java.util.Iterator;
|
|
76
|
+
import java.util.List;
|
|
77
|
+
import java.util.Locale;
|
|
78
|
+
import java.util.Map;
|
|
79
|
+
|
|
80
|
+
import javax.annotation.Nullable;
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The type Rn luciq reactnative module.
|
|
85
|
+
*/
|
|
86
|
+
public class RNLuciqReactnativeModule extends EventEmitterModule {
|
|
87
|
+
|
|
88
|
+
private static final String TAG = "Luciq-RN-Core";
|
|
89
|
+
|
|
90
|
+
private LuciqCustomTextPlaceHolder placeHolders;
|
|
91
|
+
private static Report currentReport;
|
|
92
|
+
private final ReactApplicationContext reactContext;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Instantiates a new Rn Luciq ReactNative module.
|
|
96
|
+
*
|
|
97
|
+
* @param reactContext the react context
|
|
98
|
+
*/
|
|
99
|
+
public RNLuciqReactnativeModule(ReactApplicationContext reactContext) {
|
|
100
|
+
super(reactContext);
|
|
101
|
+
|
|
102
|
+
this.reactContext = reactContext;
|
|
103
|
+
|
|
104
|
+
//init placeHolders
|
|
105
|
+
placeHolders = new LuciqCustomTextPlaceHolder();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@Override
|
|
109
|
+
public String getName() {
|
|
110
|
+
return "Luciq";
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@ReactMethod
|
|
115
|
+
public void addListener(String event) {
|
|
116
|
+
super.addListener(event);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@ReactMethod
|
|
120
|
+
public void removeListeners(Integer count) {
|
|
121
|
+
super.removeListeners(count);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Enables or disables Luciq functionality.
|
|
126
|
+
* @param isEnabled A boolean to enable/disable Luciq.
|
|
127
|
+
*/
|
|
128
|
+
@ReactMethod
|
|
129
|
+
public void setEnabled(final boolean isEnabled) {
|
|
130
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
131
|
+
@Override
|
|
132
|
+
public void run() {
|
|
133
|
+
try {
|
|
134
|
+
if (isEnabled)
|
|
135
|
+
Luciq.enable();
|
|
136
|
+
else
|
|
137
|
+
Luciq.disable();
|
|
138
|
+
} catch (Exception e) {
|
|
139
|
+
e.printStackTrace();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Initializes the SDK.
|
|
147
|
+
*
|
|
148
|
+
* @param token The token that identifies the app. You can find it on your dashboard.
|
|
149
|
+
* @param invocationEventValues The events that invoke the SDK's UI.
|
|
150
|
+
* @param logLevel The level of detail in logs that you want to print.
|
|
151
|
+
* @param codePushVersion The Code Push version to be used for all reports.
|
|
152
|
+
*/
|
|
153
|
+
@ReactMethod
|
|
154
|
+
public void init(
|
|
155
|
+
final String token,
|
|
156
|
+
final ReadableArray invocationEventValues,
|
|
157
|
+
final String logLevel,
|
|
158
|
+
final boolean useNativeNetworkInterception,
|
|
159
|
+
@Nullable final String codePushVersion,
|
|
160
|
+
@Nullable final String appVariant,
|
|
161
|
+
final ReadableMap map,
|
|
162
|
+
@Nullable final ReadableMap overAirVersion
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
) {
|
|
166
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
167
|
+
@Override
|
|
168
|
+
public void run() {
|
|
169
|
+
final RNTouchedViewExtractor rnTouchedViewExtractor = new RNTouchedViewExtractor();
|
|
170
|
+
InstabugCore.setTouchedViewExtractorExtension(rnTouchedViewExtractor);
|
|
171
|
+
final ArrayList<String> keys = ArrayUtil.parseReadableArrayOfStrings(invocationEventValues);
|
|
172
|
+
final ArrayList<LuciqInvocationEvent> parsedInvocationEvents = ArgsRegistry.invocationEvents.getAll(keys);
|
|
173
|
+
final LuciqInvocationEvent[] invocationEvents = parsedInvocationEvents.toArray(new LuciqInvocationEvent[0]);
|
|
174
|
+
final int parsedLogLevel = ArgsRegistry.sdkLogLevels.getOrDefault(logLevel, LogLevel.ERROR);
|
|
175
|
+
|
|
176
|
+
final Application application = (Application) reactContext.getApplicationContext();
|
|
177
|
+
|
|
178
|
+
RNLuciq.Builder builder = new RNLuciq.Builder(application, token)
|
|
179
|
+
.setInvocationEvents(invocationEvents)
|
|
180
|
+
.setLogLevel(parsedLogLevel);
|
|
181
|
+
|
|
182
|
+
if (map!=null&&map.hasKey("ignoreAndroidSecureFlag")) {
|
|
183
|
+
builder.ignoreFlagSecure(map.getBoolean("ignoreAndroidSecureFlag"));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (codePushVersion != null) {
|
|
187
|
+
if (Luciq.isBuilt()) {
|
|
188
|
+
Luciq.setCodePushVersion(codePushVersion);
|
|
189
|
+
} else {
|
|
190
|
+
builder.setCodePushVersion(codePushVersion);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (appVariant != null) {
|
|
194
|
+
builder.setAppVariant(appVariant);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if(overAirVersion != null ) {
|
|
198
|
+
if(Luciq.isBuilt()) {
|
|
199
|
+
Luciq.setOverAirVersion(overAirVersion.getString("version"),
|
|
200
|
+
ArgsRegistry.overAirUpdateService.get(overAirVersion.getString("service")));
|
|
201
|
+
} else {
|
|
202
|
+
builder.setOverAirVersion(overAirVersion);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
builder.build();
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
@ReactMethod
|
|
212
|
+
public void setCodePushVersion(@Nullable final String version) {
|
|
213
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
214
|
+
@Override
|
|
215
|
+
public void run() {
|
|
216
|
+
try {
|
|
217
|
+
Luciq.setCodePushVersion(version);
|
|
218
|
+
} catch (Exception e) {
|
|
219
|
+
e.printStackTrace();
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
@ReactMethod
|
|
226
|
+
public void setOverAirVersion(@Nullable final ReadableMap overAirVersion) {
|
|
227
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
228
|
+
@Override
|
|
229
|
+
public void run() {
|
|
230
|
+
try {
|
|
231
|
+
Luciq.setOverAirVersion(overAirVersion.getString("version"),
|
|
232
|
+
ArgsRegistry.overAirUpdateService.get(overAirVersion.getString("service")));
|
|
233
|
+
|
|
234
|
+
} catch (Exception e) {
|
|
235
|
+
e.printStackTrace();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Adds tag(s) to issues before sending them
|
|
244
|
+
*
|
|
245
|
+
* @param tags
|
|
246
|
+
*/
|
|
247
|
+
@ReactMethod
|
|
248
|
+
public void appendTags(final ReadableArray tags) {
|
|
249
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
250
|
+
@Override
|
|
251
|
+
public void run() {
|
|
252
|
+
try {
|
|
253
|
+
Object[] objectArray = ArrayUtil.toArray(tags);
|
|
254
|
+
String[] stringArray = Arrays.copyOf(objectArray, objectArray.length, String[].class);
|
|
255
|
+
Luciq.addTags(stringArray);
|
|
256
|
+
} catch (Exception e) {
|
|
257
|
+
e.printStackTrace();
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Change Locale of Luciq UI elements(defaults to English)
|
|
266
|
+
*
|
|
267
|
+
* @param luciqLocale
|
|
268
|
+
*/
|
|
269
|
+
@ReactMethod
|
|
270
|
+
public void setLocale(final String luciqLocale) {
|
|
271
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
272
|
+
@Override
|
|
273
|
+
public void run() {
|
|
274
|
+
try {
|
|
275
|
+
final LuciqLocale parsedLocale = ArgsRegistry.locales
|
|
276
|
+
.getOrDefault(luciqLocale, LuciqLocale.ENGLISH);
|
|
277
|
+
final Locale locale = new Locale(parsedLocale.getCode(), parsedLocale.getCountry());
|
|
278
|
+
Luciq.setLocale(locale);
|
|
279
|
+
} catch (Exception e) {
|
|
280
|
+
e.printStackTrace();
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* The file at filePath will be uploaded along upcoming reports with the name
|
|
288
|
+
* fileNameWithExtension
|
|
289
|
+
*
|
|
290
|
+
* @param fileUri the file uri
|
|
291
|
+
* @param fileNameWithExtension the file name with extension
|
|
292
|
+
*/
|
|
293
|
+
@ReactMethod
|
|
294
|
+
public void setFileAttachment(final String fileUri, final String fileNameWithExtension) {
|
|
295
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
296
|
+
@Override
|
|
297
|
+
public void run() {
|
|
298
|
+
try {
|
|
299
|
+
File file = new File(fileUri);
|
|
300
|
+
if (file.exists()) {
|
|
301
|
+
Luciq.addFileAttachment(Uri.fromFile(file), fileNameWithExtension);
|
|
302
|
+
}
|
|
303
|
+
} catch (Exception e) {
|
|
304
|
+
e.printStackTrace();
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Adds specific user data that you need to be added to the reports
|
|
313
|
+
*
|
|
314
|
+
* @param userData
|
|
315
|
+
*/
|
|
316
|
+
@ReactMethod
|
|
317
|
+
public void setUserData(final String userData) {
|
|
318
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
319
|
+
@Override
|
|
320
|
+
public void run() {
|
|
321
|
+
try {
|
|
322
|
+
Luciq.setUserData(userData);
|
|
323
|
+
} catch (Exception e) {
|
|
324
|
+
e.printStackTrace();
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Gets tags.
|
|
333
|
+
*
|
|
334
|
+
* @return all tags added
|
|
335
|
+
* @see #resetTags()
|
|
336
|
+
*/
|
|
337
|
+
@ReactMethod
|
|
338
|
+
public void getTags(final Promise promise) {
|
|
339
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
340
|
+
@Override
|
|
341
|
+
public void run() {
|
|
342
|
+
WritableArray tagsArray = Arguments.createArray();
|
|
343
|
+
try {
|
|
344
|
+
ArrayList<String> tags = Luciq.getTags();
|
|
345
|
+
for (int i = 0; i < tags.size(); i++) {
|
|
346
|
+
tagsArray.pushString(tags.get(i));
|
|
347
|
+
}
|
|
348
|
+
} catch (Exception e) {
|
|
349
|
+
e.printStackTrace();
|
|
350
|
+
}
|
|
351
|
+
promise.resolve(tagsArray);
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Set the user identity.
|
|
358
|
+
* Luciq will pre-fill the user email in reports.
|
|
359
|
+
*
|
|
360
|
+
* @param userEmail User's default email
|
|
361
|
+
* @param userName Username.
|
|
362
|
+
* @param userId User's ID
|
|
363
|
+
*/
|
|
364
|
+
@ReactMethod
|
|
365
|
+
public void identifyUser(
|
|
366
|
+
final String userEmail,
|
|
367
|
+
final String userName,
|
|
368
|
+
@Nullable final String userId
|
|
369
|
+
) {
|
|
370
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
371
|
+
@Override
|
|
372
|
+
public void run() {
|
|
373
|
+
try {
|
|
374
|
+
// The arguments get re-ordered here to match the API signature.
|
|
375
|
+
Luciq.identifyUser(userName, userEmail, userId);
|
|
376
|
+
} catch (Exception e) {
|
|
377
|
+
e.printStackTrace();
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Reset ALL tags added
|
|
385
|
+
*/
|
|
386
|
+
@ReactMethod
|
|
387
|
+
public void resetTags() {
|
|
388
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
389
|
+
@Override
|
|
390
|
+
public void run() {
|
|
391
|
+
try {
|
|
392
|
+
Luciq.resetTags();
|
|
393
|
+
} catch (Exception e) {
|
|
394
|
+
e.printStackTrace();
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
@ReactMethod
|
|
401
|
+
public void logVerbose(final String message) {
|
|
402
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
403
|
+
@Override
|
|
404
|
+
public void run() {
|
|
405
|
+
try {
|
|
406
|
+
LuciqLog.v(message);
|
|
407
|
+
} catch (Exception e) {
|
|
408
|
+
e.printStackTrace();
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
@ReactMethod
|
|
415
|
+
public void logDebug(final String message) {
|
|
416
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
417
|
+
@Override
|
|
418
|
+
public void run() {
|
|
419
|
+
try {
|
|
420
|
+
LuciqLog.d(message);
|
|
421
|
+
} catch (Exception e) {
|
|
422
|
+
e.printStackTrace();
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
@ReactMethod
|
|
429
|
+
public void logInfo(final String message) {
|
|
430
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
431
|
+
@Override
|
|
432
|
+
public void run() {
|
|
433
|
+
try {
|
|
434
|
+
LuciqLog.i(message);
|
|
435
|
+
} catch (Exception e) {
|
|
436
|
+
e.printStackTrace();
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
@ReactMethod
|
|
443
|
+
public void logError(final String message) {
|
|
444
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
445
|
+
@Override
|
|
446
|
+
public void run() {
|
|
447
|
+
try {
|
|
448
|
+
LuciqLog.e(message);
|
|
449
|
+
} catch (Exception e) {
|
|
450
|
+
e.printStackTrace();
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
@ReactMethod
|
|
457
|
+
public void logWarn(final String message) {
|
|
458
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
459
|
+
@Override
|
|
460
|
+
public void run() {
|
|
461
|
+
try {
|
|
462
|
+
LuciqLog.w(message);
|
|
463
|
+
} catch (Exception e) {
|
|
464
|
+
e.printStackTrace();
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Clears Luciq internal log
|
|
472
|
+
*/
|
|
473
|
+
@ReactMethod
|
|
474
|
+
public void clearLogs() {
|
|
475
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
476
|
+
@Override
|
|
477
|
+
public void run() {
|
|
478
|
+
try {
|
|
479
|
+
LuciqLog.clearLogs();
|
|
480
|
+
} catch (Exception e) {
|
|
481
|
+
e.printStackTrace();
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Sets user attribute to overwrite it's value or create a new one if it doesn't exist.
|
|
489
|
+
*
|
|
490
|
+
* @param key the attribute
|
|
491
|
+
* @param value the value
|
|
492
|
+
*/
|
|
493
|
+
@ReactMethod
|
|
494
|
+
public void setUserAttribute(final String key, final String value) {
|
|
495
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
496
|
+
@Override
|
|
497
|
+
public void run() {
|
|
498
|
+
try {
|
|
499
|
+
Luciq.setUserAttribute(key, value);
|
|
500
|
+
} catch (Exception e) {
|
|
501
|
+
e.printStackTrace();
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Gets specific user attribute.
|
|
509
|
+
*
|
|
510
|
+
* @param key the attribute key as string
|
|
511
|
+
* @return the desired user attribute
|
|
512
|
+
*/
|
|
513
|
+
@ReactMethod
|
|
514
|
+
public void getUserAttribute(final String key, final Promise promise) {
|
|
515
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
516
|
+
@Override
|
|
517
|
+
public void run() {
|
|
518
|
+
String userAttribute = "";
|
|
519
|
+
try {
|
|
520
|
+
userAttribute = Luciq.getUserAttribute(key);
|
|
521
|
+
} catch (Exception e) {
|
|
522
|
+
e.printStackTrace();
|
|
523
|
+
}
|
|
524
|
+
promise.resolve(userAttribute);
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Removes user attribute if exists.
|
|
533
|
+
*
|
|
534
|
+
* @param key the attribute key as string
|
|
535
|
+
* @see #setUserAttribute(String, String)
|
|
536
|
+
*/
|
|
537
|
+
@ReactMethod
|
|
538
|
+
public void removeUserAttribute(final String key) {
|
|
539
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
540
|
+
@Override
|
|
541
|
+
public void run() {
|
|
542
|
+
try {
|
|
543
|
+
Luciq.removeUserAttribute(key);
|
|
544
|
+
} catch (Exception e) {
|
|
545
|
+
e.printStackTrace();
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Gets all saved user attributes.
|
|
553
|
+
*
|
|
554
|
+
* @return all user attributes as HashMap<String, String>
|
|
555
|
+
*/
|
|
556
|
+
@ReactMethod
|
|
557
|
+
public void getAllUserAttributes(final Promise promise) {
|
|
558
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
559
|
+
@Override
|
|
560
|
+
public void run() {
|
|
561
|
+
WritableMap writableMap = Arguments.createMap();
|
|
562
|
+
try {
|
|
563
|
+
HashMap<String, String> map = Luciq.getAllUserAttributes();
|
|
564
|
+
for (HashMap.Entry<String, String> entry : map.entrySet()) {
|
|
565
|
+
writableMap.putString(entry.getKey(), entry.getValue());
|
|
566
|
+
}
|
|
567
|
+
} catch (Exception e) {
|
|
568
|
+
e.printStackTrace();
|
|
569
|
+
}
|
|
570
|
+
promise.resolve(writableMap);
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Clears all user attributes if exists.
|
|
577
|
+
*/
|
|
578
|
+
@ReactMethod
|
|
579
|
+
public void clearAllUserAttributes() {
|
|
580
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
581
|
+
@Override
|
|
582
|
+
public void run() {
|
|
583
|
+
try {
|
|
584
|
+
Luciq.clearAllUserAttributes();
|
|
585
|
+
} catch (Exception e) {
|
|
586
|
+
e.printStackTrace();
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Sets LuciqSDK theme color.
|
|
594
|
+
*
|
|
595
|
+
* @param theme which is a constant String "light" or "dark"
|
|
596
|
+
*/
|
|
597
|
+
@ReactMethod
|
|
598
|
+
public void setColorTheme(final String theme) {
|
|
599
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
600
|
+
@Override
|
|
601
|
+
public void run() {
|
|
602
|
+
try {
|
|
603
|
+
final LuciqColorTheme colorTheme = ArgsRegistry.colorThemes
|
|
604
|
+
.getOrDefault(theme, LuciqColorTheme.LuciqColorThemeLight);
|
|
605
|
+
Luciq.setColorTheme(colorTheme);
|
|
606
|
+
} catch (Exception e) {
|
|
607
|
+
e.printStackTrace();
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Overrides any of the strings shown in the SDK with custom ones.
|
|
615
|
+
* Allows you to customize any of the strings shown to users in the SDK.
|
|
616
|
+
*
|
|
617
|
+
* @param string String value to override the default one.
|
|
618
|
+
* @param key Key of string to override.
|
|
619
|
+
*/
|
|
620
|
+
@ReactMethod
|
|
621
|
+
public void setString(final String string, final String key) {
|
|
622
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
623
|
+
@Override
|
|
624
|
+
public void run() {
|
|
625
|
+
try {
|
|
626
|
+
final LuciqCustomTextPlaceHolder.Key parsedKey = ArgsRegistry.placeholders.get(key);
|
|
627
|
+
placeHolders.set(parsedKey, string);
|
|
628
|
+
Luciq.setCustomTextPlaceHolders(placeHolders);
|
|
629
|
+
} catch (java.lang.Exception exception) {
|
|
630
|
+
exception.printStackTrace();
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* Sets the default value of the user's email to null and show email field and remove user
|
|
638
|
+
* name from all reports
|
|
639
|
+
* It also reset the chats on device and removes user attributes, user data and completed
|
|
640
|
+
* surveys.
|
|
641
|
+
*/
|
|
642
|
+
@ReactMethod
|
|
643
|
+
public void logOut() {
|
|
644
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
645
|
+
@Override
|
|
646
|
+
public void run() {
|
|
647
|
+
try {
|
|
648
|
+
Luciq.logoutUser();
|
|
649
|
+
} catch (java.lang.Exception exception) {
|
|
650
|
+
exception.printStackTrace();
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* Logs a user event that happens through the lifecycle of the application.
|
|
658
|
+
* Logged user events are going to be sent with each report, as well as at the end of a session.
|
|
659
|
+
*
|
|
660
|
+
* @param name Event name.
|
|
661
|
+
*/
|
|
662
|
+
@ReactMethod
|
|
663
|
+
public void logUserEvent(final String name) {
|
|
664
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
665
|
+
@Override
|
|
666
|
+
public void run() {
|
|
667
|
+
try {
|
|
668
|
+
Luciq.logUserEvent(name);
|
|
669
|
+
} catch (java.lang.Exception exception) {
|
|
670
|
+
exception.printStackTrace();
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* Sets a block of code to be executed before sending each report.
|
|
678
|
+
* This block is executed in the background before sending each report. Could
|
|
679
|
+
* be used for attaching logs and extra data to reports.
|
|
680
|
+
*
|
|
681
|
+
* @param preSendingHandler - A callback that gets executed before
|
|
682
|
+
* sending each bug
|
|
683
|
+
* report.
|
|
684
|
+
*/
|
|
685
|
+
@ReactMethod
|
|
686
|
+
public void setPreSendingHandler(final Callback preSendingHandler) {
|
|
687
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
688
|
+
@Override
|
|
689
|
+
public void run() {
|
|
690
|
+
Luciq.onReportSubmitHandler(new Report.OnReportCreatedListener() {
|
|
691
|
+
@Override
|
|
692
|
+
public void onReportCreated(Report report) {
|
|
693
|
+
WritableMap reportParam = Arguments.createMap();
|
|
694
|
+
reportParam.putArray("tagsArray", convertArrayListToWritableArray(report.getTags()));
|
|
695
|
+
reportParam.putArray("consoleLogs", convertArrayListToWritableArray(report.getConsoleLog()));
|
|
696
|
+
reportParam.putString("userData", report.getUserData());
|
|
697
|
+
reportParam.putMap("userAttributes", convertFromHashMapToWriteableMap(report.getUserAttributes()));
|
|
698
|
+
reportParam.putMap("fileAttachments", convertFromHashMapToWriteableMap(report.getFileAttachments()));
|
|
699
|
+
sendEvent("LuciqpreSendingHandler", reportParam);
|
|
700
|
+
currentReport = report;
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
protected static void clearCurrentReport() {
|
|
708
|
+
currentReport = null;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
@ReactMethod
|
|
712
|
+
public void appendTagToReport(String tag) {
|
|
713
|
+
if (currentReport != null) {
|
|
714
|
+
currentReport.addTag(tag);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
@ReactMethod
|
|
719
|
+
public void appendConsoleLogToReport(String consoleLog) {
|
|
720
|
+
if (currentReport != null) {
|
|
721
|
+
currentReport.appendToConsoleLogs(consoleLog);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
@ReactMethod
|
|
726
|
+
public void setUserAttributeToReport(String key, String value) {
|
|
727
|
+
if (currentReport != null) {
|
|
728
|
+
currentReport.setUserAttribute(key, value);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
@ReactMethod
|
|
733
|
+
public void logDebugToReport(String log) {
|
|
734
|
+
if (currentReport != null) {
|
|
735
|
+
currentReport.logDebug(log);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
@ReactMethod
|
|
740
|
+
public void logVerboseToReport(String log) {
|
|
741
|
+
if (currentReport != null) {
|
|
742
|
+
currentReport.logVerbose(log);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
@ReactMethod
|
|
747
|
+
public void logWarnToReport(String log) {
|
|
748
|
+
if (currentReport != null) {
|
|
749
|
+
currentReport.logWarn(log);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
@ReactMethod
|
|
754
|
+
public void logErrorToReport(String log) {
|
|
755
|
+
if (currentReport != null) {
|
|
756
|
+
currentReport.logError(log);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
@ReactMethod
|
|
761
|
+
public void logInfoToReport(String log) {
|
|
762
|
+
if (currentReport != null) {
|
|
763
|
+
currentReport.logInfo(log);
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
@ReactMethod
|
|
768
|
+
public void addFileAttachmentWithURLToReport(String urlString, String fileName) {
|
|
769
|
+
if (currentReport != null) {
|
|
770
|
+
Uri uri = Uri.parse(urlString);
|
|
771
|
+
currentReport.addFileAttachment(uri, fileName);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
@ReactMethod
|
|
776
|
+
public void addFileAttachmentWithDataToReport(String data, String fileName) {
|
|
777
|
+
if (currentReport != null) {
|
|
778
|
+
currentReport.addFileAttachment(data.getBytes(), fileName);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
private WritableMap convertFromHashMapToWriteableMap(HashMap hashMap) {
|
|
783
|
+
WritableMap writableMap = new WritableNativeMap();
|
|
784
|
+
for (int i = 0; i < hashMap.size(); i++) {
|
|
785
|
+
Object key = hashMap.keySet().toArray()[i];
|
|
786
|
+
Object value = hashMap.get(key);
|
|
787
|
+
writableMap.putString((String) key, (String) value);
|
|
788
|
+
}
|
|
789
|
+
return writableMap;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
private static JSONObject objectToJSONObject(Object object) {
|
|
793
|
+
Object json = null;
|
|
794
|
+
JSONObject jsonObject = null;
|
|
795
|
+
try {
|
|
796
|
+
json = new JSONTokener(object.toString()).nextValue();
|
|
797
|
+
} catch (JSONException e) {
|
|
798
|
+
e.printStackTrace();
|
|
799
|
+
}
|
|
800
|
+
if (json instanceof JSONObject) {
|
|
801
|
+
jsonObject = (JSONObject) json;
|
|
802
|
+
}
|
|
803
|
+
return jsonObject;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
private WritableArray convertArrayListToWritableArray(List arrayList) {
|
|
807
|
+
WritableArray writableArray = new WritableNativeArray();
|
|
808
|
+
|
|
809
|
+
for (int i = 0; i < arrayList.size(); i++) {
|
|
810
|
+
Object object = arrayList.get(i);
|
|
811
|
+
|
|
812
|
+
if (object instanceof String) {
|
|
813
|
+
writableArray.pushString((String) object);
|
|
814
|
+
} else {
|
|
815
|
+
JSONObject jsonObject = objectToJSONObject(object);
|
|
816
|
+
writableArray.pushMap((WritableMap) jsonObject);
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
return writableArray;
|
|
821
|
+
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
/**
|
|
825
|
+
* Clears all Uris of the attached files.
|
|
826
|
+
* The URIs which added via {@link Luciq#addFileAttachment} API not the physical files.
|
|
827
|
+
*/
|
|
828
|
+
@ReactMethod
|
|
829
|
+
public void clearFileAttachment() {
|
|
830
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
831
|
+
@Override
|
|
832
|
+
public void run() {
|
|
833
|
+
try {
|
|
834
|
+
Luciq.clearFileAttachment();
|
|
835
|
+
} catch (Exception e) {
|
|
836
|
+
e.printStackTrace();
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
@ReactMethod
|
|
843
|
+
public void setReproStepsConfig(final String bugMode, final String crashMode, final String sessionReplayMode) {
|
|
844
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
845
|
+
@Override
|
|
846
|
+
public void run() {
|
|
847
|
+
try {
|
|
848
|
+
final Integer resolvedBugMode = ArgsRegistry.reproModes.get(bugMode);
|
|
849
|
+
final Integer resolvedCrashMode = ArgsRegistry.reproModes.get(crashMode);
|
|
850
|
+
final Integer resolvedSessionReplayMode = ArgsRegistry.reproModes.get(sessionReplayMode);
|
|
851
|
+
|
|
852
|
+
final ReproConfigurations config = new ReproConfigurations.Builder()
|
|
853
|
+
.setIssueMode(IssueType.Bug, resolvedBugMode)
|
|
854
|
+
.setIssueMode(IssueType.Crash, resolvedCrashMode)
|
|
855
|
+
.setIssueMode(IssueType.SessionReplay, resolvedSessionReplayMode)
|
|
856
|
+
.build();
|
|
857
|
+
|
|
858
|
+
Luciq.setReproConfigurations(config);
|
|
859
|
+
} catch (Exception e) {
|
|
860
|
+
e.printStackTrace();
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
/**
|
|
867
|
+
* Shows the welcome message in a specific mode.
|
|
868
|
+
*
|
|
869
|
+
* @param welcomeMessageMode An enum to set the welcome message mode to
|
|
870
|
+
* live, or beta.
|
|
871
|
+
*/
|
|
872
|
+
@ReactMethod
|
|
873
|
+
public void showWelcomeMessageWithMode(final String welcomeMessageMode) {
|
|
874
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
875
|
+
@Override
|
|
876
|
+
public void run() {
|
|
877
|
+
try {
|
|
878
|
+
final WelcomeMessage.State parsedState = ArgsRegistry.welcomeMessageStates
|
|
879
|
+
.getOrDefault(welcomeMessageMode, WelcomeMessage.State.LIVE);
|
|
880
|
+
Luciq.showWelcomeMessage(parsedState);
|
|
881
|
+
} catch (Exception e) {
|
|
882
|
+
e.printStackTrace();
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
});
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
/**
|
|
889
|
+
* Sets the welcome message mode to live, beta or disabled.
|
|
890
|
+
*
|
|
891
|
+
* @param welcomeMessageMode An enum to set the welcome message mode to
|
|
892
|
+
* live, beta or disabled.
|
|
893
|
+
*/
|
|
894
|
+
@ReactMethod
|
|
895
|
+
public void setWelcomeMessageMode(final String welcomeMessageMode) {
|
|
896
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
897
|
+
@Override
|
|
898
|
+
public void run() {
|
|
899
|
+
try {
|
|
900
|
+
final WelcomeMessage.State parsedState = ArgsRegistry.welcomeMessageStates
|
|
901
|
+
.getOrDefault(welcomeMessageMode, WelcomeMessage.State.LIVE);
|
|
902
|
+
Luciq.setWelcomeMessageState(parsedState);
|
|
903
|
+
} catch (Exception e) {
|
|
904
|
+
e.printStackTrace();
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
@ReactMethod
|
|
911
|
+
public void show() {
|
|
912
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
913
|
+
@Override
|
|
914
|
+
public void run() {
|
|
915
|
+
Luciq.show();
|
|
916
|
+
}
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
/**
|
|
921
|
+
* Enable/disable session profiler
|
|
922
|
+
*
|
|
923
|
+
* @param sessionProfilerEnabled desired state of the session profiler feature
|
|
924
|
+
*/
|
|
925
|
+
@ReactMethod
|
|
926
|
+
public void setSessionProfilerEnabled(final boolean sessionProfilerEnabled) {
|
|
927
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
928
|
+
@Override
|
|
929
|
+
public void run() {
|
|
930
|
+
try {
|
|
931
|
+
if (sessionProfilerEnabled) {
|
|
932
|
+
Luciq.setSessionProfilerState(Feature.State.ENABLED);
|
|
933
|
+
} else {
|
|
934
|
+
Luciq.setSessionProfilerState(Feature.State.DISABLED);
|
|
935
|
+
}
|
|
936
|
+
} catch (Exception e) {
|
|
937
|
+
e.printStackTrace();
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
@ReactMethod
|
|
944
|
+
public void networkLogAndroid(final String url,
|
|
945
|
+
final String requestBody,
|
|
946
|
+
final String responseBody,
|
|
947
|
+
final String method,
|
|
948
|
+
final double responseCode,
|
|
949
|
+
final String requestHeaders,
|
|
950
|
+
final String responseHeaders,
|
|
951
|
+
final double duration) {
|
|
952
|
+
try {
|
|
953
|
+
final String date = String.valueOf(System.currentTimeMillis());
|
|
954
|
+
|
|
955
|
+
NetworkLog networkLog = new NetworkLog();
|
|
956
|
+
networkLog.setDate(date);
|
|
957
|
+
networkLog.setUrl(url);
|
|
958
|
+
networkLog.setMethod(method);
|
|
959
|
+
networkLog.setResponseCode((int) responseCode);
|
|
960
|
+
networkLog.setTotalDuration((long) duration);
|
|
961
|
+
|
|
962
|
+
try {
|
|
963
|
+
networkLog.setRequest(requestBody);
|
|
964
|
+
networkLog.setResponse(responseBody);
|
|
965
|
+
networkLog.setRequestHeaders(requestHeaders);
|
|
966
|
+
networkLog.setResponseHeaders(responseHeaders);
|
|
967
|
+
} catch (OutOfMemoryError | Exception exception) {
|
|
968
|
+
Log.d(TAG, "Error: " + exception.getMessage() + "while trying to set network log contents (request body, response body, request headers, and response headers).");
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
networkLog.insert();
|
|
972
|
+
} catch (OutOfMemoryError | Exception exception) {
|
|
973
|
+
Log.d(TAG, "Error: " + exception.getMessage() + "while trying to insert a network log");
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
@UiThread
|
|
978
|
+
@Nullable
|
|
979
|
+
private View resolveReactView(final int reactTag) {
|
|
980
|
+
try {
|
|
981
|
+
final ReactApplicationContext reactContext = getReactApplicationContext();
|
|
982
|
+
final UIManagerModule uiManagerModule = reactContext.getNativeModule(UIManagerModule.class);
|
|
983
|
+
|
|
984
|
+
if (uiManagerModule == null) {
|
|
985
|
+
UIManager uiNewManagerModule = UIManagerHelper.getUIManagerForReactTag(reactContext, reactTag);
|
|
986
|
+
if (uiNewManagerModule != null) {
|
|
987
|
+
return uiNewManagerModule.resolveView(reactTag);
|
|
988
|
+
}
|
|
989
|
+
return null;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
return uiManagerModule.resolveView(reactTag);
|
|
993
|
+
} catch (Exception e) {
|
|
994
|
+
return null;
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
|
|
999
|
+
@ReactMethod
|
|
1000
|
+
public void addPrivateView(final int reactTag) {
|
|
1001
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
1002
|
+
@Override
|
|
1003
|
+
public void run() {
|
|
1004
|
+
try {
|
|
1005
|
+
final View view = resolveReactView(reactTag);
|
|
1006
|
+
|
|
1007
|
+
if(view !=null){
|
|
1008
|
+
Luciq.addPrivateViews(view);
|
|
1009
|
+
}
|
|
1010
|
+
} catch (Exception e) {
|
|
1011
|
+
e.printStackTrace();
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
@ReactMethod
|
|
1018
|
+
public void removePrivateView(final int reactTag) {
|
|
1019
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
1020
|
+
@Override
|
|
1021
|
+
public void run() {
|
|
1022
|
+
try {
|
|
1023
|
+
final View view = resolveReactView(reactTag);
|
|
1024
|
+
if(view !=null){
|
|
1025
|
+
|
|
1026
|
+
Luciq.removePrivateViews(view);
|
|
1027
|
+
}
|
|
1028
|
+
} catch (Exception e) {
|
|
1029
|
+
e.printStackTrace();
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
/**
|
|
1036
|
+
* Reports that the screen name been changed (Current View).
|
|
1037
|
+
*
|
|
1038
|
+
* @param screenName string containing the screen name
|
|
1039
|
+
*/
|
|
1040
|
+
@ReactMethod
|
|
1041
|
+
public void reportCurrentViewChange(final String screenName) {
|
|
1042
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
1043
|
+
@Override
|
|
1044
|
+
public void run() {
|
|
1045
|
+
try {
|
|
1046
|
+
Method method = getMethod(Class.forName("ai.luciq.library.Luciq"), "reportCurrentViewChange", String.class);
|
|
1047
|
+
if (method != null) {
|
|
1048
|
+
method.invoke(null, screenName);
|
|
1049
|
+
}
|
|
1050
|
+
} catch (Exception e) {
|
|
1051
|
+
e.printStackTrace();
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
/**
|
|
1058
|
+
* Reports that the screen has been changed (Repro Steps) the screen sent to this method will be the 'current view' on the dashboard
|
|
1059
|
+
*
|
|
1060
|
+
* @param screenName string containing the screen name
|
|
1061
|
+
*/
|
|
1062
|
+
@ReactMethod
|
|
1063
|
+
public void reportScreenChange(final String screenName) {
|
|
1064
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
1065
|
+
@Override
|
|
1066
|
+
public void run() {
|
|
1067
|
+
try {
|
|
1068
|
+
Method method = getMethod(Class.forName("ai.luciq.library.Luciq"), "reportScreenChange", Bitmap.class, String.class);
|
|
1069
|
+
if (method != null) {
|
|
1070
|
+
method.invoke(null, null, screenName);
|
|
1071
|
+
}
|
|
1072
|
+
} catch (Exception e) {
|
|
1073
|
+
e.printStackTrace();
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
|
|
1080
|
+
|
|
1081
|
+
@ReactMethod
|
|
1082
|
+
public void addFeatureFlags(final ReadableMap featureFlagsMap) {
|
|
1083
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
1084
|
+
@Override
|
|
1085
|
+
public void run() {
|
|
1086
|
+
try {
|
|
1087
|
+
Iterator<Map.Entry<String, Object>> iterator = featureFlagsMap.getEntryIterator();
|
|
1088
|
+
ArrayList<LuciqFeatureFlag> featureFlags = new ArrayList<>();
|
|
1089
|
+
while (iterator.hasNext()) {
|
|
1090
|
+
Map.Entry<String, Object> item = iterator.next();
|
|
1091
|
+
String variant = (String) item.getValue();
|
|
1092
|
+
String name = item.getKey();
|
|
1093
|
+
featureFlags.add(new LuciqFeatureFlag(name, variant.isEmpty() ? null : variant));
|
|
1094
|
+
}
|
|
1095
|
+
if (!featureFlags.isEmpty()) {
|
|
1096
|
+
Luciq.addFeatureFlags(featureFlags);
|
|
1097
|
+
}
|
|
1098
|
+
} catch (Exception e) {
|
|
1099
|
+
e.printStackTrace();
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
@ReactMethod
|
|
1106
|
+
public void removeFeatureFlags(final ReadableArray featureFlags) {
|
|
1107
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
1108
|
+
@Override
|
|
1109
|
+
public void run() {
|
|
1110
|
+
try {
|
|
1111
|
+
ArrayList<String> stringArray = ArrayUtil.parseReadableArrayOfStrings(featureFlags);
|
|
1112
|
+
Luciq.removeFeatureFlag(stringArray);
|
|
1113
|
+
} catch (Exception e) {
|
|
1114
|
+
e.printStackTrace();
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
@ReactMethod
|
|
1121
|
+
public void removeAllFeatureFlags() {
|
|
1122
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
1123
|
+
@Override
|
|
1124
|
+
public void run() {
|
|
1125
|
+
try {
|
|
1126
|
+
Luciq.removeAllFeatureFlags();
|
|
1127
|
+
} catch (Exception e) {
|
|
1128
|
+
e.printStackTrace();
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
@ReactMethod
|
|
1135
|
+
public void willRedirectToStore() {
|
|
1136
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
1137
|
+
@Override
|
|
1138
|
+
public void run() {
|
|
1139
|
+
try {
|
|
1140
|
+
Luciq.willRedirectToStore();
|
|
1141
|
+
} catch (Exception e) {
|
|
1142
|
+
e.printStackTrace();
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
});
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
/**
|
|
1149
|
+
* Register a listener for feature flags value change
|
|
1150
|
+
*/
|
|
1151
|
+
@ReactMethod
|
|
1152
|
+
public void registerFeatureFlagsChangeListener() {
|
|
1153
|
+
|
|
1154
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
1155
|
+
@Override
|
|
1156
|
+
public void run() {
|
|
1157
|
+
try {
|
|
1158
|
+
InternalCore.INSTANCE._setFeaturesStateListener(new FeaturesStateListener() {
|
|
1159
|
+
@Override
|
|
1160
|
+
public void invoke(@NonNull CoreFeaturesState featuresState) {
|
|
1161
|
+
WritableMap params = Arguments.createMap();
|
|
1162
|
+
params.putBoolean("isW3ExternalTraceIDEnabled", featuresState.isW3CExternalTraceIdEnabled());
|
|
1163
|
+
params.putBoolean("isW3ExternalGeneratedHeaderEnabled", featuresState.isAttachingGeneratedHeaderEnabled());
|
|
1164
|
+
params.putBoolean("isW3CaughtHeaderEnabled", featuresState.isAttachingCapturedHeaderEnabled());
|
|
1165
|
+
params.putInt("networkBodyLimit",featuresState.getNetworkLogCharLimit());
|
|
1166
|
+
|
|
1167
|
+
sendEvent(Constants.LCQ_ON_FEATURE_FLAGS_UPDATE_RECEIVED_CALLBACK, params);
|
|
1168
|
+
}
|
|
1169
|
+
});
|
|
1170
|
+
} catch (Exception e) {
|
|
1171
|
+
e.printStackTrace();
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
});
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
|
|
1180
|
+
/**
|
|
1181
|
+
* Get first time Value of W3ExternalTraceID flag
|
|
1182
|
+
*/
|
|
1183
|
+
@ReactMethod
|
|
1184
|
+
public void isW3ExternalTraceIDEnabled(Promise promise) {
|
|
1185
|
+
|
|
1186
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
1187
|
+
@Override
|
|
1188
|
+
public void run() {
|
|
1189
|
+
try {
|
|
1190
|
+
promise.resolve(InternalCore.INSTANCE._isFeatureEnabled(CoreFeature.W3C_EXTERNAL_TRACE_ID));
|
|
1191
|
+
} catch (Exception e) {
|
|
1192
|
+
e.printStackTrace();
|
|
1193
|
+
promise.resolve(false);
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
});
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
|
|
1202
|
+
/**
|
|
1203
|
+
* Get first time Value of W3ExternalGeneratedHeader flag
|
|
1204
|
+
*/
|
|
1205
|
+
@ReactMethod
|
|
1206
|
+
public void isW3ExternalGeneratedHeaderEnabled(Promise promise) {
|
|
1207
|
+
|
|
1208
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
1209
|
+
@Override
|
|
1210
|
+
public void run() {
|
|
1211
|
+
try {
|
|
1212
|
+
promise.resolve(InternalCore.INSTANCE._isFeatureEnabled(CoreFeature.W3C_ATTACHING_GENERATED_HEADER));
|
|
1213
|
+
} catch (Exception e) {
|
|
1214
|
+
e.printStackTrace();
|
|
1215
|
+
promise.resolve(false);
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
/**
|
|
1224
|
+
* Get first time Value of W3CaughtHeader flag
|
|
1225
|
+
*/
|
|
1226
|
+
@ReactMethod
|
|
1227
|
+
public void isW3CaughtHeaderEnabled(Promise promise) {
|
|
1228
|
+
|
|
1229
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
1230
|
+
@Override
|
|
1231
|
+
public void run() {
|
|
1232
|
+
try {
|
|
1233
|
+
promise.resolve(InternalCore.INSTANCE._isFeatureEnabled(CoreFeature.W3C_ATTACHING_CAPTURED_HEADER));
|
|
1234
|
+
} catch (Exception e) {
|
|
1235
|
+
e.printStackTrace();
|
|
1236
|
+
promise.resolve(false);
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
});
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
|
|
1245
|
+
/**
|
|
1246
|
+
* Map between the exported JS constant and the arg key in {@link ArgsRegistry}.
|
|
1247
|
+
* The constant name and the arg key should match to be able to resolve the
|
|
1248
|
+
* constant with its actual value from the {@link ArgsRegistry} maps.
|
|
1249
|
+
*
|
|
1250
|
+
* This is a workaround, because RN cannot resolve enums in the constants map.
|
|
1251
|
+
*/
|
|
1252
|
+
@Override
|
|
1253
|
+
public Map<String, Object> getConstants() {
|
|
1254
|
+
final Map<String, Object> args = ArgsRegistry.getAll();
|
|
1255
|
+
final Map<String, Object> constants = new HashMap<>();
|
|
1256
|
+
|
|
1257
|
+
for (String key : args.keySet()) {
|
|
1258
|
+
constants.put(key, key);
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
return constants;
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
|
|
1265
|
+
@ReactMethod
|
|
1266
|
+
public void setOnFeaturesUpdatedListener() {
|
|
1267
|
+
InternalCore.INSTANCE._setOnFeaturesUpdatedListener(new OnFeaturesUpdatedListener() {
|
|
1268
|
+
@Override
|
|
1269
|
+
public void invoke() {
|
|
1270
|
+
final boolean cpNativeInterceptionEnabled = InternalAPM._isFeatureEnabledCP(CP_NATIVE_INTERCEPTION_ENABLED, "");
|
|
1271
|
+
final boolean hasAPMPlugin = InternalAPM._isFeatureEnabledCP(APM_NETWORK_PLUGIN_INSTALLED, "");
|
|
1272
|
+
|
|
1273
|
+
WritableMap params = Arguments.createMap();
|
|
1274
|
+
params.putBoolean("cpNativeInterceptionEnabled", cpNativeInterceptionEnabled);
|
|
1275
|
+
params.putBoolean("hasAPMPlugin", hasAPMPlugin);
|
|
1276
|
+
sendEvent(Constants.LCQ_ON_FEATURES_UPDATED_CALLBACK, params);
|
|
1277
|
+
}
|
|
1278
|
+
});
|
|
1279
|
+
}
|
|
1280
|
+
/**
|
|
1281
|
+
* Enables or disables capturing network body.
|
|
1282
|
+
* @param isEnabled A boolean to enable/disable capturing network body.
|
|
1283
|
+
*/
|
|
1284
|
+
@ReactMethod
|
|
1285
|
+
public void setNetworkLogBodyEnabled(final boolean isEnabled) {
|
|
1286
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
1287
|
+
@Override
|
|
1288
|
+
public void run() {
|
|
1289
|
+
try {
|
|
1290
|
+
Luciq.setNetworkLogBodyEnabled(isEnabled);
|
|
1291
|
+
} catch (Exception e) {
|
|
1292
|
+
e.printStackTrace();
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
});
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
/**
|
|
1299
|
+
* Sets the auto mask screenshots types.
|
|
1300
|
+
*
|
|
1301
|
+
* @param autoMaskingTypes The masking type to be applied.
|
|
1302
|
+
*/
|
|
1303
|
+
@ReactMethod
|
|
1304
|
+
public void enableAutoMasking(@NonNull ReadableArray autoMaskingTypes) {
|
|
1305
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
1306
|
+
|
|
1307
|
+
@Override
|
|
1308
|
+
public void run() {
|
|
1309
|
+
int[] autoMassingTypesArray = new int[autoMaskingTypes.size()];
|
|
1310
|
+
for (int i = 0; i < autoMaskingTypes.size(); i++) {
|
|
1311
|
+
String key = autoMaskingTypes.getString(i);
|
|
1312
|
+
|
|
1313
|
+
autoMassingTypesArray[i] = ArgsRegistry.autoMaskingTypes.get(key);
|
|
1314
|
+
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
Luciq.setAutoMaskScreenshotsTypes(autoMassingTypesArray);
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
});
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
/**
|
|
1324
|
+
* Get network body size limit
|
|
1325
|
+
*/
|
|
1326
|
+
@ReactMethod
|
|
1327
|
+
public void getNetworkBodyMaxSize(Promise promise) {
|
|
1328
|
+
|
|
1329
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
1330
|
+
@Override
|
|
1331
|
+
public void run() {
|
|
1332
|
+
try {
|
|
1333
|
+
promise.resolve(InternalCore.INSTANCE.get_networkLogCharLimit());
|
|
1334
|
+
} catch (Exception e) {
|
|
1335
|
+
e.printStackTrace();
|
|
1336
|
+
promise.resolve(false);
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
});
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
/**
|
|
1343
|
+
* Sets current App variant
|
|
1344
|
+
*
|
|
1345
|
+
* @param appVariant The app variant name .
|
|
1346
|
+
*/
|
|
1347
|
+
@ReactMethod
|
|
1348
|
+
public void setAppVariant(@NonNull String appVariant) {
|
|
1349
|
+
try {
|
|
1350
|
+
Luciq.setAppVariant(appVariant);
|
|
1351
|
+
|
|
1352
|
+
} catch (Exception e) {
|
|
1353
|
+
e.printStackTrace();
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
/**
|
|
1357
|
+
* Sets the theme for Luciq using a configuration object.
|
|
1358
|
+
*
|
|
1359
|
+
* @param themeConfig A ReadableMap containing theme properties such as colors, fonts, and text styles.
|
|
1360
|
+
*/
|
|
1361
|
+
@ReactMethod
|
|
1362
|
+
public void setTheme(final ReadableMap themeConfig) {
|
|
1363
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
1364
|
+
@Override
|
|
1365
|
+
public void run() {
|
|
1366
|
+
try {
|
|
1367
|
+
ai.luciq.library.model.LuciqTheme.Builder builder = new ai.luciq.library.model.LuciqTheme.Builder();
|
|
1368
|
+
|
|
1369
|
+
// Apply colors
|
|
1370
|
+
applyColorIfPresent(themeConfig, builder, "primaryColor", (themeBuilder, color) -> themeBuilder.setPrimaryColor(color));
|
|
1371
|
+
applyColorIfPresent(themeConfig, builder, "secondaryTextColor", (themeBuilder, color) -> themeBuilder.setSecondaryTextColor(color));
|
|
1372
|
+
applyColorIfPresent(themeConfig, builder, "primaryTextColor", (themeBuilder, color) -> themeBuilder.setPrimaryTextColor(color));
|
|
1373
|
+
applyColorIfPresent(themeConfig, builder, "titleTextColor", (themeBuilder, color) -> themeBuilder.setTitleTextColor(color));
|
|
1374
|
+
applyColorIfPresent(themeConfig, builder, "backgroundColor", (themeBuilder, color) -> themeBuilder.setBackgroundColor(color));
|
|
1375
|
+
|
|
1376
|
+
// Apply text styles
|
|
1377
|
+
applyTextStyleIfPresent(themeConfig, builder, "primaryTextStyle", (themeBuilder, style) -> themeBuilder.setPrimaryTextStyle(style));
|
|
1378
|
+
applyTextStyleIfPresent(themeConfig, builder, "secondaryTextStyle", (themeBuilder, style) -> themeBuilder.setSecondaryTextStyle(style));
|
|
1379
|
+
applyTextStyleIfPresent(themeConfig, builder, "ctaTextStyle", (themeBuilder, style) -> themeBuilder.setCtaTextStyle(style));
|
|
1380
|
+
setFontIfPresent(themeConfig, builder, "primaryFontPath", "primaryFontAsset", "primary");
|
|
1381
|
+
setFontIfPresent(themeConfig, builder, "secondaryFontPath", "secondaryFontAsset", "secondary");
|
|
1382
|
+
setFontIfPresent(themeConfig, builder, "ctaFontPath", "ctaFontAsset", "CTA");
|
|
1383
|
+
|
|
1384
|
+
LuciqTheme theme = builder.build();
|
|
1385
|
+
Luciq.setTheme(theme);
|
|
1386
|
+
|
|
1387
|
+
} catch (Exception e) {
|
|
1388
|
+
e.printStackTrace();
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
});
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
/**
|
|
1395
|
+
* Retrieves a color value from the ReadableMap.
|
|
1396
|
+
*
|
|
1397
|
+
* @param map The ReadableMap object.
|
|
1398
|
+
* @param key The key to look for.
|
|
1399
|
+
* @return The parsed color as an integer, or black if missing or invalid.
|
|
1400
|
+
*/
|
|
1401
|
+
private int getColor(ReadableMap map, String key) {
|
|
1402
|
+
try {
|
|
1403
|
+
if (map != null && map.hasKey(key) && !map.isNull(key)) {
|
|
1404
|
+
String colorString = map.getString(key);
|
|
1405
|
+
return Color.parseColor(colorString);
|
|
1406
|
+
}
|
|
1407
|
+
} catch (Exception e) {
|
|
1408
|
+
e.printStackTrace();
|
|
1409
|
+
}
|
|
1410
|
+
return Color.BLACK;
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
/**
|
|
1414
|
+
* Retrieves a text style from the ReadableMap.
|
|
1415
|
+
*
|
|
1416
|
+
* @param map The ReadableMap object.
|
|
1417
|
+
* @param key The key to look for.
|
|
1418
|
+
* @return The corresponding Typeface style, or Typeface.NORMAL if missing or invalid.
|
|
1419
|
+
*/
|
|
1420
|
+
private int getTextStyle(ReadableMap map, String key) {
|
|
1421
|
+
try {
|
|
1422
|
+
if (map != null && map.hasKey(key) && !map.isNull(key)) {
|
|
1423
|
+
String style = map.getString(key);
|
|
1424
|
+
switch (style.toLowerCase()) {
|
|
1425
|
+
case "bold":
|
|
1426
|
+
return Typeface.BOLD;
|
|
1427
|
+
case "italic":
|
|
1428
|
+
return Typeface.ITALIC;
|
|
1429
|
+
case "bold_italic":
|
|
1430
|
+
return Typeface.BOLD_ITALIC;
|
|
1431
|
+
case "normal":
|
|
1432
|
+
default:
|
|
1433
|
+
return Typeface.NORMAL;
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
} catch (Exception e) {
|
|
1437
|
+
e.printStackTrace();
|
|
1438
|
+
}
|
|
1439
|
+
return Typeface.NORMAL;
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
|
|
1443
|
+
|
|
1444
|
+
/**
|
|
1445
|
+
* Applies a color to the theme builder if present in the configuration.
|
|
1446
|
+
*
|
|
1447
|
+
* @param themeConfig The theme configuration map
|
|
1448
|
+
* @param builder The theme builder
|
|
1449
|
+
* @param key The configuration key
|
|
1450
|
+
* @param setter The color setter function
|
|
1451
|
+
*/
|
|
1452
|
+
private void applyColorIfPresent(ReadableMap themeConfig, ai.luciq.library.model.LuciqTheme.Builder builder,
|
|
1453
|
+
String key, java.util.function.BiConsumer<ai.luciq.library.model.LuciqTheme.Builder, Integer> setter) {
|
|
1454
|
+
if (themeConfig.hasKey(key)) {
|
|
1455
|
+
int color = getColor(themeConfig, key);
|
|
1456
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
|
1457
|
+
setter.accept(builder, color);
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
/**
|
|
1463
|
+
* Applies a text style to the theme builder if present in the configuration.
|
|
1464
|
+
*
|
|
1465
|
+
* @param themeConfig The theme configuration map
|
|
1466
|
+
* @param builder The theme builder
|
|
1467
|
+
* @param key The configuration key
|
|
1468
|
+
* @param setter The text style setter function
|
|
1469
|
+
*/
|
|
1470
|
+
private void applyTextStyleIfPresent(ReadableMap themeConfig, ai.luciq.library.model.LuciqTheme.Builder builder,
|
|
1471
|
+
String key, java.util.function.BiConsumer<ai.luciq.library.model.LuciqTheme.Builder, Integer> setter) {
|
|
1472
|
+
if (themeConfig.hasKey(key)) {
|
|
1473
|
+
int style = getTextStyle(themeConfig, key);
|
|
1474
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
|
1475
|
+
setter.accept(builder, style);
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
/**
|
|
1481
|
+
* Sets a font on the theme builder if the font configuration is present in the theme config.
|
|
1482
|
+
*
|
|
1483
|
+
* @param themeConfig The theme configuration map
|
|
1484
|
+
* @param builder The theme builder
|
|
1485
|
+
* @param fileKey The key for font file path
|
|
1486
|
+
* @param assetKey The key for font asset path
|
|
1487
|
+
* @param fontType The type of font (for logging purposes)
|
|
1488
|
+
*/
|
|
1489
|
+
private void setFontIfPresent(ReadableMap themeConfig, ai.luciq.library.model.LuciqTheme.Builder builder,
|
|
1490
|
+
String fileKey, String assetKey, String fontType) {
|
|
1491
|
+
if (themeConfig.hasKey(fileKey) || themeConfig.hasKey(assetKey)) {
|
|
1492
|
+
Typeface typeface = getTypeface(themeConfig, fileKey, assetKey);
|
|
1493
|
+
if (typeface != null) {
|
|
1494
|
+
switch (fontType) {
|
|
1495
|
+
case "primary":
|
|
1496
|
+
builder.setPrimaryTextFont(typeface);
|
|
1497
|
+
break;
|
|
1498
|
+
case "secondary":
|
|
1499
|
+
builder.setSecondaryTextFont(typeface);
|
|
1500
|
+
break;
|
|
1501
|
+
case "CTA":
|
|
1502
|
+
builder.setCtaTextFont(typeface);
|
|
1503
|
+
break;
|
|
1504
|
+
}
|
|
1505
|
+
} else {
|
|
1506
|
+
Log.e("LuciqModule", "Failed to load " + fontType + " font");
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
/**
|
|
1512
|
+
* Loads a Typeface from a file path.
|
|
1513
|
+
*
|
|
1514
|
+
* @param fileName The filename to load
|
|
1515
|
+
* @return The loaded Typeface or null if failed
|
|
1516
|
+
*/
|
|
1517
|
+
private Typeface loadTypefaceFromFile(String fileName) {
|
|
1518
|
+
try {
|
|
1519
|
+
Typeface typeface = Typeface.create(fileName, Typeface.NORMAL);
|
|
1520
|
+
if (typeface != null && !typeface.equals(Typeface.DEFAULT)) {
|
|
1521
|
+
return typeface;
|
|
1522
|
+
}
|
|
1523
|
+
} catch (Exception e) {
|
|
1524
|
+
e.printStackTrace();
|
|
1525
|
+
}
|
|
1526
|
+
return null;
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
/**
|
|
1530
|
+
* Loads a Typeface from assets.
|
|
1531
|
+
*
|
|
1532
|
+
* @param fileName The filename in assets/fonts/ directory
|
|
1533
|
+
* @return The loaded Typeface or null if failed
|
|
1534
|
+
*/
|
|
1535
|
+
private Typeface loadTypefaceFromAssets(String fileName) {
|
|
1536
|
+
try {
|
|
1537
|
+
return Typeface.createFromAsset(getReactApplicationContext().getAssets(), "fonts/" + fileName);
|
|
1538
|
+
} catch (Exception e) {
|
|
1539
|
+
e.printStackTrace();
|
|
1540
|
+
return null;
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
private Typeface getTypeface(ReadableMap map, String fileKey, String assetKey) {
|
|
1545
|
+
try {
|
|
1546
|
+
if (fileKey != null && map.hasKey(fileKey) && !map.isNull(fileKey)) {
|
|
1547
|
+
String fontPath = map.getString(fileKey);
|
|
1548
|
+
String fileName = getFileName(fontPath);
|
|
1549
|
+
|
|
1550
|
+
// Try loading from file first
|
|
1551
|
+
Typeface typeface = loadTypefaceFromFile(fileName);
|
|
1552
|
+
if (typeface != null) {
|
|
1553
|
+
return typeface;
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
// Try loading from assets
|
|
1557
|
+
typeface = loadTypefaceFromAssets(fileName);
|
|
1558
|
+
if (typeface != null) {
|
|
1559
|
+
return typeface;
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
if (assetKey != null && map.hasKey(assetKey) && !map.isNull(assetKey)) {
|
|
1564
|
+
String assetPath = map.getString(assetKey);
|
|
1565
|
+
String fileName = getFileName(assetPath);
|
|
1566
|
+
return loadTypefaceFromAssets(fileName);
|
|
1567
|
+
}
|
|
1568
|
+
} catch (Exception e) {
|
|
1569
|
+
e.printStackTrace();
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
return Typeface.DEFAULT;
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
/**
|
|
1576
|
+
* Extracts the filename from a path, removing any directory prefixes.
|
|
1577
|
+
*
|
|
1578
|
+
* @param path The full path to the file
|
|
1579
|
+
* @return Just the filename with extension
|
|
1580
|
+
*/
|
|
1581
|
+
private String getFileName(String path) {
|
|
1582
|
+
if (path == null || path.isEmpty()) {
|
|
1583
|
+
return path;
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1586
|
+
int lastSeparator = Math.max(path.lastIndexOf('/'), path.lastIndexOf('\\'));
|
|
1587
|
+
if (lastSeparator >= 0 && lastSeparator < path.length() - 1) {
|
|
1588
|
+
return path.substring(lastSeparator + 1);
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
return path;
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
/**
|
|
1595
|
+
* Enables or disables displaying in full-screen mode, hiding the status and navigation bars.
|
|
1596
|
+
* @param isEnabled A boolean to enable/disable setFullscreen.
|
|
1597
|
+
*/
|
|
1598
|
+
@ReactMethod
|
|
1599
|
+
public void setFullscreen(final boolean isEnabled) {
|
|
1600
|
+
MainThreadHandler.runOnMainThread(new Runnable() {
|
|
1601
|
+
@Override
|
|
1602
|
+
public void run() {
|
|
1603
|
+
try {
|
|
1604
|
+
Luciq.setFullscreen(isEnabled);
|
|
1605
|
+
} catch (Exception e) {
|
|
1606
|
+
e.printStackTrace();
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
});
|
|
1610
|
+
}
|
|
1611
|
+
}
|