Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/refactor/monorepo' …
Browse files Browse the repository at this point in the history
…into refactor/monorepo-modular-package
  • Loading branch information
ahmedAlaaInstabug committed Dec 2, 2024
2 parents ad192ba + 4bbafb0 commit eb41d25
Show file tree
Hide file tree
Showing 253 changed files with 1,146 additions and 86 deletions.
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ commands:
command: sudo gem install cocoapods
- run:
name: Install Pods
working_directory: packages/Instabug-Flutter/example/ios
working_directory: packages/instabug_flutter/example/ios
command: pod install --repo-update
setup_captain:
parameters:
Expand Down Expand Up @@ -222,7 +222,7 @@ jobs:
- advanced-checkout/shallow-checkout
- setup_flutter
- android/run-tests:
working-directory: packages/Instabug-Flutter/example/android
working-directory: packages/instabug_flutter/example/android
test-command: ./gradlew test

e2e_android_captain:
Expand All @@ -239,7 +239,7 @@ jobs:
run-tests-working-directory: e2e
additional-avd-args: --device 3
system-image: system-images;android-33;default;x86_64
post-emulator-launch-assemble-command: cd packages/Instabug-Flutter/example && flutter build apk --debug
post-emulator-launch-assemble-command: cd packages/instabug_flutter/example && flutter build apk --debug
test-command: dotnet test

test_ios:
Expand All @@ -253,7 +253,7 @@ jobs:
- setup_ios
- run:
name: Build and run tests
working_directory: ~/project/packages/Instabug-Flutter/example/ios
working_directory: ~/project/packages/instabug_flutter/example/ios
command: |
xcodebuild -allowProvisioningUpdates \
-workspace Runner.xcworkspace \
Expand All @@ -274,7 +274,7 @@ jobs:
- setup_ios
- run:
name: Build Example App
working_directory: packages/Instabug-Flutter/example
working_directory: packages/instabug_flutter/example
command: flutter build ios --simulator
- run:
name: Run E2E Tests
Expand Down Expand Up @@ -368,7 +368,7 @@ workflows:
- test_flutter_without_melos:
name: test_flutter-2.10.5
version: 2.10.5
app-dir: "~/project/packages/Instabug-Flutter/"
app-dir: "~/project/packages/instabug_flutter/"
- e2e_android_captain
- test_ios
- e2e_ios_captain
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*.mocks.dart
*.g.dart
packages/**/android/**/generated/
packages/**ios/**/Generated/
packages/**/ios/**/Generated/

# Miscellaneous
*.class
Expand Down Expand Up @@ -84,4 +84,4 @@ android/gradlew.bat
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
/packages/Instabug-Flutter/lib/src/generated/
/packages/**/lib/src/generated/
4 changes: 2 additions & 2 deletions e2e/Utils/CaptainTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ public class CaptainTest : IDisposable
{
private static readonly CaptainConfig _config = new()
{
AndroidApp = Path.GetFullPath("../../../../packages/Instabug-Flutter/example/build/app/outputs/flutter-apk/app-debug.apk"),
AndroidApp = Path.GetFullPath("../../../../packages/instabug_flutter/example/build/app/outputs/flutter-apk/app-debug.apk"),
AndroidAppId = "com.instabug.flutter.example",
AndroidVersion = "13",
IosApp = Path.GetFullPath("../../../../packages/Instabug-Flutter/example/build/ios/iphonesimulator/Runner.app"),
IosApp = Path.GetFullPath("../../../../packages/instabug_flutter/example/build/ios/iphonesimulator/Runner.app"),
IosAppId = "com.instabug.InstabugSample",
IosVersion = "17.2",
IosDevice = "iPhone 15 Pro Max"
Expand Down
3 changes: 0 additions & 3 deletions packages/Instabug-Flutter/example/android/gradle.properties

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Changelog

## [Unreleased](https://github.com/Instabug/Instabug-Flutter/compare/v13.4.0...dev)
## [14.0.0](https://github.com/Instabug/Instabug-Flutter/compare/v13.4.0...v14.0.0) (November 11, 2024)

### Changed
### Added

- Set the minimum Flutter SDK version to v2.10.0. ([#518](https://github.com/Instabug/Instabug-Flutter/pull/518))
- Add support for tracing network requests from Instabug to services like Datadog and New Relic ([#481](https://github.com/Instabug/Instabug-Flutter/pull/481)).

### Changed

- Bump Instabug Android SDK to v14.0.0 ([#532](https://github.com/Instabug/Instabug-Flutter/pull/532)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v14.0.0).
- Bump Instabug iOS SDK to v14.0.0 ([#532](https://github.com/Instabug/Instabug-Flutter/pull/532)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/14.0.0),

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

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group 'com.instabug.flutter'
version '13.4.0'
version '14.0.0'

buildscript {
repositories {
Expand All @@ -22,7 +22,10 @@ rootProject.allprojects {
apply plugin: 'com.android.library'

android {
compileSdkVersion 28
if (project.android.hasProperty("namespace")) {
namespace "com.instabug.flutter"
}
compileSdkVersion 33

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -41,10 +44,11 @@ android {
}

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

api 'com.instabug.library:instabug:14.0.0'
testImplementation 'junit:junit:4.13.2'
testImplementation "org.mockito:mockito-inline:3.12.1"
testImplementation "io.mockk:mockk:1.13.13"

}

// add upload_symbols task
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.instabug.flutter">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application>
<meta-data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
import com.instabug.apm.configuration.cp.FeatureAvailabilityCallback;
import com.instabug.apm.model.ExecutionTrace;
import com.instabug.apm.networking.APMNetworkLogger;
import com.instabug.apm.networkinterception.cp.APMCPNetworkLog;
import com.instabug.flutter.generated.ApmPigeon;
import com.instabug.flutter.util.Reflection;
import com.instabug.flutter.util.ThreadManager;
import com.instabug.apm.networkinterception.cp.APMCPNetworkLog;

import io.flutter.plugin.common.BinaryMessenger;

import org.jetbrains.annotations.NotNull;
import org.json.JSONObject;

import java.lang.reflect.Method;
Expand Down Expand Up @@ -210,18 +209,62 @@ public void networkLogAndroid(@NonNull Map<String, Object> data) {
if (data.containsKey("serverErrorMessage")) {
serverErrorMessage = (String) data.get("serverErrorMessage");
}
Boolean isW3cHeaderFound = null;
Number partialId = null;
Number networkStartTimeInSeconds = null;
String w3CGeneratedHeader = null;
String w3CCaughtHeader = null;

if (data.containsKey("isW3cHeaderFound")) {
isW3cHeaderFound = (Boolean) data.get("isW3cHeaderFound");
}

if (data.containsKey("partialId")) {


partialId = ((Number) data.get("partialId"));

Method method = Reflection.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);
if (method != null) {
method.invoke(apmNetworkLogger, requestStartTime, requestDuration, requestHeaders, requestBody, requestBodySize, requestMethod, requestUrl, requestContentType, responseHeaders, responseBody, responseBodySize, statusCode, responseContentType, errorMessage, gqlQueryName, serverErrorMessage, null);
} else {
Log.e(TAG, "APMNetworkLogger.log was not found by reflection");
}
if (data.containsKey("networkStartTimeInSeconds")) {
networkStartTimeInSeconds = ((Number) data.get("networkStartTimeInSeconds"));
}

} catch (Exception e) {
e.printStackTrace();
if (data.containsKey("w3CGeneratedHeader")) {

w3CGeneratedHeader = (String) data.get("w3CGeneratedHeader");


}
if (data.containsKey("w3CCaughtHeader")) {
w3CCaughtHeader = (String) data.get("w3CCaughtHeader");

}


APMCPNetworkLog.W3CExternalTraceAttributes w3cExternalTraceAttributes =
null;
if (isW3cHeaderFound != null) {
w3cExternalTraceAttributes = new APMCPNetworkLog.W3CExternalTraceAttributes(
isW3cHeaderFound, partialId == null ? null : partialId.longValue(),
networkStartTimeInSeconds == null ? null : networkStartTimeInSeconds.longValue(),
w3CGeneratedHeader, w3CCaughtHeader

);
}

Method method = Reflection.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);
if (method != null) {
method.invoke(apmNetworkLogger, requestStartTime, requestDuration, requestHeaders, requestBody, requestBodySize, requestMethod, requestUrl, requestContentType, responseHeaders, responseBody, responseBodySize, statusCode, responseContentType, errorMessage, gqlQueryName, serverErrorMessage, w3cExternalTraceAttributes);
} else {
Log.e(TAG, "APMNetworkLogger.log was not found by reflection");
}

} catch(Exception e){
e.printStackTrace();
}
}
}




@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
import com.instabug.flutter.util.ArgsRegistry;
import com.instabug.flutter.util.Reflection;
import com.instabug.flutter.util.ThreadManager;
import com.instabug.library.internal.crossplatform.CoreFeature;
import com.instabug.library.internal.crossplatform.CoreFeaturesState;
import com.instabug.library.internal.crossplatform.FeaturesStateListener;
import com.instabug.library.internal.crossplatform.InternalCore;
import com.instabug.library.Feature;
import com.instabug.library.Instabug;
import com.instabug.library.InstabugColorTheme;
Expand Down Expand Up @@ -48,14 +52,19 @@ public class InstabugApi implements InstabugPigeon.InstabugHostApi {
private final Callable<Bitmap> screenshotProvider;
private final InstabugCustomTextPlaceHolder placeHolder = new InstabugCustomTextPlaceHolder();

private final InstabugPigeon.FeatureFlagsFlutterApi featureFlagsFlutterApi;

public static void init(BinaryMessenger messenger, Context context, Callable<Bitmap> screenshotProvider) {
final InstabugApi api = new InstabugApi(context, screenshotProvider);
final InstabugPigeon.FeatureFlagsFlutterApi flutterApi = new InstabugPigeon.FeatureFlagsFlutterApi(messenger);

final InstabugApi api = new InstabugApi(context, screenshotProvider, flutterApi);
InstabugPigeon.InstabugHostApi.setup(messenger, api);
}

public InstabugApi(Context context, Callable<Bitmap> screenshotProvider) {
public InstabugApi(Context context, Callable<Bitmap> screenshotProvider, InstabugPigeon.FeatureFlagsFlutterApi featureFlagsFlutterApi) {
this.context = context;
this.screenshotProvider = screenshotProvider;
this.featureFlagsFlutterApi = featureFlagsFlutterApi;
}

@VisibleForTesting
Expand Down Expand Up @@ -437,6 +446,48 @@ public void networkLog(@NonNull Map<String, Object> data) {
}
}

@Override
public void registerFeatureFlagChangeListener() {

try {
InternalCore.INSTANCE._setFeaturesStateListener(new FeaturesStateListener() {
@Override
public void invoke(@NonNull CoreFeaturesState featuresState) {
ThreadManager.runOnMainThread(new Runnable() {
@Override
public void run() {
featureFlagsFlutterApi.onW3CFeatureFlagChange(featuresState.isW3CExternalTraceIdEnabled(),
featuresState.isAttachingGeneratedHeaderEnabled(),
featuresState.isAttachingCapturedHeaderEnabled(),
new InstabugPigeon.FeatureFlagsFlutterApi.Reply<Void>() {
@Override
public void reply(Void reply) {

}
});
}
});
}

});
} catch (Exception e) {
e.printStackTrace();
}

}

@NonNull
@Override
public Map<String, Boolean> isW3CFeatureFlagsEnabled() {
Map<String, Boolean> params = new HashMap<String, Boolean>();
params.put("isW3cExternalTraceIDEnabled", InternalCore.INSTANCE._isFeatureEnabled(CoreFeature.W3C_EXTERNAL_TRACE_ID));
params.put("isW3cExternalGeneratedHeaderEnabled", InternalCore.INSTANCE._isFeatureEnabled(CoreFeature.W3C_ATTACHING_GENERATED_HEADER));
params.put("isW3cCaughtHeaderEnabled", InternalCore.INSTANCE._isFeatureEnabled(CoreFeature.W3C_ATTACHING_CAPTURED_HEADER));


return params;
}

@Override
public void willRedirectToStore() {
Instabug.willRedirectToStore();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
package com.instabug.flutter;

import static com.instabug.flutter.util.GlobalMocks.reflected;
import static com.instabug.flutter.util.MockResult.makeResult;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockConstruction;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import com.instabug.apm.APM;
import com.instabug.apm.InternalAPM;
import com.instabug.apm.configuration.cp.APMFeature;
Expand Down
Loading

0 comments on commit eb41d25

Please sign in to comment.