=> {
+ 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/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/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/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/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/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/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 102b0bb0aa..88db2c4be9 100644
--- a/examples/default/ios/InstabugTests/InstabugSampleTests.m
+++ b/examples/default/ios/InstabugTests/InstabugSampleTests.m
@@ -8,12 +8,12 @@
#import
#import "OCMock/OCMock.h"
#import "Instabug/Instabug.h"
-#import "Instabug/IBGSurvey.h"
#import "InstabugReactBridge.h"
#import
#import "IBGConstants.h"
#import "RNInstabug.h"
#import
+
@protocol InstabugCPTestProtocol
/**
* This protocol helps in correctly mapping Instabug mocked methods
@@ -72,7 +72,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];
@@ -84,9 +84,9 @@ - (void)testInit {
- (void)testSetCodePushVersion {
id mock = OCMClassMock([Instabug class]);
NSString *codePushVersion = @"123";
-
+
[self.instabugBridge setCodePushVersion:codePushVersion];
-
+
OCMVerify([mock setCodePushVersion:codePushVersion]);
}
@@ -353,8 +353,7 @@ - (void)testNetworkLogIOS {
startTime:startTime
duration:duration
gqlQueryName:gqlQueryName
- serverErrorMessage:serverErrorMessage
- w3cExternalTraceAttributes:nil
+ w3cExternalTraceAttributes:nil
];
OCMVerify([mIBGNetworkLogger addNetworkLogWithUrl:url
@@ -372,7 +371,6 @@ - (void)testNetworkLogIOS {
startTime:startTime * 1000
duration:duration * 1000
gqlQueryName:gqlQueryName
- serverErrorMessage:serverErrorMessage
isW3cCaughted:nil
partialID:nil
timestamp:nil
@@ -570,4 +568,43 @@ - (void) testIsW3CaughtHeaderEnabled {
}
+- (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/ios/InstabugTests/RNInstabugTests.m b/examples/default/ios/InstabugTests/RNInstabugTests.m
index 70320a4cf0..930da52ca5 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/examples/default/ios/Podfile b/examples/default/ios/Podfile
index 63c0029932..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 e6b560a9da..2993610539 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
- React-Core
- RNReanimated (3.5.4):
@@ -748,7 +748,7 @@ SPEC CHECKSUMS:
ReactCommon: 3ccb8fb14e6b3277e38c73b0ff5e4a1b8db017a9
RNCClipboard: 41d8d918092ae8e676f18adada19104fa3e68495
RNGestureHandler: 6e46dde1f87e5f018a54fe5d40cd0e0b942b49ee
- RNInstabug: e515e490416a20b604e27bdbbebf5316ff3a2012
+ RNInstabug: 80b369d623a473c31ff3b8b8ea1d17daaca44132
RNReanimated: ab2e96c6d5591c3dfbb38a464f54c8d17fb34a87
RNScreens: b21dc57dfa2b710c30ec600786a3fc223b1b92e7
RNSVG: 80584470ff1ffc7994923ea135a3e5ad825546b9
@@ -756,6 +756,6 @@ SPEC CHECKSUMS:
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Yoga: 8796b55dba14d7004f980b54bcc9833ee45b28ce
-PODFILE CHECKSUM: 26b8b1f0273d40b2b21568157bd5df0421935faa
+PODFILE CHECKSUM: 281036e04bd4b9e7c2cc03a503b3245d3f1dd0dd
-COCOAPODS: 1.12.0
+COCOAPODS: 1.15.2
diff --git a/examples/default/src/App.tsx b/examples/default/src/App.tsx
index d92db633c1..33a3c34f94 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,17 @@ export const App: React.FC = () => {
});
}, []);
+ useEffect(() => {
+ const unregisterListener = Instabug.setNavigationListener(navigationRef);
+
+ return unregisterListener;
+ }, [navigationRef]);
+
return (
-
+
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}
+ />
+
+
+
+
+
+
+
+
+