Skip to content

Commit

Permalink
Merge pull request #463 from Instabug/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
mzelzoghbi authored Apr 29, 2024
2 parents a18e8d2 + aaca54e commit d8017cd
Show file tree
Hide file tree
Showing 36 changed files with 489 additions and 102 deletions.
72 changes: 35 additions & 37 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
version: 2.1

orbs:
android: circleci/[email protected]
android: circleci/android@2.5.0
flutter: circleci/[email protected]
node: circleci/[email protected]
node: circleci/[email protected]
advanced-checkout: vsco/[email protected]

commands:
setup_flutter:
Expand Down Expand Up @@ -46,7 +47,7 @@ commands:
steps:
- run:
name: Install XCUITest Driver
command: appium driver install xcuitest@4.35.0
command: appium driver install xcuitest@7.14.0
- when:
condition:
equal:
Expand All @@ -55,7 +56,7 @@ commands:
steps:
- run:
name: Install UIAutomator2 Driver
command: appium driver install uiautomator2@2.29.5
command: appium driver install uiautomator2@3.1.0
- run:
name: Launch Appium
# Enable --relaxed-security for `mobile: shell` command that Captain uses internally.
Expand Down Expand Up @@ -103,13 +104,12 @@ commands:
name: Build Pigeons
command: dart run build_runner build --delete-conflicting-outputs


jobs:
danger:
executor:
name: node/default
steps:
- checkout
- advanced-checkout/shallow-checkout
- node/install-packages:
pkg-manager: yarn
override-ci-command: yarn install --frozen-lockfile --network-concurrency 1
Expand All @@ -126,7 +126,7 @@ jobs:
docker:
- image: cirrusci/flutter:<<parameters.version>>
steps:
- checkout
- advanced-checkout/shallow-checkout
- install_flutter_and_dart_packages:
generate_pigeons: true
- run: flutter test --coverage
Expand All @@ -142,16 +142,10 @@ jobs:
executor:
name: android/android-machine
resource-class: xlarge
tag: 2022.04.1
tag: default
steps:
- checkout
- advanced-checkout/shallow-checkout
- setup_flutter
- android/start-emulator-and-run-tests:
system-image: system-images;android-30;google_apis;x86
additional-avd-args: -d "Nexus 5"
post-emulator-launch-assemble-command: cd example && flutter build apk
run-tests-working-directory: example/android
test-command: ./gradlew app:connectedAndroidTest -Ptarget=`pwd`/../test_driver/example.dart
- android/run-tests:
working-directory: example/android
test-command: ./gradlew test
Expand All @@ -160,42 +154,46 @@ jobs:
executor:
name: android/android-machine
resource-class: xlarge
tag: 2022.04.1
tag: default
steps:
- checkout
- advanced-checkout/shallow-checkout
- setup_captain:
platform: android
- setup_flutter
- android/start-emulator-and-run-tests:
system-image: system-images;android-30;google_apis;x86
additional-avd-args: -d "pixel_4"
post-emulator-launch-assemble-command: cd example || true && flutter build apk --debug
test-command: cd e2e || true && dotnet test
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 example && flutter build apk --debug
test-command: dotnet test

test_ios:
macos:
xcode: 13.4.1
xcode: 15.2.0
resource_class: macos.m1.medium.gen1
environment:
INSTABUG_SOURCEMAPS_UPLOAD_DISABLE: true
steps:
- checkout
- advanced-checkout/shallow-checkout
- setup_ios
- run:
name: Build and run tests
working_directory: example/ios
working_directory: ~/project/example/ios
command: |
xcodebuild -allowProvisioningUpdates \
-workspace Runner.xcworkspace \
-scheme Runner \
-sdk iphonesimulator \
-destination 'name=iPhone 12 Pro Max' \
test | xcpretty
-workspace Runner.xcworkspace \
-scheme Runner \
-resultBundlePath coverage/result.xcresult \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 15 Pro Max,OS=17.2' \
test | xcpretty
e2e_ios_captain:
macos:
xcode: 13.4.1
xcode: 15.2.0
resource_class: macos.m1.medium.gen1
steps:
- checkout
- advanced-checkout/shallow-checkout
- setup_captain:
platform: ios
- setup_ios
Expand All @@ -213,7 +211,7 @@ jobs:
docker:
- image: cirrusci/flutter
steps:
- checkout
- advanced-checkout/shallow-checkout
- install_flutter_and_dart_packages:
generate_pigeons: false
- run:
Expand All @@ -224,7 +222,7 @@ jobs:
docker:
- image: cirrusci/flutter
steps:
- checkout
- advanced-checkout/shallow-checkout
- install_flutter_and_dart_packages:
generate_pigeons: true
- run:
Expand All @@ -235,7 +233,7 @@ jobs:
docker:
- image: cirrusci/flutter
steps:
- checkout
- advanced-checkout/shallow-checkout
- install_flutter_and_dart_packages:
generate_pigeons: true
- run:
Expand All @@ -245,11 +243,11 @@ jobs:

release:
macos:
xcode: 13.4.1
xcode: 15.2.0
resource_class: macos.m1.medium.gen1
working_directory: "~"
steps:
- checkout:
- advanced-checkout/shallow-checkout:
path: ~/project
# Flutter doesn't support Apple Silicon yet, so we need to install Rosetta use Flutter on M1 machines.
- run:
Expand Down Expand Up @@ -284,6 +282,7 @@ workflows:
version: 2
build-test-and-approval-deploy:
jobs:
- test_android
- danger:
requires:
- test_flutter-stable
Expand All @@ -293,7 +292,6 @@ workflows:
- test_flutter:
name: test_flutter-2.10.5
version: 2.10.5
- test_android
- e2e_android_captain
- test_ios
- e2e_ios_captain
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## [13.0.0](https://github.com/Instabug/Instabug-React-Native/compare/v12.7.0...dev) (April 29, 2024)

### Added

- Adds custom app rating api ([#453](https://github.com/Instabug/Instabug-Flutter/pull/453))
- Add `SessionReplay.getSessionReplayLink` API which retrieves the current session's replay link ([#445](https://github.com/Instabug/Instabug-Flutter/pull/445)).
- Add support for App Flows APIs `APM.startFlow`, `APM.endFlow` and `APM.setFlowAttribute` ([#446](https://github.com/Instabug/Instabug-Flutter/pull/446)).

### Deprecated

- Deprecate execution traces APIs `APM.startExecutionTrace`, `APM.setExecutionTraceAttribute`, `APM.endExecutionTrace`, `Trace.setAttribute` and `Trace.end` in favor of the new app flow APIs ([#446](https://github.com/Instabug/Instabug-Flutter/pull/446)).

### Changed
- Bump Instabug Android SDK to v13.0.0 ([#455](https://github.com/Instabug/Instabug-Flutter/pull/455)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v13.0.0).
- Bump Instabug iOS SDK to v13.0.0 ([#446](https://github.com/Instabug/Instabug-Flutter/pull/446)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/13.0.0).

## [12.7.0](https://github.com/Instabug/Instabug-Flutter/compare/v12.5.0...v12.7.0) (February 15, 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 '12.7.0'
version '13.0.0'

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

dependencies {
api 'com.instabug.library:instabug:12.7.1'
api 'com.instabug.library:instabug:13.0.0'

testImplementation 'junit:junit:4.13.2'
testImplementation "org.mockito:mockito-inline:3.12.1"
Expand Down
34 changes: 29 additions & 5 deletions android/src/main/java/com/instabug/flutter/modules/ApmApi.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
package com.instabug.flutter.modules;

import android.util.Log;

import androidx.annotation.NonNull;

import androidx.annotation.Nullable;
import com.instabug.apm.APM;
import com.instabug.apm.model.ExecutionTrace;
import com.instabug.apm.networking.APMNetworkLogger;
import com.instabug.flutter.generated.ApmPigeon;
import com.instabug.flutter.util.Reflection;
import com.instabug.flutter.util.ThreadManager;

import io.flutter.plugin.common.BinaryMessenger;
import org.json.JSONObject;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

import io.flutter.plugin.common.BinaryMessenger;

public class ApmApi implements ApmPigeon.ApmHostApi {
private final String TAG = ApmApi.class.getName();
private final HashMap<String, ExecutionTrace> traces = new HashMap<>();
Expand Down Expand Up @@ -95,6 +92,33 @@ public void run() {
);
}

@Override
public void startFlow(@NonNull String name) {
try {
APM.startFlow(name);
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
public void setFlowAttribute(@NonNull String name, @NonNull String key, @Nullable String value) {
try {
APM.setFlowAttribute(name, key, value);
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
public void endFlow(@NonNull String name) {
try {
APM.endFlow(name);
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
public void setExecutionTraceAttribute(@NonNull String id, @NonNull String key, @NonNull String value) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void setCurrentPlatform() {
@Override
public void setEnabled(@NonNull Boolean isEnabled) {
try {
if(isEnabled)
if (isEnabled)
Instabug.enable();
else
Instabug.disable();
Expand Down Expand Up @@ -171,13 +171,12 @@ public void setSessionProfilerEnabled(@NonNull Boolean enabled) {

@Override
public void setValueForStringWithKey(@NonNull String value, @NonNull String key) {
if(ArgsRegistry.placeholders.containsKey(key)) {
if (ArgsRegistry.placeholders.containsKey(key)) {
InstabugCustomTextPlaceHolder.Key resolvedKey = ArgsRegistry.placeholders.get(key);
placeHolder.set(resolvedKey, value);
Instabug.setCustomTextPlaceHolders(placeHolder);
}
else {
Log.i(TAG, "Instabug: " + key + " is only relevant to iOS.");
} else {
Log.i(TAG, "Instabug: " + key + " is only relevant to iOS.");
}
}

Expand Down Expand Up @@ -397,4 +396,9 @@ public void networkLog(@NonNull Map<String, Object> data) {
Log.e(TAG, "Network logging failed");
}
}

@Override
public void willRedirectToStore() {
Instabug.willRedirectToStore();
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.instabug.flutter.modules;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.instabug.flutter.generated.SessionReplayPigeon;
import com.instabug.library.OnSessionReplayLinkReady;
import com.instabug.library.sessionreplay.SessionReplay;

import io.flutter.plugin.common.BinaryMessenger;
Expand Down Expand Up @@ -33,4 +35,11 @@ public void setInstabugLogsEnabled(@NonNull Boolean isEnabled) {
public void setUserStepsEnabled(@NonNull Boolean isEnabled) {
SessionReplay.setUserStepsEnabled(isEnabled);
}

@Override
public void getSessionReplayLink(@NonNull SessionReplayPigeon.Result<String> result) {
SessionReplay.getSessionReplayLink(result::success);
}


}
33 changes: 33 additions & 0 deletions android/src/test/java/com/instabug/flutter/ApmApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,39 @@ public void testEndExecutionTrace() {
verify(mTrace).end();
}

@Test
public void testStartFlow() {
String appFlowName = "appFlowName";

api.startFlow(appFlowName);

mAPM.verify(() -> APM.startFlow(appFlowName));
mAPM.verifyNoMoreInteractions();
}

@Test
public void testEndFlow() {
String appFlowName = "appFlowName";

api.startFlow(appFlowName);

mAPM.verify(() -> APM.startFlow(appFlowName));
mAPM.verifyNoMoreInteractions();
}

@Test
public void testSetFlowAttribute() {
String appFlowName = "appFlowName";
String flowAttributeKey = "attributeKey";
String flowAttributeValue = "attributeValue";


api.setFlowAttribute(appFlowName, flowAttributeKey, flowAttributeValue);

mAPM.verify(() -> APM.setFlowAttribute(appFlowName, flowAttributeKey, flowAttributeValue));
mAPM.verifyNoMoreInteractions();
}

@Test
public void testStartUITrace() {
String name = "login";
Expand Down
Loading

0 comments on commit d8017cd

Please sign in to comment.