Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7c642cc

Browse files
Release(Dream11):v14.0.0 (#1323)
* release : 14.0.0 * release : 14.0.0 * release : 14.0.0 * release : 14.0.0 * release : 14.0.0 * release : 14.0.0 * release : 14.0.0 * release : 14.0.0 * release : 14.0.0 * release : 14.0.0 * release : 14.0.0 * release : 14.0.0
1 parent 8d35b79 commit 7c642cc

File tree

138 files changed

+8505
-5393
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+8505
-5393
lines changed

.circleci/config.yml

Lines changed: 234 additions & 133 deletions
Large diffs are not rendered by default.

CHANGELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,37 @@
11
# Changelog
22

3+
## [14.0.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.0.5...14.0.0) (November 25, 2024)
4+
5+
### Added
6+
7+
- Add support for opting into session syncing ([#1292](https://github.com/Instabug/Instabug-React-Native/pull/1292)).
8+
- Add support for Expo Router navigation tracking ([#1270](https://github.com/Instabug/Instabug-React-Native/pull/1270)).
9+
- Enhance the network interceptor to capture more client error messages ([#1257](https://github.com/Instabug/Instabug-React-Native/pull/1257)).
10+
- Add support for Feature Flags APIs `Instabug.addFeatureFlags`, `Instabug.removeFeatureFlags` and `Instabug.clearAllFeatureFlags` ([#1230](https://github.com/Instabug/Instabug-React-Native/pull/1230)).
11+
- Export `uploadSourcemaps` and `uploadSoFiles` utilities in the `instabug-reactnative/upload` sub-package for usage in custom Node.js upload scripts ([#1252](https://github.com/Instabug/Instabug-React-Native/pull/1252)).
12+
- Add support for passing a grouping fingerprint, error level, and user attributes to the `CrashReporting.reportError` non-fatals API ([#1194](https://github.com/Instabug/Instabug-React-Native/pull/1194)).
13+
14+
### Deprecated
15+
16+
- Deprecate Experiments APIs `Instabug.addExperiments`, `Instabug.removeExperiments` and `Instabug.clearAllExperiments` in favor of the new Feature Flags APIs ([#1230](https://github.com/Instabug/Instabug-React-Native/pull/1230)).
17+
18+
### Changed
19+
20+
- Bump Instabug iOS SDK to v14.0.0 ([#1312](https://github.com/Instabug/Instabug-React-Native/pull/1312)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/14.0.0).
21+
- Bump Instabug Android SDK to v14.0.0 ([#1312](https://github.com/Instabug/Instabug-React-Native/pull/1312)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v14.0.0).
22+
23+
### Fixed
24+
25+
- Replace thrown errors with logs ([#1220](https://github.com/Instabug/Instabug-React-Native/pull/1220))
26+
- Fix an issue with JavaScript fatal crashes on iOS causing them to be reported as native iOS crashes instead. ([#1290](https://github.com/Instabug/Instabug-React-Native/pull/1290)).
27+
- Correctly resolve the flavor path when uploading sourcemaps on Android. ([#1225](https://github.com/Instabug/Instabug-React-Native/pull/1225)).
28+
- Drop non-error objects reported as crashes since they don't have a stack trace ([#1279](https://github.com/Instabug/Instabug-React-Native/pull/1279)).
29+
- Fix APM network logging on iOS when the response body is missing or empty. ([#1273](https://github.com/Instabug/Instabug-React-Native/pull/1273)).
30+
- Fix APM network logging on Android ([#1253](https://github.com/Instabug/Instabug-React-Native/pull/1253)).
31+
- Fix an OOM (out-of-memory) crash while saving network logs on Android ([#1244](https://github.com/Instabug/Instabug-React-Native/pull/1244)).
32+
- Change parameters used inside inner classes to `final` in Android code to maintain compatibility with Java 7 and earlier ([#1239](https://github.com/Instabug/Instabug-React-Native/pull/1239)).
33+
- Read `INSTABUG_APP_TOKEN` from system environment when there is no default value ([#1232](https://github.com/Instabug/Instabug-React-Native/pull/1232)).
34+
335
## [13.0.6](https://github.com/Instabug/Instabug-React-Native/compare/v13.0.5...v13.0.6) (JUN 17, 2024)
436

537
### Changed

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ android {
5757
minSdkVersion getExtOrDefault('minSdkVersion').toInteger()
5858
targetSdkVersion getExtOrDefault('targetSdkVersion').toInteger()
5959
versionCode 1
60-
versionName "13.0.5"
60+
versionName "14.0.0"
6161
multiDexEnabled true
6262
ndk {
6363
abiFilters "armeabi-v7a", "x86"

android/jacoco.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ task jacocoTestReport(type: JacocoReport) {
3737
'**/*Binding.*'
3838
]
3939

40-
def jClasses = "${project.buildDir}/intermediates/javac/debug/classes"
40+
def jClasses = "${project.buildDir}/intermediates/javac/debug/compileDebugJavaWithJavac/classes"
4141
def javaClasses = fileTree(dir: jClasses, excludes: excludes)
4242
def sourceDirs = ["${project.projectDir}/src/main/java"]
4343
classDirectories.from = files(javaClasses)

android/native.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project.ext.instabug = [
2-
version: '13.0.7'
2+
version: '14.0.0'
33
]
44

55
dependencies {

android/sourcemaps.gradle

Lines changed: 60 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ gradle.projectsEvaluated {
1313
def start = name.startsWith(prefixes[0]) ? prefixes[0].length() : prefixes[1].length()
1414
def end = name.length() - suffix.length()
1515
def flavor = name.substring(start, end).uncapitalize()
16+
def defaultVersion = getDefaultVersion(flavor)
1617

17-
task.finalizedBy createUploadSourcemapsTask(flavor)
18+
task.finalizedBy createUploadSourcemapsTask(flavor, defaultVersion.name, defaultVersion.code)
1819
}
1920
}
2021

21-
Task createUploadSourcemapsTask(String flavor) {
22+
Task createUploadSourcemapsTask(String flavor, String defaultVersionName, String defaultVersionCode) {
2223
def name = 'uploadSourcemaps' + flavor.capitalize()
2324

2425
// Don't recreate the task if it already exists.
@@ -38,13 +39,7 @@ Task createUploadSourcemapsTask(String flavor) {
3839
try {
3940
def appProject = project(':app')
4041
def appDir = appProject.projectDir
41-
def flavorPath = flavor + (flavor.empty ? '' : '/')
42-
def sourceMapDest = "build/generated/sourcemaps/react/${flavorPath}release/index.android.bundle.map"
43-
def sourceMapFile = new File(appDir, sourceMapDest)
44-
45-
if (!sourceMapFile.exists()) {
46-
throw new InvalidUserDataException("Unable to find source map file at: ${sourceMapFile.absolutePath}")
47-
}
42+
def sourceMapFile = getSourceMapFile(appDir, flavor)
4843

4944
def jsProjectDir = rootDir.parentFile
5045
def instabugDir = new File(['node', '-p', 'require.resolve("instabug-reactnative/package.json")'].execute(null, rootDir).text.trim()).getParentFile()
@@ -53,9 +48,8 @@ Task createUploadSourcemapsTask(String flavor) {
5348
def inferredToken = executeShellScript(tokenShellFile, jsProjectDir)
5449
def appToken = resolveVar('App Token', 'INSTABUG_APP_TOKEN', inferredToken)
5550

56-
def projectConfig = appProject.android.defaultConfig
57-
def versionName = resolveVar('Version Name', 'INSTABUG_VERSION_NAME', "${projectConfig.versionName}")
58-
def versionCode = resolveVar('Version Code', 'INSTABUG_VERSION_CODE', "${projectConfig.versionCode}")
51+
def versionName = resolveVar('Version Name', 'INSTABUG_VERSION_NAME', defaultVersionName)
52+
def versionCode = resolveVar('Version Code', 'INSTABUG_VERSION_CODE', defaultVersionCode)
5953

6054
exec {
6155
def osCompatibility = Os.isFamily(Os.FAMILY_WINDOWS) ? ['cmd', '/c'] : []
@@ -80,6 +74,59 @@ Task createUploadSourcemapsTask(String flavor) {
8074
return provider.get()
8175
}
8276

77+
File getSourceMapFile(File appDir, String flavor) {
78+
def defaultFlavorPath = flavor.empty ? 'release' : "${flavor}Release"
79+
def defaultSourceMapDest = "build/generated/sourcemaps/react/${defaultFlavorPath}/index.android.bundle.map"
80+
def defaultSourceMapFile = new File(appDir, defaultSourceMapDest)
81+
82+
if (defaultSourceMapFile.exists()) {
83+
return defaultSourceMapFile
84+
}
85+
86+
if (flavor.empty) {
87+
throw new InvalidUserDataException("Unable to find source map file at: ${defaultSourceMapFile.absolutePath}.")
88+
}
89+
90+
def fallbackSourceMapDest = "build/generated/sourcemaps/react/${flavor}/release/index.android.bundle.map"
91+
def fallbackSourceMapFile = new File(appDir, fallbackSourceMapDest)
92+
93+
project.logger.info "Unable to find source map file at: ${defaultSourceMapFile.absolutePath}.\n" +
94+
"Falling back to ${fallbackSourceMapFile.absolutePath}."
95+
96+
if (!fallbackSourceMapFile.exists()) {
97+
throw new InvalidUserDataException("Unable to find source map file at: ${fallbackSourceMapFile.absolutePath} either.")
98+
}
99+
100+
return fallbackSourceMapFile
101+
}
102+
103+
/**
104+
* Infers the app version to use in source map upload based on the flavor.
105+
* This is needed since different flavors may have different version codes and names (e.g. version suffixes).
106+
*
107+
* It checks the version for the flavor's variant.
108+
* If no variant is found it falls back to the app's default config.
109+
*
110+
*
111+
* @param flavor The flavor to get the app version for.
112+
* @return A map containing the version code and version name.
113+
*/
114+
Map<String, String> getDefaultVersion(String flavor) {
115+
def appProject = project(':app')
116+
def defaultConfig = appProject.android.defaultConfig
117+
118+
def variants = appProject.android.applicationVariants
119+
120+
// uncapitalize is used to turn "Release" into "release" if the flavor is empty
121+
def variantName = "${flavor}Release".uncapitalize()
122+
def variant = variants.find { it.name.uncapitalize() == variantName }
123+
124+
def versionName = variant?.versionName ?: defaultConfig.versionName
125+
def versionCode = variant?.versionCode ?: defaultConfig.versionCode
126+
127+
return [name: "${versionName}", code: "${versionCode}"]
128+
}
129+
83130
boolean isUploadSourcemapsEnabled() {
84131
def envValue = System.getenv('INSTABUG_SOURCEMAPS_UPLOAD_DISABLE')?.toBoolean()
85132
def defaultValue = true
@@ -91,7 +138,7 @@ String resolveVar(String name, String envKey, String defaultValue) {
91138
def env = System.getenv()
92139
def envValue = env.get(envKey)
93140

94-
if (envValue != null && envValue != defaultValue) {
141+
if (envValue != null && defaultValue !=null && envValue != defaultValue) {
95142
project.logger.warn "Environment variable `${envKey}` might have incorrect value, " +
96143
"make sure this was intentional:\n" +
97144
" Environment Value: ${envValue}\n" +

android/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<manifest package="com.instabug.reactlibrary"
1+
<manifest
22
xmlns:android="http://schemas.android.com/apk/res/android">
33

44
</manifest>

android/src/main/java/com/instabug/reactlibrary/ArgsRegistry.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import com.instabug.bug.BugReporting;
66
import com.instabug.bug.invocation.Option;
7+
import com.instabug.crash.models.IBGNonFatalException;
78
import com.instabug.featuresrequest.ActionType;
89
import com.instabug.library.InstabugColorTheme;
910
import com.instabug.library.InstabugCustomTextPlaceHolder.Key;
@@ -14,6 +15,7 @@
1415
import com.instabug.library.invocation.InstabugInvocationEvent;
1516
import com.instabug.library.invocation.util.InstabugFloatingButtonEdge;
1617
import com.instabug.library.invocation.util.InstabugVideoRecordingButtonPosition;
18+
import com.instabug.library.sessionreplay.model.SessionMetadata;
1719
import com.instabug.library.ui.onboarding.WelcomeMessage;
1820

1921
import java.util.ArrayList;
@@ -54,11 +56,20 @@ static Map<String, Object> getAll() {
5456
putAll(extendedBugReportStates);
5557
putAll(reproModes);
5658
putAll(sdkLogLevels);
59+
putAll(nonFatalExceptionLevel);
5760
putAll(locales);
5861
putAll(placeholders);
62+
putAll(launchType);
5963
}};
6064
}
6165

66+
public static ArgsMap<IBGNonFatalException.Level> nonFatalExceptionLevel = new ArgsMap<IBGNonFatalException.Level>() {{
67+
put("nonFatalErrorLevelCritical", IBGNonFatalException.Level.CRITICAL);
68+
put("nonFatalErrorLevelError", IBGNonFatalException.Level.ERROR);
69+
put("nonFatalErrorLevelWarning", IBGNonFatalException.Level.WARNING);
70+
put("nonFatalErrorLevelInfo", IBGNonFatalException.Level.INFO);
71+
}};
72+
6273
static ArgsMap<InstabugInvocationEvent> invocationEvents = new ArgsMap<InstabugInvocationEvent>() {{
6374
put("invocationEventNone", InstabugInvocationEvent.NONE);
6475
put("invocationEventShake", InstabugInvocationEvent.SHAKE);
@@ -229,4 +240,18 @@ static Map<String, Object> getAll() {
229240
put("team", Key.CHATS_TEAM_STRING_NAME);
230241
put("insufficientContentMessage", Key.COMMENT_FIELD_INSUFFICIENT_CONTENT);
231242
}};
243+
244+
public static ArgsMap<String> launchType = new ArgsMap<String>() {{
245+
put("cold", SessionMetadata.LaunchType.COLD);
246+
put("warm",SessionMetadata.LaunchType.WARM );
247+
put("unknown","unknown");
248+
}};
249+
250+
// Temporary workaround to be removed in future release
251+
// This is used for mapping native `LaunchType` values into React Native enum values.
252+
public static HashMap<String,String> launchTypeReversed = new HashMap<String,String>() {{
253+
put(SessionMetadata.LaunchType.COLD,"cold");
254+
put(SessionMetadata.LaunchType.WARM,"warm" );
255+
}};
256+
232257
}

android/src/main/java/com/instabug/reactlibrary/Constants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ final class Constants {
1010

1111
final static String IBG_ON_NEW_MESSAGE_HANDLER = "IBGonNewMessageHandler";
1212
final static String IBG_ON_NEW_REPLY_RECEIVED_CALLBACK = "IBGOnNewReplyReceivedCallback";
13+
final static String IBG_SESSION_REPLAY_ON_SYNC_CALLBACK_INVOCATION = "IBGSessionReplayOnSyncCallback";
14+
1315
}

android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java

Lines changed: 47 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@
55
import android.util.Log;
66

77
import androidx.annotation.NonNull;
8+
import androidx.annotation.Nullable;
9+
810
import com.facebook.react.bridge.Promise;
911
import com.facebook.react.bridge.ReactApplicationContext;
1012
import com.facebook.react.bridge.ReactContextBaseJavaModule;
1113
import com.facebook.react.bridge.ReactMethod;
1214
import com.instabug.apm.APM;
1315
import com.instabug.apm.model.ExecutionTrace;
1416
import com.instabug.apm.networking.APMNetworkLogger;
17+
import com.instabug.apm.networkinterception.cp.APMCPNetworkLog;
1518
import com.instabug.reactlibrary.utils.MainThreadHandler;
1619

1720
import org.json.JSONException;
@@ -312,56 +315,59 @@ public void run() {
312315
});
313316
}
314317

315-
/**
316-
* Send Apm network log by Reflection
317-
*/
318318
@ReactMethod
319-
public void networkLog(String networkData) throws JSONException {
320-
try{
321-
APMNetworkLogger apmNetworkLogger = new APMNetworkLogger();
322-
JSONObject jsonObject = new JSONObject(networkData);
323-
final String requestUrl = (String) jsonObject.get("url");
324-
final String requestBody = (String) jsonObject.get("requestBody");
325-
final String responseBody = (String) jsonObject.get("responseBody");
326-
final String requestMethod = (String) jsonObject.get("method");
327-
//--------------------------------------------
328-
final String requestContentType = (String) jsonObject.get("requestContentType");
329-
final String responseContentType = (String) jsonObject.get("contentType");
330-
//--------------------------------------------
331-
final long requestBodySize = ((Number) jsonObject.get("requestBodySize")).longValue();
332-
final long responseBodySize = ((Number) jsonObject.get("responseBodySize")).longValue();
333-
//--------------------------------------------
334-
final String errorDomain = (String) jsonObject.get("errorDomain");
335-
final Integer statusCode = (Integer) jsonObject.get("responseCode");
336-
final long requestDuration = ((Number) jsonObject.get("duration")).longValue();
337-
final long requestStartTime = ((Number) jsonObject.get("startTime")).longValue() * 1000;
338-
final String requestHeaders = (String) jsonObject.get("requestHeaders").toString();
339-
final String responseHeaders = (String) jsonObject.get("responseHeaders").toString();
340-
final String errorMessage;
341-
if(errorDomain.equals("")) {
342-
errorMessage = null;
343-
} else {
344-
errorMessage = errorDomain;
345-
}
346-
//--------------------------------------------
347-
String gqlQueryName = null;
348-
if(jsonObject.has("gqlQueryName")){
349-
gqlQueryName = (String) jsonObject.get("gqlQueryName");
350-
}
351-
final String serverErrorMessage = (String) jsonObject.get("serverErrorMessage");
319+
private void networkLogAndroid(final double requestStartTime,
320+
final double requestDuration,
321+
final String requestHeaders,
322+
final String requestBody,
323+
final double requestBodySize,
324+
final String requestMethod,
325+
final String requestUrl,
326+
final String requestContentType,
327+
final String responseHeaders,
328+
final String responseBody,
329+
final double responseBodySize,
330+
final double statusCode,
331+
final String responseContentType,
332+
@Nullable final String errorDomain,
333+
@Nullable final String gqlQueryName,
334+
@Nullable final String serverErrorMessage) {
335+
try {
336+
APMNetworkLogger networkLogger = new APMNetworkLogger();
337+
338+
final boolean hasError = errorDomain != null && !errorDomain.isEmpty();
339+
final String errorMessage = hasError ? errorDomain : null;
352340

353341
try {
354-
Method method = getMethod(Class.forName("com.instabug.apm.networking.APMNetworkLogger"), "log", long.class, long.class, String.class, String.class, long.class, String.class, String.class, String.class, String.class, String.class, long.class, int.class, String.class, String.class, String.class, String.class);
342+
Method method = getMethod(Class.forName("com.instabug.apm.networking.APMNetworkLogger"), "log", long.class, long.class, String.class, String.class, long.class, String.class, String.class, String.class, String.class, String.class, long.class, int.class, String.class, String.class, String.class, String.class, APMCPNetworkLog.W3CExternalTraceAttributes.class);
355343
if (method != null) {
356-
method.invoke(apmNetworkLogger, requestStartTime, requestDuration, requestHeaders, requestBody, requestBodySize, requestMethod, requestUrl, requestContentType, responseHeaders, responseBody, responseBodySize, statusCode, responseContentType, errorMessage, gqlQueryName, serverErrorMessage);
344+
method.invoke(
345+
networkLogger,
346+
(long) requestStartTime * 1000,
347+
(long) requestDuration,
348+
requestHeaders,
349+
requestBody,
350+
(long) requestBodySize,
351+
requestMethod,
352+
requestUrl,
353+
requestContentType,
354+
responseHeaders,
355+
responseBody,
356+
(long)responseBodySize,
357+
(int) statusCode,
358+
responseContentType,
359+
errorMessage,
360+
gqlQueryName,
361+
serverErrorMessage,
362+
null
363+
);
357364
} else {
358-
Log.e("IB-CP-Bridge", "apmNetworkLogByReflection was not found by reflection");
365+
Log.e("IB-CP-Bridge", "APMNetworkLogger.log was not found by reflection");
359366
}
360367
} catch (Throwable e) {
361368
e.printStackTrace();
362369
}
363-
}
364-
catch(Throwable e) {
370+
} catch(Throwable e) {
365371
e.printStackTrace();
366372
}
367373
}

0 commit comments

Comments
 (0)