=> {
+ const fileName = `${opts.platform}-sourcemap.json`;
+ const fileBlob = fs.readFileSync(opts.file);
+
+ const version = {
+ code: opts.code,
+ name: opts.name,
+ codepush: opts.label,
+ };
+
+ const form = new FormData();
+ form.append('app_version', JSON.stringify(version));
+ form.append('symbols_file', fileBlob, fileName);
+ form.append('application_token', opts.token);
+ form.append('platform', 'react_native');
+ form.append('os', opts.platform);
+
+ if (!opts.silent) {
+ console.log('Uploading Source map file...');
+ }
+
+ try {
+ const response = await axios.post('https://api.instabug.com/api/sdk/v3/symbols_files', form, {
+ headers: form.getHeaders(),
+ });
+
+ const appVersion = version.codepush
+ ? `${version.name} (${version.code})+codepush:${version.codepush}`
+ : `${version.name} (${version.code})`;
+
+ if (!opts.silent) {
+ console.log(`Successfully uploaded Source maps for version: ${appVersion}`);
+ console.log(response.data);
+ }
+
+ return true;
+ } catch (err) {
+ if (!opts.silent) {
+ console.error(
+ 'Failed to upload source maps:',
+ axios.isAxiosError(err) ? err.response?.data : err,
+ );
+ }
+
+ return false;
+ }
+};
diff --git a/rollup.config.js b/rollup.config.js
index 9b3068d89e..ae91a89060 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -5,19 +5,30 @@ import typescript from '@rollup/plugin-typescript';
import cleanup from 'rollup-plugin-cleanup';
import shebang from 'rollup-plugin-preserve-shebang';
+const commonPlugins = [
+ shebang(),
+ json(),
+ nodeResolve({ preferBuiltins: true }),
+ commonjs(),
+ cleanup(),
+];
+
/** @type import('rollup').RollupOptions */
-export default {
- input: ['cli/index.ts'],
- output: {
- dir: 'bin',
- format: 'cjs',
+export default [
+ {
+ input: ['cli/index.ts'],
+ output: {
+ dir: 'bin',
+ format: 'cjs',
+ },
+ plugins: [...commonPlugins, typescript({ tsconfig: './tsconfig.cli.json' })],
+ },
+ {
+ input: ['cli/upload/index.ts'],
+ output: {
+ dir: 'upload',
+ format: 'cjs',
+ },
+ plugins: [...commonPlugins, typescript({ tsconfig: './tsconfig.upload.json' })],
},
- plugins: [
- typescript({ tsconfig: './tsconfig.cli.json' }),
- shebang(),
- json(),
- nodeResolve({ preferBuiltins: true }),
- commonjs(),
- cleanup(),
- ],
-};
+];
diff --git a/tsconfig.upload.json b/tsconfig.upload.json
new file mode 100644
index 0000000000..5ade7ea9a7
--- /dev/null
+++ b/tsconfig.upload.json
@@ -0,0 +1,10 @@
+{
+ "extends": "./tsconfig.json",
+ "include": ["cli/upload/**/*"],
+ "exclude": [],
+ "compilerOptions": {
+ "lib": ["dom"],
+ "outDir": "upload",
+ "module": "esnext"
+ }
+}
diff --git a/upload/package.json b/upload/package.json
new file mode 100644
index 0000000000..778c7ebf51
--- /dev/null
+++ b/upload/package.json
@@ -0,0 +1,5 @@
+{
+ "main": "index.js",
+ "module": "index.mjs",
+ "types": "index.d.ts"
+}
From 6eaf49616363ab95577c0b11bb31b8a6108c7e36 Mon Sep 17 00:00:00 2001
From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com>
Date: Wed, 31 Jul 2024 16:50:42 +0300
Subject: [PATCH 15/40] chore(example): remove flipper (#1259)
---
android/src/main/AndroidManifest.xml | 2 +-
examples/default/android/app/build.gradle | 6 -
.../react/example/ReactNativeFlipper.java | 75 ------------
.../react/example/MainApplication.java | 1 -
.../instabugexample/ReactNativeFlipper.java | 20 ----
examples/default/android/gradle.properties | 3 -
examples/default/ios/Podfile | 16 ---
examples/default/ios/Podfile.lock | 108 +-----------------
8 files changed, 2 insertions(+), 229 deletions(-)
delete mode 100644 examples/default/android/app/src/debug/java/com/instabug/react/example/ReactNativeFlipper.java
delete mode 100644 examples/default/android/app/src/release/java/com/instabugexample/ReactNativeFlipper.java
diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml
index 44ad85bcd7..9af27fbd31 100644
--- a/android/src/main/AndroidManifest.xml
+++ b/android/src/main/AndroidManifest.xml
@@ -1,4 +1,4 @@
-
diff --git a/examples/default/android/app/build.gradle b/examples/default/android/app/build.gradle
index f556607edc..c3d5374954 100644
--- a/examples/default/android/app/build.gradle
+++ b/examples/default/android/app/build.gradle
@@ -171,12 +171,6 @@ dependencies {
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
- debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
- debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
- exclude group:'com.squareup.okhttp3', module:'okhttp'
- }
-
- debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {
diff --git a/examples/default/android/app/src/debug/java/com/instabug/react/example/ReactNativeFlipper.java b/examples/default/android/app/src/debug/java/com/instabug/react/example/ReactNativeFlipper.java
deleted file mode 100644
index a769aa68fc..0000000000
--- a/examples/default/android/app/src/debug/java/com/instabug/react/example/ReactNativeFlipper.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * Copyright (c) Meta Platforms, Inc. and affiliates.
- *
- * This source code is licensed under the MIT license found in the LICENSE file in the root
- * directory of this source tree.
- */
-package com.instabug.react.example;
-
-import android.content.Context;
-import com.facebook.flipper.android.AndroidFlipperClient;
-import com.facebook.flipper.android.utils.FlipperUtils;
-import com.facebook.flipper.core.FlipperClient;
-import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
-import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
-import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
-import com.facebook.flipper.plugins.inspector.DescriptorMapping;
-import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
-import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
-import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
-import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
-import com.facebook.react.ReactInstanceEventListener;
-import com.facebook.react.ReactInstanceManager;
-import com.facebook.react.bridge.ReactContext;
-import com.facebook.react.modules.network.NetworkingModule;
-import okhttp3.OkHttpClient;
-
-/**
- * Class responsible of loading Flipper inside your React Native application. This is the debug
- * flavor of it. Here you can add your own plugins and customize the Flipper setup.
- */
-public class ReactNativeFlipper {
- public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
- if (FlipperUtils.shouldEnableFlipper(context)) {
- final FlipperClient client = AndroidFlipperClient.getInstance(context);
-
- client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
- client.addPlugin(new DatabasesFlipperPlugin(context));
- client.addPlugin(new SharedPreferencesFlipperPlugin(context));
- client.addPlugin(CrashReporterPlugin.getInstance());
-
- NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
- NetworkingModule.setCustomClientBuilder(
- new NetworkingModule.CustomClientBuilder() {
- @Override
- public void apply(OkHttpClient.Builder builder) {
- builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
- }
- });
- client.addPlugin(networkFlipperPlugin);
- client.start();
-
- // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
- // Hence we run if after all native modules have been initialized
- ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
- if (reactContext == null) {
- reactInstanceManager.addReactInstanceEventListener(
- new ReactInstanceEventListener() {
- @Override
- public void onReactContextInitialized(ReactContext reactContext) {
- reactInstanceManager.removeReactInstanceEventListener(this);
- reactContext.runOnNativeModulesQueueThread(
- new Runnable() {
- @Override
- public void run() {
- client.addPlugin(new FrescoFlipperPlugin());
- }
- });
- }
- });
- } else {
- client.addPlugin(new FrescoFlipperPlugin());
- }
- }
- }
-}
diff --git a/examples/default/android/app/src/main/java/com/instabug/react/example/MainApplication.java b/examples/default/android/app/src/main/java/com/instabug/react/example/MainApplication.java
index a988f0a841..a5b32db53f 100644
--- a/examples/default/android/app/src/main/java/com/instabug/react/example/MainApplication.java
+++ b/examples/default/android/app/src/main/java/com/instabug/react/example/MainApplication.java
@@ -56,6 +56,5 @@ public void onCreate() {
// If you opted-in for the New Architecture, we load the native entry point for this app.
DefaultNewArchitectureEntryPoint.load();
}
- ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}
}
diff --git a/examples/default/android/app/src/release/java/com/instabugexample/ReactNativeFlipper.java b/examples/default/android/app/src/release/java/com/instabugexample/ReactNativeFlipper.java
deleted file mode 100644
index 34e4708ab0..0000000000
--- a/examples/default/android/app/src/release/java/com/instabugexample/ReactNativeFlipper.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * Copyright (c) Meta Platforms, Inc. and affiliates.
- *
- *
This source code is licensed under the MIT license found in the LICENSE file in the root
- * directory of this source tree.
- */
-package com.instabug.react.example;
-
-import android.content.Context;
-import com.facebook.react.ReactInstanceManager;
-
-/**
- * Class responsible of loading Flipper inside your React Native application. This is the release
- * flavor of it so it's empty as we don't want to load Flipper.
- */
-public class ReactNativeFlipper {
- public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
- // Do nothing as we don't want to initialize Flipper on Release.
- }
-}
diff --git a/examples/default/android/gradle.properties b/examples/default/android/gradle.properties
index d1a632d51f..6a35482a52 100644
--- a/examples/default/android/gradle.properties
+++ b/examples/default/android/gradle.properties
@@ -24,9 +24,6 @@ android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
-# Version of flipper SDK to use with React Native
-FLIPPER_VERSION=0.182.0
-
# Use this property to specify which architecture you want to build.
# You can also override it from the CLI using
# ./gradlew -PreactNativeArchitectures=x86_64
diff --git a/examples/default/ios/Podfile b/examples/default/ios/Podfile
index 7fa5129f99..3d0c8ceedb 100644
--- a/examples/default/ios/Podfile
+++ b/examples/default/ios/Podfile
@@ -5,17 +5,6 @@ require_relative '../node_modules/@react-native-community/cli-platform-ios/nativ
platform :ios, '13.4'
prepare_react_native_project!
-# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
-# because `react-native-flipper` depends on (FlipperKit,...) that will be excluded
-#
-# To fix this you can also exclude `react-native-flipper` using a `react-native.config.js`
-# ```js
-# module.exports = {
-# dependencies: {
-# ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
-# ```
-flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
-
linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
@@ -36,11 +25,6 @@ target 'InstabugExample' do
# we make it explicit here to aid in the React Native upgrade process.
:hermes_enabled => flags[:hermes_enabled],
:fabric_enabled => flags[:fabric_enabled],
- # Enables Flipper.
- #
- # Note that if you have use_frameworks! enabled, Flipper will not work and
- # you should disable the next line.
- :flipper_configuration => flipper_config,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
diff --git a/examples/default/ios/Podfile.lock b/examples/default/ios/Podfile.lock
index dcaa1c6971..543a31b57a 100644
--- a/examples/default/ios/Podfile.lock
+++ b/examples/default/ios/Podfile.lock
@@ -1,6 +1,5 @@
PODS:
- boost (1.76.0)
- - CocoaAsyncSocket (7.6.5)
- DoubleConversion (1.1.6)
- FBLazyVector (0.72.3)
- FBReactNativeSpec (0.72.3):
@@ -10,64 +9,6 @@ PODS:
- React-Core (= 0.72.3)
- React-jsi (= 0.72.3)
- ReactCommon/turbomodule/core (= 0.72.3)
- - Flipper (0.182.0):
- - Flipper-Folly (~> 2.6)
- - Flipper-Boost-iOSX (1.76.0.1.11)
- - Flipper-DoubleConversion (3.2.0.1)
- - Flipper-Fmt (7.1.7)
- - Flipper-Folly (2.6.10):
- - Flipper-Boost-iOSX
- - Flipper-DoubleConversion
- - Flipper-Fmt (= 7.1.7)
- - Flipper-Glog
- - libevent (~> 2.1.12)
- - OpenSSL-Universal (= 1.1.1100)
- - Flipper-Glog (0.5.0.5)
- - Flipper-PeerTalk (0.0.4)
- - FlipperKit (0.182.0):
- - FlipperKit/Core (= 0.182.0)
- - FlipperKit/Core (0.182.0):
- - Flipper (~> 0.182.0)
- - FlipperKit/CppBridge
- - FlipperKit/FBCxxFollyDynamicConvert
- - FlipperKit/FBDefines
- - FlipperKit/FKPortForwarding
- - SocketRocket (~> 0.6.0)
- - FlipperKit/CppBridge (0.182.0):
- - Flipper (~> 0.182.0)
- - FlipperKit/FBCxxFollyDynamicConvert (0.182.0):
- - Flipper-Folly (~> 2.6)
- - FlipperKit/FBDefines (0.182.0)
- - FlipperKit/FKPortForwarding (0.182.0):
- - CocoaAsyncSocket (~> 7.6)
- - Flipper-PeerTalk (~> 0.0.4)
- - FlipperKit/FlipperKitHighlightOverlay (0.182.0)
- - FlipperKit/FlipperKitLayoutHelpers (0.182.0):
- - FlipperKit/Core
- - FlipperKit/FlipperKitHighlightOverlay
- - FlipperKit/FlipperKitLayoutTextSearchable
- - FlipperKit/FlipperKitLayoutIOSDescriptors (0.182.0):
- - FlipperKit/Core
- - FlipperKit/FlipperKitHighlightOverlay
- - FlipperKit/FlipperKitLayoutHelpers
- - YogaKit (~> 1.18)
- - FlipperKit/FlipperKitLayoutPlugin (0.182.0):
- - FlipperKit/Core
- - FlipperKit/FlipperKitHighlightOverlay
- - FlipperKit/FlipperKitLayoutHelpers
- - FlipperKit/FlipperKitLayoutIOSDescriptors
- - FlipperKit/FlipperKitLayoutTextSearchable
- - YogaKit (~> 1.18)
- - FlipperKit/FlipperKitLayoutTextSearchable (0.182.0)
- - FlipperKit/FlipperKitNetworkPlugin (0.182.0):
- - FlipperKit/Core
- - FlipperKit/FlipperKitReactPlugin (0.182.0):
- - FlipperKit/Core
- - FlipperKit/FlipperKitUserDefaultsPlugin (0.182.0):
- - FlipperKit/Core
- - FlipperKit/SKIOSNetworkPlugin (0.182.0):
- - FlipperKit/Core
- - FlipperKit/FlipperKitNetworkPlugin
- fmt (6.2.1)
- glog (0.3.5)
- Google-Maps-iOS-Utils (4.2.2):
@@ -103,7 +44,6 @@ PODS:
- React-Core
- libevent (2.1.12)
- OCMock (3.9.3)
- - OpenSSL-Universal (1.1.1100)
- RCT-Folly (2021.07.22.00):
- boost
- DoubleConversion
@@ -576,40 +516,17 @@ PODS:
- React-Core
- SocketRocket (0.6.1)
- Yoga (1.14.0)
- - YogaKit (1.18.1):
- - Yoga (~> 1.14)
DEPENDENCIES:
- boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`)
- DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
- FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`)
- FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`)
- - Flipper (= 0.182.0)
- - Flipper-Boost-iOSX (= 1.76.0.1.11)
- - Flipper-DoubleConversion (= 3.2.0.1)
- - Flipper-Fmt (= 7.1.7)
- - Flipper-Folly (= 2.6.10)
- - Flipper-Glog (= 0.5.0.5)
- - Flipper-PeerTalk (= 0.0.4)
- - FlipperKit (= 0.182.0)
- - FlipperKit/Core (= 0.182.0)
- - FlipperKit/CppBridge (= 0.182.0)
- - FlipperKit/FBCxxFollyDynamicConvert (= 0.182.0)
- - FlipperKit/FBDefines (= 0.182.0)
- - FlipperKit/FKPortForwarding (= 0.182.0)
- - FlipperKit/FlipperKitHighlightOverlay (= 0.182.0)
- - FlipperKit/FlipperKitLayoutPlugin (= 0.182.0)
- - FlipperKit/FlipperKitLayoutTextSearchable (= 0.182.0)
- - FlipperKit/FlipperKitNetworkPlugin (= 0.182.0)
- - FlipperKit/FlipperKitReactPlugin (= 0.182.0)
- - FlipperKit/FlipperKitUserDefaultsPlugin (= 0.182.0)
- - FlipperKit/SKIOSNetworkPlugin (= 0.182.0)
- glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
- hermes-engine (from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`)
- instabug-reactnative-ndk (from `../node_modules/instabug-reactnative-ndk`)
- libevent (~> 2.1.12)
- OCMock
- - OpenSSL-Universal (= 1.1.1100)
- RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`)
- RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`)
- RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`)
@@ -617,7 +534,6 @@ DEPENDENCIES:
- React-callinvoker (from `../node_modules/react-native/ReactCommon/callinvoker`)
- React-Codegen (from `build/generated/ios`)
- React-Core (from `../node_modules/react-native/`)
- - React-Core/DevSupport (from `../node_modules/react-native/`)
- React-Core/RCTWebSocket (from `../node_modules/react-native/`)
- React-CoreModules (from `../node_modules/react-native/React/CoreModules`)
- React-cxxreact (from `../node_modules/react-native/ReactCommon/cxxreact`)
@@ -661,24 +577,13 @@ DEPENDENCIES:
SPEC REPOS:
trunk:
- - CocoaAsyncSocket
- - Flipper
- - Flipper-Boost-iOSX
- - Flipper-DoubleConversion
- - Flipper-Fmt
- - Flipper-Folly
- - Flipper-Glog
- - Flipper-PeerTalk
- - FlipperKit
- fmt
- Google-Maps-iOS-Utils
- GoogleMaps
- Instabug
- libevent
- OCMock
- - OpenSSL-Universal
- SocketRocket
- - YogaKit
EXTERNAL SOURCES:
boost:
@@ -791,18 +696,9 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
boost: 7dcd2de282d72e344012f7d6564d024930a6a440
- CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
FBLazyVector: 4cce221dd782d3ff7c4172167bba09d58af67ccb
FBReactNativeSpec: c6bd9e179757b3c0ecf815864fae8032377903ef
- Flipper: 6edb735e6c3e332975d1b17956bcc584eccf5818
- Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c
- Flipper-DoubleConversion: 2dc99b02f658daf147069aad9dbd29d8feb06d30
- Flipper-Fmt: 60cbdd92fc254826e61d669a5d87ef7015396a9b
- Flipper-Folly: 584845625005ff068a6ebf41f857f468decd26b3
- Flipper-Glog: 70c50ce58ddaf67dc35180db05f191692570f446
- Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9
- FlipperKit: 2efad7007d6745a3f95e4034d547be637f89d3f6
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
Google-Maps-iOS-Utils: f77eab4c4326d7e6a277f8e23a0232402731913a
@@ -812,7 +708,6 @@ SPEC CHECKSUMS:
instabug-reactnative-ndk: 960119a69380cf4cbe47ccd007c453f757927d17
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
OCMock: 300b1b1b9155cb6378660b981c2557448830bdc6
- OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1
RCTRequired: a2faf4bad4e438ca37b2040cb8f7799baa065c18
RCTTypeSafety: cb09f3e4747b6d18331a15eb05271de7441ca0b3
@@ -860,8 +755,7 @@ SPEC CHECKSUMS:
RNVectorIcons: 8b5bb0fa61d54cd2020af4f24a51841ce365c7e9
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Yoga: 8796b55dba14d7004f980b54bcc9833ee45b28ce
- YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
-PODFILE CHECKSUM: ad82a989387dcdb1ce80667f16b998a2644cf0b2
+PODFILE CHECKSUM: 281036e04bd4b9e7c2cc03a503b3245d3f1dd0dd
COCOAPODS: 1.12.0
From f2197b8b90ad55b7367b873e565674189874b79c Mon Sep 17 00:00:00 2001
From: Ahmed alaa
Date: Thu, 1 Aug 2024 15:40:53 +0300
Subject: [PATCH 16/40] fix: Pr comments
---
src/utils/XhrNetworkInterceptor.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/utils/XhrNetworkInterceptor.ts b/src/utils/XhrNetworkInterceptor.ts
index 283c036d2f..1039b59216 100644
--- a/src/utils/XhrNetworkInterceptor.ts
+++ b/src/utils/XhrNetworkInterceptor.ts
@@ -152,7 +152,7 @@ export default {
const _response = this._response;
// Detect a more descriptive error message.
if (typeof _response === 'string' && _response.length > 0) {
- cloneNetwork.errorDomain = _response;
+ cloneNetwork.errorDomain = _response.replaceAll(' ', '-');
}
// @ts-ignore
From 79afb4bde6393e35c1b2b3a1c5dc7f34d2308ba8 Mon Sep 17 00:00:00 2001
From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com>
Date: Thu, 18 Jul 2024 15:58:56 +0300
Subject: [PATCH 17/40] fix(android): resolve an OOM in network logs (#1244)
---
CHANGELOG.md | 5 ---
.../reactlibrary/RNInstabugAPMModule.java | 42 +++++++++----------
2 files changed, 20 insertions(+), 27 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1035a998d0..7ec9aad5b6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,13 +2,8 @@
## [Unreleased](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...dev)
-### Added
-
-- Export `uploadSourcemaps` and `uploadSoFiles` utilities in the `instabug-reactnative/upload` sub-package for usage in custom Node.js upload scripts ([#1252](https://github.com/Instabug/Instabug-React-Native/pull/1252)).
-
### Fixed
-- Fix APM network logging on Android ([#1253](https://github.com/Instabug/Instabug-React-Native/pull/1253)).
- Fix an OOM (out-of-memory) crash while saving network logs on Android ([#1244](https://github.com/Instabug/Instabug-React-Native/pull/1244)).
## [13.2.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.1.1...v13.2.0) (July 7, 2024)
diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java
index 70487f8cc5..7ffaf4de73 100644
--- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java
+++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java
@@ -14,7 +14,6 @@
import com.instabug.apm.APM;
import com.instabug.apm.model.ExecutionTrace;
import com.instabug.apm.networking.APMNetworkLogger;
-import com.instabug.apm.networkinterception.cp.APMCPNetworkLog;
import com.instabug.reactlibrary.utils.MainThreadHandler;
import org.json.JSONException;
@@ -339,28 +338,27 @@ private void networkLogAndroid(final double requestStartTime,
final String errorMessage = hasError ? errorDomain : null;
try {
- Method method = 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);
+ Method method = 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);
if (method != null) {
- method.invoke(
- networkLogger,
- (long) requestStartTime,
- (long) requestDuration,
- requestHeaders,
- requestBody,
- (long) requestBodySize,
- requestMethod,
- requestUrl,
- requestContentType,
- responseHeaders,
- responseBody,
- (long)responseBodySize,
- (int) statusCode,
- responseContentType,
- errorMessage,
- gqlQueryName,
- serverErrorMessage,
- null
- );
+ method.invoke(
+ networkLogger,
+ requestStartTime,
+ requestDuration,
+ requestHeaders,
+ requestBody,
+ requestBodySize,
+ requestMethod,
+ requestUrl,
+ requestContentType,
+ responseHeaders,
+ responseBody,
+ responseBodySize,
+ statusCode,
+ responseContentType,
+ errorMessage,
+ gqlQueryName,
+ serverErrorMessage
+ );
} else {
Log.e("IB-CP-Bridge", "APMNetworkLogger.log was not found by reflection");
}
From 61274de6b91074a4fb27528f27d5c1d2d4f21b8b Mon Sep 17 00:00:00 2001
From: kholood
Date: Tue, 23 Jul 2024 10:15:55 +0300
Subject: [PATCH 18/40] fix(android): APM network logging(#1253)
* fix(android): add W3C External Trace Attributes placeholder
* chore: add CHANGLOG
* chore: add CHANGLOG
* fix: remove ios sub module
---
CHANGELOG.md | 1 +
.../reactlibrary/RNInstabugAPMModule.java | 42 ++++++++++---------
2 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7ec9aad5b6..4221fa8a26 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@
### Fixed
+- Fix APM network logging on Android ([#1253](https://github.com/Instabug/Instabug-React-Native/pull/1253)).
- Fix an OOM (out-of-memory) crash while saving network logs on Android ([#1244](https://github.com/Instabug/Instabug-React-Native/pull/1244)).
## [13.2.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.1.1...v13.2.0) (July 7, 2024)
diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java
index 7ffaf4de73..70487f8cc5 100644
--- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java
+++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java
@@ -14,6 +14,7 @@
import com.instabug.apm.APM;
import com.instabug.apm.model.ExecutionTrace;
import com.instabug.apm.networking.APMNetworkLogger;
+import com.instabug.apm.networkinterception.cp.APMCPNetworkLog;
import com.instabug.reactlibrary.utils.MainThreadHandler;
import org.json.JSONException;
@@ -338,27 +339,28 @@ private void networkLogAndroid(final double requestStartTime,
final String errorMessage = hasError ? errorDomain : null;
try {
- Method method = 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);
+ Method method = 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(
- networkLogger,
- requestStartTime,
- requestDuration,
- requestHeaders,
- requestBody,
- requestBodySize,
- requestMethod,
- requestUrl,
- requestContentType,
- responseHeaders,
- responseBody,
- responseBodySize,
- statusCode,
- responseContentType,
- errorMessage,
- gqlQueryName,
- serverErrorMessage
- );
+ method.invoke(
+ networkLogger,
+ (long) requestStartTime,
+ (long) requestDuration,
+ requestHeaders,
+ requestBody,
+ (long) requestBodySize,
+ requestMethod,
+ requestUrl,
+ requestContentType,
+ responseHeaders,
+ responseBody,
+ (long)responseBodySize,
+ (int) statusCode,
+ responseContentType,
+ errorMessage,
+ gqlQueryName,
+ serverErrorMessage,
+ null
+ );
} else {
Log.e("IB-CP-Bridge", "APMNetworkLogger.log was not found by reflection");
}
From 36c9974f17c3f25fc3e3df80b1ac3eb04fc24704 Mon Sep 17 00:00:00 2001
From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com>
Date: Wed, 31 Jul 2024 16:28:42 +0300
Subject: [PATCH 19/40] feat: export upload utils (#1252)
---
CHANGELOG.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4221fa8a26..1035a998d0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,10 @@
## [Unreleased](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...dev)
+### Added
+
+- Export `uploadSourcemaps` and `uploadSoFiles` utilities in the `instabug-reactnative/upload` sub-package for usage in custom Node.js upload scripts ([#1252](https://github.com/Instabug/Instabug-React-Native/pull/1252)).
+
### Fixed
- Fix APM network logging on Android ([#1253](https://github.com/Instabug/Instabug-React-Native/pull/1253)).
From 8677585488cad06b64cb1cb39ad441574f321f7e Mon Sep 17 00:00:00 2001
From: ahmed alaa <154802748+ahmedAlaaInstabug@users.noreply.github.com>
Date: Fri, 2 Aug 2024 10:54:38 +0300
Subject: [PATCH 20/40] fix(android): pass network start time in microseconds
(#1260)
* fix: network timestamp in android side
* fix: PR comments
Co-authored-by: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com>
---------
Co-authored-by: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com>
---
.../java/com/instabug/reactlibrary/RNInstabugAPMModule.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java
index 70487f8cc5..e2ff10b991 100644
--- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java
+++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java
@@ -343,7 +343,7 @@ private void networkLogAndroid(final double requestStartTime,
if (method != null) {
method.invoke(
networkLogger,
- (long) requestStartTime,
+ (long) requestStartTime * 1000,
(long) requestDuration,
requestHeaders,
requestBody,
From b638d12db1f9ead92b823a6617d8d9ad04d2c600 Mon Sep 17 00:00:00 2001
From: ahmed alaa <154802748+ahmedAlaaInstabug@users.noreply.github.com>
Date: Fri, 2 Aug 2024 19:07:10 +0300
Subject: [PATCH 21/40] feat: support feature flags with variants (#1230)
Jira ID: MOB-14684
---------
Co-authored-by: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com>
---
CHANGELOG.md | 5 ++
.../RNInstabugReactnativeModule.java | 66 ++++++++++++++++
.../RNInstabugReactnativeModuleTest.java | 54 ++++++++++++-
.../ios/InstabugTests/InstabugSampleTests.m | 45 ++++++++++-
.../default/src/screens/SettingsScreen.tsx | 76 +++++++++++++++++++
ios/RNInstabug/InstabugReactBridge.h | 4 +-
ios/RNInstabug/InstabugReactBridge.m | 32 ++++++++
src/models/FeatureFlag.ts | 12 +++
src/modules/Instabug.ts | 47 ++++++++++++
src/native/NativeInstabug.ts | 6 ++
test/mocks/mockInstabug.ts | 3 +
test/modules/Instabug.spec.ts | 52 +++++++++++++
12 files changed, 396 insertions(+), 6 deletions(-)
create mode 100644 src/models/FeatureFlag.ts
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1035a998d0..f277b26077 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,8 +4,13 @@
### Added
+- Add support for Feature Flags APIs `Instabug.addFeatureFlags`, `Instabug.removeFeatureFlags` and `Instabug.clearAllFeatureFlags` ([#1230](https://github.com/Instabug/Instabug-React-Native/pull/1230)).
- Export `uploadSourcemaps` and `uploadSoFiles` utilities in the `instabug-reactnative/upload` sub-package for usage in custom Node.js upload scripts ([#1252](https://github.com/Instabug/Instabug-React-Native/pull/1252)).
+### Deprecated
+
+- Deprecate Experiments APIs `Instabug.addExperiments`, `Instabug.removeExperiments` and `Instabug.clearAllExperiments` in favor of the new Feature Flags APIs ([#1230](https://github.com/Instabug/Instabug-React-Native/pull/1230)).
+
### Fixed
- Fix APM network logging on Android ([#1253](https://github.com/Instabug/Instabug-React-Native/pull/1253)).
diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java
index 7d14656089..f936eaa12e 100644
--- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java
+++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java
@@ -16,6 +16,7 @@
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableArray;
+import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableArray;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeArray;
@@ -29,6 +30,7 @@
import com.instabug.library.LogLevel;
import com.instabug.library.ReproConfigurations;
import com.instabug.library.core.InstabugCore;
+import com.instabug.library.featuresflags.model.IBGFeatureFlag;
import com.instabug.library.internal.module.InstabugLocale;
import com.instabug.library.invocation.InstabugInvocationEvent;
import com.instabug.library.logging.InstabugLog;
@@ -41,6 +43,7 @@
import com.instabug.reactlibrary.utils.MainThreadHandler;
import com.instabug.reactlibrary.utils.RNTouchedViewExtractor;
+
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
@@ -50,6 +53,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -1023,6 +1027,9 @@ public void run() {
});
}
+ /**
+ * @deprecated see {@link #addFeatureFlags(ReadableArray)}
+ */
@ReactMethod
public void addExperiments(final ReadableArray experiments) {
MainThreadHandler.runOnMainThread(new Runnable() {
@@ -1039,6 +1046,9 @@ public void run() {
});
}
+ /**
+ * @deprecated see {@link #removeFeatureFlags(ReadableArray)}
+ */
@ReactMethod
public void removeExperiments(final ReadableArray experiments) {
MainThreadHandler.runOnMainThread(new Runnable() {
@@ -1055,6 +1065,9 @@ public void run() {
});
}
+ /**
+ * @deprecated see {@link #removeAllFeatureFlags()}
+ */
@ReactMethod
public void clearAllExperiments() {
MainThreadHandler.runOnMainThread(new Runnable() {
@@ -1069,6 +1082,59 @@ public void run() {
});
}
+ @ReactMethod
+ public void addFeatureFlags(final ReadableMap featureFlagsMap) {
+ MainThreadHandler.runOnMainThread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ Iterator> iterator = featureFlagsMap.getEntryIterator();
+ ArrayList featureFlags = new ArrayList<>();
+ while (iterator.hasNext()) {
+ Map.Entry item = iterator.next();
+ String variant = (String) item.getValue();
+ String name = item.getKey();
+ featureFlags.add(new IBGFeatureFlag(name, variant.isEmpty() ? null : variant));
+ }
+ if (!featureFlags.isEmpty()) {
+ Instabug.addFeatureFlags(featureFlags);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+
+ @ReactMethod
+ public void removeFeatureFlags(final ReadableArray featureFlags) {
+ MainThreadHandler.runOnMainThread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ ArrayList stringArray = ArrayUtil.parseReadableArrayOfStrings(featureFlags);
+ Instabug.removeFeatureFlag(stringArray);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+
+ @ReactMethod
+ public void removeAllFeatureFlags() {
+ MainThreadHandler.runOnMainThread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ Instabug.removeAllFeatureFlags();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+
@ReactMethod
public void willRedirectToStore() {
MainThreadHandler.runOnMainThread(new Runnable() {
diff --git a/android/src/test/java/com/instabug/reactlibrary/RNInstabugReactnativeModuleTest.java b/android/src/test/java/com/instabug/reactlibrary/RNInstabugReactnativeModuleTest.java
index beee65c4bf..b9bf2308cc 100644
--- a/android/src/test/java/com/instabug/reactlibrary/RNInstabugReactnativeModuleTest.java
+++ b/android/src/test/java/com/instabug/reactlibrary/RNInstabugReactnativeModuleTest.java
@@ -18,6 +18,7 @@
import com.instabug.library.IssueType;
import com.instabug.library.ReproConfigurations;
import com.instabug.library.ReproMode;
+import com.instabug.library.featuresflags.model.IBGFeatureFlag;
import com.instabug.library.internal.module.InstabugLocale;
import com.instabug.library.ui.onboarding.WelcomeMessage;
import com.instabug.reactlibrary.utils.MainThreadHandler;
@@ -38,6 +39,7 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -567,8 +569,6 @@ public void testIdentifyUserWithId() {
@Test
public void given$clearAllExperiments_whenQuery_thenShouldCallNativeApi() {
- // given
-
// when
rnModule.clearAllExperiments();
@@ -577,6 +577,56 @@ public void testIdentifyUserWithId() {
Instabug.clearAllExperiments();
}
+ @Test
+ public void testAddFeatureFlags() {
+ // given
+ JavaOnlyMap map = new JavaOnlyMap();
+ map.putString("key1", "value1");
+ map.putString("key2", "value2");
+
+ // when
+ rnModule.addFeatureFlags(map);
+
+ // then
+ Iterator> iterator = map.getEntryIterator();
+ ArrayList featureFlags = new ArrayList<>();
+ while (iterator.hasNext()) {
+ Map.Entry item = iterator.next();
+ featureFlags.add(new IBGFeatureFlag(item.getKey(), (String) item.getValue()));
+ }
+
+ mockInstabug.verify(() -> Instabug.addFeatureFlags(featureFlags));
+
+ }
+
+ @Test
+ public void testRemoveFeatureFlags() {
+ // given
+ JavaOnlyArray array = new JavaOnlyArray();
+ array.pushString("exp1");
+ array.pushString("exp2");
+
+ // when
+ rnModule.removeFeatureFlags(array);
+
+ // then
+ List expectedList = new ArrayList();
+ for (Object o : array.toArrayList()) {
+ expectedList.add((String) o);
+ }
+ mockInstabug.verify(() -> Instabug.removeFeatureFlag(expectedList));
+
+ }
+
+ @Test
+ public void testRemoveAllFeatureFlags() {
+ // when
+ rnModule.removeAllFeatureFlags();
+
+ // then
+ mockInstabug.verify(() -> Instabug.removeAllFeatureFlags());
+ }
+
@Test
public void testWillRedirectToStore() {
// when
diff --git a/examples/default/ios/InstabugTests/InstabugSampleTests.m b/examples/default/ios/InstabugTests/InstabugSampleTests.m
index 37990b450c..565a21b1a7 100644
--- a/examples/default/ios/InstabugTests/InstabugSampleTests.m
+++ b/examples/default/ios/InstabugTests/InstabugSampleTests.m
@@ -73,7 +73,7 @@ - (void)testInit {
NSArray *invocationEvents = [NSArray arrayWithObjects:[NSNumber numberWithInteger:floatingButtonInvocationEvent], nil];
BOOL useNativeNetworkInterception = YES;
IBGSDKDebugLogsLevel sdkDebugLogsLevel = IBGSDKDebugLogsLevelDebug;
-
+
OCMStub([mock setCodePushVersion:codePushVersion]);
[self.instabugBridge init:appToken invocationEvents:invocationEvents debugLogsLevel:sdkDebugLogsLevel useNativeNetworkInterception:useNativeNetworkInterception codePushVersion:codePushVersion];
@@ -85,9 +85,9 @@ - (void)testInit {
- (void)testSetCodePushVersion {
id mock = OCMClassMock([Instabug class]);
NSString *codePushVersion = @"123";
-
+
[self.instabugBridge setCodePushVersion:codePushVersion];
-
+
OCMVerify([mock setCodePushVersion:codePushVersion]);
}
@@ -498,4 +498,43 @@ - (void)testClearAllExperiments {
OCMVerify([mock clearAllExperiments]);
}
+- (void)testAddFeatureFlags {
+ id mock = OCMClassMock([Instabug class]);
+ NSDictionary *featureFlagsMap = @{ @"key13" : @"value1", @"key2" : @"value2"};
+
+ OCMStub([mock addFeatureFlags :[OCMArg any]]);
+ [self.instabugBridge addFeatureFlags:featureFlagsMap];
+ OCMVerify([mock addFeatureFlags: [OCMArg checkWithBlock:^(id value) {
+ NSArray *featureFlags = value;
+ NSString* firstFeatureFlagName = [featureFlags objectAtIndex:0 ].name;
+ NSString* firstFeatureFlagKey = [[featureFlagsMap allKeys] objectAtIndex:0] ;
+ if([ firstFeatureFlagKey isEqualToString: firstFeatureFlagName]){
+ return YES;
+ }
+ return NO;
+ }]]);
+}
+
+- (void)testRemoveFeatureFlags {
+ id mock = OCMClassMock([Instabug class]);
+ NSArray *featureFlags = @[@"exp1", @"exp2"];
+ [self.instabugBridge removeFeatureFlags:featureFlags];
+ OCMVerify([mock removeFeatureFlags: [OCMArg checkWithBlock:^(id value) {
+ NSArray *featureFlagsObJ = value;
+ NSString* firstFeatureFlagName = [featureFlagsObJ objectAtIndex:0 ].name;
+ NSString* firstFeatureFlagKey = [featureFlags firstObject] ;
+ if([ firstFeatureFlagKey isEqualToString: firstFeatureFlagName]){
+ return YES;
+ }
+ return NO;
+ }]]);
+}
+
+- (void)testRemoveAllFeatureFlags {
+ id mock = OCMClassMock([Instabug class]);
+ OCMStub([mock removeAllFeatureFlags]);
+ [self.instabugBridge removeAllFeatureFlags];
+ OCMVerify([mock removeAllFeatureFlags]);
+}
+
@end
diff --git a/examples/default/src/screens/SettingsScreen.tsx b/examples/default/src/screens/SettingsScreen.tsx
index 618de54a22..6390bb7a0a 100644
--- a/examples/default/src/screens/SettingsScreen.tsx
+++ b/examples/default/src/screens/SettingsScreen.tsx
@@ -17,8 +17,12 @@ export const SettingsScreen: React.FC = () => {
const [userID, setUserID] = useState('');
const [userAttributeKey, setUserAttributeKey] = useState('');
const [userAttributeValue, setUserAttributeValue] = useState('');
+ const [featureFlagName, setFeatureFlagName] = useState('');
+ const [featureFlagVariant, setfeatureFlagVariant] = useState('');
+
const toast = useToast();
const [userAttributesFormError, setUserAttributesFormError] = useState({});
+ const [featureFlagFormError, setFeatureFlagFormError] = useState({});
const validateUserAttributeForm = () => {
const errors: any = {};
@@ -31,6 +35,15 @@ export const SettingsScreen: React.FC = () => {
setUserAttributesFormError(errors);
return Object.keys(errors).length === 0;
};
+ const validateFeatureFlagForm = () => {
+ const errors: any = {};
+ if (featureFlagName.length === 0) {
+ errors.featureFlagName = 'Value is required';
+ }
+ setFeatureFlagFormError(errors);
+ return Object.keys(errors).length === 0;
+ };
+
const styles = StyleSheet.create({
inputWrapper: {
padding: 4,
@@ -60,6 +73,37 @@ export const SettingsScreen: React.FC = () => {
setUserAttributeValue('');
}
};
+ const saveFeatureFlags = () => {
+ if (validateFeatureFlagForm()) {
+ Instabug.addFeatureFlag({
+ name: featureFlagName,
+ variant: featureFlagVariant,
+ });
+ toast.show({
+ description: 'Feature Flag added successfully',
+ });
+ setFeatureFlagName('');
+ setfeatureFlagVariant('');
+ }
+ };
+ const removeFeatureFlags = () => {
+ if (validateFeatureFlagForm()) {
+ Instabug.removeFeatureFlag(featureFlagName);
+ toast.show({
+ description: 'Feature Flag removed successfully',
+ });
+ setFeatureFlagName('');
+ setfeatureFlagVariant('');
+ }
+ };
+ const removeAllFeatureFlags = () => {
+ Instabug.removeAllFeatureFlags();
+ toast.show({
+ description: 'Feature Flags removed successfully',
+ });
+ setFeatureFlagName('');
+ setfeatureFlagVariant('');
+ };
const logout = () => {
Instabug.logOut();
@@ -215,6 +259,38 @@ export const SettingsScreen: React.FC = () => {
+
+
+
+
+ setFeatureFlagName(key)}
+ value={featureFlagName}
+ errorText={featureFlagFormError.featureFlagName}
+ />
+
+
+ setfeatureFlagVariant(value)}
+ value={featureFlagVariant}
+ />
+
+
+
+
+
+
+
+
+
);
diff --git a/ios/RNInstabug/InstabugReactBridge.h b/ios/RNInstabug/InstabugReactBridge.h
index 5da9b9cc71..c2accc9955 100644
--- a/ios/RNInstabug/InstabugReactBridge.h
+++ b/ios/RNInstabug/InstabugReactBridge.h
@@ -133,5 +133,7 @@
- (void)addExperiments:(NSArray *)experiments;
- (void)removeExperiments:(NSArray *)experiments;
- (void)clearAllExperiments;
-
+- (void)addFeatureFlags:(NSDictionary *)featureFlagsMap;
+- (void)removeFeatureFlags:(NSArray *)featureFlags;
+- (void)removeAllFeatureFlags;
@end
diff --git a/ios/RNInstabug/InstabugReactBridge.m b/ios/RNInstabug/InstabugReactBridge.m
index 2f2b24f27a..a6f56109c2 100644
--- a/ios/RNInstabug/InstabugReactBridge.m
+++ b/ios/RNInstabug/InstabugReactBridge.m
@@ -355,6 +355,38 @@ - (dispatch_queue_t)methodQueue {
[Instabug clearAllExperiments];
}
+RCT_EXPORT_METHOD(addFeatureFlags:(NSDictionary *)featureFlagsMap) {
+ NSMutableArray *featureFlags = [NSMutableArray array];
+ for(id key in featureFlagsMap){
+ NSString* variant =[featureFlagsMap objectForKey:key];
+ if ([variant length]==0) {
+ [featureFlags addObject:[[IBGFeatureFlag alloc] initWithName:key]];
+ } else{
+ [featureFlags addObject:[[IBGFeatureFlag alloc] initWithName:key variant:variant]];
+ }
+ }
+
+ [Instabug addFeatureFlags:featureFlags];
+}
+
+RCT_EXPORT_METHOD(removeFeatureFlags:(NSArray *)featureFlags) {
+ NSMutableArray *features = [NSMutableArray array];
+ for(id item in featureFlags){
+ [features addObject:[[IBGFeatureFlag alloc] initWithName:item]];
+ }
+
+ @try {
+ [Instabug removeFeatureFlags:features];
+ }
+ @catch (NSException *exception) {
+ NSLog(@"%@", exception);
+ }
+}
+
+RCT_EXPORT_METHOD(removeAllFeatureFlags) {
+ [Instabug removeAllFeatureFlags];
+}
+
RCT_EXPORT_METHOD(willRedirectToStore){
[Instabug willRedirectToAppStore];
}
diff --git a/src/models/FeatureFlag.ts b/src/models/FeatureFlag.ts
new file mode 100644
index 0000000000..d2fd58e0f6
--- /dev/null
+++ b/src/models/FeatureFlag.ts
@@ -0,0 +1,12 @@
+export interface FeatureFlag {
+ /**
+ * the name of feature flag
+ */
+ name: string;
+
+ /**
+ * The variant of the feature flag.
+ * Leave it `undefined` for boolean (kill switch) feature flags.
+ */
+ variant?: string;
+}
diff --git a/src/modules/Instabug.ts b/src/modules/Instabug.ts
index 07b3c079d6..baec7660aa 100644
--- a/src/modules/Instabug.ts
+++ b/src/modules/Instabug.ts
@@ -21,6 +21,7 @@ import InstabugUtils, { stringifyIfNotString } from '../utils/InstabugUtils';
import * as NetworkLogger from './NetworkLogger';
import { captureUnhandledRejections } from '../utils/UnhandledRejectionTracking';
import type { ReproConfig } from '../models/ReproConfig';
+import type { FeatureFlag } from '../models/FeatureFlag';
let _currentScreen: string | null = null;
let _lastScreen: string | null = null;
@@ -539,6 +540,8 @@ export const reportScreenChange = (screenName: string) => {
/**
* Add experiments to next report.
* @param experiments An array of experiments to add to the next report.
+ *
+ * @deprecated Please migrate to the new Feature Flags APIs: {@link addFeatureFlags}.
*/
export const addExperiments = (experiments: string[]) => {
NativeInstabug.addExperiments(experiments);
@@ -547,6 +550,8 @@ export const addExperiments = (experiments: string[]) => {
/**
* Remove experiments from next report.
* @param experiments An array of experiments to remove from the next report.
+ *
+ * @deprecated Please migrate to the new Feature Flags APIs: {@link removeFeatureFlags}.
*/
export const removeExperiments = (experiments: string[]) => {
NativeInstabug.removeExperiments(experiments);
@@ -554,11 +559,53 @@ export const removeExperiments = (experiments: string[]) => {
/**
* Clear all experiments
+ *
+ * @deprecated Please migrate to the new Feature Flags APIs: {@link removeAllFeatureFlags}.
*/
export const clearAllExperiments = () => {
NativeInstabug.clearAllExperiments();
};
+/**
+ * Add feature flags to the next report.
+ * @param featureFlags An array of feature flags to add to the next report.
+ */
+export const addFeatureFlags = (featureFlags: FeatureFlag[]) => {
+ const entries = featureFlags.map((item) => [item.name, item.variant || '']);
+ const flags = Object.fromEntries(entries);
+ NativeInstabug.addFeatureFlags(flags);
+};
+
+/**
+ * Add a feature flag to the to next report.
+ */
+export const addFeatureFlag = (featureFlag: FeatureFlag) => {
+ addFeatureFlags([featureFlag]);
+};
+
+/**
+ * Remove feature flags from the next report.
+ * @param featureFlags An array of feature flags to remove from the next report.
+ */
+export const removeFeatureFlags = (featureFlags: string[]) => {
+ NativeInstabug.removeFeatureFlags(featureFlags);
+};
+
+/**
+ * Remove a feature flag from the next report.
+ * @param name the name of the feature flag to remove from the next report.
+ */
+export const removeFeatureFlag = (name: string) => {
+ removeFeatureFlags([name]);
+};
+
+/**
+ * Clear all feature flags
+ */
+export const removeAllFeatureFlags = () => {
+ NativeInstabug.removeAllFeatureFlags();
+};
+
/**
* This API has to be call when using custom app rating prompt
*/
diff --git a/src/native/NativeInstabug.ts b/src/native/NativeInstabug.ts
index 3990da4c8b..3b72f5951f 100644
--- a/src/native/NativeInstabug.ts
+++ b/src/native/NativeInstabug.ts
@@ -118,6 +118,12 @@ export interface InstabugNativeModule extends NativeModule {
removeExperiments(experiments: string[]): void;
clearAllExperiments(): void;
+ addFeatureFlags(featureFlags: Record): void;
+
+ removeFeatureFlags(featureFlags: string[]): void;
+
+ removeAllFeatureFlags(): void;
+
// Files APIs //
setFileAttachment(filePath: string, fileName?: string): void;
diff --git a/test/mocks/mockInstabug.ts b/test/mocks/mockInstabug.ts
index c2dac12b5a..5139afcde3 100644
--- a/test/mocks/mockInstabug.ts
+++ b/test/mocks/mockInstabug.ts
@@ -54,6 +54,9 @@ const mockInstabug: InstabugNativeModule = {
clearAllExperiments: jest.fn(),
networkLogIOS: jest.fn(),
networkLogAndroid: jest.fn(),
+ addFeatureFlags: jest.fn(),
+ removeFeatureFlags: jest.fn(),
+ removeAllFeatureFlags: jest.fn(),
appendTagToReport: jest.fn(),
appendConsoleLogToReport: jest.fn(),
setUserAttributeToReport: jest.fn(),
diff --git a/test/modules/Instabug.spec.ts b/test/modules/Instabug.spec.ts
index f2e52099f9..fdbdcae64e 100644
--- a/test/modules/Instabug.spec.ts
+++ b/test/modules/Instabug.spec.ts
@@ -21,6 +21,7 @@ import {
WelcomeMessageMode,
} from '../../src/utils/Enums';
import InstabugUtils from '../../src/utils/InstabugUtils';
+import type { FeatureFlag } from '../../src/models/FeatureFlag';
describe('Instabug Module', () => {
beforeEach(() => {
@@ -770,6 +771,57 @@ describe('Instabug Module', () => {
expect(NativeInstabug.clearAllExperiments).toBeCalledTimes(1);
});
+ it('should call native addFeatureFlags method', () => {
+ const featureFlags: Array = [
+ {
+ name: 'key1',
+ variant: 'variant1',
+ },
+ {
+ name: 'key2',
+ variant: 'variant2',
+ },
+ ];
+ const expected: Record = {};
+ expected.key1 = 'variant1';
+ expected.key2 = 'variant2';
+
+ Instabug.addFeatureFlags(featureFlags);
+ expect(NativeInstabug.addFeatureFlags).toBeCalledTimes(1);
+ expect(NativeInstabug.addFeatureFlags).toBeCalledWith(expected);
+ });
+
+ it('should call native addFeatureFlag method', () => {
+ const featureFlag: FeatureFlag = {
+ name: 'key1',
+ variant: 'variant2',
+ };
+ const expected: Record = {};
+ expected.key1 = 'variant2';
+
+ Instabug.addFeatureFlag(featureFlag);
+ expect(NativeInstabug.addFeatureFlags).toBeCalledTimes(1);
+ expect(NativeInstabug.addFeatureFlags).toBeCalledWith(expected);
+ });
+ it('should call native removeFeatureFlags method', () => {
+ const featureFlags = ['exp1', 'exp2'];
+ Instabug.removeFeatureFlags(featureFlags);
+ expect(NativeInstabug.removeFeatureFlags).toBeCalledTimes(1);
+ expect(NativeInstabug.removeFeatureFlags).toBeCalledWith(featureFlags);
+ });
+
+ it('should call native removeFeatureFlag method', () => {
+ const featureFlag = 'exp1';
+ Instabug.removeFeatureFlag(featureFlag);
+ expect(NativeInstabug.removeFeatureFlags).toBeCalledTimes(1);
+ expect(NativeInstabug.removeFeatureFlags).toBeCalledWith([featureFlag]);
+ });
+
+ it('should call native removeAllFeatureFlags method', () => {
+ Instabug.removeAllFeatureFlags();
+ expect(NativeInstabug.removeAllFeatureFlags).toBeCalledTimes(1);
+ });
+
it('should call the native willRedirectToStore method', () => {
Instabug.willRedirectToStore();
expect(NativeInstabug.willRedirectToStore).toBeCalledTimes(1);
From 27a10e356a55c1d19d15f5b3ea457c8bf1dda496 Mon Sep 17 00:00:00 2001
From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com>
Date: Sun, 4 Aug 2024 15:29:53 +0300
Subject: [PATCH 22/40] chore(android): bump android sdk to v13.3.0 (#1261)
---
CHANGELOG.md | 4 ++++
android/native.gradle | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f277b26077..21e5ecaea5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,10 @@
- Add support for Feature Flags APIs `Instabug.addFeatureFlags`, `Instabug.removeFeatureFlags` and `Instabug.clearAllFeatureFlags` ([#1230](https://github.com/Instabug/Instabug-React-Native/pull/1230)).
- Export `uploadSourcemaps` and `uploadSoFiles` utilities in the `instabug-reactnative/upload` sub-package for usage in custom Node.js upload scripts ([#1252](https://github.com/Instabug/Instabug-React-Native/pull/1252)).
+### Changed
+
+- Bump Instabug Android SDK to v13.3.0 ([#1261](https://github.com/Instabug/Instabug-React-Native/pull/1261)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v13.3.0).
+
### Deprecated
- Deprecate Experiments APIs `Instabug.addExperiments`, `Instabug.removeExperiments` and `Instabug.clearAllExperiments` in favor of the new Feature Flags APIs ([#1230](https://github.com/Instabug/Instabug-React-Native/pull/1230)).
diff --git a/android/native.gradle b/android/native.gradle
index 916c957e59..0e86a4edff 100644
--- a/android/native.gradle
+++ b/android/native.gradle
@@ -1,5 +1,5 @@
project.ext.instabug = [
- version: '13.2.0'
+ version: '13.3.0'
]
dependencies {
From f5f64f8e126a40308cf9ece12254424439e07800 Mon Sep 17 00:00:00 2001
From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com>
Date: Sun, 4 Aug 2024 15:31:14 +0300
Subject: [PATCH 23/40] chore(ios): bump sdk to v13.3.0 (#1262)
---
CHANGELOG.md | 1 +
examples/default/ios/Podfile.lock | 8 ++++----
ios/native.rb | 2 +-
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 21e5ecaea5..7301cb18fc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@
### Changed
- Bump Instabug Android SDK to v13.3.0 ([#1261](https://github.com/Instabug/Instabug-React-Native/pull/1261)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v13.3.0).
+- Bump Instabug iOS SDK to v13.3.0 ([#1262](https://github.com/Instabug/Instabug-React-Native/pull/1262)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/13.3.0).
### Deprecated
diff --git a/examples/default/ios/Podfile.lock b/examples/default/ios/Podfile.lock
index 543a31b57a..d84aab147f 100644
--- a/examples/default/ios/Podfile.lock
+++ b/examples/default/ios/Podfile.lock
@@ -38,7 +38,7 @@ PODS:
- hermes-engine (0.72.3):
- hermes-engine/Pre-built (= 0.72.3)
- hermes-engine/Pre-built (0.72.3)
- - Instabug (13.2.0)
+ - Instabug (13.3.0)
- instabug-reactnative-ndk (0.1.0):
- RCT-Folly (= 2021.07.22.00)
- React-Core
@@ -476,7 +476,7 @@ PODS:
- RCT-Folly (= 2021.07.22.00)
- React-Core
- RNInstabug (13.2.0):
- - Instabug (= 13.2.0)
+ - Instabug (= 13.3.0)
- React-Core
- RNReanimated (3.5.4):
- DoubleConversion
@@ -704,7 +704,7 @@ SPEC CHECKSUMS:
Google-Maps-iOS-Utils: f77eab4c4326d7e6a277f8e23a0232402731913a
GoogleMaps: 032f676450ba0779bd8ce16840690915f84e57ac
hermes-engine: 10fbd3f62405c41ea07e71973ea61e1878d07322
- Instabug: aee76898789d17c55b36c7fbaa697e443effe3b1
+ Instabug: 4f26295103a330ec0236918359eef7ccaa74e2fa
instabug-reactnative-ndk: 960119a69380cf4cbe47ccd007c453f757927d17
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
OCMock: 300b1b1b9155cb6378660b981c2557448830bdc6
@@ -748,7 +748,7 @@ SPEC CHECKSUMS:
ReactCommon: 3ccb8fb14e6b3277e38c73b0ff5e4a1b8db017a9
RNCClipboard: 41d8d918092ae8e676f18adada19104fa3e68495
RNGestureHandler: 6e46dde1f87e5f018a54fe5d40cd0e0b942b49ee
- RNInstabug: 6fa68cd181533f83154df2ebba000d0c47ca7ba3
+ RNInstabug: 2fbe75c9903c0a7d070d6d6a9b5c2a389f0b6862
RNReanimated: ab2e96c6d5591c3dfbb38a464f54c8d17fb34a87
RNScreens: b21dc57dfa2b710c30ec600786a3fc223b1b92e7
RNSVG: 80584470ff1ffc7994923ea135a3e5ad825546b9
diff --git a/ios/native.rb b/ios/native.rb
index 0047a90883..c5188a3a73 100644
--- a/ios/native.rb
+++ b/ios/native.rb
@@ -1,4 +1,4 @@
-$instabug = { :version => '13.2.0' }
+$instabug = { :version => '13.3.0' }
def use_instabug! (spec = nil)
version = $instabug[:version]
From 2485faca5aebe69e7225bf1bdc10e4497de55e93 Mon Sep 17 00:00:00 2001
From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com>
Date: Sun, 4 Aug 2024 15:56:00 +0300
Subject: [PATCH 24/40] release: v13.3.0 (#1263)
---
CHANGELOG.md | 2 +-
android/build.gradle | 2 +-
examples/default/ios/Podfile.lock | 4 ++--
package.json | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7301cb18fc..026fafd2e1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,6 @@
# Changelog
-## [Unreleased](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...dev)
+## [13.3.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...v13.3.0) (August 4, 2024)
### Added
diff --git a/android/build.gradle b/android/build.gradle
index 2d3eceb239..ffd71b5f87 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -57,7 +57,7 @@ android {
minSdkVersion getExtOrDefault('minSdkVersion').toInteger()
targetSdkVersion getExtOrDefault('targetSdkVersion').toInteger()
versionCode 1
- versionName "13.2.0"
+ versionName "13.3.0"
multiDexEnabled true
ndk {
abiFilters "armeabi-v7a", "x86"
diff --git a/examples/default/ios/Podfile.lock b/examples/default/ios/Podfile.lock
index d84aab147f..1da6e558ee 100644
--- a/examples/default/ios/Podfile.lock
+++ b/examples/default/ios/Podfile.lock
@@ -475,7 +475,7 @@ PODS:
- RNGestureHandler (2.13.4):
- RCT-Folly (= 2021.07.22.00)
- React-Core
- - RNInstabug (13.2.0):
+ - RNInstabug (13.3.0):
- Instabug (= 13.3.0)
- React-Core
- RNReanimated (3.5.4):
@@ -748,7 +748,7 @@ SPEC CHECKSUMS:
ReactCommon: 3ccb8fb14e6b3277e38c73b0ff5e4a1b8db017a9
RNCClipboard: 41d8d918092ae8e676f18adada19104fa3e68495
RNGestureHandler: 6e46dde1f87e5f018a54fe5d40cd0e0b942b49ee
- RNInstabug: 2fbe75c9903c0a7d070d6d6a9b5c2a389f0b6862
+ RNInstabug: a4ac0bd09123f6be7d58be541dc220acbaff8dc3
RNReanimated: ab2e96c6d5591c3dfbb38a464f54c8d17fb34a87
RNScreens: b21dc57dfa2b710c30ec600786a3fc223b1b92e7
RNSVG: 80584470ff1ffc7994923ea135a3e5ad825546b9
diff --git a/package.json b/package.json
index cd62475f6a..d641ecad65 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "instabug-reactnative",
"description": "React Native plugin for integrating the Instabug SDK",
- "version": "13.2.0",
+ "version": "13.3.0",
"author": "Instabug (https://instabug.com)",
"repository": "github:Instabug/Instabug-React-Native",
"homepage": "https://www.instabug.com/platforms/react-native",
From f66f3e1e31657a33e1f0aa6ea23b87b0184183af Mon Sep 17 00:00:00 2001
From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com>
Date: Sun, 4 Aug 2024 16:10:45 +0300
Subject: [PATCH 25/40] chore: remove duplicate app flows entries in changelog
(#1264)
---
CHANGELOG.md | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 026fafd2e1..96695f29c0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -73,21 +73,16 @@
- Bump Instabug iOS SDK to v13.0.0 ([#1189](https://github.com/Instabug/Instabug-React-Native/pull/1189)). [See release notes](https://github.com/instabug/instabug-ios/releases/tag/13.0.0).
- Bump Instabug Android SDK to v13.0.0 ([#1188](https://github.com/Instabug/Instabug-React-Native/pull/1188)). [See release notes](https://github.com/Instabug/android/releases/tag/v13.0.0).
+### Deprecated
+
+- Deprecate Execution Traces APIs `APM.startExecutionTrace`, `Trace.end` and `Trace.setAttribute` in favor of the new App Flows APIs ([#1138](https://github.com/Instabug/Instabug-React-Native/pull/1138)).
+
## [12.9.0](https://github.com/Instabug/Instabug-React-Native/compare/v12.8.0...12.9.0)(April 2, 2024)
### Added
- Adds symbol files upload script ([#1137](https://github.com/Instabug/Instabug-React-Native/pull/1137))
- Support enabling NDK crash capturing on Android ([#1132](https://github.com/Instabug/Instabug-React-Native/pull/1132)).
-- Add support for App Flows APIs `APM.startFlow`, `APM.setFlowAttribute` and `APM.endFlow` ([#1138](https://github.com/Instabug/Instabug-React-Native/pull/1138)).
-
-### Deprecated
-
-- Deprecate execution traces APIs `APM.startExecutionTrace`, `Trace.end` and `Trace.setFlowAttribute` in favor of the new app flow APIs ([#1138](https://github.com/Instabug/Instabug-React-Native/pull/1138)).
-
-### Deprecated
-
-- Deprecate Execution Traces APIs `APM.startExecutionTrace`, `Trace.end` and `Trace.setAttribute` in favor of the new App Flows APIs ([#1138](https://github.com/Instabug/Instabug-React-Native/pull/1138)).
### Changed
From efe42408279e3fe6d81584daa4d8dcf2c30d9b22 Mon Sep 17 00:00:00 2001
From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com>
Date: Sun, 4 Aug 2024 16:22:29 +0300
Subject: [PATCH 26/40] chore: remove duplicate execution traces deprecation in
changelog (#1265)
---
CHANGELOG.md | 4 ----
1 file changed, 4 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 96695f29c0..9400332650 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -105,10 +105,6 @@
- Bump Instabug Android SDK to v12.8.0 ([#1149](https://github.com/Instabug/Instabug-React-Native/pull/1149)). [See release notes](https://github.com/Instabug/android/releases/tag/v12.8.0).
-### Deprecated
-
-- Deprecate Execution Traces APIs `APM.startExecutionTrace`, `Trace.end` and `Trace.setAttribute` in favor of the new App Flows APIs ([#1138](https://github.com/Instabug/Instabug-React-Native/pull/1138)).
-
## [12.7.1](https://github.com/Instabug/Instabug-React-Native/compare/v12.7.0...v12.7.1) (February 15, 2024)
### Changed
From be8daf0bbf61252bff079927beeb624b2bd7dc5a Mon Sep 17 00:00:00 2001
From: Ahmed alaa
Date: Wed, 7 Aug 2024 02:02:03 +0300
Subject: [PATCH 27/40] feat: add axios button to example app
---
.../default/src/screens/apm/NetworkScreen.tsx | 32 +++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/examples/default/src/screens/apm/NetworkScreen.tsx b/examples/default/src/screens/apm/NetworkScreen.tsx
index 467a621f21..40ad2b5faf 100644
--- a/examples/default/src/screens/apm/NetworkScreen.tsx
+++ b/examples/default/src/screens/apm/NetworkScreen.tsx
@@ -7,6 +7,7 @@ import { useQuery } from 'react-query';
import { HStack, VStack } from 'native-base';
import { gql, request } from 'graphql-request';
import { CustomButton } from '../../components/CustomButton';
+import axios from 'axios';
export const NetworkScreen: React.FC = () => {
const [endpointUrl, setEndpointUrl] = useState('');
@@ -45,6 +46,32 @@ export const NetworkScreen: React.FC = () => {
}
}
+ async function sendRequestToUrlUsingAxios() {
+ let urlToSend = '';
+
+ if (endpointUrl.trim() !== '') {
+ urlToSend = endpointUrl;
+ console.log('Sending request to: ', endpointUrl);
+ } else {
+ // Use json placeholder URL as a default if endpointUrl is empty
+ console.log('sending request to default json placeholder');
+ urlToSend = defaultRequestUrl;
+ }
+
+ try {
+ // Perform the request using the urlToSend
+ const response = await axios.get(urlToSend);
+ // Format the JSON response for better logging
+ const formattedData = JSON.stringify(response.data, null, 2);
+
+ // Log the formatted response
+ console.log('Response:', formattedData);
+ } catch (error) {
+ // Handle errors appropriately
+ console.error('Error:', error);
+ }
+ }
+
const fetchGraphQlData = async () => {
const document = gql`
query {
@@ -75,6 +102,11 @@ export const NetworkScreen: React.FC = () => {
value={endpointUrl}
/>
+
+
refetch} title="Reload GraphQL" />
{isLoading && Loading...}
From 8f0a5c4345fab7e9aa00653775a2c7de00bc466d Mon Sep 17 00:00:00 2001
From: Ahmed alaa
Date: Thu, 22 Aug 2024 12:37:08 +0300
Subject: [PATCH 28/40] fix: change client error code to 9876
---
src/utils/XhrNetworkInterceptor.ts | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/utils/XhrNetworkInterceptor.ts b/src/utils/XhrNetworkInterceptor.ts
index 1039b59216..bd6660a61d 100644
--- a/src/utils/XhrNetworkInterceptor.ts
+++ b/src/utils/XhrNetworkInterceptor.ts
@@ -72,7 +72,8 @@ export default {
originalXHROpen = XMLHttpRequest.prototype.open;
originalXHRSend = XMLHttpRequest.prototype.send;
originalXHRSetRequestHeader = XMLHttpRequest.prototype.setRequestHeader;
-
+ // An error code that signifies an issue with the RN client.
+ const clientErrorCode = 9876;
XMLHttpRequest.prototype.open = function (method, url, ...args) {
_reset();
network.url = url;
@@ -145,7 +146,7 @@ export default {
// @ts-ignore
if (this._hasError) {
- cloneNetwork.errorCode = 0;
+ cloneNetwork.errorCode = clientErrorCode;
cloneNetwork.errorDomain = 'ClientError';
// @ts-ignore
@@ -157,7 +158,7 @@ export default {
// @ts-ignore
} else if (this._timedOut) {
- cloneNetwork.errorCode = 0;
+ cloneNetwork.errorCode = clientErrorCode;
cloneNetwork.errorDomain = 'TimeOutError';
}
From 398262d5b75c1427356869bc4e2b38bc4e38b1d4 Mon Sep 17 00:00:00 2001
From: Ahmed alaa
Date: Thu, 22 Aug 2024 14:41:09 +0300
Subject: [PATCH 29/40] fix: change client error code to 9876
---
test/utils/XhrNetworkInterceptor.spec.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/utils/XhrNetworkInterceptor.spec.ts b/test/utils/XhrNetworkInterceptor.spec.ts
index 7ec818278f..10a8f1abb8 100644
--- a/test/utils/XhrNetworkInterceptor.spec.ts
+++ b/test/utils/XhrNetworkInterceptor.spec.ts
@@ -235,7 +235,7 @@ describe('Network Interceptor', () => {
expect(callback).toBeCalledWith(
expect.objectContaining({
errorDomain: 'ClientError',
- errorCode: 0,
+ errorCode: 9876,
responseBody: '',
}),
);
From ac2d7e6b38249d8a9ddab04d97fd289ed537f39c Mon Sep 17 00:00:00 2001
From: Ahmed alaa
Date: Thu, 22 Aug 2024 14:43:20 +0300
Subject: [PATCH 30/40] fix: change client error code to 9876
---
examples/default/package.json | 1 +
1 file changed, 1 insertion(+)
diff --git a/examples/default/package.json b/examples/default/package.json
index 529521802d..a618c2811c 100644
--- a/examples/default/package.json
+++ b/examples/default/package.json
@@ -16,6 +16,7 @@
"@react-navigation/native": "^6.1.6",
"@react-navigation/native-stack": "^6.9.12",
"graphql": "^16.8.1",
+ "axios": "^1.7.4",
"graphql-request": "^6.1.0",
"instabug-reactnative": "link:../..",
"instabug-reactnative-ndk": "github:https://github.com/Instabug/Instabug-React-Native-NDK",
From 9550ce91a95aaa2abf29e8f05cd5bc8976210481 Mon Sep 17 00:00:00 2001
From: Ahmed alaa
Date: Thu, 22 Aug 2024 14:52:14 +0300
Subject: [PATCH 31/40] fix: change client error code to 9876
---
examples/default/yarn.lock | 50 ++++++++++++++++++++++++++++++++++++--
1 file changed, 48 insertions(+), 2 deletions(-)
diff --git a/examples/default/yarn.lock b/examples/default/yarn.lock
index 74f7ce0e3b..10aaed1cd9 100644
--- a/examples/default/yarn.lock
+++ b/examples/default/yarn.lock
@@ -3239,11 +3239,25 @@ async@^3.2.2:
resolved "https://registry.yarnpkg.com/async/-/async-3.2.4.tgz#2d22e00f8cddeb5fde5dd33522b56d1cf569a81c"
integrity sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==
+asynckit@^0.4.0:
+ version "0.4.0"
+ resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
+ integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==
+
at-least-node@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2"
integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==
+axios@^1.7.4:
+ version "1.7.4"
+ resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.4.tgz#4c8ded1b43683c8dd362973c393f3ede24052aa2"
+ integrity sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw==
+ dependencies:
+ follow-redirects "^1.15.6"
+ form-data "^4.0.0"
+ proxy-from-env "^1.1.0"
+
babel-core@^7.0.0-bridge.0:
version "7.0.0-bridge.0"
resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-7.0.0-bridge.0.tgz#95a492ddd90f9b4e9a4a1da14eb335b87b634ece"
@@ -3729,6 +3743,13 @@ colorette@^1.0.7:
resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.4.0.tgz#5190fbb87276259a86ad700bff2c6d6faa3fca40"
integrity sha512-Y2oEozpomLn7Q3HFP7dpww7AtMJplbM9lGZP6RDfHqmbeRjiwRg4n6VM6j4KLmRke85uWEI7JqF17f3pqdRA0g==
+combined-stream@^1.0.8:
+ version "1.0.8"
+ resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f"
+ integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==
+ dependencies:
+ delayed-stream "~1.0.0"
+
command-exists@^1.2.8:
version "1.2.9"
resolved "https://registry.yarnpkg.com/command-exists/-/command-exists-1.2.9.tgz#c50725af3808c8ab0260fd60b01fbfa25b954f69"
@@ -3941,6 +3962,11 @@ define-data-property@^1.1.1:
gopd "^1.0.1"
has-property-descriptors "^1.0.0"
+delayed-stream@~1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
+ integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==
+
denodeify@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/denodeify/-/denodeify-1.2.1.tgz#3a36287f5034e699e7577901052c2e6c94251631"
@@ -4329,6 +4355,20 @@ flow-parser@^0.206.0:
resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.206.0.tgz#f4f794f8026535278393308e01ea72f31000bfef"
integrity sha512-HVzoK3r6Vsg+lKvlIZzaWNBVai+FXTX1wdYhz/wVlH13tb/gOdLXmlTqy6odmTBhT5UoWUbq0k8263Qhr9d88w==
+follow-redirects@^1.15.6:
+ version "1.15.6"
+ resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.6.tgz#7f815c0cda4249c74ff09e95ef97c23b5fd0399b"
+ integrity sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==
+
+form-data@^4.0.0:
+ version "4.0.0"
+ resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
+ integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==
+ dependencies:
+ asynckit "^0.4.0"
+ combined-stream "^1.0.8"
+ mime-types "^2.1.12"
+
fresh@0.5.2:
version "0.5.2"
resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7"
@@ -4650,7 +4690,8 @@ inline-style-prefixer@^6.0.1:
resolved "https://codeload.github.com/Instabug/Instabug-React-Native-NDK/tar.gz/3b0bac281253133852d32f52aa50cc805dd0b570"
"instabug-reactnative@link:../..":
- version "13.0.5"
+ version "0.0.0"
+ uid ""
intl-messageformat@^10.1.0:
version "10.5.0"
@@ -6105,7 +6146,7 @@ mime-db@1.52.0, "mime-db@>= 1.43.0 < 2":
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70"
integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==
-mime-types@^2.1.27, mime-types@~2.1.34:
+mime-types@^2.1.12, mime-types@^2.1.27, mime-types@~2.1.34:
version "2.1.35"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a"
integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==
@@ -6664,6 +6705,11 @@ proper-lockfile@^3.0.2:
retry "^0.12.0"
signal-exit "^3.0.2"
+proxy-from-env@^1.1.0:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2"
+ integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==
+
pseudomap@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"
From b41ff4f612d2cdd1895dad2566c7da5523ebdd2f Mon Sep 17 00:00:00 2001
From: kholood
Date: Mon, 12 Aug 2024 14:10:34 +0300
Subject: [PATCH 32/40] feat: navigation tracking support with expo router
(#1270)
* feat: add screen tracker on screen change listener and tests
* feat (example): add screen change listener
---
examples/default/src/App.tsx | 9 +++++++--
src/modules/Instabug.ts | 18 +++++++++++++++++-
test/modules/Instabug.spec.ts | 18 ++++++++++++++++++
3 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/examples/default/src/App.tsx b/examples/default/src/App.tsx
index d92db633c1..ae548f97c5 100644
--- a/examples/default/src/App.tsx
+++ b/examples/default/src/App.tsx
@@ -2,7 +2,7 @@ import React, { useEffect } from 'react';
import { StyleSheet } from 'react-native';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
-import { NavigationContainer } from '@react-navigation/native';
+import { NavigationContainer, useNavigationContainerRef } from '@react-navigation/native';
import Instabug, {
CrashReporting,
InvocationEvent,
@@ -20,6 +20,7 @@ import { QueryClient, QueryClientProvider } from 'react-query';
const queryClient = new QueryClient();
export const App: React.FC = () => {
+ const navigationRef = useNavigationContainerRef();
useEffect(() => {
Instabug.init({
token: 'deb1910a7342814af4e4c9210c786f35',
@@ -33,11 +34,15 @@ export const App: React.FC = () => {
});
}, []);
+ useEffect(() => {
+ Instabug.setNavigationListener(navigationRef);
+ }, [navigationRef]);
+
return (
-
+
diff --git a/src/modules/Instabug.ts b/src/modules/Instabug.ts
index baec7660aa..b0a05032c4 100644
--- a/src/modules/Instabug.ts
+++ b/src/modules/Instabug.ts
@@ -1,7 +1,10 @@
import type React from 'react';
import { Platform, findNodeHandle, processColor } from 'react-native';
-import type { NavigationState as NavigationStateV5 } from '@react-navigation/native';
+import type {
+ NavigationContainerRefWithCurrent,
+ NavigationState as NavigationStateV5,
+} from '@react-navigation/native';
import type { ComponentDidAppearEvent } from 'react-native-navigation';
import type { NavigationAction, NavigationState as NavigationStateV4 } from 'react-navigation';
@@ -533,6 +536,19 @@ export const onStateChange = (state?: NavigationStateV5) => {
}, 1000);
};
+/**
+ * Sets a listener for screen change
+ * @param navigationRef a refrence of a navigation container
+ *
+ */
+export const setNavigationListener = (
+ navigationRef: NavigationContainerRefWithCurrent,
+) => {
+ navigationRef.addListener('state', () => {
+ onStateChange(navigationRef.getRootState());
+ });
+};
+
export const reportScreenChange = (screenName: string) => {
NativeInstabug.reportScreenChange(screenName);
};
diff --git a/test/modules/Instabug.spec.ts b/test/modules/Instabug.spec.ts
index fdbdcae64e..518e53ce93 100644
--- a/test/modules/Instabug.spec.ts
+++ b/test/modules/Instabug.spec.ts
@@ -2,6 +2,7 @@ import '../mocks/mockInstabugUtils';
import '../mocks/mockNetworkLogger';
import { Platform, findNodeHandle, processColor } from 'react-native';
+import type { NavigationContainerRefWithCurrent } from '@react-navigation/native'; // Import the hook
import { mocked } from 'jest-mock';
import waitForExpect from 'wait-for-expect';
@@ -236,6 +237,23 @@ describe('Instabug Module', () => {
await waitForExpect(() => expect(NativeInstabug.reportScreenChange).toBeCalledTimes(2));
});
+ it('setNavigationListener should call the onStateChange on a screen change', async () => {
+ const mockNavigationContainerRef = {
+ current: null,
+ navigate: jest.fn(),
+ reset: jest.fn(),
+ goBack: jest.fn(),
+ dispatch: jest.fn(),
+ getRootState: jest.fn(),
+ canGoBack: jest.fn(),
+ addListener: jest.fn(),
+ removeListener: jest.fn(),
+ } as unknown as NavigationContainerRefWithCurrent;
+
+ Instabug.setNavigationListener(mockNavigationContainerRef);
+ expect(mockNavigationContainerRef.addListener).toBeCalledTimes(1);
+ });
+
it('should call the native method init', () => {
const instabugConfig = {
token: 'some-token',
From 10286cdeccd19c88dd625639b3d303de5034c17c Mon Sep 17 00:00:00 2001
From: kholood
Date: Tue, 13 Aug 2024 17:37:27 +0300
Subject: [PATCH 33/40] chore: enhance expo router tracking support (#1272)
---
CHANGELOG.md | 6 ++++++
examples/default/src/App.tsx | 4 +++-
src/modules/Instabug.ts | 2 +-
test/modules/Instabug.spec.ts | 23 +++++++++++++++++++++--
4 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9400332650..acb003486f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
# Changelog
+## [Unreleased](https://github.com/Instabug/Instabug-React-Native/compare/v13.3.0...dev)
+
+### Added
+
+- Add support for Expo Router navigation tracking ([#1270](https://github.com/Instabug/Instabug-React-Native/pull/1270)).
+
## [13.3.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...v13.3.0) (August 4, 2024)
### Added
diff --git a/examples/default/src/App.tsx b/examples/default/src/App.tsx
index ae548f97c5..33a3c34f94 100644
--- a/examples/default/src/App.tsx
+++ b/examples/default/src/App.tsx
@@ -35,7 +35,9 @@ export const App: React.FC = () => {
}, []);
useEffect(() => {
- Instabug.setNavigationListener(navigationRef);
+ const unregisterListener = Instabug.setNavigationListener(navigationRef);
+
+ return unregisterListener;
}, [navigationRef]);
return (
diff --git a/src/modules/Instabug.ts b/src/modules/Instabug.ts
index b0a05032c4..29ff1d27c9 100644
--- a/src/modules/Instabug.ts
+++ b/src/modules/Instabug.ts
@@ -544,7 +544,7 @@ export const onStateChange = (state?: NavigationStateV5) => {
export const setNavigationListener = (
navigationRef: NavigationContainerRefWithCurrent,
) => {
- navigationRef.addListener('state', () => {
+ return navigationRef.addListener('state', () => {
onStateChange(navigationRef.getRootState());
});
};
diff --git a/test/modules/Instabug.spec.ts b/test/modules/Instabug.spec.ts
index 518e53ce93..fdc1b91b24 100644
--- a/test/modules/Instabug.spec.ts
+++ b/test/modules/Instabug.spec.ts
@@ -238,20 +238,39 @@ describe('Instabug Module', () => {
});
it('setNavigationListener should call the onStateChange on a screen change', async () => {
+ const mockedState = { routes: [{ name: 'ScreenName' }], index: 0 };
+
const mockNavigationContainerRef = {
current: null,
navigate: jest.fn(),
reset: jest.fn(),
goBack: jest.fn(),
dispatch: jest.fn(),
- getRootState: jest.fn(),
+ getRootState: () => mockedState,
canGoBack: jest.fn(),
- addListener: jest.fn(),
+
+ addListener: jest.fn((event, callback) => {
+ expect(event).toBe('state');
+ callback(mockedState);
+ return jest.fn();
+ }),
removeListener: jest.fn(),
} as unknown as NavigationContainerRefWithCurrent;
+ const onStateChangeMock = jest.fn();
+
+ jest.spyOn(Instabug, 'onStateChange').mockImplementation(onStateChangeMock);
+
Instabug.setNavigationListener(mockNavigationContainerRef);
+
expect(mockNavigationContainerRef.addListener).toBeCalledTimes(1);
+ expect(mockNavigationContainerRef.addListener).toHaveBeenCalledWith(
+ 'state',
+ expect.any(Function),
+ );
+
+ expect(onStateChangeMock).toBeCalledTimes(1);
+ expect(onStateChangeMock).toHaveBeenCalledWith(mockNavigationContainerRef.getRootState());
});
it('should call the native method init', () => {
From ef5a023360cb32294dda7bc4ecdb28cd2ae6ff6e Mon Sep 17 00:00:00 2001
From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com>
Date: Thu, 22 Aug 2024 15:38:04 +0300
Subject: [PATCH 34/40] ci: generalize enterprise releases (#1275)
---
.circleci/config.yml | 159 +++++++++++++++++++++++--------------------
1 file changed, 85 insertions(+), 74 deletions(-)
diff --git a/.circleci/config.yml b/.circleci/config.yml
index c218cf7e93..64a6b4013a 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -59,10 +59,67 @@ commands:
type: string
replace:
type: string
+ working_directory:
+ type: string
+ default: ~/project
steps:
- run:
name: Find and Replace in << parameters.files >>
command: node ~/project/scripts/replace.js << parameters.search >> << parameters.replace >> << parameters.files >>
+ working_directory: << parameters.working_directory >>
+
+ prepare_custom_package:
+ parameters:
+ npm_package:
+ type: string
+ android_package:
+ type: string
+ api_endpoint:
+ type: string
+ working_directory:
+ type: string
+ default: ~/project
+ steps:
+ - run:
+ name: Remove README.md file
+ command: rm README.md
+ working_directory: << parameters.working_directory >>
+ - find_and_replace:
+ files: package.json android/sourcemaps.gradle ios/sourcemaps.sh
+ search: instabug-reactnative
+ replace: << parameters.npm_package >>
+ working_directory: << parameters.working_directory >>
+ - find_and_replace:
+ files: cli/upload/uploadSourcemaps.ts cli/upload/uploadSoFiles.ts
+ search: api.instabug.com
+ replace: << parameters.api_endpoint >>
+ working_directory: << parameters.working_directory >>
+ - find_and_replace:
+ files: android/native.gradle
+ search: 'com.instabug.library:instabug:'
+ replace: 'com.instabug.library-<< parameters.android_package >>:instabug:'
+ working_directory: << parameters.working_directory >>
+
+ prepare_dream11:
+ parameters:
+ working_directory:
+ type: string
+ default: ~/project
+ steps:
+ - install_node_modules
+ - prepare_custom_package:
+ npm_package: '@instabug/instabug-reactnative-dream11'
+ android_package: dream11
+ api_endpoint: st001012dream11.instabug.com
+ working_directory: << parameters.working_directory >>
+ - run:
+ name: Give execute permission to Dream11 script
+ command: chmod +x ./scripts/dream-11-delete-unused-features.sh
+ working_directory: << parameters.working_directory >>
+ - run:
+ name: Remove unused features
+ command: ./scripts/dream-11-delete-unused-features.sh
+ working_directory: << parameters.working_directory >>
notify_github:
parameters:
@@ -264,33 +321,16 @@ jobs:
release_custom_package:
parameters:
- npm_package:
- type: string
- android_package:
- type: string
- api_endpoint:
- type: string
+ prepare_steps:
+ type: steps
+ default: []
working_directory: ~/project
executor:
name: node/default
steps:
- advanced-checkout/shallow-checkout
+ - steps: << parameters.prepare_steps >>
- install_node_modules
- - run:
- name: Remove README.md file
- command: rm README.md
- - find_and_replace:
- files: package.json android/sourcemaps.gradle ios/sourcemaps.sh
- search: instabug-reactnative
- replace: << parameters.npm_package >>
- - find_and_replace:
- files: cli/UploadSourcemaps.ts cli/UploadSoFiles.ts
- search: api.instabug.com
- replace: << parameters.api_endpoint >>
- - find_and_replace:
- files: android/native.gradle
- search: 'com.instabug.library:instabug:'
- replace: 'com.instabug.library-<< parameters.android_package >>:instabug:'
- run:
name: Build the SDK
command: yarn build
@@ -301,45 +341,6 @@ jobs:
name: Publish new enterprise version
command: npm publish
- # Automate the enterprise D11 sdk changes
- release_d11:
- working_directory: ~/project
- executor:
- name: node/default
- steps:
- - advanced-checkout/shallow-checkout
- - install_node_modules
- - run:
- name: Remove README.md file
- command: rm README.md
- - find_and_replace:
- files: package.json ios/sourcemaps.sh android/sourcemaps.gradle
- search: instabug-reactnative
- replace: '@instabug/instabug-reactnative-dream11'
- - find_and_replace:
- files: cli/UploadSourcemaps.ts cli/UploadSoFiles.ts
- search: api.instabug.com
- replace: st001012dream11.instabug.com
- - find_and_replace:
- files: android/native.gradle
- search: com.instabug.library:instabug
- replace: 'com.instabug.library-dream11:instabug'
- - run:
- name: give exec permssion to d11 script
- command: chmod +x ./scripts/dream-11-delete-unused-features.sh
- - run:
- name: remove un-required features
- command: ./scripts/dream-11-delete-unused-features.sh
- - run:
- name: Build the SDK
- command: yarn build
- - run:
- name: Authorize with npm
- command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
- - run:
- name: Publish new enterprise version
- command: npm publish
-
publish:
macos:
xcode: 13.4.1
@@ -463,12 +464,6 @@ workflows:
filters:
branches:
only: master
- - hold_release_d11:
- requires: *release_dependencies
- type: approval
- filters:
- branches:
- only: dream11
- publish:
requires:
- hold_publish
@@ -481,6 +476,7 @@ workflows:
filters:
branches:
only: master
+
- hold_release_nn:
requires: *release_dependencies
type: approval
@@ -494,9 +490,12 @@ workflows:
filters:
branches:
only: master
- npm_package: '@instabug/react-native-nn'
- android_package: nn
- api_endpoint: st001009nn.instabug.com
+ prepare_steps:
+ - prepare_custom_package:
+ npm_package: '@instabug/react-native-nn'
+ android_package: nn
+ api_endpoint: st001009nn.instabug.com
+
- hold_release_injazat:
requires: *release_dependencies
type: approval
@@ -510,12 +509,24 @@ workflows:
filters:
branches:
only: master
- npm_package: '@instabug/react-native-injazat'
- android_package: injazat
- api_endpoint: st001013mec1.instabug.com
- - release_d11:
+ prepare_steps:
+ - prepare_custom_package:
+ npm_package: '@instabug/react-native-injazat'
+ android_package: injazat
+ api_endpoint: st001013mec1.instabug.com
+
+ - hold_release_dream11:
+ requires: *release_dependencies
+ type: approval
+ filters:
+ branches:
+ only: dream11
+ - release_custom_package:
+ name: release_dream11
requires:
- - hold_release_d11
+ - hold_release_dream11
filters:
branches:
only: dream11
+ prepare_steps:
+ - prepare_dream11
From 253c92ca72cbfb18ee94283eb033c0c7fdf94637 Mon Sep 17 00:00:00 2001
From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com>
Date: Thu, 22 Aug 2024 16:02:11 +0300
Subject: [PATCH 35/40] ci: run tests before enterprise releases (#1271)
---
.circleci/config.yml | 151 +++++++++++++++---
.../RNInstabugExampleReactnativePackage.java | 8 -
.../app/src/main/res/raw/instabug_config.json | 4 +
examples/default/android/build.gradle | 8 +
.../InstabugExample.xcodeproj/project.pbxproj | 4 +
.../ios/InstabugExample/Instabug.plist | Bin 0 -> 157 bytes
.../ios/InstabugTests/InstabugSampleTests.m | 1 -
.../ios/InstabugTests/RNInstabugTests.m | 1 -
ios/RNInstabug/InstabugReactBridge.h | 1 -
ios/RNInstabug/InstabugReactBridge.m | 1 -
scripts/customize-ios-endpoints.sh | 28 ++++
scripts/dream-11-delete-unused-features.sh | 70 ++++----
scripts/replace.js | 24 ++-
13 files changed, 231 insertions(+), 70 deletions(-)
create mode 100644 examples/default/android/app/src/main/res/raw/instabug_config.json
create mode 100644 examples/default/ios/InstabugExample/Instabug.plist
create mode 100755 scripts/customize-ios-endpoints.sh
mode change 100644 => 100755 scripts/dream-11-delete-unused-features.sh
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 64a6b4013a..d8334f0b32 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -17,6 +17,12 @@ references:
- e2e_ios
- e2e_android
+ dream11_prepare_config: &dream11_prepare_config
+ prepare_steps:
+ - prepare_dream11
+ requires:
+ - hold_test_dream11
+
commands:
install_node_modules:
parameters:
@@ -36,15 +42,28 @@ commands:
parameters:
working_directory:
type: string
+ deployment:
+ type: boolean
+ default: false
steps:
- restore_cache:
name: Restore Pods Cache
keys:
- v1-pods-{{ checksum "<< parameters.working_directory >>/Podfile.lock" }}
- - run:
- name: Install Pods
- working_directory: << parameters.working_directory >>
- command: pod install --deployment
+ - when:
+ condition: << parameters.deployment >>
+ steps:
+ - run:
+ name: Install Pods
+ working_directory: << parameters.working_directory >>
+ command: pod install --deployment
+ - unless:
+ condition: << parameters.deployment >>
+ steps:
+ - run:
+ name: Install Pods
+ working_directory: << parameters.working_directory >>
+ command: pod install
- save_cache:
name: Save Pods Cache
key: v1-pods-{{ checksum "<< parameters.working_directory >>/Podfile.lock" }}
@@ -120,6 +139,11 @@ commands:
name: Remove unused features
command: ./scripts/dream-11-delete-unused-features.sh
working_directory: << parameters.working_directory >>
+ # Remove the NDK package to avoid dependency conflicts on Android.
+ - run:
+ name: Remove the NDK package
+ command: yarn remove instabug-reactnative-ndk
+ working_directory: << parameters.working_directory >>/examples/default
notify_github:
parameters:
@@ -158,20 +182,38 @@ jobs:
command: yarn lint:ci
test_module:
+ parameters:
+ prepare_steps:
+ type: steps
+ default: []
+ collect_coverage:
+ type: boolean
+ default: false
executor:
name: node/default
steps:
- advanced-checkout/shallow-checkout
+ - steps: << parameters.prepare_steps >>
- install_node_modules
- run:
name: Run Tests
command: yarn test
- - persist_to_workspace:
- root: coverage
- paths:
- - lcov.info
+ - when:
+ condition: << parameters.collect_coverage >>
+ steps:
+ - persist_to_workspace:
+ root: coverage
+ paths:
+ - lcov.info
test_android:
+ parameters:
+ prepare_steps:
+ type: steps
+ default: []
+ collect_coverage:
+ type: boolean
+ default: false
executor:
name: android/android-machine
tag: '2024.01.1'
@@ -180,15 +222,18 @@ jobs:
INSTABUG_SOURCEMAPS_UPLOAD_DISABLE: true
steps:
- advanced-checkout/shallow-checkout
- # - node/install-yarn
+ - steps: << parameters.prepare_steps >>
- install_node_modules
- android/run-tests:
working-directory: android
test-command: ./gradlew test
- - persist_to_workspace:
- root: ~/project/android/build/reports/jacoco/jacocoTestReport
- paths:
- - jacocoTestReport.xml
+ - when:
+ condition: << parameters.collect_coverage >>
+ steps:
+ - persist_to_workspace:
+ root: ~/project/android/build/reports/jacoco/jacocoTestReport
+ paths:
+ - jacocoTestReport.xml
validate_shell_files:
machine:
@@ -217,10 +262,18 @@ jobs:
app-dir: examples/default
- install_pods:
working_directory: examples/default/ios
+ deployment: true
- run: git --no-pager diff
- run: git diff-index HEAD --exit-code -p -I EXCLUDED_ARCHS # Ignore Arch Changes
test_ios:
+ parameters:
+ prepare_steps:
+ type: steps
+ default: []
+ collect_coverage:
+ type: boolean
+ default: false
macos:
xcode: 13.4.1
resource_class: macos.m1.medium.gen1
@@ -229,6 +282,7 @@ jobs:
INSTABUG_SOURCEMAPS_UPLOAD_DISABLE: true
steps:
- advanced-checkout/shallow-checkout
+ - steps: << parameters.prepare_steps >>
- install_node_modules
- install_pods:
working_directory: ios
@@ -243,16 +297,23 @@ jobs:
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 13 Pro Max,OS=15.5' \
test | xcpretty
- - run:
- name: Convert xcresult into JSON report
- working_directory: ios/coverage
- command: xcrun xccov view --report --json result.xcresult > xcode.json
- - persist_to_workspace:
- root: ios/coverage
- paths:
- - xcode.json
+ - when:
+ condition: << parameters.collect_coverage >>
+ steps:
+ - run:
+ name: Convert xcresult into JSON report
+ working_directory: ios/coverage
+ command: xcrun xccov view --report --json result.xcresult > xcode.json
+ - persist_to_workspace:
+ root: ios/coverage
+ paths:
+ - xcode.json
e2e_ios:
+ parameters:
+ prepare_steps:
+ type: steps
+ default: []
macos:
xcode: 13.4.1
resource_class: macos.m1.medium.gen1
@@ -260,6 +321,7 @@ jobs:
INSTABUG_SOURCEMAPS_UPLOAD_DISABLE: true
steps:
- advanced-checkout/shallow-checkout
+ - steps: << parameters.prepare_steps >>
- install_node_modules
- node/install-packages:
pkg-manager: yarn
@@ -276,6 +338,11 @@ jobs:
name: Rebuild Detox.framework Cache
working_directory: examples/default
command: detox clean-framework-cache && detox build-framework-cache
+ # This is a workaround until the iOS SDK is updated to prioritize the custom
+ # Instabug.plist over the internal Config.plist.
+ - run:
+ name: Customize API Endpoints
+ command: ./scripts/customize-ios-endpoints.sh
- run:
name: Detox - Build Release App
working_directory: examples/default
@@ -286,6 +353,10 @@ jobs:
command: detox test --configuration ios.sim.release --cleanup
e2e_android:
+ parameters:
+ prepare_steps:
+ type: steps
+ default: []
executor:
name: android/android-machine
tag: '2024.01.1'
@@ -294,7 +365,7 @@ jobs:
INSTABUG_SOURCEMAPS_UPLOAD_DISABLE: true
steps:
- advanced-checkout/shallow-checkout
- # - node/install-yarn
+ - steps: << parameters.prepare_steps >>
- install_node_modules
- node/install-packages:
pkg-manager: yarn
@@ -439,11 +510,14 @@ workflows:
- test_android
- test_ios
- lint
- - test_module
- - test_android
+ - test_module:
+ collect_coverage: true
+ - test_android:
+ collect_coverage: true
+ - test_ios:
+ collect_coverage: true
- validate_shell_files
- sync_generated_files
- - test_ios
- e2e_ios
- e2e_android
- hold_generate_snapshot:
@@ -515,8 +589,33 @@ workflows:
android_package: injazat
api_endpoint: st001013mec1.instabug.com
+ # Dream11 tests
+ - hold_test_dream11:
+ type: approval
+ - test_module:
+ name: test_module_dream11
+ <<: *dream11_prepare_config
+ - test_android:
+ name: test_android_dream11
+ <<: *dream11_prepare_config
+ - test_ios:
+ name: test_ios_dream11
+ <<: *dream11_prepare_config
+ - e2e_android:
+ name: e2e_android_dream11
+ <<: *dream11_prepare_config
+ - e2e_ios:
+ name: e2e_ios_dream11
+ <<: *dream11_prepare_config
+
+ # Dream11 release
- hold_release_dream11:
- requires: *release_dependencies
+ requires:
+ - test_module_dream11
+ - test_android_dream11
+ - test_ios_dream11
+ - e2e_android_dream11
+ - e2e_ios_dream11
type: approval
filters:
branches:
diff --git a/examples/default/android/app/src/main/java/com/instabug/react/example/RNInstabugExampleReactnativePackage.java b/examples/default/android/app/src/main/java/com/instabug/react/example/RNInstabugExampleReactnativePackage.java
index 304ab68704..977afa782e 100644
--- a/examples/default/android/app/src/main/java/com/instabug/react/example/RNInstabugExampleReactnativePackage.java
+++ b/examples/default/android/app/src/main/java/com/instabug/react/example/RNInstabugExampleReactnativePackage.java
@@ -6,14 +6,6 @@
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
-import com.instabug.reactlibrary.RNInstabugAPMModule;
-import com.instabug.reactlibrary.RNInstabugBugReportingModule;
-import com.instabug.reactlibrary.RNInstabugCrashReportingModule;
-import com.instabug.reactlibrary.RNInstabugFeatureRequestsModule;
-import com.instabug.reactlibrary.RNInstabugReactnativeModule;
-import com.instabug.reactlibrary.RNInstabugRepliesModule;
-import com.instabug.reactlibrary.RNInstabugSessionReplayModule;
-import com.instabug.reactlibrary.RNInstabugSurveysModule;
import java.util.ArrayList;
import java.util.Collections;
diff --git a/examples/default/android/app/src/main/res/raw/instabug_config.json b/examples/default/android/app/src/main/res/raw/instabug_config.json
new file mode 100644
index 0000000000..86b3a7a225
--- /dev/null
+++ b/examples/default/android/app/src/main/res/raw/instabug_config.json
@@ -0,0 +1,4 @@
+{
+ "instabug-domain": "api.instabug.com",
+ "apm-domain": "api-apm.instabug.com"
+}
diff --git a/examples/default/android/build.gradle b/examples/default/android/build.gradle
index 0336ff851f..7fa616eb1b 100644
--- a/examples/default/android/build.gradle
+++ b/examples/default/android/build.gradle
@@ -27,5 +27,13 @@ allprojects {
maven {
url("$rootDir/../node_modules/detox/Detox-android")
}
+
+ maven {
+ credentials {
+ username System.getenv("DREAM11_MAVEN_USERNAME")
+ password System.getenv("DREAM11_MAVEN_PASSWORD")
+ }
+ url "https://mvn.instabug.com/nexus/repository/dream-11"
+ }
}
}
diff --git a/examples/default/ios/InstabugExample.xcodeproj/project.pbxproj b/examples/default/ios/InstabugExample.xcodeproj/project.pbxproj
index afe4ffe605..3b05a8f1e0 100644
--- a/examples/default/ios/InstabugExample.xcodeproj/project.pbxproj
+++ b/examples/default/ios/InstabugExample.xcodeproj/project.pbxproj
@@ -21,6 +21,7 @@
CC3DF8932A1DFC9A003E9914 /* InstabugSurveysTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CC3DF88B2A1DFC99003E9914 /* InstabugSurveysTests.m */; };
CC3DF8942A1DFC9A003E9914 /* InstabugAPMTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CC3DF88C2A1DFC99003E9914 /* InstabugAPMTests.m */; };
CC3DF8952A1DFC9A003E9914 /* IBGConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = CC3DF88D2A1DFC9A003E9914 /* IBGConstants.m */; };
+ CC487A9C2C71FCFC0021F680 /* Instabug.plist in Resources */ = {isa = PBXBuildFile; fileRef = CC487A9B2C71FCFC0021F680 /* Instabug.plist */; };
CCF1E4092B022CF20024802D /* RNInstabugTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CCF1E4082B022CF20024802D /* RNInstabugTests.m */; };
CD36F4707EA1F435D2CC7A15 /* libPods-InstabugExample-InstabugTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3AF7A6E02D40E0CEEA833CC4 /* libPods-InstabugExample-InstabugTests.a */; };
F7BF47401EF3A435254C97BB /* libPods-InstabugExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BAED0D0441A708AE2390E153 /* libPods-InstabugExample.a */; };
@@ -64,6 +65,7 @@
CC3DF88B2A1DFC99003E9914 /* InstabugSurveysTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InstabugSurveysTests.m; sourceTree = ""; };
CC3DF88C2A1DFC99003E9914 /* InstabugAPMTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InstabugAPMTests.m; sourceTree = ""; };
CC3DF88D2A1DFC9A003E9914 /* IBGConstants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IBGConstants.m; sourceTree = ""; };
+ CC487A9B2C71FCFC0021F680 /* Instabug.plist */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; name = Instabug.plist; path = InstabugExample/Instabug.plist; sourceTree = ""; };
CCF1E4082B022CF20024802D /* RNInstabugTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNInstabugTests.m; sourceTree = ""; };
DBCB1B1D023646D84146C91E /* Pods-InstabugExample-InstabugTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InstabugExample-InstabugTests.release.xcconfig"; path = "Target Support Files/Pods-InstabugExample-InstabugTests/Pods-InstabugExample-InstabugTests.release.xcconfig"; sourceTree = ""; };
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
@@ -120,6 +122,7 @@
13B07FAE1A68108700A75B9A /* InstabugExample */ = {
isa = PBXGroup;
children = (
+ CC487A9B2C71FCFC0021F680 /* Instabug.plist */,
13B07FAF1A68108700A75B9A /* AppDelegate.h */,
13B07FB01A68108700A75B9A /* AppDelegate.mm */,
13B07FB51A68108700A75B9A /* Images.xcassets */,
@@ -296,6 +299,7 @@
buildActionMask = 2147483647;
files = (
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */,
+ CC487A9C2C71FCFC0021F680 /* Instabug.plist in Resources */,
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
diff --git a/examples/default/ios/InstabugExample/Instabug.plist b/examples/default/ios/InstabugExample/Instabug.plist
new file mode 100644
index 0000000000000000000000000000000000000000..24d035f427616a1490762b3e7c6b8861c863c4a4
GIT binary patch
literal 157
zcmYc)$jK}&F)+Bq$i&PN=b2Yrl9*JQ?ik=38srlV;{w_70_qthB?ZM+`ud3lnYxJu
vxq6vU#d^v4xgbIP;*@OtGUIpwWh9ljRB`aiXaq5U0V5-XW?+TVFscFo;^Zpb
literal 0
HcmV?d00001
diff --git a/examples/default/ios/InstabugTests/InstabugSampleTests.m b/examples/default/ios/InstabugTests/InstabugSampleTests.m
index 565a21b1a7..70ef410258 100644
--- a/examples/default/ios/InstabugTests/InstabugSampleTests.m
+++ b/examples/default/ios/InstabugTests/InstabugSampleTests.m
@@ -8,7 +8,6 @@
#import
#import "OCMock/OCMock.h"
#import "Instabug/Instabug.h"
-#import "Instabug/IBGSurvey.h"
#import "InstabugReactBridge.h"
#import
#import "IBGConstants.h"
diff --git a/examples/default/ios/InstabugTests/RNInstabugTests.m b/examples/default/ios/InstabugTests/RNInstabugTests.m
index 0df2fd8430..cde248ad30 100644
--- a/examples/default/ios/InstabugTests/RNInstabugTests.m
+++ b/examples/default/ios/InstabugTests/RNInstabugTests.m
@@ -1,7 +1,6 @@
#import
#import "OCMock/OCMock.h"
#import "Instabug/Instabug.h"
-#import "Instabug/IBGSurvey.h"
#import
#import "RNInstabug.h"
#import "RNInstabug/Instabug+CP.h"
diff --git a/ios/RNInstabug/InstabugReactBridge.h b/ios/RNInstabug/InstabugReactBridge.h
index c2accc9955..a3cfc21c13 100644
--- a/ios/RNInstabug/InstabugReactBridge.h
+++ b/ios/RNInstabug/InstabugReactBridge.h
@@ -12,7 +12,6 @@
#import
#import
#import
-#import
#import
#import
#import "ArgsRegistry.h"
diff --git a/ios/RNInstabug/InstabugReactBridge.m b/ios/RNInstabug/InstabugReactBridge.m
index a6f56109c2..dd18513163 100644
--- a/ios/RNInstabug/InstabugReactBridge.m
+++ b/ios/RNInstabug/InstabugReactBridge.m
@@ -8,7 +8,6 @@
#import
#import
#import
-#import
#import
#import
#import
diff --git a/scripts/customize-ios-endpoints.sh b/scripts/customize-ios-endpoints.sh
new file mode 100755
index 0000000000..2fecd9d729
--- /dev/null
+++ b/scripts/customize-ios-endpoints.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+# Replaces the internal Config.plist file inside the Instabug iOS SDK with the
+# Instabug.plist file in the example app.
+#
+# This is a workaround until the iOS SDK is updated to prioritize the custom
+# Instabug.plist over the internal Config.plist.
+
+instabug_plist=examples/default/ios/InstabugExample/Instabug.plist
+
+if [ ! -f $instabug_plist ]; then
+ echo "Instabug.plist not found"
+ exit 1
+fi
+
+for dir in examples/default/ios/Pods/Instabug/Instabug.xcframework/ios-*/
+do
+ echo "Replacing Config.plist in $dir"
+
+ config_path=$dir/Instabug.framework/InstabugResources.bundle/Config.plist
+
+ if [ ! -f $config_path ]; then
+ echo "Config.plist not found in $dir"
+ exit 1
+ fi
+
+ cp -f $instabug_plist $config_path
+done
diff --git a/scripts/dream-11-delete-unused-features.sh b/scripts/dream-11-delete-unused-features.sh
old mode 100644
new mode 100755
index 58ab392885..fa10a9181e
--- a/scripts/dream-11-delete-unused-features.sh
+++ b/scripts/dream-11-delete-unused-features.sh
@@ -2,47 +2,61 @@
# remove survey and featureRequest features in JavaScript files
deletedFeaturesFilesInJavaScript=("Surveys" "FeatureRequests" "Survey")
-for feature in "${deletedFeaturesFilesInJavaScript[@]}";
- do
- echo "$feature"
-rm -f src/modules/"$feature".ts
-rm -f test/mocks/mock"$feature".ts
-sed -i "s/import..*$feature';//g" src/index.ts
-sed -i "s/$feature,//g" src/index.ts
-
+for feature in "${deletedFeaturesFilesInJavaScript[@]}"; do
+ echo "$feature"
+
+ rm -f src/modules/"$feature".ts
+ rm -f src/native/Native"$feature".ts
+ rm -f test/mocks/mock"$feature".ts
+ rm -f test/modules/"$feature".spec.ts
+
+ node scripts/replace.js --pattern "import.+$feature';" "" src/index.ts
+ node scripts/replace.js --pattern "$feature," "" src/index.ts
+ node scripts/replace.js --pattern ".*$feature.*" "" src/native/NativePackage.ts
+ node scripts/replace.js --pattern ".*$feature.*" "" test/mocks/mockNativeModules.ts
done
-npx eslint src/index.ts --fix
+
+npx eslint src/index.ts --fix
# remove survey and featureRequest features in Android files
deletedFeaturesFilesInAndroidApp=("RNInstabugSurveysModule" "RNInstabugFeatureRequestsModule")
-for feature in "${deletedFeaturesFilesInAndroidApp[@]}";
- do
- echo "$feature"
-
-rm -f android/src/main/java/com/instabug/reactlibrary/"$feature".java
-rm -f android/src/test/java/com/instabug/reactlibrary/"$feature"Test.java
-sed -i "s/modules.add(new $feature(reactContext));//g" android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java
+for feature in "${deletedFeaturesFilesInAndroidApp[@]}"; do
+ echo "$feature"
+ rm -f android/src/main/java/com/instabug/reactlibrary/"$feature".java
+ rm -f android/src/test/java/com/instabug/reactlibrary/"$feature"Test.java
+ node scripts/replace.js "modules.add(new $feature(reactContext));" "" android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java
done
# remove survey and featureRequest features in IOS files
deletedFeaturesFilesInIosApp=("InstabugSurveysBridge" "InstabugFeatureRequestsBridge")
-for feature in "${deletedFeaturesFilesInIosApp[@]}";
- do
- echo "$feature"
-rm -f ios/RNInstabug/"$feature".h
-rm -f ios/RNInstabug/"$feature".m
+for feature in "${deletedFeaturesFilesInIosApp[@]}"; do
+ echo "$feature"
+ rm -f ios/RNInstabug/"$feature".h
+ rm -f ios/RNInstabug/"$feature".m
done
-sed -i "s/\#import //g" ios/RNInstabug/InstabugReactBridge.m
-sed -i "s/\#import //g" ios/RNInstabug/InstabugReactBridge.h
+# Remove unused features iOS test files
+iosTestFiles=("InstabugSurveysTests.m" "InstabugFeatureRequestsTests.m")
+for file in "${iosTestFiles[@]}"; do
+ echo "Deleting $file"
+
+ rm -f examples/default/ios/InstabugTests/"$file"
+ node scripts/replace.js --pattern ".*$file.*" "" examples/default/ios/InstabugExample.xcodeproj/project.pbxproj
+done
-# remove all locales except English locale
-sed -i -E '/english/!s/.*constants.locale.*//g' src/utils/Enums.ts
-npx eslint src/index.ts --fix src/utils/Enums.ts
+node scripts/replace.js "#import " "" ios/RNInstabug/InstabugReactBridge.m
+node scripts/replace.js "#import " "" ios/RNInstabug/InstabugReactBridge.h
-sed -i "s/return (major == 7 && minor >= 3) || major >= 8/return false/g" android/build.gradle
+# Remove all locales except for English
+# This ugly regular expression matches all lines not containing "english" and containing "constants.locale"
+node scripts/replace.js --pattern "^(?!.*english).+constants\.locale.*" "" src/utils/Enums.ts
+npx eslint src/index.ts --fix src/utils/Enums.ts
-sed -i "s/static boolean supportsNamespace() {/static boolean supportsNamespace() { \n return false/g" android/build.gradle
+node scripts/replace.js "return (major == 7 && minor >= 3) || major >= 8" "return false" android/build.gradle
+# Note: printf is used here as the string contains a newline character which would be escaped otherwise.
+node scripts/replace.js "static boolean supportsNamespace() {" "$(printf "static boolean supportsNamespace() {\n return false")" android/build.gradle
+# Add Dream11 custom iOS build podspec to Podfile
+node scripts/replace.js "target 'InstabugExample' do" "$(printf "target 'InstabugExample' do\n pod 'Instabug', :podspec => 'https://ios-releases.instabug.com/custom/dream11/Instabug.podspec'")" examples/default/ios/Podfile
diff --git a/scripts/replace.js b/scripts/replace.js
index 5682b47265..aeb483ae8f 100644
--- a/scripts/replace.js
+++ b/scripts/replace.js
@@ -10,10 +10,25 @@
const fs = require('fs');
const path = require('path');
+const { parseArgs } = require('util');
-const [search, replace, ...files] = process.argv.slice(2);
+const { values, positionals } = parseArgs({
+ allowPositionals: true,
+ options: {
+ pattern: {
+ type: 'boolean',
+ default: false,
+ short: 'p',
+ },
+ },
+});
-if (!search || !replace || !files.length) {
+const [search, replace, ...files] = positionals;
+
+/** Whether to replace the search string as a regular expression or as a literal string. */
+const isPattern = values.pattern;
+
+if (search == null || replace == null || !files.length) {
// The path of the script relative to the directory where the user ran the
// script to be used in the error message demonstrating the usage.
const scriptPath = path.relative(process.cwd(), __filename);
@@ -21,7 +36,7 @@ if (!search || !replace || !files.length) {
console.error('Missing arguments.');
console.table({ search, replace, files });
- console.error(`Usage: node ${scriptPath} `);
+ console.error(`Usage: node ${scriptPath} [-p | --pattern] `);
process.exit(1);
}
@@ -31,7 +46,8 @@ for (const file of files) {
const fileContent = fs.readFileSync(filePath, 'utf8');
- const newContent = fileContent.replaceAll(search, replace);
+ const searchPattern = isPattern ? new RegExp(search, 'gm') : search;
+ const newContent = fileContent.replaceAll(searchPattern, replace);
fs.writeFileSync(filePath, newContent);
} catch (error) {
From 030fa97faa347d9794575a008f342ded77a9011c Mon Sep 17 00:00:00 2001
From: Ahmed Elrefaey <68241710+a7medev@users.noreply.github.com>
Date: Thu, 22 Aug 2024 17:35:40 +0300
Subject: [PATCH 36/40] ci: publish snapshots to npm (#1274)
---
.circleci/config.yml | 35 +++++++++++------------------------
scripts/snapshot-branch.sh | 30 ------------------------------
scripts/snapshot-comment.md | 4 ++--
scripts/snapshot-version.sh | 11 +++++++++++
4 files changed, 24 insertions(+), 56 deletions(-)
delete mode 100755 scripts/snapshot-branch.sh
create mode 100755 scripts/snapshot-version.sh
diff --git a/.circleci/config.yml b/.circleci/config.yml
index d8334f0b32..efca5acab3 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -469,35 +469,22 @@ jobs:
- run: yarn build
- run: yarn remove @instabug/danger-plugin-coverage
- run:
- name: Remove build files from .gitignore
- command: sed -i '/dist/d' .gitignore && sed -i '/bin/d' .gitignore
- - run:
- name: Get snapshot branch name
- command: |
- source scripts/snapshot-branch.sh
- echo "export SNAPSHOT_BRANCH=$SNAPSHOT_BRANCH" >> "$BASH_ENV"
- - run:
- name: Setup Git
- command: |
- git config --global user.name "Instabug-CP-CI"
- git config --global user.email github-ci+cp@instabug.com
- - run:
- name: Create snapshot branch
- command: git checkout -b $SNAPSHOT_BRANCH
- - run:
- name: Commit changes
+ name: Get snapshot version
command: |
- git add .
- git commit -m "chore: add generate files"
+ source scripts/snapshot-version.sh
+ echo "export SNAPSHOT_VERSION=$SNAPSHOT_VERSION" >> "$BASH_ENV"
- run:
- name: Push snapshot
- command: git push --force origin $SNAPSHOT_BRANCH
+ name: Authorize with NPM
+ command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
+ - run: npm version $SNAPSHOT_VERSION --no-git-tag-version
+ - run: npm publish --tag snapshot
- run:
name: Install jq
command: sudo apt-get update && sudo apt-get install -y jq
- - run:
- name: Replace snapshot branch in comment template
- command: sed -i "s|{BRANCH}|$SNAPSHOT_BRANCH|g" scripts/snapshot-comment.md
+ - find_and_replace:
+ files: scripts/snapshot-comment.md
+ search: '{VERSION}'
+ replace: $SNAPSHOT_VERSION
- notify_github:
data: "$(jq -Rcs '{ body: . }' scripts/snapshot-comment.md)"
diff --git a/scripts/snapshot-branch.sh b/scripts/snapshot-branch.sh
deleted file mode 100755
index 652dd1bb98..0000000000
--- a/scripts/snapshot-branch.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/bash
-
-pr_url="https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls?head=$CIRCLE_PROJECT_USERNAME:$CIRCLE_BRANCH&state=open"
-pr_response=$(curl --location --request GET "$pr_url" --header "Authorization: Bearer $RELEASE_GITHUB_TOKEN")
-
-if [ $(echo "$pr_response" | jq length) -eq 0 ]; then
- echo "No PR found, proceeding with branch name instead"
-
- SNAPSHOT_BRANCH="snapshot/$CIRCLE_BRANCH"
-else
- pr_description=$(echo "$pr_response" | jq -r '.[].body')
-
- # The `sed "s/\r//g"` is used to remove the carriage return character \r from the end of the string
- SNAPSHOT_BRANCH=$(echo -E "$pr_description" | grep 'Snapshot name:' | cut -d ':' -f 2 | xargs echo -n | sed "s/\r//g" || echo -n)
-
- if [ -z "$SNAPSHOT_BRANCH" ]; then
- echo "No custom snapshot name found, proceeding with default snapshot naming convention"
-
- version=$(jq -r '.version' package.json)
- jira_id=$(echo -E "$pr_description" | grep 'Jira ID:' | grep -Eo '[A-Z]+-[0-9]+' || echo -n)
-
- if [ -z "$jira_id" ]; then
- echo "No Jira ID found, proceeding with branch name instead"
-
- SNAPSHOT_BRANCH="snapshot/$CIRCLE_BRANCH"
- else
- SNAPSHOT_BRANCH="snapshot/$version-$jira_id"
- fi
- fi
-fi
diff --git a/scripts/snapshot-comment.md b/scripts/snapshot-comment.md
index 25ee16227b..6acb6d7267 100644
--- a/scripts/snapshot-comment.md
+++ b/scripts/snapshot-comment.md
@@ -5,11 +5,11 @@ Your snapshot has been generated! :rocket:
You can install the snapshot through NPM:
```sh
-npm install https://github.com/Instabug/Instabug-React-Native\#{BRANCH}
+npm install instabug-reactnative@{VERSION}
```
or Yarn:
```sh
-yarn add https://github.com/Instabug/Instabug-React-Native\#{BRANCH}
+yarn add instabug-reactnative@{VERSION}
```
diff --git a/scripts/snapshot-version.sh b/scripts/snapshot-version.sh
new file mode 100755
index 0000000000..7ba0a0fd58
--- /dev/null
+++ b/scripts/snapshot-version.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+# Generates a snapshot version following the format {version}-{pr}{random-3-digit}-SNAPSHOT
+# Example: 13.3.0-502861-SNAPSHOT
+
+pr=$(basename $CIRCLE_PULL_REQUEST)
+random=$(($RANDOM % 900 + 100))
+version=$(jq -r '.version' package.json)
+suffix="SNAPSHOT"
+
+SNAPSHOT_VERSION="$version-$pr$random-$suffix"
From ee836a130741b96a68809d2ecf642622a204c564 Mon Sep 17 00:00:00 2001
From: Ahmed alaa
Date: Thu, 12 Sep 2024 12:20:52 +0300
Subject: [PATCH 37/40] fix: changelog merge issues
---
CHANGELOG.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index acb003486f..80cd1b9fe2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@
### Added
- Add support for Expo Router navigation tracking ([#1270](https://github.com/Instabug/Instabug-React-Native/pull/1270)).
+- Enhance the network interceptor to capture some client error messages ([#1256](https://github.com/Instabug/Instabug-React-Native/pull/1256)).
## [13.3.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...v13.3.0) (August 4, 2024)
From 97350b4cc398100f788f736460e80c856fc62251 Mon Sep 17 00:00:00 2001
From: Ahmed alaa
Date: Thu, 12 Sep 2024 12:21:28 +0300
Subject: [PATCH 38/40] fix: changelog merge issues
---
CHANGELOG.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 80cd1b9fe2..3b1ee5e7b7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,7 +5,7 @@
### Added
- Add support for Expo Router navigation tracking ([#1270](https://github.com/Instabug/Instabug-React-Native/pull/1270)).
-- Enhance the network interceptor to capture some client error messages ([#1256](https://github.com/Instabug/Instabug-React-Native/pull/1256)).
+- Enhance the network interceptor to capture some client error messages ([#1257](https://github.com/Instabug/Instabug-React-Native/pull/1257)).
## [13.3.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...v13.3.0) (August 4, 2024)
From 0a16c77da86b2a2a90ab75559b4ba066fc6a074d Mon Sep 17 00:00:00 2001
From: Ahmed alaa
Date: Thu, 12 Sep 2024 17:03:42 +0300
Subject: [PATCH 39/40] fix: PR comments
---
src/utils/XhrNetworkInterceptor.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/utils/XhrNetworkInterceptor.ts b/src/utils/XhrNetworkInterceptor.ts
index bd6660a61d..54f4bf5108 100644
--- a/src/utils/XhrNetworkInterceptor.ts
+++ b/src/utils/XhrNetworkInterceptor.ts
@@ -153,7 +153,7 @@ export default {
const _response = this._response;
// Detect a more descriptive error message.
if (typeof _response === 'string' && _response.length > 0) {
- cloneNetwork.errorDomain = _response.replaceAll(' ', '-');
+ cloneNetwork.errorDomain = _response;
}
// @ts-ignore
From b1424becfea768de86f5b62c28ee9b45f45f5ff3 Mon Sep 17 00:00:00 2001
From: Ahmed alaa
Date: Sun, 15 Sep 2024 18:59:29 +0300
Subject: [PATCH 40/40] fix: merge issues
---
CHANGELOG.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3b1ee5e7b7..5516848a07 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,7 +5,7 @@
### Added
- Add support for Expo Router navigation tracking ([#1270](https://github.com/Instabug/Instabug-React-Native/pull/1270)).
-- Enhance the network interceptor to capture some client error messages ([#1257](https://github.com/Instabug/Instabug-React-Native/pull/1257)).
+- Enhance the network interceptor to capture more client error messages ([#1257](https://github.com/Instabug/Instabug-React-Native/pull/1257)).
## [13.3.0](https://github.com/Instabug/Instabug-React-Native/compare/v13.2.0...v13.3.0) (August 4, 2024)