diff --git a/CHANGELOG.md b/CHANGELOG.md index 77f97581f7..6ba6240c28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ ### Added +- Add support for expo updates versioning ([#1391](https://github.com/Instabug/Instabug-React-Native/pull/1391)) + - Add support enable/disable screenshot auto masking. ([#1389](https://github.com/Instabug/Instabug-React-Native/pull/1389)) - Add support for BugReporting user consents. ([#1383](https://github.com/Instabug/Instabug-React-Native/pull/1383)) diff --git a/android/native.gradle b/android/native.gradle index 7177b8c279..e5da252978 100644 --- a/android/native.gradle +++ b/android/native.gradle @@ -1,5 +1,5 @@ project.ext.instabug = [ - version: '14.3.0.6752106-SNAPSHOT' + version: '14.3.0.6745894-SNAPSHOT' ] dependencies { diff --git a/android/src/main/java/com/instabug/reactlibrary/ArgsRegistry.java b/android/src/main/java/com/instabug/reactlibrary/ArgsRegistry.java index 15fa45a1db..3c01751987 100644 --- a/android/src/main/java/com/instabug/reactlibrary/ArgsRegistry.java +++ b/android/src/main/java/com/instabug/reactlibrary/ArgsRegistry.java @@ -17,6 +17,7 @@ import com.instabug.library.invocation.util.InstabugVideoRecordingButtonPosition; import com.instabug.library.sessionreplay.model.SessionMetadata; import com.instabug.library.ui.onboarding.WelcomeMessage; +import com.instabug.library.util.overairversion.OverAirVersionType; import com.instabug.library.MaskingType; import java.util.ArrayList; @@ -61,6 +62,7 @@ static Map getAll() { putAll(locales); putAll(placeholders); putAll(launchType); + putAll(overAirUpdateService); putAll(autoMaskingTypes); putAll(userConsentActionType); }}; @@ -255,6 +257,11 @@ static Map getAll() { put("warm",SessionMetadata.LaunchType.WARM ); put("unknown","unknown"); }}; + + public static ArgsMap overAirUpdateService = new ArgsMap() {{ + put("expo", OverAirVersionType.EXPO); + put("codePush",OverAirVersionType.CODE_PUSH ); + }}; // Temporary workaround to be removed in future release // This is used for mapping native `LaunchType` values into React Native enum values. diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabug.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabug.java index 9b6348ab43..5ba1100e85 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabug.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabug.java @@ -6,6 +6,7 @@ import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; +import com.facebook.react.bridge.ReadableMap; import com.instabug.apm.APM; import com.instabug.library.Instabug; import com.instabug.library.LogLevel; @@ -156,6 +157,11 @@ public static class Builder { */ private String codePushVersion; + /** + * The overAirUpdate Version to be used for all reports. + */ + private ReadableMap overAirVersion; + /** * The events that trigger the SDK's user interface. */ @@ -210,6 +216,16 @@ public Builder setCodePushVersion(String codePushVersion) { return this; } + /** + * Sets over air update version to be used for all reports. + * + * @param overAirVersion the over air update version and service map. + */ + public Builder setOverAirVersion(ReadableMap overAirVersion) { + this.overAirVersion = overAirVersion; + return this; + } + /** * Sets the invocation triggering events for the SDK's user interface * @@ -237,6 +253,17 @@ public void build() { instabugBuilder.setCodePushVersion(codePushVersion); } + if (overAirVersion != null ) { + if (overAirVersion.hasKey("service") && overAirVersion.hasKey("version")) + { + if (overAirVersion.getString("service")!=null && overAirVersion.getString("version")!=null) + { + instabugBuilder.setOverAirVersion(overAirVersion.getString("version"), + ArgsRegistry.overAirUpdateService.get(overAirVersion.getString("service"))); + } + } + } + instabugBuilder.build(); // Temporarily disabling APM hot launches diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index 991dc97259..e93e409f56 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -148,7 +148,8 @@ public void init( final ReadableArray invocationEventValues, final String logLevel, final boolean useNativeNetworkInterception, - @Nullable final String codePushVersion + @Nullable final String codePushVersion, + @Nullable final ReadableMap overAirVersion ) { MainThreadHandler.runOnMainThread(new Runnable() { @Override @@ -173,6 +174,16 @@ public void run() { builder.setCodePushVersion(codePushVersion); } } + + if(overAirVersion != null ) { + if(Instabug.isBuilt()) { + Instabug.setOverAirVersion(overAirVersion.getString("version"), + ArgsRegistry.overAirUpdateService.get(overAirVersion.getString("service"))); + } else { + builder.setOverAirVersion(overAirVersion); + } + } + builder.build(); } }); @@ -192,6 +203,22 @@ public void run() { }); } + @ReactMethod + public void setOverAirVersion(@Nullable final ReadableMap overAirVersion) { + MainThreadHandler.runOnMainThread(new Runnable() { + @Override + public void run() { + try { + Instabug.setOverAirVersion(overAirVersion.getString("version"), + ArgsRegistry.overAirUpdateService.get(overAirVersion.getString("service"))); + + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + /** * Adds tag(s) to issues before sending them diff --git a/android/src/test/java/com/instabug/reactlibrary/RNInstabugReactnativeModuleTest.java b/android/src/test/java/com/instabug/reactlibrary/RNInstabugReactnativeModuleTest.java index 3083410f3d..7288660832 100644 --- a/android/src/test/java/com/instabug/reactlibrary/RNInstabugReactnativeModuleTest.java +++ b/android/src/test/java/com/instabug/reactlibrary/RNInstabugReactnativeModuleTest.java @@ -24,6 +24,7 @@ import com.instabug.library.featuresflags.model.IBGFeatureFlag; import com.instabug.library.internal.module.InstabugLocale; import com.instabug.library.ui.onboarding.WelcomeMessage; +import com.instabug.library.util.overairversion.OverAirVersionType; import com.instabug.reactlibrary.utils.MainThreadHandler; import com.instabug.library.MaskingType; @@ -214,6 +215,21 @@ public void testSetCodePushVersion() { mockInstabug.verify(() -> Instabug.setCodePushVersion(codePushVersion)); } + @Test + public void testSetOverAirVersion() { + WritableMap mockMap = mock(WritableMap.class); + + String version="D0A12345-6789-4B3C-A123-4567ABCDEF0"; + + when(mockMap.getString("version")).thenReturn(version); + when(mockMap.getString("service")).thenReturn("expo"); + + rnModule.setOverAirVersion(mockMap); + + mockInstabug.verify(() -> Instabug.setOverAirVersion( + version, OverAirVersionType.EXPO)); + } + @Test public void testIdentifyUserWithNoId() { // given diff --git a/examples/default/ios/InstabugTests/InstabugSampleTests.m b/examples/default/ios/InstabugTests/InstabugSampleTests.m index 76b4cbc0cb..968a2ac2ed 100644 --- a/examples/default/ios/InstabugTests/InstabugSampleTests.m +++ b/examples/default/ios/InstabugTests/InstabugSampleTests.m @@ -70,18 +70,26 @@ - (void)testInit { NSString *appToken = @"app_token"; NSString *codePushVersion = @"1.0.0(1)"; NSArray *invocationEvents = [NSArray arrayWithObjects:[NSNumber numberWithInteger:floatingButtonInvocationEvent], nil]; + NSDictionary *overAirVersion = @{ + @"service":@"expo", + @"version":@"D0A12345-6789-4B3C-A123-4567ABCDEF01" + }; BOOL useNativeNetworkInterception = YES; IBGSDKDebugLogsLevel sdkDebugLogsLevel = IBGSDKDebugLogsLevelDebug; + IBGOverAirType service = [ArgsRegistry.overAirServices[overAirVersion[@"service"]] intValue]; OCMStub([mock setCodePushVersion:codePushVersion]); + OCMStub([mock setOverAirVersion:overAirVersion[@"version"] withType:service]); - [self.instabugBridge init:appToken invocationEvents:invocationEvents debugLogsLevel:sdkDebugLogsLevel useNativeNetworkInterception:useNativeNetworkInterception codePushVersion:codePushVersion]; + [self.instabugBridge init:appToken invocationEvents:invocationEvents debugLogsLevel:sdkDebugLogsLevel useNativeNetworkInterception:useNativeNetworkInterception codePushVersion:codePushVersion overAirVersion:overAirVersion]; OCMVerify([mock setCodePushVersion:codePushVersion]); - + + OCMVerify([mock setOverAirVersion:overAirVersion[@"version"] withType:service]); + OCMVerify([self.mRNInstabug initWithToken:appToken invocationEvents:floatingButtonInvocationEvent debugLogsLevel:sdkDebugLogsLevel useNativeNetworkInterception:useNativeNetworkInterception]); } -- (void)testSetCodePushVersion { +- (void)test { id mock = OCMClassMock([Instabug class]); NSString *codePushVersion = @"123"; @@ -90,6 +98,20 @@ - (void)testSetCodePushVersion { OCMVerify([mock setCodePushVersion:codePushVersion]); } +- (void)testSetOverAirVersion { + id mock = OCMClassMock([Instabug class]); + NSDictionary *overAirVersion = @{ + @"service":@"expo", + @"version":@"D0A12345-6789-4B3C-A123-4567ABCDEF01" + }; + + [self.instabugBridge setOverAirVersion:overAirVersion]; + + IBGOverAirType service = [ArgsRegistry.overAirServices[overAirVersion[@"service"]] intValue]; + + OCMVerify([mock setOverAirVersion:overAirVersion[@"version"] withType:service]); +} + - (void)testSetUserData { id mock = OCMClassMock([Instabug class]); NSString *userData = @"user_data"; diff --git a/examples/default/ios/InstabugTests/RNInstabugTests.m b/examples/default/ios/InstabugTests/RNInstabugTests.m index abf355614f..94003f42ed 100644 --- a/examples/default/ios/InstabugTests/RNInstabugTests.m +++ b/examples/default/ios/InstabugTests/RNInstabugTests.m @@ -73,4 +73,26 @@ - (void) testSetCodePushVersion { OCMVerify([self.mInstabug setCodePushVersion:codePushVersion]); } +- (void)testSetOverAirVersionExpo { + NSDictionary *overAirVersion = @{ + @"service":@"expo", + @"version":@"D0A12345-6789-4B3C-A123-4567ABCDEF01" + }; + + [RNInstabug setOverAirVersion:overAirVersion]; + + OCMVerify([self.mInstabug setOverAirVersion:overAirVersion[@"version"] withType:IBGOverAirTypeExpo]); +} + +- (void)testSetOverAirVersionCodepush { + NSDictionary *overAirVersion = @{ + @"service":@"codePush", + @"version":@"2.0.0" + }; + + [RNInstabug setOverAirVersion:overAirVersion]; + + OCMVerify([self.mInstabug setOverAirVersion:overAirVersion[@"version"] withType:IBGOverAirTypeCodePush]); +} + @end diff --git a/examples/default/ios/Podfile b/examples/default/ios/Podfile index ea3be9c257..66e193af93 100644 --- a/examples/default/ios/Podfile +++ b/examples/default/ios/Podfile @@ -16,7 +16,7 @@ target 'InstabugExample' do rn_maps_path = '../node_modules/react-native-maps' pod 'react-native-google-maps', :path => rn_maps_path # add this line - pod 'Instabug', :podspec => 'https://ios-releases.instabug.com/custom/sanity/15.0.1/Instabug.podspec' + pod 'Instabug', :podspec => 'https://ios-releases.instabug.com/custom/feature-support_expo_updates-base/15.0.1/Instabug.podspec' # Flags change depending on the env values. flags = get_default_flags() diff --git a/examples/default/ios/Podfile.lock b/examples/default/ios/Podfile.lock index 9cde707ae3..7861baecd1 100644 --- a/examples/default/ios/Podfile.lock +++ b/examples/default/ios/Podfile.lock @@ -1626,7 +1626,7 @@ PODS: - ReactCommon/turbomodule/core - Yoga - RNInstabug (14.3.0): - - Instabug + - Instabug (= 15.0.1) - React-Core - RNReanimated (3.16.1): - DoubleConversion @@ -1770,7 +1770,7 @@ DEPENDENCIES: - fmt (from `../node_modules/react-native/third-party-podspecs/fmt.podspec`) - 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 (from `https://ios-releases.instabug.com/custom/sanity/15.0.1/Instabug.podspec`) + - Instabug (from `https://ios-releases.instabug.com/custom/feature-support_expo_updates-base/15.0.1/Instabug.podspec`) - instabug-reactnative-ndk (from `../node_modules/instabug-reactnative-ndk`) - OCMock - RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`) @@ -1869,7 +1869,7 @@ EXTERNAL SOURCES: :podspec: "../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec" :tag: hermes-2024-08-15-RNv0.75.1-4b3bf912cc0f705b51b71ce1a5b8bd79b93a451b Instabug: - :podspec: https://ios-releases.instabug.com/custom/sanity/15.0.1/Instabug.podspec + :podspec: https://ios-releases.instabug.com/custom/feature-support_expo_updates-base/15.0.1/Instabug.podspec instabug-reactnative-ndk: :path: "../node_modules/instabug-reactnative-ndk" RCT-Folly: @@ -2024,7 +2024,7 @@ SPEC CHECKSUMS: Google-Maps-iOS-Utils: f77eab4c4326d7e6a277f8e23a0232402731913a GoogleMaps: 032f676450ba0779bd8ce16840690915f84e57ac hermes-engine: ea92f60f37dba025e293cbe4b4a548fd26b610a0 - Instabug: 9e81b71be68626dafc74759f3458f7c5894dd2e1 + Instabug: 0361d294a630f64f4d6f43a5b14b752c05ed33bd instabug-reactnative-ndk: d765ac289d56e8896398d02760d9abf2562fc641 OCMock: 589f2c84dacb1f5aaf6e4cec1f292551fe748e74 RCT-Folly: 4464f4d875961fce86008d45f4ecf6cef6de0740 @@ -2092,7 +2092,7 @@ SPEC CHECKSUMS: ReactCommon: 6a952e50c2a4b694731d7682aaa6c79bc156e4ad RNCClipboard: 2821ac938ef46f736a8de0c8814845dde2dcbdfb RNGestureHandler: 511250b190a284388f9dd0d2e56c1df76f14cfb8 - RNInstabug: a038636a8fb8e078e69d3c51fca38396fa1ffdab + RNInstabug: 8e04255f8502e9d5ed698cfa6004250eb5f47c34 RNReanimated: f42a5044d121d68e91680caacb0293f4274228eb RNScreens: c7ceced6a8384cb9be5e7a5e88e9e714401fd958 RNSVG: 8b1a777d54096b8c2a0fd38fc9d5a454332bbb4d diff --git a/examples/default/src/App.tsx b/examples/default/src/App.tsx index 1220028577..45f5ed48f8 100644 --- a/examples/default/src/App.tsx +++ b/examples/default/src/App.tsx @@ -13,6 +13,7 @@ import Instabug, { NetworkLogger, ReproStepsMode, SessionReplay, + OverAirUpdateServices, } from 'instabug-reactnative'; import { NativeBaseProvider } from 'native-base'; @@ -51,6 +52,7 @@ export const App: React.FC = () => { invocationEvents: [InvocationEvent.floatingButton], debugLogsLevel: LogLevel.verbose, networkInterceptionMode: NetworkInterceptionMode.native, + overAirVersion: { service: OverAirUpdateServices.codePush, version: '1.0.0' }, }); CrashReporting.setNDKCrashesEnabled(true); diff --git a/examples/default/src/screens/HomeScreen.tsx b/examples/default/src/screens/HomeScreen.tsx index 7a5aeeb466..bee9905e6e 100644 --- a/examples/default/src/screens/HomeScreen.tsx +++ b/examples/default/src/screens/HomeScreen.tsx @@ -1,7 +1,6 @@ import React from 'react'; import type { NativeStackScreenProps } from '@react-navigation/native-stack'; - import { ListTile } from '../components/ListTile'; import { Screen } from '../components/Screen'; import type { HomeStackParamList } from '../navigation/HomeStack'; diff --git a/ios/RNInstabug/ArgsRegistry.h b/ios/RNInstabug/ArgsRegistry.h index c760ae36c1..2197a8c312 100644 --- a/ios/RNInstabug/ArgsRegistry.h +++ b/ios/RNInstabug/ArgsRegistry.h @@ -23,6 +23,7 @@ typedef NSDictionary ArgsDictionary; + (ArgsDictionary *) locales; + (ArgsDictionary *)nonFatalExceptionLevel; + (ArgsDictionary *) launchType; ++ (ArgsDictionary *) overAirServices; + (ArgsDictionary *) userConsentActionTypes; + (NSDictionary *) placeholders; diff --git a/ios/RNInstabug/ArgsRegistry.m b/ios/RNInstabug/ArgsRegistry.m index 8fb1e9b77d..b96229775a 100644 --- a/ios/RNInstabug/ArgsRegistry.m +++ b/ios/RNInstabug/ArgsRegistry.m @@ -21,6 +21,8 @@ + (NSMutableDictionary *) getAll { [all addEntriesFromDictionary:ArgsRegistry.nonFatalExceptionLevel]; [all addEntriesFromDictionary:ArgsRegistry.placeholders]; [all addEntriesFromDictionary:ArgsRegistry.launchType]; + [all addEntriesFromDictionary:ArgsRegistry.overAirServices]; + [all addEntriesFromDictionary:ArgsRegistry.autoMaskingTypes]; [all addEntriesFromDictionary:ArgsRegistry.userConsentActionTypes]; @@ -256,6 +258,12 @@ + (ArgsDictionary *) launchType { @"unknown":@(LaunchTypeUnknown) }; } ++ (ArgsDictionary *) overAirServices { + return @{ + @"expo":@(IBGOverAirTypeExpo) , + @"codePush":@(IBGOverAirTypeCodePush), + }; +} + (ArgsDictionary *)autoMaskingTypes { return @{ diff --git a/ios/RNInstabug/InstabugReactBridge.h b/ios/RNInstabug/InstabugReactBridge.h index 8d6efcf69c..1ecc1cde2f 100644 --- a/ios/RNInstabug/InstabugReactBridge.h +++ b/ios/RNInstabug/InstabugReactBridge.h @@ -26,10 +26,12 @@ - (void)setEnabled:(BOOL)isEnabled; -- (void)init:(NSString *)token invocationEvents:(NSArray *)invocationEventsArray debugLogsLevel:(IBGSDKDebugLogsLevel)sdkDebugLogsLevel useNativeNetworkInterception:(BOOL)useNativeNetworkInterception codePushVersion:(NSString *)codePushVersion; +- (void)init:(NSString *)token invocationEvents:(NSArray *)invocationEventsArray debugLogsLevel:(IBGSDKDebugLogsLevel)sdkDebugLogsLevel useNativeNetworkInterception:(BOOL)useNativeNetworkInterception codePushVersion:(NSString *)codePushVersion overAirVersion:(NSDictionary *)overAirVersion; - (void)setCodePushVersion:(NSString *)version; +- (void)setOverAirVersion:(NSDictionary *)overAirVersion; + - (void)setUserData:(NSString *)userData; - (void)setTrackUserSteps:(BOOL)isEnabled; diff --git a/ios/RNInstabug/InstabugReactBridge.m b/ios/RNInstabug/InstabugReactBridge.m index a2c75aa551..851f338f25 100644 --- a/ios/RNInstabug/InstabugReactBridge.m +++ b/ios/RNInstabug/InstabugReactBridge.m @@ -41,7 +41,9 @@ - (dispatch_queue_t)methodQueue { invocationEvents:(NSArray *)invocationEventsArray debugLogsLevel:(IBGSDKDebugLogsLevel)sdkDebugLogsLevel useNativeNetworkInterception:(BOOL)useNativeNetworkInterception - codePushVersion:(NSString *)codePushVersion) { + codePushVersion:(NSString *)codePushVersion + overAirVersion :(NSDictionary *)overAirVersion + ) { IBGInvocationEvent invocationEvents = 0; for (NSNumber *boxedValue in invocationEventsArray) { @@ -50,6 +52,9 @@ - (dispatch_queue_t)methodQueue { [Instabug setCodePushVersion:codePushVersion]; + IBGOverAirType service = [ArgsRegistry.overAirServices[overAirVersion[@"service"]] intValue]; + [Instabug setOverAirVersion:overAirVersion[@"version"] withType:service]; + [RNInstabug initWithToken:token invocationEvents:invocationEvents debugLogsLevel:sdkDebugLogsLevel @@ -60,6 +65,11 @@ - (dispatch_queue_t)methodQueue { [Instabug setCodePushVersion:version]; } +RCT_EXPORT_METHOD(setOverAirVersion:(NSDictionary *)overAirVersion) { + IBGOverAirType service = [ArgsRegistry.overAirServices[overAirVersion[@"service"]] intValue]; + [Instabug setOverAirVersion:overAirVersion[@"version"] withType:service]; +} + RCT_EXPORT_METHOD(setReproStepsConfig:(IBGUserStepsMode)bugMode :(IBGUserStepsMode)crashMode:(IBGUserStepsMode)sessionReplayMode) { [Instabug setReproStepsFor:IBGIssueTypeBug withMode:bugMode]; [Instabug setReproStepsFor:IBGIssueTypeCrash withMode:crashMode]; diff --git a/ios/RNInstabug/RNInstabug.h b/ios/RNInstabug/RNInstabug.h index 70612fef70..1f93a44e46 100644 --- a/ios/RNInstabug/RNInstabug.h +++ b/ios/RNInstabug/RNInstabug.h @@ -2,6 +2,7 @@ #define RNInstabug_h #import +#import "ArgsRegistry.h" @interface RNInstabug : NSObject @@ -27,6 +28,8 @@ useNativeNetworkInterception:(BOOL)useNativeNetworkInterception; */ + (void)setCodePushVersion:(NSString *)codePushVersion; ++ (void)setOverAirVersion:(NSDictionary *)overAirVersion; + @end #endif /* RNInstabug_h */ diff --git a/ios/RNInstabug/RNInstabug.m b/ios/RNInstabug/RNInstabug.m index 3ea51ae594..c8b91329d1 100644 --- a/ios/RNInstabug/RNInstabug.m +++ b/ios/RNInstabug/RNInstabug.m @@ -61,6 +61,12 @@ + (void)setCodePushVersion:(NSString *)codePushVersion { [Instabug setCodePushVersion:codePushVersion]; } ++ (void)setOverAirVersion:(NSDictionary *)overAirVersion { + IBGOverAirType service = [ArgsRegistry.overAirServices[overAirVersion[@"service"]] intValue]; + [Instabug setOverAirVersion:overAirVersion[@"version"] withType:service]; +} + + // Note: This function is used to bridge IBGNSLog with RCTLogFunction. // This log function should not be used externally and is only an implementation detail. void RNIBGLog(IBGLogLevel logLevel, NSString *format, ...) { diff --git a/src/models/InstabugConfig.ts b/src/models/InstabugConfig.ts index 614ade8925..73a12ad002 100644 --- a/src/models/InstabugConfig.ts +++ b/src/models/InstabugConfig.ts @@ -1,4 +1,5 @@ import type { InvocationEvent, LogLevel, NetworkInterceptionMode } from '../utils/Enums'; +import type { OverAirUpdate } from './OverAirUpdate'; export interface InstabugConfig { /** @@ -29,4 +30,9 @@ export interface InstabugConfig { * @default NetworkInterceptionMode.javascript */ networkInterceptionMode?: NetworkInterceptionMode; + + /** + * An optional over air service update version to be used for all reports. + */ + overAirVersion?: OverAirUpdate; } diff --git a/src/models/OverAirUpdate.ts b/src/models/OverAirUpdate.ts new file mode 100644 index 0000000000..dd7de040fa --- /dev/null +++ b/src/models/OverAirUpdate.ts @@ -0,0 +1,14 @@ +import { OverAirUpdateServices } from '../utils/Enums'; +export interface OverAirUpdate { + /** + * the name of OTA service + * e.g. `codePush` or `expo` + */ + service: OverAirUpdateServices; + + /** + * The version or UUID of the OTA service + */ + + version: string; +} diff --git a/src/modules/Instabug.ts b/src/modules/Instabug.ts index 1bcd5bf8b5..b0807163a4 100644 --- a/src/modules/Instabug.ts +++ b/src/modules/Instabug.ts @@ -42,6 +42,7 @@ import { NativeNetworkLogger } from '../native/NativeNetworkLogger'; import InstabugConstants from '../utils/InstabugConstants'; import { InstabugRNConfig } from '../utils/config'; import { Logger } from '../utils/logger'; +import type { OverAirUpdate } from '../models/OverAirUpdate'; let _currentScreen: string | null = null; let _lastScreen: string | null = null; @@ -275,6 +276,7 @@ const initializeNativeInstabug = (config: InstabugConfig) => { shouldEnableNativeInterception && config.networkInterceptionMode === NetworkInterceptionMode.native, config.codePushVersion, + config.overAirVersion, ); }; @@ -317,11 +319,22 @@ function addOnFeatureUpdatedListener(config: InstabugConfig) { /** * Sets the Code Push version to be sent with each report. * @param version the Code Push version. + * + * @deprecated Use {@link setOverAirVersion} instead. */ export const setCodePushVersion = (version: string) => { NativeInstabug.setCodePushVersion(version); }; +/** + * Sets over air update version to be sent with each report. + * @param version the OTA version. + * + */ +export const setOverAirVersion = (OTAserviceVersion: OverAirUpdate) => { + NativeInstabug.setOverAirVersion(OTAserviceVersion); +}; + /** * Attaches user data to each report being sent. * Each call to this method overrides the user data to be attached. diff --git a/src/native/NativeConstants.ts b/src/native/NativeConstants.ts index f95634caf7..22891ebf35 100644 --- a/src/native/NativeConstants.ts +++ b/src/native/NativeConstants.ts @@ -14,6 +14,7 @@ export type NativeConstants = NativeSdkDebugLogsLevel & NativeNonFatalErrorLevel & NativeStringKey & NativeLaunchType & + NativeOverAirUpdateServices & NativeAutoMaskingType & NativeUserConsentActionType; @@ -202,6 +203,10 @@ interface NativeLaunchType { unknown: any; } +interface NativeOverAirUpdateServices { + expo: any; + codePush: any; +} interface NativeAutoMaskingType { labels: any; textInputs: any; diff --git a/src/native/NativeInstabug.ts b/src/native/NativeInstabug.ts index c9204a4c59..a27590375b 100644 --- a/src/native/NativeInstabug.ts +++ b/src/native/NativeInstabug.ts @@ -14,6 +14,7 @@ import type { import type { NativeConstants } from './NativeConstants'; import type { W3cExternalTraceAttributes } from '../models/W3cExternalTraceAttributes'; import { NativeModules } from './NativePackage'; +import type { OverAirUpdate } from '../models/OverAirUpdate'; export interface InstabugNativeModule extends NativeModule { getConstants(): NativeConstants; @@ -26,11 +27,13 @@ export interface InstabugNativeModule extends NativeModule { debugLogsLevel: LogLevel, useNativeNetworkInterception: boolean, codePushVersion?: string, + overAirVersion?: OverAirUpdate, ): void; show(): void; // Misc APIs // setCodePushVersion(version: string): void; + setOverAirVersion(OTAserviceVersion: OverAirUpdate): void; setIBGLogPrintsToConsole(printsToConsole: boolean): void; setSessionProfilerEnabled(isEnabled: boolean): void; diff --git a/src/utils/Enums.ts b/src/utils/Enums.ts index 1859ed2bed..7044f49a23 100644 --- a/src/utils/Enums.ts +++ b/src/utils/Enums.ts @@ -250,6 +250,14 @@ export enum LaunchType { */ warm = constants.warm, } + +/** + * Over Air Update Service + */ +export enum OverAirUpdateServices { + codePush = constants.codePush, + expo = constants.expo, +} export enum AutoMaskingType { labels = constants.labels, textInputs = constants.textInputs, diff --git a/test/mocks/mockInstabug.ts b/test/mocks/mockInstabug.ts index 05d817b353..fe9abe234f 100644 --- a/test/mocks/mockInstabug.ts +++ b/test/mocks/mockInstabug.ts @@ -14,6 +14,7 @@ const mockInstabug: InstabugNativeModule = { setEnabled: jest.fn(), init: jest.fn(), setCodePushVersion: jest.fn(), + setOverAirVersion: jest.fn(), setUserData: jest.fn(), setTrackUserSteps: jest.fn(), setIBGLogPrintsToConsole: jest.fn(), diff --git a/test/modules/Instabug.spec.ts b/test/modules/Instabug.spec.ts index 904cefb7d7..a817051ed6 100644 --- a/test/modules/Instabug.spec.ts +++ b/test/modules/Instabug.spec.ts @@ -18,6 +18,7 @@ import { Locale, LogLevel, NetworkInterceptionMode, + OverAirUpdateServices, ReproStepsMode, StringKey, WelcomeMessageMode, @@ -289,6 +290,10 @@ describe('Instabug Module', () => { invocationEvents: [InvocationEvent.floatingButton, InvocationEvent.shake], debugLogsLevel: LogLevel.debug, codePushVersion: '1.1.0', + overAirVersion: { + service: OverAirUpdateServices.expo, + version: 'D0A12345-6789-4B3C-A123-4567ABCDEF01', + }, }; const usesNativeNetworkInterception = false; @@ -302,6 +307,7 @@ describe('Instabug Module', () => { instabugConfig.debugLogsLevel, usesNativeNetworkInterception, instabugConfig.codePushVersion, + instabugConfig.overAirVersion, ); }); @@ -314,6 +320,18 @@ describe('Instabug Module', () => { expect(NativeInstabug.setCodePushVersion).toBeCalledWith(codePushVersion); }); + it('setOverAirVersion should call native method setOverAirVersion', () => { + const OTAversion = { + service: OverAirUpdateServices.expo, + version: 'D0A12345-6789-4B3C-A123-4567ABCDEF01', + }; + + Instabug.setOverAirVersion(OTAversion); + + expect(NativeInstabug.setOverAirVersion).toBeCalledTimes(1); + expect(NativeInstabug.setOverAirVersion).toBeCalledWith(OTAversion); + }); + it('init should disable JavaScript interceptor when using native interception mode', async () => { const instabugConfig = { token: 'some-token', @@ -321,6 +339,10 @@ describe('Instabug Module', () => { debugLogsLevel: LogLevel.debug, networkInterceptionMode: NetworkInterceptionMode.native, codePushVersion: '1.1.0', + overAirVersion: { + service: OverAirUpdateServices.expo, + version: 'D0A12345-6789-4B3C-A123-4567ABCDEF01', + }, }; // Stubbing Network feature flags @@ -342,6 +364,7 @@ describe('Instabug Module', () => { // usesNativeNetworkInterception should be false when using native interception mode with Android false, instabugConfig.codePushVersion, + instabugConfig.overAirVersion, ); } else { expect(NativeInstabug.init).toBeCalledTimes(1); @@ -353,6 +376,7 @@ describe('Instabug Module', () => { // usesNativeNetworkInterception should be true when using native interception mode with iOS true, instabugConfig.codePushVersion, + instabugConfig.overAirVersion, ); } }); @@ -934,6 +958,10 @@ describe('Instabug iOS initialization tests', () => { debugLogsLevel: LogLevel.debug, networkInterceptionMode: NetworkInterceptionMode.native, codePushVersion: '1.1.0', + overAirVersion: { + service: OverAirUpdateServices.expo, + version: 'D0A12345-6789-4B3C-A123-4567ABCDEF01', + }, }; // Fast-forward until all timers have been executed jest.advanceTimersByTime(1000); @@ -952,6 +980,7 @@ describe('Instabug iOS initialization tests', () => { config.debugLogsLevel, false, // Disable native interception config.codePushVersion, + config.overAirVersion, ); }); @@ -970,6 +999,7 @@ describe('Instabug iOS initialization tests', () => { config.debugLogsLevel, true, // Enable native interception config.codePushVersion, + config.overAirVersion, ); }); @@ -988,6 +1018,7 @@ describe('Instabug iOS initialization tests', () => { config.debugLogsLevel, false, // Disable native interception config.codePushVersion, + config.overAirVersion, ); }); @@ -1017,6 +1048,10 @@ describe('Instabug Android initialization tests', () => { debugLogsLevel: LogLevel.debug, networkInterceptionMode: NetworkInterceptionMode.javascript, codePushVersion: '1.1.0', + overAirVersion: { + service: OverAirUpdateServices.expo, + version: 'D0A12345-6789-4B3C-A123-4567ABCDEF01', + }, }; }); @@ -1032,6 +1067,7 @@ describe('Instabug Android initialization tests', () => { config.debugLogsLevel, false, // always disable native interception to insure sending network logs to core (Bugs & Crashes). config.codePushVersion, + config.overAirVersion, ); }); });