Skip to content

Commit 49ea245

Browse files
Merge pull request #527 from Instabug/refactor/monorepo-private-view-package
Refactor: merge private-views package into mono-repo
2 parents daae1ac + 05fac1f commit 49ea245

File tree

170 files changed

+7418
-94
lines changed

Some content is hidden

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

170 files changed

+7418
-94
lines changed

.circleci/config.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,15 @@ jobs:
334334
- run: chmod +x packages/instabug_flutter_modular/release.sh
335335
- run: ./packages/instabug_flutter_modular/release.sh
336336

337+
release_instabug_private_views_plugin:
338+
executor: flutter-executor
339+
steps:
340+
- advanced-checkout/shallow-checkout
341+
- setup_flutter
342+
- run: chmod +x packages/instabug_private_views/release.sh
343+
- run: ./packages/instabug_private_views/release.sh
344+
345+
337346
release_instabug_flutter:
338347
macos:
339348
xcode: 15.2.0
@@ -454,6 +463,20 @@ workflows:
454463
filters:
455464
branches:
456465
only: master
466+
- hold_release_instabug_private_views_plugin:
467+
type: approval
468+
requires:
469+
- test_flutter-stable
470+
filters:
471+
branches:
472+
only: master
473+
- release_instabug_private_views_plugin:
474+
requires:
475+
- hold_release_instabug_private_views_plugin
476+
- verify_pub
477+
filters:
478+
branches:
479+
only: master
457480
- release_instabug_flutter:
458481
requires:
459482
- hold_release_instabug_flutter

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ android/gradlew.bat
6363
**/ios/**/DerivedData/
6464
**/ios/**/Icon?
6565
**/ios/**/Pods/
66+
**/ios/**/Pods/
67+
6668
**/ios/**/.symlinks/
6769
**/ios/**/profile
6870
**/ios/**/xcuserdata

analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ analyzer:
44
exclude:
55
- "packages/**/*.g.dart"
66
- "packages/**/example/**"
7+
- "packages/instabug_private_views/example-hybrid-ios-app/**/**"
78

89

910
linter:

packages/instabug_dio_interceptor/lib/instabug_dio_interceptor.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ class InstabugDioInterceptor extends Interceptor {
7676

7777
var responseBodySize = 0;
7878
if (responseHeaders.containsKey('content-length')) {
79-
responseBodySize = int.parse(responseHeaders['content-length'][0] ?? '0');
79+
// ignore: avoid_dynamic_calls
80+
responseBodySize = int.parse((responseHeaders['content-length'][0]) ?? '0');
8081
} else if (response.data != null) {
8182
responseBodySize = response.data.toString().length;
8283
}

packages/instabug_flutter/android/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ android {
4444
}
4545

4646
dependencies {
47-
api 'com.instabug.library:instabug:14.0.0'
47+
api 'com.instabug.library:instabug:13.4.1.6295791-SNAPSHOT'
48+
4849
testImplementation 'junit:junit:4.13.2'
4950
testImplementation "org.mockito:mockito-inline:3.12.1"
5051
testImplementation "io.mockk:mockk:1.13.13"

packages/instabug_flutter/android/src/main/java/com/instabug/flutter/InstabugFlutterPlugin.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.instabug.flutter.modules.RepliesApi;
2020
import com.instabug.flutter.modules.SessionReplayApi;
2121
import com.instabug.flutter.modules.SurveysApi;
22+
import com.instabug.library.internal.crossplatform.InternalCore;
2223

2324
import java.util.concurrent.Callable;
2425

@@ -35,6 +36,7 @@ public class InstabugFlutterPlugin implements FlutterPlugin, ActivityAware {
3536
@SuppressLint("StaticFieldLeak")
3637
private static Activity activity;
3738

39+
3840
/**
3941
* Embedding v1
4042
*/

packages/instabug_flutter/android/src/main/java/com/instabug/flutter/modules/InstabugApi.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.instabug.library.internal.crossplatform.CoreFeaturesState;
1818
import com.instabug.library.internal.crossplatform.FeaturesStateListener;
1919
import com.instabug.library.internal.crossplatform.InternalCore;
20+
import com.instabug.flutter.util.privateViews.ScreenshotCaptor;
2021
import com.instabug.library.Feature;
2122
import com.instabug.library.Instabug;
2223
import com.instabug.library.InstabugColorTheme;
@@ -25,9 +26,11 @@
2526
import com.instabug.library.Platform;
2627
import com.instabug.library.ReproConfigurations;
2728
import com.instabug.library.featuresflags.model.IBGFeatureFlag;
29+
import com.instabug.library.internal.crossplatform.InternalCore;
2830
import com.instabug.library.internal.module.InstabugLocale;
2931
import com.instabug.library.invocation.InstabugInvocationEvent;
3032
import com.instabug.library.model.NetworkLog;
33+
import com.instabug.library.screenshot.instacapture.ScreenshotRequest;
3134
import com.instabug.library.ui.onboarding.WelcomeMessage;
3235
import io.flutter.FlutterInjector;
3336
import io.flutter.embedding.engine.loader.FlutterLoader;
@@ -492,4 +495,24 @@ public Map<String, Boolean> isW3CFeatureFlagsEnabled() {
492495
public void willRedirectToStore() {
493496
Instabug.willRedirectToStore();
494497
}
498+
499+
public static void setScreenshotCaptor(ScreenshotCaptor screenshotCaptor,InternalCore internalCore) {
500+
internalCore._setScreenshotCaptor(new com.instabug.library.screenshot.ScreenshotCaptor() {
501+
@Override
502+
public void capture(@NonNull ScreenshotRequest screenshotRequest) {
503+
screenshotCaptor.capture(new ScreenshotCaptor.CapturingCallback() {
504+
@Override
505+
public void onCapturingFailure(Throwable throwable) {
506+
screenshotRequest.getListener().onCapturingFailure(throwable);
507+
}
508+
509+
@Override
510+
public void onCapturingSuccess(Bitmap bitmap) {
511+
screenshotRequest.getListener().onCapturingSuccess(bitmap);
512+
}
513+
});
514+
}
515+
});
516+
}
517+
495518
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.instabug.flutter.util.privateViews;
2+
3+
import android.graphics.Bitmap;
4+
5+
public interface ScreenshotCaptor {
6+
public void capture(CapturingCallback listener);
7+
8+
public interface CapturingCallback {
9+
public void onCapturingFailure(Throwable throwable);
10+
11+
public void onCapturingSuccess(Bitmap bitmap);
12+
}
13+
}

packages/instabug_flutter/android/src/test/java/com/instabug/flutter/InstabugApiTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@
4646
import com.instabug.library.internal.crossplatform.FeaturesStateListener;
4747
import com.instabug.library.internal.crossplatform.InternalCore;
4848
import com.instabug.library.featuresflags.model.IBGFeatureFlag;
49+
import com.instabug.library.internal.crossplatform.InternalCore;
4950
import com.instabug.library.invocation.InstabugInvocationEvent;
5051
import com.instabug.library.model.NetworkLog;
52+
import com.instabug.library.screenshot.ScreenshotCaptor;
5153
import com.instabug.library.ui.onboarding.WelcomeMessage;
5254
import com.instabug.survey.Surveys;
5355
import com.instabug.survey.callbacks.OnShowCallback;
@@ -72,6 +74,7 @@
7274
import java.util.concurrent.Callable;
7375

7476
import io.flutter.plugin.common.BinaryMessenger;
77+
7578
import kotlin.jvm.functions.Function1;
7679

7780
import org.mockito.Mockito;
@@ -643,4 +646,12 @@ public void isW3CFeatureFlagsEnabled() {
643646
assertEquals(isW3cCaughtHeaderEnabled, flags.get("isW3cCaughtHeaderEnabled"));
644647

645648
}
649+
650+
@Test
651+
public void testSetScreenshotCaptor() {
652+
InternalCore internalCore = spy(InternalCore.INSTANCE);
653+
654+
InstabugApi.setScreenshotCaptor(any(), internalCore);
655+
verify(internalCore)._setScreenshotCaptor(any(ScreenshotCaptor.class));
656+
}
646657
}

packages/instabug_flutter/example/android/app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2828
android {
2929
compileSdkVersion 34
3030
ndkVersion flutter.ndkVersion
31+
namespace = "com.instabug.flutter.example"
3132

3233
compileOptions {
3334
sourceCompatibility JavaVersion.VERSION_1_8

packages/instabug_flutter/example/android/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ subprojects {
2424
}
2525
subprojects {
2626
project.evaluationDependsOn(':app')
27+
tasks.withType(Test) {
28+
// Prevent tests in moduleA from running
29+
if (project.name == 'video_player_android') {
30+
exclude '**/*'
31+
}
32+
}
2733
}
2834

2935
tasks.register("clean", Delete) {
Loading

packages/instabug_flutter/example/ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ flutter_ios_podfile_setup
2929
target 'Runner' do
3030
use_frameworks!
3131
use_modular_headers!
32-
32+
pod 'Instabug', :podspec => 'https://ios-releases.instabug.com/custom/feature-flutter-private-views-base/14.0.0/Instabug.podspec'
3333
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
3434
end
3535

packages/instabug_flutter/example/ios/Podfile.lock

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,46 @@ PODS:
44
- instabug_flutter (14.0.0):
55
- Flutter
66
- Instabug (= 14.0.0)
7+
- instabug_private_views (0.0.1):
8+
- Flutter
9+
- instabug_flutter
710
- OCMock (3.6)
11+
- video_player_avfoundation (0.0.1):
12+
- Flutter
13+
- FlutterMacOS
814

915
DEPENDENCIES:
1016
- Flutter (from `Flutter`)
17+
- Instabug (from `https://ios-releases.instabug.com/custom/feature-flutter-private-views-base/14.0.0/Instabug.podspec`)
1118
- instabug_flutter (from `.symlinks/plugins/instabug_flutter/ios`)
19+
- instabug_private_views (from `.symlinks/plugins/instabug_private_views/ios`)
1220
- OCMock (= 3.6)
21+
- video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/darwin`)
1322

1423
SPEC REPOS:
1524
trunk:
16-
- Instabug
1725
- OCMock
1826

1927
EXTERNAL SOURCES:
2028
Flutter:
2129
:path: Flutter
30+
Instabug:
31+
:podspec: https://ios-releases.instabug.com/custom/feature-flutter-private-views-base/14.0.0/Instabug.podspec
2232
instabug_flutter:
2333
:path: ".symlinks/plugins/instabug_flutter/ios"
34+
instabug_private_views:
35+
:path: ".symlinks/plugins/instabug_private_views/ios"
36+
video_player_avfoundation:
37+
:path: ".symlinks/plugins/video_player_avfoundation/darwin"
2438

2539
SPEC CHECKSUMS:
2640
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
27-
Instabug: a0beffc01658773e2fac549845782f8937707dc4
41+
Instabug: 9d2b06afbadfbd4630bc0116dc27d84360ed70b0
2842
instabug_flutter: ff8ab5ff34a476b1d2d887478ec190cda962b973
43+
instabug_private_views: df53ff3f1cc842cb686d43e077099d3b36426a7f
2944
OCMock: 5ea90566be239f179ba766fd9fbae5885040b992
45+
video_player_avfoundation: 7c6c11d8470e1675df7397027218274b6d2360b3
3046

31-
PODFILE CHECKSUM: 8f7552fd115ace1988c3db54a69e4a123c448f84
47+
PODFILE CHECKSUM: 32bd1b5b0a93d31b74cc581a86b5fa93c1cc923f
3248

3349
COCOAPODS: 1.14.3

packages/instabug_flutter/example/lib/main.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import 'dart:convert';
55

66
import 'package:flutter/material.dart';
77
import 'package:instabug_flutter/instabug_flutter.dart';
8+
import 'package:instabug_flutter_example/src/screens/private_view_page.dart';
89
import 'package:instabug_http_client/instabug_http_client.dart';
910
import 'package:instabug_flutter_example/src/app_routes.dart';
1011
import 'package:instabug_flutter_example/src/widget/nested_view.dart';
12+
import 'package:instabug_private_views/instabug_private_view.dart';
1113

1214
import 'src/native/instabug_flutter_example_method_channel.dart';
1315
import 'src/widget/instabug_button.dart';
@@ -56,6 +58,8 @@ void main() {
5658
Zone.current.handleUncaughtError(details.exception, details.stack!);
5759
};
5860

61+
enableInstabugMaskingPrivateViews();
62+
5963
runApp(const MyApp());
6064
},
6165
CrashReporting.reportCrash,

packages/instabug_flutter/example/lib/src/screens/my_home_page.dart

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ class _MyHomePageState extends State<MyHomePage> {
3535
BugReporting.setInvocationEvents([InvocationEvent.floatingButton]);
3636
}
3737

38+
void disableInstabug() {
39+
Instabug.setEnabled(false);
40+
}
41+
3842
void setOnDismissCallback() {
3943
BugReporting.setOnDismissCallback((dismissType, reportType) {
4044
showDialog(
@@ -161,6 +165,16 @@ class _MyHomePageState extends State<MyHomePage> {
161165
);
162166
}
163167

168+
void _navigateToPrivateViewPage() {
169+
Navigator.push(
170+
context,
171+
MaterialPageRoute(
172+
builder: (context) => const PrivateViewPage(),
173+
settings: const RouteSettings(name: ComplexPage.screenName),
174+
),
175+
);
176+
}
177+
164178
@override
165179
Widget build(BuildContext context) {
166180
return Page(
@@ -178,6 +192,10 @@ class _MyHomePageState extends State<MyHomePage> {
178192
onPressed: restartInstabug,
179193
text: 'Restart Instabug',
180194
),
195+
InstabugButton(
196+
onPressed: disableInstabug,
197+
text: 'Disable Instabug',
198+
),
181199
const SectionTitle('Primary Color'),
182200
InstabugTextField(
183201
controller: primaryColorController,
@@ -306,6 +324,10 @@ class _MyHomePageState extends State<MyHomePage> {
306324
onPressed: _navigateToComplex,
307325
text: 'Complex',
308326
),
327+
InstabugButton(
328+
onPressed: _navigateToPrivateViewPage,
329+
text: 'Private views',
330+
),
309331
const SectionTitle('Sessions Replay'),
310332
InstabugButton(
311333
onPressed: getCurrentSessionReplaylink,

0 commit comments

Comments
 (0)