Skip to content

Commit

Permalink
Merge pull request #508 from Instabug/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
mzelzoghbi authored Sep 29, 2024
2 parents 4832a23 + 7ae921c commit c699efc
Show file tree
Hide file tree
Showing 25 changed files with 601 additions and 76 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## [13.4.0](https://github.com/Instabug/Instabug-Flutter/compare/v13.3.0...v13.4.0) (September 29, 2024)

### Added

- Add support for masking screen names captured by Instabug through the `Instabug.setScreenNameMaskingCallback` API ([#500](https://github.com/Instabug/Instabug-Flutter/pull/500)).

### Changed

- Bump Instabug Android SDK to v13.4.1 ([#509](https://github.com/Instabug/Instabug-Flutter/pull/509)). See release notes for [13.4.0](https://github.com/Instabug/Instabug-Android/releases/tag/v13.4.0) and [13.4.1](https://github.com/Instabug/Instabug-Android/releases/tag/v13.4.1).
- Bump Instabug iOS SDK to v13.4.2 ([#515](https://github.com/Instabug/Instabug-Flutter/pull/515)). See release notes for [13.4.0](https://github.com/Instabug/Instabug-iOS/releases/tag/13.4.0), [13.4.1](https://github.com/Instabug/Instabug-iOS/releases/tag/13.4.1) and [13.4.2](https://github.com/Instabug/Instabug-iOS/releases/tag/13.4.2).

### Fixed

- Fixed an issue with empty screen names captured in `InstabugNavigatorObserver` and fallback to `N/A` when the screen name is empty ([#505](https://github.com/Instabug/Instabug-Flutter/pull/505)), closes [#504](https://github.com/Instabug/Instabug-Flutter/issues/504).

## [13.3.0](https://github.com/Instabug/Instabug-Flutter/compare/v13.2.0...v13.3.0) (August 5, 2024)

### Added
Expand Down Expand Up @@ -30,7 +45,7 @@
- Bump Instabug Android SDK to v13.2.0 ([#482](https://github.com/Instabug/Instabug-Flutter/pull/482)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v13.2.0).
- Bump Instabug iOS SDK to v13.2.0 ([#483](https://github.com/Instabug/Instabug-Flutter/pull/483)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/13.2.0).

## [13.1.1](https://github.com/Instabug/Instabug-Flutter/compare/v13.0.0...dev) (Jun,11 2024)
## [13.1.1](https://github.com/Instabug/Instabug-Flutter/compare/v13.0.0...v13.1.1) (June 11, 2024)

### Added

Expand Down
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'com.instabug.flutter'
version '13.3.0'
version '13.4.0'

buildscript {
repositories {
Expand Down Expand Up @@ -41,7 +41,7 @@ android {
}

dependencies {
api 'com.instabug.library:instabug:13.3.0'
api 'com.instabug.library:instabug:13.4.1'

testImplementation 'junit:junit:4.13.2'
testImplementation "org.mockito:mockito-inline:3.12.1"
Expand Down
8 changes: 6 additions & 2 deletions example/ios/InstabugTests/InstabugApiTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#import "InstabugApi.h"
#import "Instabug/Instabug.h"
#import "Util/Instabug+Test.h"
#import "Util/IBGNetworkLogger+Test.h"
#import "IBGNetworkLogger+CP.h"
#import "Flutter/Flutter.h"

@interface InstabugTests : XCTestCase
Expand Down Expand Up @@ -435,7 +435,11 @@ - (void)testNetworkLog {
duration:duration.integerValue
gqlQueryName:nil
serverErrorMessage:nil
]);
isW3cCaughted:nil
partialID:nil
timestamp:nil
generatedW3CTraceparent:nil
caughtedW3CTraceparent:nil]);
}

- (void)testWillRedirectToAppStore {
Expand Down
10 changes: 5 additions & 5 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
PODS:
- Flutter (1.0.0)
- Instabug (13.3.0)
- instabug_flutter (13.3.0):
- Instabug (13.4.2)
- instabug_flutter (13.4.0):
- Flutter
- Instabug (= 13.3.0)
- Instabug (= 13.4.2)
- OCMock (3.6)

DEPENDENCIES:
Expand All @@ -24,8 +24,8 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
Instabug: 4f26295103a330ec0236918359eef7ccaa74e2fa
instabug_flutter: 6be22be13b3dda72b293151d2c009952bb20b940
Instabug: 7a71890217b97b1e32dbca96661845396b66da2f
instabug_flutter: a2df87e3d4d9e410785e0b1ffef4bc64d1f4b787
OCMock: 5ea90566be239f179ba766fd9fbae5885040b992

PODFILE CHECKSUM: 8f7552fd115ace1988c3db54a69e4a123c448f84
Expand Down
2 changes: 0 additions & 2 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
CC359DB82937720C0067A924 /* ApmApiTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ApmApiTests.m; sourceTree = "<group>"; };
CC3D69E6293F47FC000DCE54 /* ArgsRegistryTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ArgsRegistryTests.m; sourceTree = "<group>"; };
CC78720E293CA8EE008CB2A5 /* Instabug+Test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Instabug+Test.h"; sourceTree = "<group>"; };
CC787211293CAB28008CB2A5 /* IBGNetworkLogger+Test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "IBGNetworkLogger+Test.h"; sourceTree = "<group>"; };
CC9925D1293DEB0B001FD3EE /* CrashReportingApiTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CrashReportingApiTests.m; sourceTree = "<group>"; };
CC9925D4293DF534001FD3EE /* FeatureRequestsApiTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FeatureRequestsApiTests.m; sourceTree = "<group>"; };
CC9925D6293DFB03001FD3EE /* InstabugLogApiTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InstabugLogApiTests.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -216,7 +215,6 @@
children = (
BE26C80C2BD55575009FECCF /* IBGCrashReporting+CP.h */,
CC78720E293CA8EE008CB2A5 /* Instabug+Test.h */,
CC787211293CAB28008CB2A5 /* IBGNetworkLogger+Test.h */,
CC198C62293E2392007077C8 /* IBGSurvey+Test.h */,
);
path = Util;
Expand Down
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import 'dart:async';
import 'dart:developer';
import 'dart:io';
import 'dart:convert';
import 'package:http/http.dart' as http;

import 'package:flutter/material.dart';
import 'package:instabug_flutter/instabug_flutter.dart';
import 'package:instabug_http_client/instabug_http_client.dart';
import 'package:instabug_flutter_example/src/app_routes.dart';
import 'package:instabug_flutter_example/src/widget/nested_view.dart';

Expand Down
2 changes: 2 additions & 0 deletions example/lib/src/components/network_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class NetworkContent extends StatefulWidget {
}

class _NetworkContentState extends State<NetworkContent> {
final http = InstabugHttpClient();

final endpointUrlController = TextEditingController();

@override
Expand Down
10 changes: 9 additions & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,15 @@ packages:
path: ".."
relative: true
source: path
version: "13.3.0"
version: "13.4.0"
instabug_http_client:
dependency: "direct main"
description:
name: instabug_http_client
sha256: "7d52803c0dd639f6dddbe07333418eb251ae02f3f9f4d30402517533ca692784"
url: "https://pub.dev"
source: hosted
version: "2.4.0"
leak_tracker:
dependency: transitive
description:
Expand Down
5 changes: 5 additions & 0 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies:
http: ^0.13.0
instabug_flutter:
path: ../
instabug_http_client: ^2.4.0

dev_dependencies:
espresso: 0.2.0+5
Expand All @@ -35,6 +36,10 @@ dev_dependencies:
sdk: flutter
flutter_lints: 1.0.4

dependency_overrides:
instabug_flutter:
path: ../

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

Expand Down
51 changes: 23 additions & 28 deletions ios/Classes/Modules/InstabugApi.m
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@ - (void)networkLogData:(NSDictionary<NSString *, id> *)data error:(FlutterError
NSString *method = data[@"method"];
NSString *requestBody = data[@"requestBody"];
NSString *responseBody = data[@"responseBody"];
int32_t responseCode = [data[@"responseCode"] integerValue];
int32_t responseCode = (int32_t) [data[@"responseCode"] integerValue];
int64_t requestBodySize = [data[@"requestBodySize"] integerValue];
int64_t responseBodySize = [data[@"responseBodySize"] integerValue];
int32_t errorCode = [data[@"errorCode"] integerValue];
int32_t errorCode = (int32_t) [data[@"errorCode"] integerValue];
NSString *errorDomain = data[@"errorDomain"];
NSDictionary *requestHeaders = data[@"requestHeaders"];
if ([requestHeaders count] == 0) {
Expand All @@ -286,32 +286,27 @@ - (void)networkLogData:(NSDictionary<NSString *, id> *)data error:(FlutterError
serverErrorMessage = data[@"serverErrorMessage"];
}

SEL networkLogSEL = NSSelectorFromString(@"addNetworkLogWithUrl:method:requestBody:requestBodySize:responseBody:responseBodySize:responseCode:requestHeaders:responseHeaders:contentType:errorDomain:errorCode:startTime:duration:gqlQueryName:serverErrorMessage:");

if ([[IBGNetworkLogger class] respondsToSelector:networkLogSEL]) {
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[[IBGNetworkLogger class] methodSignatureForSelector:networkLogSEL]];
[inv setSelector:networkLogSEL];
[inv setTarget:[IBGNetworkLogger class]];

[inv setArgument:&(url) atIndex:2];
[inv setArgument:&(method) atIndex:3];
[inv setArgument:&(requestBody) atIndex:4];
[inv setArgument:&(requestBodySize) atIndex:5];
[inv setArgument:&(responseBody) atIndex:6];
[inv setArgument:&(responseBodySize) atIndex:7];
[inv setArgument:&(responseCode) atIndex:8];
[inv setArgument:&(requestHeaders) atIndex:9];
[inv setArgument:&(responseHeaders) atIndex:10];
[inv setArgument:&(contentType) atIndex:11];
[inv setArgument:&(errorDomain) atIndex:12];
[inv setArgument:&(errorCode) atIndex:13];
[inv setArgument:&(startTime) atIndex:14];
[inv setArgument:&(duration) atIndex:15];
[inv setArgument:&(gqlQueryName) atIndex:16];
[inv setArgument:&(serverErrorMessage) atIndex:17];

[inv invoke];
}
[IBGNetworkLogger addNetworkLogWithUrl:url
method:method
requestBody:requestBody
requestBodySize:requestBodySize
responseBody:responseBody
responseBodySize:responseBodySize
responseCode:responseCode
requestHeaders:requestHeaders
responseHeaders:responseHeaders
contentType:contentType
errorDomain:errorDomain
errorCode:errorCode
startTime:startTime
duration:duration
gqlQueryName:gqlQueryName
serverErrorMessage:serverErrorMessage
isW3cCaughted:nil
partialID:nil
timestamp:nil
generatedW3CTraceparent:nil
caughtedW3CTraceparent:nil];
}

- (void)willRedirectToStoreWithError:(FlutterError * _Nullable __autoreleasing *)error {
Expand Down
22 changes: 22 additions & 0 deletions ios/Classes/Util/IBGNetworkLogger+CP.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,28 @@ NS_ASSUME_NONNULL_BEGIN

+ (void)disableAutomaticCapturingOfNetworkLogs;

+ (void)addNetworkLogWithUrl:(NSString *_Nonnull)url
method:(NSString *_Nonnull)method
requestBody:(NSString *_Nonnull)request
requestBodySize:(int64_t)requestBodySize
responseBody:(NSString *_Nonnull)response
responseBodySize:(int64_t)responseBodySize
responseCode:(int32_t)code
requestHeaders:(NSDictionary *_Nonnull)requestHeaders
responseHeaders:(NSDictionary *_Nonnull)responseHeaders
contentType:(NSString *_Nonnull)contentType
errorDomain:(NSString *_Nullable)errorDomain
errorCode:(int32_t)errorCode
startTime:(int64_t)startTime
duration:(int64_t) duration
gqlQueryName:(NSString * _Nullable)gqlQueryName
serverErrorMessage:(NSString * _Nullable)serverErrorMessage
isW3cCaughted:(NSNumber * _Nullable)isW3cCaughted
partialID:(NSNumber * _Nullable)partialID
timestamp:(NSNumber * _Nullable)timestamp
generatedW3CTraceparent:(NSString * _Nullable)generatedW3CTraceparent
caughtedW3CTraceparent:(NSString * _Nullable)caughtedW3CTraceparent;

@end

NS_ASSUME_NONNULL_END
4 changes: 2 additions & 2 deletions ios/instabug_flutter.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'instabug_flutter'
s.version = '13.3.0'
s.version = '13.4.0'
s.summary = 'Flutter plugin for integrating the Instabug SDK.'
s.author = 'Instabug'
s.homepage = 'https://www.instabug.com/platforms/flutter'
Expand All @@ -17,6 +17,6 @@ Pod::Spec.new do |s|
s.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-framework "Flutter" -framework "Instabug"'}

s.dependency 'Flutter'
s.dependency 'Instabug', '13.3.0'
s.dependency 'Instabug', '13.4.2'
end

1 change: 1 addition & 0 deletions lib/instabug_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ export 'src/modules/surveys.dart';
export 'src/utils/instabug_navigator_observer.dart';
export 'src/utils/screen_loading/instabug_capture_screen_loading.dart';
export 'src/utils/screen_loading/route_matcher.dart';
export 'src/utils/screen_name_masker.dart' show ScreenNameMaskingCallback;
11 changes: 11 additions & 0 deletions lib/src/models/instabug_route.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'package:flutter/material.dart';

class InstabugRoute {
final Route<dynamic> route;
final String name;

const InstabugRoute({
required this.route,
required this.name,
});
}
9 changes: 9 additions & 0 deletions lib/src/modules/instabug.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import 'package:instabug_flutter/src/generated/instabug.api.g.dart';
import 'package:instabug_flutter/src/utils/enum_converter.dart';
import 'package:instabug_flutter/src/utils/ibg_build_info.dart';
import 'package:instabug_flutter/src/utils/instabug_logger.dart';
import 'package:instabug_flutter/src/utils/screen_name_masker.dart';
import 'package:meta/meta.dart';

enum InvocationEvent {
Expand Down Expand Up @@ -191,6 +192,14 @@ class Instabug {
);
}

/// Sets a [callback] to be called wehenever a screen name is captured to mask
/// sensitive information in the screen name.
static void setScreenNameMaskingCallback(
ScreenNameMaskingCallback? callback,
) {
ScreenNameMasker.I.setMaskingCallback(callback);
}

/// Shows the welcome message in a specific mode.
/// [welcomeMessageMode] is an enum to set the welcome message mode to live, or beta.
static Future<void> showWelcomeMessageWithMode(
Expand Down
34 changes: 23 additions & 11 deletions lib/src/utils/instabug_navigator_observer.dart
Original file line number Diff line number Diff line change
@@ -1,32 +1,44 @@
import 'package:flutter/material.dart';
import 'package:instabug_flutter/instabug_flutter.dart';
import 'package:instabug_flutter/src/models/instabug_route.dart';
import 'package:instabug_flutter/src/modules/instabug.dart';
import 'package:instabug_flutter/src/utils/instabug_logger.dart';
import 'package:instabug_flutter/src/utils/repro_steps_constants.dart';
import 'package:instabug_flutter/src/utils/screen_loading/screen_loading_manager.dart';
import 'package:instabug_flutter/src/utils/screen_name_masker.dart';

class InstabugNavigatorObserver extends NavigatorObserver {
final List<Route> _steps = <Route>[];
final List<InstabugRoute> _steps = [];

void screenChanged(Route newRoute) {
try {
final screenName = newRoute.settings.name.toString();
final rawScreenName = newRoute.settings.name.toString().trim();
final screenName = rawScreenName.isEmpty
? ReproStepsConstants.emptyScreenFallback
: rawScreenName;
final maskedScreenName = ScreenNameMasker.I.mask(screenName);

final route = InstabugRoute(
route: newRoute,
name: maskedScreenName,
);

// Starts a the new UI trace which is exclusive to screen loading
ScreenLoadingManager.I.startUiTrace(screenName);
ScreenLoadingManager.I.startUiTrace(maskedScreenName, screenName);
// If there is a step that hasn't been pushed yet
if (_steps.isNotEmpty) {
// Report the last step and remove it from the list
Instabug.reportScreenChange(
_steps[_steps.length - 1].settings.name.toString(),
);
_steps.remove(_steps[_steps.length - 1]);
Instabug.reportScreenChange(_steps.last.name);
_steps.removeLast();
}

// Add the new step to the list
_steps.add(newRoute);
_steps.add(route);
Future<dynamic>.delayed(const Duration(milliseconds: 1000), () {
// If this route is in the array, report it and remove it from the list
if (_steps.contains(newRoute)) {
Instabug.reportScreenChange(screenName);
_steps.remove(newRoute);
if (_steps.contains(route)) {
Instabug.reportScreenChange(route.name);
_steps.remove(route);
}
});
} catch (e) {
Expand Down
3 changes: 3 additions & 0 deletions lib/src/utils/repro_steps_constants.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class ReproStepsConstants {
static const emptyScreenFallback = 'N/A';
}
Loading

0 comments on commit c699efc

Please sign in to comment.