Skip to content

Commit 5b2271b

Browse files
authored
Merge pull request #214 from Instabug/release/10.11.0
[MOB-6534] Release/10.11.0
2 parents 4ba9e18 + 9c64fd3 commit 5b2271b

18 files changed

+600
-134
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,13 @@ jobs:
125125

126126
gh_ibg_release:
127127
macos:
128-
xcode: "10.1.0"
128+
xcode: "12.5.1"
129129
working_directory: "~"
130130
steps:
131131
- checkout:
132132
path: ~/project
133133
- run: git clone https://InstabugCI:[email protected]/Instabug/Escape.git
134-
- run: cd Escape && swift build -c release -Xswiftc -static-stdlib
134+
- run: cd Escape && swift build -c release
135135
- run: cd Escape/.build/release && cp -f Escape /usr/local/bin/escape
136136
- run: cd project && Escape flutter publish
137137

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## v10.11.0 (2021-12-28)
2+
3+
* Adds support for APM.endAppLaunch API
4+
* Bumps Instabug native SDKs to v10.11
5+
* Fixes an issue with APM logged requests payload size
6+
17
## v10.9.1 (2021-10-13)
28

39
* Bumps Instabug Android SDK to v10.9.1

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ android {
3434
}
3535
}
3636
dependencies {
37-
implementation 'com.instabug.library:instabug:10.9.1'
37+
implementation 'com.instabug.library:instabug:10.11.0'
3838
testImplementation 'junit:junit:4.12'
3939
}

android/src/main/java/com/instabug/instabugflutter/InstabugFlutterPlugin.java

Lines changed: 64 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,42 +1131,74 @@ public void run() {
11311131
});
11321132
}
11331133

1134-
public void apmNetworkLogByReflection(HashMap<String, Object> jsonObject) throws JSONException {
1135-
APMNetworkLogger apmNetworkLogger = new APMNetworkLogger();
1136-
final String requestUrl = (String) jsonObject.get("url");
1137-
final String requestBody = (String) jsonObject.get("requestBody");
1138-
final String responseBody = (String) jsonObject.get("responseBody");
1139-
final String requestMethod = (String) jsonObject.get("method");
1140-
//--------------------------------------------
1141-
final String requestContentType = (String) jsonObject.get("contentType");
1142-
final String responseContentType = (String) jsonObject.get("responseContentType");
1143-
//--------------------------------------------
1144-
final String errorDomain = (String) jsonObject.get("errorDomain");
1145-
final Integer statusCode = (Integer) jsonObject.get("responseCode");
1146-
final long requestDuration = ((Number) jsonObject.get("duration")).longValue() / 1000;
1147-
final long requestStartTime = ((Number) jsonObject.get("startTime")).longValue() * 1000;
1148-
final String requestHeaders = (new JSONObject((HashMap<String, String>) jsonObject.get("requestHeaders"))).toString(4);
1149-
final String responseHeaders = (new JSONObject((HashMap<String, String>) jsonObject.get("responseHeaders"))).toString(4);
1150-
final String errorMessage;
1151-
1152-
if(errorDomain.equals("")) {
1153-
errorMessage = null;
1154-
} else {
1155-
errorMessage = errorDomain;
1156-
}
1134+
/**
1135+
* Ends app launch
1136+
*/
1137+
public void endAppLaunch() {
1138+
new Handler(Looper.getMainLooper()).post(new Runnable() {
1139+
@Override
1140+
public void run() {
1141+
try {
1142+
APM.endAppLaunch();
1143+
} catch (Exception e) {
1144+
e.printStackTrace();
1145+
}
1146+
}
1147+
});
1148+
}
11571149

1150+
public void apmNetworkLogByReflection(HashMap<String, Object> jsonObject) throws JSONException {
11581151
try {
1159-
Method method = getMethod(Class.forName("com.instabug.apm.networking.APMNetworkLogger"), "log", long.class, long.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, int.class, String.class, String.class);
1160-
if (method != null) {
1161-
method.invoke(apmNetworkLogger, requestStartTime, requestDuration, requestHeaders, requestBody, requestMethod, requestUrl, requestContentType, responseHeaders, responseBody, statusCode, responseContentType, errorMessage);
1152+
APMNetworkLogger apmNetworkLogger = new APMNetworkLogger();
1153+
final String requestUrl = (String) jsonObject.get("url");
1154+
final String requestBody = (String) jsonObject.get("requestBody");
1155+
final String responseBody = (String) jsonObject.get("responseBody");
1156+
final String requestMethod = (String) jsonObject.get("method");
1157+
//--------------------------------------------
1158+
final String requestContentType = (String) jsonObject.get("requestContentType");
1159+
final String responseContentType = (String) jsonObject.get("responseContentType");
1160+
//--------------------------------------------
1161+
final long requestBodySize = ((Number) jsonObject.get("requestBodySize")).longValue();
1162+
final long responseBodySize = ((Number) jsonObject.get("responseBodySize")).longValue();
1163+
//--------------------------------------------
1164+
final String errorDomain = (String) jsonObject.get("errorDomain");
1165+
final Integer statusCode = (Integer) jsonObject.get("responseCode");
1166+
final long requestDuration = ((Number) jsonObject.get("duration")).longValue() / 1000;
1167+
final long requestStartTime = ((Number) jsonObject.get("startTime")).longValue() * 1000;
1168+
final String requestHeaders = (new JSONObject((HashMap<String, String>) jsonObject.get("requestHeaders"))).toString(4);
1169+
final String responseHeaders = (new JSONObject((HashMap<String, String>) jsonObject.get("responseHeaders"))).toString(4);
1170+
final String errorMessage;
1171+
1172+
if(errorDomain.equals("")) {
1173+
errorMessage = null;
11621174
} else {
1163-
Log.e("IB-CP-Bridge", "apmNetworkLogByReflection was not found by reflection");
1175+
errorMessage = errorDomain;
11641176
}
1165-
} catch (ClassNotFoundException e) {
1166-
e.printStackTrace();
1167-
} catch (IllegalAccessException e) {
1168-
e.printStackTrace();
1169-
} catch (InvocationTargetException e) {
1177+
//--------------------------------------------------
1178+
String gqlQueryName = null;
1179+
if(jsonObject.containsKey("gqlQueryName")){
1180+
gqlQueryName = (String) jsonObject.get("gqlQueryName");
1181+
}
1182+
String serverErrorMessage = "";
1183+
if(jsonObject.containsKey("serverErrorMessage")){
1184+
serverErrorMessage = (String) jsonObject.get("serverErrorMessage");
1185+
}
1186+
1187+
try {
1188+
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);
1189+
if (method != null) {
1190+
method.invoke(apmNetworkLogger, requestStartTime, requestDuration, requestHeaders, requestBody, requestBodySize, requestMethod, requestUrl, requestContentType, responseHeaders, responseBody, responseBodySize, statusCode, responseContentType, errorMessage, gqlQueryName, serverErrorMessage);
1191+
} else {
1192+
Log.e("IB-CP-Bridge", "apmNetworkLogByReflection was not found by reflection");
1193+
}
1194+
} catch (ClassNotFoundException e) {
1195+
e.printStackTrace();
1196+
} catch (IllegalAccessException e) {
1197+
e.printStackTrace();
1198+
} catch (InvocationTargetException e) {
1199+
e.printStackTrace();
1200+
}
1201+
} catch (Exception e) {
11701202
e.printStackTrace();
11711203
}
11721204

example/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
buildscript {
2-
ext.kotlin_version = '1.3.50'
2+
ext.kotlin_version = '1.4.32'
33
repositories {
44
google()
55
jcenter()

ios/Classes/InstabugFlutterPlugin.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,4 +493,10 @@
493493
*/
494494
+ (void)endUITrace;
495495

496+
/**
497+
* Ends the current session’s App Launch. Calling this API is optional, App Launches will still be captured and ended automatically by the SDK;
498+
* this API just allows you to change when an App Launch actually ends.
499+
*/
500+
+ (void)endAppLaunch;
501+
496502
@end

ios/Classes/InstabugFlutterPlugin.m

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ + (void)networkLog:(NSDictionary *) networkData {
766766
requestHeaders = @{};
767767
}
768768
NSDictionary* responseHeaders = networkData[@"responseHeaders"];
769-
NSString* contentType = @"application/json";
769+
NSString* contentType = networkData[@"responseContentType"];
770770
int64_t duration = [networkData[@"duration"] integerValue];
771771
int64_t startTime = [networkData[@"startTime"] integerValue] * 1000;
772772

@@ -775,7 +775,16 @@ + (void)networkLog:(NSDictionary *) networkData {
775775
NSLog(@"value: %@",[requestHeaders objectForKey:key]);
776776
}
777777

778-
SEL networkLogSEL = NSSelectorFromString(@"addNetworkLogWithUrl:method:requestBody:requestBodySize:responseBody:responseBodySize:responseCode:requestHeaders:responseHeaders:contentType:errorDomain:errorCode:startTime:duration:");
778+
NSString* gqlQueryName = nil;
779+
NSString* serverErrorMessage = nil;
780+
if (networkData[@"gqlQueryName"] != [NSNull null]) {
781+
gqlQueryName = networkData[@"gqlQueryName"];
782+
}
783+
if (networkData[@"serverErrorMessage"] != [NSNull null]) {
784+
serverErrorMessage = networkData[@"serverErrorMessage"];
785+
}
786+
787+
SEL networkLogSEL = NSSelectorFromString(@"addNetworkLogWithUrl:method:requestBody:requestBodySize:responseBody:responseBodySize:responseCode:requestHeaders:responseHeaders:contentType:errorDomain:errorCode:startTime:duration:gqlQueryName:serverErrorMessage:");
779788

780789
if([[IBGNetworkLogger class] respondsToSelector:networkLogSEL]) {
781790
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[[IBGNetworkLogger class] methodSignatureForSelector:networkLogSEL]];
@@ -796,6 +805,8 @@ + (void)networkLog:(NSDictionary *) networkData {
796805
[inv setArgument:&(errorCode) atIndex:13];
797806
[inv setArgument:&(startTime) atIndex:14];
798807
[inv setArgument:&(duration) atIndex:15];
808+
[inv setArgument:&(gqlQueryName) atIndex:16];
809+
[inv setArgument:&(serverErrorMessage) atIndex:17];
799810

800811
[inv invoke];
801812
}
@@ -934,6 +945,13 @@ + (void)endUITrace {
934945
[IBGAPM endUITrace];
935946
}
936947

948+
/**
949+
* Ends app launch.
950+
*/
951+
+ (void)endAppLaunch {
952+
[IBGAPM endAppLaunch];
953+
}
954+
937955
/** Reports that the screen has been changed (Repro Steps) the screen sent to this method will be the 'current view' on the dashboard
938956
*
939957
* @param screenName string containing the screen name

ios/instabug_flutter.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ A new flutter plugin project.
1515
s.source_files = 'Classes/**/*'
1616
s.public_header_files = 'Classes/**/*.h'
1717
s.dependency 'Flutter'
18-
s.dependency 'Instabug', '10.9.3'
18+
s.dependency 'Instabug', '10.11.2'
1919

2020
s.ios.deployment_target = '10.0'
2121
s.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-framework "Flutter" -framework "Instabug"'}

lib/APM.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ class APM {
113113
static void endUITrace() async {
114114
await _channel.invokeMethod<Object>('endUITrace');
115115
}
116+
/// Ends UI trace.
117+
static void endAppLaunch() async {
118+
await _channel.invokeMethod<Object>('endAppLaunch');
119+
}
116120

117121
static Future<bool?> networkLogAndroid(NetworkData data) async {
118122
if (Platform.isAndroid) {

lib/NetworkLogger.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class NetworkLogger {
1212
static Future<String?> get platformVersion async =>
1313
await _channel.invokeMethod<String>('getPlatformVersion');
1414

15-
static Future<bool?> networkLog(NetworkData data) async {
15+
Future<bool?> networkLog(NetworkData data) async {
1616
final params = <dynamic>[data.toMap()];
1717
await _channel.invokeMethod<bool>('networkLog:', params);
1818
await APM.networkLogAndroid(data);

0 commit comments

Comments
 (0)