Skip to content

Commit 4d0f3a6

Browse files
TheBuggedYRNAli Abdelfattah
andauthored
[MOB-8850] Remove Deprecated APIs (#703)
* Remove Chats Module * Remove Deprecated Surveys APIs * Remove Deprecated Replies APIs * Remove Deprecated BugReporting APIs * Remove Deprecated Instabug APIs There were 3 types of deprecated APIs: 1. Methods who got renamed in JS but the native methods still had the old JS name (e.g. `start`). 2. Methods who got moved to different modules, they were removed from iOS module but not Android (e.g. `getUnreadMessagesCount`). 3. Methods who just got renamed in JS to match the native method name (e.g. `setStringToKey`). * Update CHANGELOG Co-authored-by: Ali Abdelfattah <[email protected]>
1 parent a775796 commit 4d0f3a6

30 files changed

+78
-1493
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Adds the ability to opt out of iOS source maps auto upload through the INSTABUG_SOURCEMAPS_UPLOAD_DISABLE env variable
44
* Adds dynamic entry file support through the INSTABUG_ENTRY_FILE env variable
55
* Fixes an issue with swipe invocation event not working on Android
6+
* Breaking: Removes the deprecated APIs. For the full list, check PR #703
67

78
## 10.13.0 (2022-03-17)
89

InstabugSample/App.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import Instabug, {
2020
BugReporting,
2121
FeatureRequests,
2222
Surveys,
23-
Chats,
2423
CrashReporting,
2524
Replies,
2625
} from 'instabug-reactnative';
@@ -138,13 +137,11 @@ class Home extends Component<{}> {
138137
}
139138

140139
sendFeedback() {
141-
BugReporting.showWithOptions(BugReporting.reportType.feedback, [
142-
BugReporting.option.emailFieldHidden,
143-
]);
140+
BugReporting.show(BugReporting.reportType.feedback, [BugReporting.option.emailFieldHidden]);
144141
}
145142

146143
startNewConversation() {
147-
BugReporting.showWithOptions(BugReporting.reportType.question);
144+
BugReporting.show(BugReporting.reportType.question);
148145
}
149146

150147
showUnreadMessagesCount() {

InstabugSample/ios/InstabugSample.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
1313
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
1414
5614D013CB1F880181CC6385 /* libPods-InstabugSample-InstabugSampleTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 195CA9739B516DE1C316BC72 /* libPods-InstabugSample-InstabugSampleTests.a */; };
15-
63D4BF6E2715AA740039BE63 /* InstabugChatsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 63D4BF662715AA740039BE63 /* InstabugChatsTests.m */; };
1615
63D4BF6F2715AA740039BE63 /* InstabugSurveysTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 63D4BF682715AA740039BE63 /* InstabugSurveysTests.m */; };
1716
63D4BF702715AA740039BE63 /* InstabugFeatureRequestsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 63D4BF692715AA740039BE63 /* InstabugFeatureRequestsTests.m */; };
1817
63D4BF712715AA740039BE63 /* InstabugAPMTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 63D4BF6A2715AA740039BE63 /* InstabugAPMTests.m */; };
@@ -48,7 +47,6 @@
4847
3FAC85A98493CDAD1F8FB224 /* libPods-InstabugSample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InstabugSample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
4948
4787814ECE7122710F5A5A59 /* Pods-InstabugSample-InstabugSampleTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InstabugSample-InstabugSampleTests.debug.xcconfig"; path = "Target Support Files/Pods-InstabugSample-InstabugSampleTests/Pods-InstabugSample-InstabugSampleTests.debug.xcconfig"; sourceTree = "<group>"; };
5049
618F0D2C25DB5EDD119673AA /* Pods-InstabugSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InstabugSample.debug.xcconfig"; path = "Target Support Files/Pods-InstabugSample/Pods-InstabugSample.debug.xcconfig"; sourceTree = "<group>"; };
51-
63D4BF662715AA740039BE63 /* InstabugChatsTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InstabugChatsTests.m; sourceTree = "<group>"; };
5250
63D4BF672715AA740039BE63 /* IBGConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IBGConstants.h; sourceTree = "<group>"; };
5351
63D4BF682715AA740039BE63 /* InstabugSurveysTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InstabugSurveysTests.m; sourceTree = "<group>"; };
5452
63D4BF692715AA740039BE63 /* InstabugFeatureRequestsTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InstabugFeatureRequestsTests.m; sourceTree = "<group>"; };
@@ -88,7 +86,6 @@
8886
63D4BF6D2715AA740039BE63 /* IBGConstants.m */,
8987
63D4BF6A2715AA740039BE63 /* InstabugAPMTests.m */,
9088
63D4BF6C2715AA740039BE63 /* InstabugBugReportingTests.m */,
91-
63D4BF662715AA740039BE63 /* InstabugChatsTests.m */,
9289
63D4BF692715AA740039BE63 /* InstabugFeatureRequestsTests.m */,
9390
63D4BF6B2715AA740039BE63 /* InstabugRepliesTests.m */,
9491
63D4BF682715AA740039BE63 /* InstabugSurveysTests.m */,
@@ -438,7 +435,6 @@
438435
files = (
439436
63D4BF742715AA740039BE63 /* IBGConstants.m in Sources */,
440437
63D4BF712715AA740039BE63 /* InstabugAPMTests.m in Sources */,
441-
63D4BF6E2715AA740039BE63 /* InstabugChatsTests.m in Sources */,
442438
63D4BF702715AA740039BE63 /* InstabugFeatureRequestsTests.m in Sources */,
443439
63D4BF732715AA740039BE63 /* InstabugBugReportingTests.m in Sources */,
444440
00E356F31AD99517003FC87E /* InstabugSampleTests.m in Sources */,

InstabugSample/ios/InstabugSampleTests/InstabugChatsTests.m

Lines changed: 0 additions & 59 deletions
This file was deleted.

InstabugSample/ios/InstabugSampleTests/InstabugSampleTests.m

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ - (void)setUp {
5252
+------------------------------------------------------------------------+
5353
*/
5454

55-
- (void)testStartWithToken {
55+
- (void)testStart {
5656
id<InstabugCPTestProtocol> mock = OCMClassMock([Instabug class]);
5757
IBGInvocationEvent floatingButtonInvocationEvent = IBGInvocationEventFloatingButton;
5858
NSString *appToken = @"app_token";
5959
NSArray *invocationEvents = [NSArray arrayWithObjects:[NSNumber numberWithInteger:floatingButtonInvocationEvent], nil];
60-
XCTestExpectation *expectation = [self expectationWithDescription:@"Testing [Instabug startWithToken]"];
60+
XCTestExpectation *expectation = [self expectationWithDescription:@"Testing [Instabug start]"];
6161

6262
OCMStub([mock startWithToken:appToken invocationEvents:floatingButtonInvocationEvent]);
63-
[self.instabugBridge startWithToken:appToken invocationEvents:invocationEvents];
63+
[self.instabugBridge start:appToken invocationEvents:invocationEvents];
6464

6565
[[NSRunLoop mainRunLoop] performBlock:^{
6666
OCMVerify([mock startWithToken:appToken invocationEvents:floatingButtonInvocationEvent]);
@@ -171,13 +171,13 @@ - (void)testSetString {
171171
OCMVerify([mock setValue:value forStringWithKey:key]);
172172
}
173173

174-
- (void)testIdentifyUserWithEmail {
174+
- (void)testIdentifyUser {
175175
id mock = OCMClassMock([Instabug class]);
176176
NSString *email = @"[email protected]";
177177
NSString *name = @"this is my name";
178178

179179
OCMStub([mock identifyUserWithEmail:email name:name]);
180-
[self.instabugBridge identifyUserWithEmail:email name:name];
180+
[self.instabugBridge identifyUser:email name:name];
181181
OCMVerify([mock identifyUserWithEmail:email name:name]);
182182
}
183183

@@ -189,12 +189,12 @@ - (void)testLogOut {
189189
OCMVerify([mock logOut]);
190190
}
191191

192-
- (void)testLogUserEventWithName {
192+
- (void)testLogUserEvent {
193193
id mock = OCMClassMock([Instabug class]);
194194
NSString *name = @"event name";
195195

196196
OCMStub([mock logUserEventWithName:name]);
197-
[self.instabugBridge logUserEventWithName:name];
197+
[self.instabugBridge logUserEvent:name];
198198
OCMVerify([mock logUserEventWithName:name]);
199199
}
200200

@@ -266,12 +266,6 @@ - (void)testClearAllUserAttributes {
266266
OCMVerify([mock removeUserAttributeForKey:key]);
267267
}
268268

269-
- (void)testSetViewHierarchyEnabled {
270-
BOOL enabled = true;
271-
[self.instabugBridge setViewHierarchyEnabled:enabled];
272-
XCTAssertTrue(Instabug.shouldCaptureViewHierarchy);
273-
}
274-
275269
- (void)testShowWelcomeMessageWithMode {
276270
id mock = OCMClassMock([Instabug class]);
277271
IBGWelcomeMessageMode welcomeMessageMode = IBGWelcomeMessageModeBeta;

__tests__/bugReporting.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ describe('Testing BugReporting Module', () => {
6565

6666
});
6767

68-
it('should call the native method setInvocationOptions with an array of invocationOptions', () => {
68+
it('should call the native method setOptions with an array of options', () => {
6969

70-
const arrayOfInvocationOptions = [BugReporting.invocationOptions.commentFieldRequired];
71-
BugReporting.setInvocationOptions(arrayOfInvocationOptions);
70+
const arrayOfOptions = [BugReporting.option.commentFieldRequired];
71+
BugReporting.setOptions(arrayOfOptions);
7272

73-
expect(setOptions.calledOnceWithExactly(arrayOfInvocationOptions)).toBe(true);
73+
expect(setOptions.calledOnceWithExactly(arrayOfOptions)).toBe(true);
7474

7575
});
7676

@@ -151,7 +151,7 @@ describe('Testing BugReporting Module', () => {
151151
it('should call the native method show with a reportType and array of options', () => {
152152

153153
const reportType = BugReporting.reportType.bug;
154-
const arrayOfOptions = [BugReporting.invocationOptions.commentFieldRequired];
154+
const arrayOfOptions = [BugReporting.option.commentFieldRequired];
155155
BugReporting.show(reportType, arrayOfOptions);
156156

157157
expect(show.calledOnceWithExactly(reportType, arrayOfOptions)).toBe(true);

__tests__/chats.spec.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

__tests__/index.spec.js

Lines changed: 12 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,21 @@ import InstabugUtils from '../utils/InstabugUtils';
2020

2121
describe('Instabug Module', () => {
2222

23-
const startWithToken = sinon.spy(NativeModules.Instabug, 'startWithToken');
23+
const start = sinon.spy(NativeModules.Instabug, 'start');
2424
const setUserData = sinon.spy(NativeModules.Instabug, 'setUserData');
2525
const setTrackUserSteps = sinon.spy(NativeModules.Instabug, 'setTrackUserSteps');
2626
const setIBGLogPrintsToConsole = sinon.spy(NativeModules.Instabug, 'setIBGLogPrintsToConsole');
2727
const setSessionProfilerEnabled = sinon.spy(NativeModules.Instabug, 'setSessionProfilerEnabled');
28-
const setPushNotificationsEnabled = sinon.spy(NativeModules.IBGReplies, 'setPushNotificationsEnabled');
29-
const setFloatingButtonEdge = sinon.spy(NativeModules.IBGBugReporting, 'setFloatingButtonEdge');
3028
const setLocale = sinon.spy(NativeModules.Instabug, 'setLocale');
3129
const setColorTheme = sinon.spy(NativeModules.Instabug, 'setColorTheme');
3230
const setPrimaryColor = sinon.spy(NativeModules.Instabug, 'setPrimaryColor');
3331
const appendTags = sinon.spy(NativeModules.Instabug, 'appendTags');
3432
const resetTags = sinon.spy(NativeModules.Instabug, 'resetTags');
3533
const getTags = sinon.spy(NativeModules.Instabug, 'getTags');
3634
const setString = sinon.spy(NativeModules.Instabug, 'setString');
37-
const setEnabledAttachmentTypes = sinon.spy(NativeModules.IBGBugReporting, 'setEnabledAttachmentTypes');
38-
const identifyUserWithEmail = sinon.spy(NativeModules.Instabug, 'identifyUserWithEmail');
35+
const identifyUser = sinon.spy(NativeModules.Instabug, 'identifyUser');
3936
const logOut = sinon.spy(NativeModules.Instabug, 'logOut');
40-
const logUserEventWithName = sinon.spy(NativeModules.Instabug, 'logUserEventWithName');
37+
const logUserEvent = sinon.spy(NativeModules.Instabug, 'logUserEvent');
4138
const log = sinon.spy(NativeModules.Instabug, 'log');
4239
const logVerbose = sinon.spy(NativeModules.Instabug, 'logVerbose');
4340
const logInfo = sinon.spy(NativeModules.Instabug, 'logInfo');
@@ -71,10 +68,9 @@ describe('Instabug Module', () => {
7168
const clearAllExperiments = sinon.spy(NativeModules.Instabug, 'clearAllExperiments');
7269

7370
beforeEach(() => {
74-
startWithToken.resetHistory();
71+
start.resetHistory();
7572
setTrackUserSteps.resetHistory();
7673
setIBGLogPrintsToConsole.resetHistory();
77-
setPushNotificationsEnabled.resetHistory();
7874
log.resetHistory();
7975
setSdkDebugLogsLevel.resetHistory();
8076
setDebugEnabled.resetHistory();
@@ -104,25 +100,25 @@ describe('Instabug Module', () => {
104100
expect(reportScreenChange.calledOnceWithExactly(screenName)).toBe(true);
105101
});
106102

107-
it('should call the native method startWithToken', () => {
103+
it('should call the native method start', () => {
108104

109105
Platform.OS = 'ios';
110106
const token = 'some-token';
111107
const invocationEvents = [Instabug.invocationEvent.floatingButton, Instabug.invocationEvent.shake];
112108
Instabug.start(token, invocationEvents);
113109

114-
expect(startWithToken.calledOnceWithExactly(token, invocationEvents)).toBe(true);
110+
expect(start.calledOnceWithExactly(token, invocationEvents)).toBe(true);
115111

116112
});
117113

118-
// it('should not call the native method startWithToken when platform is android', () => {
114+
// it('should not call the native method start when platform is android', () => {
119115

120116
// Platform.OS = 'android';
121117
// const token = 'some-token';
122118
// const invocationEvents = [Instabug.invocationEvent.floatingButton, Instabug.invocationEvent.shake];
123119
// Instabug.start(token, invocationEvents);
124120

125-
// expect(startWithToken.calledOnceWithExactly(token, invocationEvents)).toBe(true);
121+
// expect(start.calledOnceWithExactly(token, invocationEvents)).toBe(true);
126122

127123
// });
128124

@@ -179,25 +175,6 @@ describe('Instabug Module', () => {
179175

180176
});
181177

182-
it('should call the native method setPushNotificationsEnabled', () => {
183-
184-
Platform.OS = 'ios';
185-
Instabug.setPushNotificationsEnabled(true);
186-
187-
expect(setPushNotificationsEnabled.calledOnceWithExactly(true)).toBe(true);
188-
189-
});
190-
191-
it('should call the native method setFloatingButtonEdge', () => {
192-
193-
const offsetFromTop = 10;
194-
const edge = Instabug.floatingButtonEdge.left;
195-
Instabug.setFloatingButtonEdge(edge, offsetFromTop);
196-
197-
expect(setFloatingButtonEdge.calledOnceWithExactly(edge, offsetFromTop)).toBe(true);
198-
199-
});
200-
201178
it('should call the native method setLocale', () => {
202179

203180
const locale = Instabug.locale.english;
@@ -263,22 +240,14 @@ describe('Instabug Module', () => {
263240

264241
});
265242

266-
it('should call the native method setEnabledAttachmentTypes', () => {
267-
268-
Instabug.setEnabledAttachmentTypes(true, true, false, true);
269-
270-
expect(setEnabledAttachmentTypes.calledOnceWithExactly(true, true, false, true)).toBe(true);
271-
272-
});
273-
274-
it('should call the native method identifyUserWithEmail', () => {
243+
it('should call the native method identifyUser', () => {
275244

276245

277246
const email = '[email protected]';
278247
const name = 'Instabug';
279248
Instabug.identifyUser(email, name);
280249

281-
expect(identifyUserWithEmail.calledOnceWithExactly(email, name)).toBe(true);
250+
expect(identifyUser.calledOnceWithExactly(email, name)).toBe(true);
282251

283252
});
284253

@@ -290,12 +259,12 @@ describe('Instabug Module', () => {
290259

291260
});
292261

293-
it('should call the native method logUserEventWithName', () => {
262+
it('should call the native method logUserEvent', () => {
294263

295264
const event = 'click';
296265
Instabug.logUserEvent(event);
297266

298-
expect(logUserEventWithName.calledOnceWithExactly(event)).toBe(true);
267+
expect(logUserEvent.calledOnceWithExactly(event)).toBe(true);
299268

300269
});
301270

0 commit comments

Comments
 (0)