Skip to content

Commit 69d66c5

Browse files
feat: support expo updates (#1391)
* feat: xcode 16 support * feat: xcode 16 support * feat: xcode 16 support * feat: xcode 16 support * feat: xcode 16 support * feat: xcode 16 support * feat: xcode 16 support * feat: xcode 16 support * feat: xcode 16 support * feat: xcode 16 support * feat: xcode 16 support * chore: integrate iOS expo updates support custom build * feat[ios]: add setOverAirVersion * feat[ios]: test setOverAirVersion * feat: add setOverAirVersion * feat: test setOverAirVersion * chore[ios]: revert old cocoapods version * chore(example): revert old example app * chore (example): fix lint * chore(android): integrate with expo updates android snapshot * feat(android): add setOverAirVersion API * chore: add changelog item * chore(android): remove log * chore(iOS): fix failing CI * chore(ios): workaround failing CI * ci: fix ci running * ci: fix ci running * chore(android): add dependency * chore(CI): fix sync_generated_files task * chore(CI): fix sync_generated_files task * chore(android): update snapshot * chore(CI): fix ios sync * chore: fix CI sync_generated_files job * hore: fix CI sync_generated_files job * chore(ios): update custom build * chore: fix CI sync_generated_files job * fix(ios): service type mismatch * fix(ios): fix test SetOverAirVersion * fix(ios): fix test SetOverAirVersion * chore: fix CI job * chore: revert old podfile.lock * feat: add new ios custom build * chore: add latest android snapshot * fix: type conversion * fix: ios test cases * fix: migration issue * fix: migration issue * fix: podfile issue --------- Co-authored-by: Ahmed alaa <[email protected]> Co-authored-by: ahmed alaa <[email protected]>
1 parent 46c64df commit 69d66c5

File tree

25 files changed

+249
-10
lines changed

25 files changed

+249
-10
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434

3535
### Added
3636

37+
- Add support for expo updates versioning ([#1391](https://github.com/Instabug/Instabug-React-Native/pull/1391))
38+
3739
- Add support enable/disable screenshot auto masking. ([#1389](https://github.com/Instabug/Instabug-React-Native/pull/1389))
3840

3941
- Add support for BugReporting user consents. ([#1383](https://github.com/Instabug/Instabug-React-Native/pull/1383))

android/src/main/java/com/instabug/reactlibrary/ArgsRegistry.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.instabug.library.invocation.util.InstabugVideoRecordingButtonPosition;
1818
import com.instabug.library.sessionreplay.model.SessionMetadata;
1919
import com.instabug.library.ui.onboarding.WelcomeMessage;
20+
import com.instabug.library.util.overairversion.OverAirVersionType;
2021
import com.instabug.library.MaskingType;
2122

2223
import java.util.ArrayList;
@@ -61,6 +62,7 @@ static Map<String, Object> getAll() {
6162
putAll(locales);
6263
putAll(placeholders);
6364
putAll(launchType);
65+
putAll(overAirUpdateService);
6466
putAll(autoMaskingTypes);
6567
putAll(userConsentActionType);
6668
}};
@@ -255,6 +257,11 @@ static Map<String, Object> getAll() {
255257
put("warm",SessionMetadata.LaunchType.WARM );
256258
put("unknown","unknown");
257259
}};
260+
261+
public static ArgsMap<Integer> overAirUpdateService = new ArgsMap<Integer>() {{
262+
put("expo", OverAirVersionType.EXPO);
263+
put("codePush",OverAirVersionType.CODE_PUSH );
264+
}};
258265

259266
// Temporary workaround to be removed in future release
260267
// This is used for mapping native `LaunchType` values into React Native enum values.

android/src/main/java/com/instabug/reactlibrary/RNInstabug.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import androidx.annotation.NonNull;
77
import androidx.annotation.VisibleForTesting;
88

9+
import com.facebook.react.bridge.ReadableMap;
910
import com.instabug.apm.APM;
1011
import com.instabug.library.Instabug;
1112
import com.instabug.library.LogLevel;
@@ -175,6 +176,11 @@ public static class Builder {
175176
*/
176177
private String codePushVersion;
177178

179+
/**
180+
* The overAirUpdate Version to be used for all reports.
181+
*/
182+
private ReadableMap overAirVersion;
183+
178184
/**
179185
* The events that trigger the SDK's user interface.
180186
*/
@@ -235,6 +241,16 @@ public Builder setCodePushVersion(String codePushVersion) {
235241
return this;
236242
}
237243

244+
/**
245+
* Sets over air update version to be used for all reports.
246+
*
247+
* @param overAirVersion the over air update version and service map.
248+
*/
249+
public Builder setOverAirVersion(ReadableMap overAirVersion) {
250+
this.overAirVersion = overAirVersion;
251+
return this;
252+
}
253+
238254
/**
239255
* Sets flag to override SDK screenshot security behavior.
240256
*
@@ -289,6 +305,17 @@ public void build() {
289305
instabugBuilder.ignoreFlagSecure(ignoreFlagSecure);
290306
}
291307

308+
if (overAirVersion != null ) {
309+
if (overAirVersion.hasKey("service") && overAirVersion.hasKey("version"))
310+
{
311+
if (overAirVersion.getString("service")!=null && overAirVersion.getString("version")!=null)
312+
{
313+
instabugBuilder.setOverAirVersion(overAirVersion.getString("version"),
314+
ArgsRegistry.overAirUpdateService.get(overAirVersion.getString("service")));
315+
}
316+
}
317+
}
318+
292319
instabugBuilder.build();
293320

294321
// Temporarily disabling APM hot launches

android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,10 @@ public void init(
157157
final boolean useNativeNetworkInterception,
158158
@Nullable final String codePushVersion,
159159
@Nullable final String appVariant,
160-
final ReadableMap map
160+
final ReadableMap map,
161+
@Nullable final ReadableMap overAirVersion
162+
163+
161164
) {
162165
MainThreadHandler.runOnMainThread(new Runnable() {
163166
@Override
@@ -189,6 +192,16 @@ public void run() {
189192
if (appVariant != null) {
190193
builder.setAppVariant(appVariant);
191194
}
195+
196+
if(overAirVersion != null ) {
197+
if(Instabug.isBuilt()) {
198+
Instabug.setOverAirVersion(overAirVersion.getString("version"),
199+
ArgsRegistry.overAirUpdateService.get(overAirVersion.getString("service")));
200+
} else {
201+
builder.setOverAirVersion(overAirVersion);
202+
}
203+
}
204+
192205
builder.build();
193206
}
194207
});
@@ -208,6 +221,22 @@ public void run() {
208221
});
209222
}
210223

224+
@ReactMethod
225+
public void setOverAirVersion(@Nullable final ReadableMap overAirVersion) {
226+
MainThreadHandler.runOnMainThread(new Runnable() {
227+
@Override
228+
public void run() {
229+
try {
230+
Instabug.setOverAirVersion(overAirVersion.getString("version"),
231+
ArgsRegistry.overAirUpdateService.get(overAirVersion.getString("service")));
232+
233+
} catch (Exception e) {
234+
e.printStackTrace();
235+
}
236+
}
237+
});
238+
}
239+
211240

212241
/**
213242
* Adds tag(s) to issues before sending them

android/src/test/java/com/instabug/reactlibrary/RNInstabugReactnativeModuleTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.instabug.library.featuresflags.model.IBGFeatureFlag;
2525
import com.instabug.library.internal.module.InstabugLocale;
2626
import com.instabug.library.ui.onboarding.WelcomeMessage;
27+
import com.instabug.library.util.overairversion.OverAirVersionType;
2728
import com.instabug.reactlibrary.utils.MainThreadHandler;
2829
import com.instabug.library.MaskingType;
2930

@@ -202,6 +203,21 @@ public void testSetCodePushVersion() {
202203
mockInstabug.verify(() -> Instabug.setCodePushVersion(codePushVersion));
203204
}
204205

206+
@Test
207+
public void testSetOverAirVersion() {
208+
WritableMap mockMap = mock(WritableMap.class);
209+
210+
String version="D0A12345-6789-4B3C-A123-4567ABCDEF0";
211+
212+
when(mockMap.getString("version")).thenReturn(version);
213+
when(mockMap.getString("service")).thenReturn("expo");
214+
215+
rnModule.setOverAirVersion(mockMap);
216+
217+
mockInstabug.verify(() -> Instabug.setOverAirVersion(
218+
version, OverAirVersionType.EXPO));
219+
}
220+
205221
@Test
206222
public void testIdentifyUserWithNoId() {
207223
// given

examples/default/ios/InstabugTests/InstabugSampleTests.m

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,29 @@ - (void)testInit {
7272
NSString *appVariant = @"variant 1";
7373

7474
NSArray *invocationEvents = [NSArray arrayWithObjects:[NSNumber numberWithInteger:floatingButtonInvocationEvent], nil];
75+
NSDictionary *overAirVersion = @{
76+
@"service":@"expo",
77+
@"version":@"D0A12345-6789-4B3C-A123-4567ABCDEF01"
78+
};
7579
BOOL useNativeNetworkInterception = YES;
7680
IBGSDKDebugLogsLevel sdkDebugLogsLevel = IBGSDKDebugLogsLevelDebug;
81+
IBGOverAirType service = [ArgsRegistry.overAirServices[overAirVersion[@"service"]] intValue];
7782

7883
OCMStub([mock setCodePushVersion:codePushVersion]);
84+
OCMStub([mock setOverAirVersion:overAirVersion[@"version"] withType:service]);
7985

80-
[self.instabugBridge init:appToken invocationEvents:invocationEvents debugLogsLevel:sdkDebugLogsLevel useNativeNetworkInterception:useNativeNetworkInterception codePushVersion:codePushVersion appVariant:appVariant options:nil ];
86+
[self.instabugBridge init:appToken invocationEvents:invocationEvents debugLogsLevel:sdkDebugLogsLevel useNativeNetworkInterception:useNativeNetworkInterception codePushVersion:codePushVersion appVariant:appVariant options:nil overAirVersion:overAirVersion ];
8187
OCMVerify([mock setCodePushVersion:codePushVersion]);
8288

89+
OCMVerify([mock setOverAirVersion:overAirVersion[@"version"] withType:[overAirVersion[@"service"] intValue]]);
90+
91+
8392
XCTAssertEqual(Instabug.appVariant, appVariant);
8493

8594
OCMVerify([self.mRNInstabug initWithToken:appToken invocationEvents:floatingButtonInvocationEvent debugLogsLevel:sdkDebugLogsLevel useNativeNetworkInterception:useNativeNetworkInterception]);
8695
}
8796

88-
- (void)testSetCodePushVersion {
97+
- (void)test {
8998
id mock = OCMClassMock([Instabug class]);
9099
NSString *codePushVersion = @"123";
91100

@@ -94,6 +103,20 @@ - (void)testSetCodePushVersion {
94103
OCMVerify([mock setCodePushVersion:codePushVersion]);
95104
}
96105

106+
- (void)testSetOverAirVersion {
107+
id mock = OCMClassMock([Instabug class]);
108+
NSDictionary *overAirVersion = @{
109+
@"service":@"expo",
110+
@"version":@"D0A12345-6789-4B3C-A123-4567ABCDEF01"
111+
};
112+
113+
[self.instabugBridge setOverAirVersion:overAirVersion];
114+
115+
IBGOverAirType service = [ArgsRegistry.overAirServices[overAirVersion[@"service"]] intValue];
116+
117+
OCMVerify([mock setOverAirVersion:overAirVersion[@"version"] withType:[overAirVersion[@"service"] intValue]]);
118+
}
119+
97120
- (void)testSetUserData {
98121
id mock = OCMClassMock([Instabug class]);
99122
NSString *userData = @"user_data";

examples/default/ios/InstabugTests/RNInstabugTests.m

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,26 @@ - (void) testSetCodePushVersion {
7373
OCMVerify([self.mInstabug setCodePushVersion:codePushVersion]);
7474
}
7575

76+
- (void)testSetOverAirVersionExpo {
77+
NSDictionary *overAirVersion = @{
78+
@"service":@(IBGOverAirTypeExpo),
79+
@"version":@"D0A12345-6789-4B3C-A123-4567ABCDEF01"
80+
};
81+
82+
[RNInstabug setOverAirVersion:overAirVersion];
83+
84+
OCMVerify([self.mInstabug setOverAirVersion:overAirVersion[@"version"] withType:[overAirVersion[@"service"] intValue]]);
85+
}
86+
87+
- (void)testSetOverAirVersionCodepush {
88+
NSDictionary *overAirVersion = @{
89+
@"service":@(IBGOverAirTypeCodePush),
90+
@"version":@"2.0.0"
91+
};
92+
93+
[RNInstabug setOverAirVersion:overAirVersion];
94+
95+
OCMVerify([self.mInstabug setOverAirVersion:overAirVersion[@"version"] withType:[overAirVersion[@"service"] intValue]]);
96+
}
97+
7698
@end

examples/default/ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ target 'InstabugExample' do
1616
rn_maps_path = '../node_modules/react-native-maps'
1717
pod 'react-native-google-maps', :path => rn_maps_path
1818

19-
# Flags change depending on the env values.
19+
# add this line
2020
flags = get_default_flags()
2121

2222
use_react_native!(

examples/default/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2098,6 +2098,6 @@ SPEC CHECKSUMS:
20982098
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
20992099
Yoga: 055f92ad73f8c8600a93f0e25ac0b2344c3b07e6
21002100

2101-
PODFILE CHECKSUM: 837b933596e1616ff02cc206bb17dee4f611fdbc
2101+
PODFILE CHECKSUM: ac02ce223b69d8b05ac5901eaaac229f19e6d881
21022102

21032103
COCOAPODS: 1.14.0

examples/default/src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Instabug, {
1313
NetworkLogger,
1414
ReproStepsMode,
1515
SessionReplay,
16+
OverAirUpdateServices,
1617
} from 'instabug-reactnative';
1718
import { NativeBaseProvider } from 'native-base';
1819

@@ -50,6 +51,7 @@ export const App: React.FC = () => {
5051
debugLogsLevel: LogLevel.verbose,
5152
networkInterceptionMode: NetworkInterceptionMode.javascript,
5253
appVariant: 'App variant',
54+
overAirVersion: { service: OverAirUpdateServices.codePush, version: '1.0.0' },
5355
});
5456

5557
CrashReporting.setNDKCrashesEnabled(true);

0 commit comments

Comments
 (0)