Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MOB-12858]: Add passing SDK version to the native support #387

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ commands:
setup_flutter:
steps:
- flutter/install_sdk_and_pub:
flutter_version: 3.3.0
flutter_version: 3.10.5
- run:
name: Generate Pigeons
command: sh ./scripts/pigeon.sh
Expand All @@ -33,7 +33,7 @@ commands:
steps:
- run:
name: Install Appium
command: npm install -g appium@next
command: npm install -g appium
- when:
condition:
equal:
Expand All @@ -42,7 +42,7 @@ commands:
steps:
- run:
name: Install XCUITest Driver
command: appium driver install xcuitest
command: appium driver install xcuitest@4.35.0
- when:
condition:
equal:
Expand All @@ -51,7 +51,7 @@ commands:
steps:
- run:
name: Install UIAutomator2 Driver
command: appium driver install uiautomator2
command: appium driver install uiautomator2@2.29.5
- run:
name: Launch Appium
# Enable --relaxed-security for `mobile: shell` command that Captain uses internally.
Expand Down
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
source "https://rubygems.org"

gem 'danger', '~> 8.6', '>= 8.6.1'
73 changes: 0 additions & 73 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,84 +1,11 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.8.1)
public_suffix (>= 2.0.2, < 6.0)
claide (1.1.0)
claide-plugins (0.9.2)
cork
nap
open4 (~> 1.3)
colored2 (3.1.2)
cork (0.3.0)
colored2 (~> 3.1)
danger (8.6.1)
claide (~> 1.0)
claide-plugins (>= 0.9.2)
colored2 (~> 3.1)
cork (~> 0.1)
faraday (>= 0.9.0, < 2.0)
faraday-http-cache (~> 2.0)
git (~> 1.7)
kramdown (~> 2.3)
kramdown-parser-gfm (~> 1.0)
no_proxy_fix
octokit (~> 4.7)
terminal-table (>= 1, < 4)
faraday (1.10.2)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0)
faraday-multipart (~> 1.0)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.0)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
faraday-retry (~> 1.0)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-http-cache (2.4.1)
faraday (>= 0.8)
faraday-httpclient (1.0.1)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
git (1.12.0)
addressable (~> 2.8)
rchardet (~> 1.8)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
multipart-post (2.2.3)
nap (1.1.0)
no_proxy_fix (0.1.2)
octokit (4.25.1)
faraday (>= 1, < 3)
sawyer (~> 0.9)
open4 (1.3.4)
public_suffix (5.0.0)
rchardet (1.8.0)
rexml (3.2.5)
ruby2_keywords (0.0.5)
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
unicode-display_width (2.3.0)

PLATFORMS
ruby

DEPENDENCIES
danger (~> 8.6, >= 8.6.1)

BUNDLED WITH
1.17.2
29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ A Flutter plugin for [Instabug](https://instabug.com/).

### Installation


1. Add Instabug to your `pubspec.yaml` file.

```yaml
Expand Down Expand Up @@ -65,18 +64,23 @@ Instabug automatically captures every crash of your app and sends relevant detai

```dart
void main() {
WidgetsFlutterBinding.ensureInitialized();

Instabug.init(
token: 'APP_TOKEN',
invocationEvents: [InvocationEvent.floatingButton],
runZonedGuarded(
() {
WidgetsFlutterBinding.ensureInitialized();

Instabug.init(
token: 'APP_TOKEN',
invocationEvents: [InvocationEvent.shake],
);

FlutterError.onError = (FlutterErrorDetails details) {
Zone.current.handleUncaughtError(details.exception, details.stack!);
};

runApp(MyApp());
},
CrashReporting.reportCrash,
);

FlutterError.onError = (FlutterErrorDetails details) {
Zone.current.handleUncaughtError(details.exception, details.stack!);
};

runZonedGuarded(() => runApp(MyApp()), CrashReporting.reportCrash);
}
```

Expand All @@ -90,7 +94,6 @@ Repro Steps list all of the actions an app user took before reporting a bug or c
));
```


## Network Logging
You can choose to attach all your network requests to the reports being sent to the dashboard. To enable the feature when using the `dart:io` package `HttpClient`, please refer to the [Instabug Dart IO Http Client](https://github.com/Instabug/instabug-dart-io-http-client) repository.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ public InstabugApi(Context context, Callable<Bitmap> screenshotProvider) {
@VisibleForTesting
public void setCurrentPlatform() {
try {
Method method = Reflection.getMethod(Class.forName("com.instabug.library.Instabug"), "setCurrentPlatform", int.class);
Method method = Reflection.getMethod(Class.forName("com.instabug.library.Instabug"), "setCurrentPlatform", int.class, String.class);
if (method != null) {
method.invoke(null, Platform.FLUTTER);
method.invoke(null, Platform.FLUTTER, "11.13.0");
} else {
Log.e(TAG, "setCurrentPlatform was not found by reflection");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void testInit() {
public void testSetCurrentPlatform() {
api.setCurrentPlatform();

reflected.verify(() -> MockReflected.setCurrentPlatform(Platform.FLUTTER));
reflected.verify(() -> MockReflected.setCurrentPlatform(Platform.FLUTTER, "11.13.0"));
}

@Test
Expand Down Expand Up @@ -132,7 +132,7 @@ public void testSdkInit() {
mInstabug.verify(() -> Instabug.setScreenshotProvider(screenshotProvider));

// Sets current platform
reflected.verify(() -> MockReflected.setCurrentPlatform(Platform.FLUTTER));
reflected.verify(() -> MockReflected.setCurrentPlatform(Platform.FLUTTER, "11.13.0"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ public static void setUp() throws NoSuchMethodException {
Bitmap.class, Bitmap.class))
.thenReturn(mSetCustomBrandingImage);

Method mSetCurrentPlatform = MockReflected.class.getDeclaredMethod("setCurrentPlatform", int.class);
Method mSetCurrentPlatform = MockReflected.class.getDeclaredMethod("setCurrentPlatform", int.class, String.class);
mSetCurrentPlatform.setAccessible(true);
reflection
.when(() -> Reflection.getMethod(Class.forName("com.instabug.library.Instabug"), "setCurrentPlatform", int.class))
.when(() -> Reflection.getMethod(Class.forName("com.instabug.library.Instabug"), "setCurrentPlatform", int.class, String.class))
.thenReturn(mSetCurrentPlatform);

Method mAPMNetworkLog = MockReflected.class.getDeclaredMethod("apmNetworkLog", 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static void setCustomBrandingImage(Bitmap light, Bitmap dark) {}
/**
* Instabug.setCurrentPlatform
*/
public static void setCurrentPlatform(int platform) {}
public static void setCurrentPlatform(int platform, String cpSDKVersion) {}

/**
* APMNetworkLogger.log
Expand Down
5 changes: 4 additions & 1 deletion e2e/Utils/CaptainTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ public class CaptainTest : IDisposable
private static readonly CaptainConfig _config = new()
{
AndroidApp = Path.GetFullPath("../../../../example/build/app/outputs/flutter-apk/app-debug.apk"),
AndroidAppId = "com.instabug.flutter.example",
AndroidVersion = "11",
IosApp = Path.GetFullPath("../../../../example/build/ios/iphonesimulator/Runner.app"),
IosVersion = "15.5"
IosAppId = "com.instabug.InstabugSample",
IosVersion = "15.5",
IosDevice = "iPhone 13 Pro Max"
};
protected static readonly Captain captain = new(_config);

Expand Down
4 changes: 3 additions & 1 deletion example/ios/InstabugTests/InstabugApiTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ - (void)testInit {
NSArray<NSString *> *invocationEvents = @[@"InvocationEvent.floatingButton", @"InvocationEvent.screenshot"];
NSString *logLevel = @"LogLevel.error";
FlutterError *error;

NSString *cpSDKVersion = @"11.13.0";

[self.api initToken:token invocationEvents:invocationEvents debugLogsLevel:logLevel error:&error];

OCMVerify([self.mInstabug setCurrentPlatform:IBGPlatformFlutter]);
OCMVerify([self.mInstabug setCurrentPlatform:IBGPlatformFlutter cpSDKVersion:cpSDKVersion]);
OCMVerify([self.mInstabug setSdkDebugLogsLevel:IBGSDKDebugLogsLevelError]);
OCMVerify([self.mInstabug startWithToken:token invocationEvents:(IBGInvocationEventFloatingButton | IBGInvocationEventScreenshot)]);
}
Expand Down
2 changes: 1 addition & 1 deletion example/ios/InstabugTests/Util/Instabug+Test.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
#import <Instabug/Instabug.h>

@interface Instabug (Test)
+ (void)setCurrentPlatform:(IBGPlatform)platform;
+ (void)setCurrentPlatform:(IBGPlatform)platform cpSDKVersion:(NSString *)cpSDKVersion;
+ (void)reportCrashWithStackTrace:(NSDictionary*)stackTrace handled:(NSNumber*)handled;
@end
2 changes: 2 additions & 0 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ project 'Runner', {
'Release' => :release,
}

pod 'Instabug', :podspec => 'https://ios-releases.instabug.com/custom/feature-cp-versions/12.0.0/Instabug.podspec'

def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
Expand Down
15 changes: 8 additions & 7 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
PODS:
- Flutter (1.0.0)
- Instabug (11.13.3)
- Instabug (12.0.0)
- instabug_flutter (11.13.0):
- Flutter
- Instabug (= 11.13.3)
- OCMock (3.6)

DEPENDENCIES:
- Flutter (from `Flutter`)
- Instabug (from `https://ios-releases.instabug.com/custom/feature-cp-versions/12.0.0/Instabug.podspec`)
- instabug_flutter (from `.symlinks/plugins/instabug_flutter/ios`)
- OCMock (= 3.6)

SPEC REPOS:
trunk:
- Instabug
- OCMock

EXTERNAL SOURCES:
Flutter:
:path: Flutter
Instabug:
:podspec: https://ios-releases.instabug.com/custom/feature-cp-versions/12.0.0/Instabug.podspec
instabug_flutter:
:path: ".symlinks/plugins/instabug_flutter/ios"

SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
Instabug: f7c3880823873cff9ee70307d373e8266c9ea0f8
instabug_flutter: e935f80f03127586ebb4fc61c6b891d87a978ee3
Instabug: 2890cfbab52331d4aeab143a579347a545ac822f
instabug_flutter: 51643ee0f0cf2a1d884798b6e6b3f40490790d19
OCMock: 5ea90566be239f179ba766fd9fbae5885040b992

PODFILE CHECKSUM: 637e800c0a0982493b68adb612d2dd60c15c8e5c
PODFILE CHECKSUM: 1d5a0d539bfb3f5a39d16888e7e07034697aa2f4

COCOAPODS: 1.11.3
COCOAPODS: 1.12.1
35 changes: 14 additions & 21 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@ import 'package:flutter/material.dart';
import 'package:instabug_flutter/instabug_flutter.dart';

void main() {
WidgetsFlutterBinding.ensureInitialized();
runZonedGuarded(
() {
WidgetsFlutterBinding.ensureInitialized();

Instabug.init(
token: 'ed6f659591566da19b67857e1b9d40ab',
invocationEvents: [InvocationEvent.floatingButton],
debugLogsLevel: LogLevel.verbose,
);

Instabug.setWelcomeMessageMode(WelcomeMessageMode.disabled);
Instabug.init(
token: 'ed6f659591566da19b67857e1b9d40ab',
invocationEvents: [InvocationEvent.floatingButton],
);

FlutterError.onError = (FlutterErrorDetails details) {
Zone.current.handleUncaughtError(details.exception, details.stack!);
};
FlutterError.onError = (FlutterErrorDetails details) {
Zone.current.handleUncaughtError(details.exception, details.stack!);
};

runZonedGuarded(() => runApp(MyApp()), CrashReporting.reportCrash);
runApp(MyApp());
},
CrashReporting.reportCrash,
);
}

class MyApp extends StatelessWidget {
Expand Down Expand Up @@ -160,11 +162,6 @@ class _MyHomePageState extends State<MyHomePage> {
ReportType.feedback, [InvocationOption.emailFieldOptional]);
}

void askQuestion() {
BugReporting.show(
ReportType.question, [InvocationOption.emailFieldOptional]);
}

void showNpsSurvey() {
Surveys.showSurvey('pcV_mE2ttqHxT1iqvBxL0w');
}
Expand Down Expand Up @@ -331,10 +328,6 @@ class _MyHomePageState extends State<MyHomePage> {
onPressed: sendFeedback,
text: 'Send Feedback',
),
InstabugButton(
onPressed: askQuestion,
text: 'Ask a Question',
),
InstabugButton(
onPressed: showNpsSurvey,
text: 'Show NPS Survey',
Expand Down
Loading