Skip to content

Commit 411dfe3

Browse files
authored
💎 Bump to version 8.5.4
* 📝 Fixing setFloatingButtonEdge Api * 📝updates changelog * 📝 Adjusting tests * 💎 Bump to version 8.5.4 * 📝 Coverage * 📝 Fixes setEnabledAttachmentTypes
1 parent 1208541 commit 411dfe3

File tree

10 files changed

+81
-56
lines changed

10 files changed

+81
-56
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v8.5.4 (2019-08-10)
2+
3+
* Hot Fixes an issue with `Instabug.setFloatingButtonEdge` and `Instabug.setEnabledAttachmentTypes` causing the app to crash.
4+
15
## v8.5.3 (2019-08-08)
26

37
* Fixes hang/crash issues on iOS 9 devices

__tests__/bugReporting.spec.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ describe('Testing BugReporting Module', () => {
3333
const setAutoScreenRecordingMaxDuration = sinon.spy(NativeModules.IBGBugReporting, 'setAutoScreenRecordingMaxDuration');
3434
const setViewHierarchyEnabled = sinon.spy(NativeModules.IBGBugReporting, 'setViewHierarchyEnabled');
3535
const didSelectPromptOptionHandler = sinon.spy(NativeModules.IBGBugReporting, 'setDidSelectPromptOptionHandler');
36+
const setFloatingButtonEdge = sinon.spy(NativeModules.IBGBugReporting, 'setFloatingButtonEdge');
37+
const setEnabledAttachmentTypes = sinon.spy(NativeModules.IBGBugReporting, 'setEnabledAttachmentTypes');
38+
3639

3740
beforeEach(() => {
3841
setShakingThresholdForiPhone.resetHistory();
@@ -258,4 +261,22 @@ describe('Testing BugReporting Module', () => {
258261

259262
});
260263

264+
it('should call the native method setFloatingButtonEdge', () => {
265+
266+
const offsetFromTop = 10;
267+
const edge = Instabug.floatingButtonEdge.left;
268+
BugReporting.setFloatingButtonEdge(edge, offsetFromTop);
269+
270+
expect(setFloatingButtonEdge.calledOnceWithExactly(edge, offsetFromTop)).toBe(true);
271+
272+
});
273+
274+
it('should call the native method setEnabledAttachmentTypes', () => {
275+
276+
BugReporting.setEnabledAttachmentTypes(true, true, false, true);
277+
278+
expect(setEnabledAttachmentTypes.calledOnceWithExactly(true, true, false, true)).toBe(true);
279+
280+
});
281+
261282
});

__tests__/index.spec.js

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ describe('Instabug Module', () => {
2525
const setIBGLogPrintsToConsole = sinon.spy(NativeModules.Instabug, 'setIBGLogPrintsToConsole');
2626
const setSessionProfilerEnabled = sinon.spy(NativeModules.Instabug, 'setSessionProfilerEnabled');
2727
const setPushNotificationsEnabled = sinon.spy(NativeModules.Instabug, 'setPushNotificationsEnabled');
28-
const setFloatingButtonEdge = sinon.spy(NativeModules.Instabug, 'setFloatingButtonEdge');
28+
const setFloatingButtonEdge = sinon.spy(NativeModules.IBGBugReporting, 'setFloatingButtonEdge');
2929
const setLocale = sinon.spy(NativeModules.Instabug, 'setLocale');
3030
const setColorTheme = sinon.spy(NativeModules.Instabug, 'setColorTheme');
3131
const setPrimaryColor = sinon.spy(NativeModules.Instabug, 'setPrimaryColor');
3232
const appendTags = sinon.spy(NativeModules.Instabug, 'appendTags');
3333
const resetTags = sinon.spy(NativeModules.Instabug, 'resetTags');
3434
const getTags = sinon.spy(NativeModules.Instabug, 'getTags');
3535
const setString = sinon.spy(NativeModules.Instabug, 'setString');
36-
const setEnabledAttachmentTypes = sinon.spy(NativeModules.Instabug, 'setEnabledAttachmentTypes');
36+
const setEnabledAttachmentTypes = sinon.spy(NativeModules.IBGBugReporting, 'setEnabledAttachmentTypes');
3737
const identifyUserWithEmail = sinon.spy(NativeModules.Instabug, 'identifyUserWithEmail');
3838
const logOut = sinon.spy(NativeModules.Instabug, 'logOut');
3939
const logUserEventWithName = sinon.spy(NativeModules.Instabug, 'logUserEventWithName');
@@ -71,7 +71,6 @@ describe('Instabug Module', () => {
7171
setTrackUserSteps.resetHistory();
7272
setIBGLogPrintsToConsole.resetHistory();
7373
setPushNotificationsEnabled.resetHistory();
74-
setFloatingButtonEdge.resetHistory();
7574
log.resetHistory();
7675
setDebugEnabled.resetHistory();
7776
enable.resetHistory();
@@ -169,18 +168,8 @@ describe('Instabug Module', () => {
169168

170169
});
171170

172-
it('should not call the native method setPushNotificationsEnabled when platform is android', () => {
173-
174-
Platform.OS = 'android';
175-
Instabug.setPushNotificationsEnabled(true);
176-
177-
expect(setPushNotificationsEnabled.notCalled).toBe(true);
178-
179-
});
180-
181171
it('should call the native method setFloatingButtonEdge', () => {
182172

183-
Platform.OS = 'ios';
184173
const offsetFromTop = 10;
185174
const edge = Instabug.floatingButtonEdge.left;
186175
Instabug.setFloatingButtonEdge(edge, offsetFromTop);
@@ -189,12 +178,12 @@ describe('Instabug Module', () => {
189178

190179
});
191180

192-
it('should not call the native method setFloatingButtonEdge when platform is android', () => {
181+
it('should not call the native method setPushNotificationsEnabled when platform is android', () => {
193182

194183
Platform.OS = 'android';
195-
Instabug.setPushNotificationsEnabled(Instabug.floatingButtonEdge.left, 10);
184+
Instabug.setPushNotificationsEnabled(true);
196185

197-
expect(setFloatingButtonEdge.notCalled).toBe(true);
186+
expect(setPushNotificationsEnabled.notCalled).toBe(true);
198187

199188
});
200189

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

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -544,25 +544,6 @@ public void run() {
544544
}
545545
});
546546
}
547-
548-
/**
549-
* Sets whether attachments in bug reporting and in-app messaging are enabled or not.
550-
*
551-
* @param screenshot A boolean to enable or disable screenshot attachments.
552-
* @param {boolean} extraScreenShot A boolean to enable or disable extra screenshot attachments.
553-
* @param {boolean} galleryImage A boolean to enable or disable gallery image attachments.
554-
* @param {boolean} screenRecording A boolean to enable or disable screen recording attachments.
555-
*/
556-
@ReactMethod
557-
public void setEnabledAttachmentTypes(boolean screenshot, boolean extraScreenshot, boolean
558-
galleryImage, boolean screenRecording) {
559-
try {
560-
BugReporting.setAttachmentTypesEnabled(screenshot, extraScreenshot, galleryImage,
561-
screenRecording);
562-
} catch (Exception e) {
563-
e.printStackTrace();
564-
}
565-
}
566547

567548
/**
568549
* Gets tags.
@@ -2079,22 +2060,6 @@ public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
20792060
});
20802061
}
20812062

2082-
2083-
@ReactMethod
2084-
public void setFloatingButtonEdge(final String floatingButtonEdge, final int floatingButtonOffset) {
2085-
new Handler(Looper.getMainLooper()).post(new Runnable() {
2086-
@Override
2087-
public void run() {
2088-
BugReporting.setFloatingButtonOffset(floatingButtonOffset);
2089-
if (floatingButtonEdge.equals("left"))
2090-
BugReporting.setFloatingButtonEdge(InstabugFloatingButtonEdge.LEFT);
2091-
else
2092-
BugReporting.setFloatingButtonEdge(InstabugFloatingButtonEdge.RIGHT);
2093-
}
2094-
});
2095-
}
2096-
2097-
20982063
private InstabugCustomTextPlaceHolder.Key getStringToKeyConstant(String key) {
20992064
switch (key) {
21002065
case SHAKE_HINT:

index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ const InstabugModule = {
189189
},
190190

191191
/**
192+
* @deprecated use {@link BugReporting.setFloatingButtonEdge}
192193
* Sets the default edge and offset from the top at which the floating button
193194
* will be shown. Different orientations are already handled.
194195
* Default for `floatingButtonEdge` is `rectEdge.maxX`.
@@ -199,7 +200,7 @@ const InstabugModule = {
199200
* floating button.
200201
*/
201202
setFloatingButtonEdge(floatingButtonEdge, offsetFromTop) {
202-
Instabug.setFloatingButtonEdge(floatingButtonEdge, offsetFromTop);
203+
BugReporting.setFloatingButtonEdge(floatingButtonEdge, offsetFromTop);
203204
},
204205

205206
/**
@@ -279,6 +280,7 @@ const InstabugModule = {
279280
},
280281

281282
/**
283+
* @deprecated use {@link BugReporting.setEnabledAttachmentTypes}
282284
* Sets whether attachments in bug reporting and in-app messaging are enabled or not.
283285
* @param {boolean} screenshot A boolean to enable or disable screenshot attachments.
284286
* @param {boolean} extraScreenshot A boolean to enable or disable extra
@@ -294,7 +296,7 @@ const InstabugModule = {
294296
galleryImage,
295297
screenRecording
296298
) {
297-
Instabug.setEnabledAttachmentTypes(
299+
BugReporting.setEnabledAttachmentTypes(
298300
screenshot,
299301
extraScreenshot,
300302
galleryImage,

ios/RNInstabug/InstabugBugReportingBridge.h

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

2828
- (void)setOptions:(NSArray *)optionsArray;
2929

30+
- (void)setFloatingButtonEdge:(CGRectEdge)floatingButtonEdge withTopOffset:(double)floatingButtonOffsetFromTop;
31+
3032
- (void)invokeWithInvocationModeAndOptions:(IBGInvocationMode)invocationMode options:(NSArray *)options;
3133

3234
- (void)setOnInvokeHandler:(RCTResponseSenderBlock)callBack;

jest/mockBugReporting.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ jest.mock('NativeModules', () => {
44
setEnabled: jest.fn(),
55
setInvocationEvents: jest.fn(),
66
setOptions: jest.fn(),
7+
setFloatingButtonEdge: jest.fn(),
78
setShakingThresholdForiPhone: jest.fn(),
89
setShakingThresholdForiPad: jest.fn(),
910
setShakingThresholdForAndroid: jest.fn(),
@@ -16,6 +17,7 @@ jest.mock('NativeModules', () => {
1617
setAutoScreenRecordingEnabled: jest.fn(),
1718
setAutoScreenRecordingMaxDuration: jest.fn(),
1819
setViewHierarchyEnabled: jest.fn(),
20+
setEnabledAttachmentTypes: jest.fn(),
1921
setDidSelectPromptOptionHandler: jest.fn()
2022
},
2123
Instabug: {}

jest/mockInstabug.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ jest.mock('NativeModules', () => {
88
didSelectPromptOptionHandler: jest.fn(),
99
setSessionProfilerEnabled: jest.fn(),
1010
setPushNotificationsEnabled: jest.fn(),
11-
setFloatingButtonEdge: jest.fn(),
1211
setLocale: jest.fn(),
1312
setColorTheme: jest.fn(),
1413
setPrimaryColor: jest.fn(),
1514
appendTags: jest.fn(),
1615
resetTags: jest.fn(),
1716
getTags: jest.fn(cb => cb(['tags1', 'tags2'])),
1817
setString: jest.fn(),
19-
setEnabledAttachmentTypes: jest.fn(),
2018
identifyUserWithEmail: jest.fn(),
2119
logOut: jest.fn(),
2220
logUserEventWithName: jest.fn(),
@@ -52,5 +50,9 @@ jest.mock('NativeModules', () => {
5250
sendJSCrash: jest.fn()
5351

5452
},
53+
IBGBugReporting: {
54+
setFloatingButtonEdge: jest.fn(),
55+
setEnabledAttachmentTypes: jest.fn(),
56+
}
5557
};
5658
});

modules/BugReporting.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,44 @@ export default {
256256
IBGBugReporting.setDidSelectPromptOptionHandler(didSelectPromptOptionHandler);
257257
},
258258

259+
/**
260+
* Sets the default edge and offset from the top at which the floating button
261+
* will be shown. Different orientations are already handled.
262+
* Default for `floatingButtonEdge` is `rectEdge.maxX`.
263+
* Default for `floatingButtonOffsetFromTop` is 50
264+
* @param {rectEdge} floatingButtonEdge `maxX` to show on the right,
265+
* or `minX` to show on the left.
266+
* @param {number} offsetFromTop floatingButtonOffsetFromTop Top offset for
267+
* floating button.
268+
*/
269+
setFloatingButtonEdge(floatingButtonEdge, offsetFromTop) {
270+
IBGBugReporting.setFloatingButtonEdge(floatingButtonEdge, offsetFromTop);
271+
},
272+
273+
/**
274+
* Sets whether attachments in bug reporting and in-app messaging are enabled or not.
275+
* @param {boolean} screenshot A boolean to enable or disable screenshot attachments.
276+
* @param {boolean} extraScreenshot A boolean to enable or disable extra
277+
* screenshot attachments.
278+
* @param {boolean} galleryImage A boolean to enable or disable gallery image
279+
* attachments. In iOS 10+,NSPhotoLibraryUsageDescription should be set in
280+
* info.plist to enable gallery image attachments.
281+
* @param {boolean} screenRecording A boolean to enable or disable screen recording attachments.
282+
*/
283+
setEnabledAttachmentTypes(
284+
screenshot,
285+
extraScreenshot,
286+
galleryImage,
287+
screenRecording
288+
) {
289+
IBGBugReporting.setEnabledAttachmentTypes(
290+
screenshot,
291+
extraScreenshot,
292+
galleryImage,
293+
screenRecording
294+
);
295+
},
296+
259297
/**
260298
* The event used to invoke the feedback form
261299
* @readonly

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "instabug-reactnative",
3-
"version": "8.5.3",
3+
"version": "8.5.4",
44
"description": "React Native plugin for integrating the Instabug SDK",
55
"main": "index.js",
66
"types": "index.d.ts",

0 commit comments

Comments
 (0)