Skip to content

Commit

Permalink
💎 Bump to version 8.5.4
Browse files Browse the repository at this point in the history
* 📝 Fixing setFloatingButtonEdge Api

* 📝updates changelog

* 📝 Adjusting tests

* 💎 Bump to version 8.5.4

* 📝 Coverage

* 📝 Fixes setEnabledAttachmentTypes
  • Loading branch information
alyezz authored Aug 10, 2019
1 parent 1208541 commit 411dfe3
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 56 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v8.5.4 (2019-08-10)

* Hot Fixes an issue with `Instabug.setFloatingButtonEdge` and `Instabug.setEnabledAttachmentTypes` causing the app to crash.

## v8.5.3 (2019-08-08)

* Fixes hang/crash issues on iOS 9 devices
Expand Down
21 changes: 21 additions & 0 deletions __tests__/bugReporting.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ describe('Testing BugReporting Module', () => {
const setAutoScreenRecordingMaxDuration = sinon.spy(NativeModules.IBGBugReporting, 'setAutoScreenRecordingMaxDuration');
const setViewHierarchyEnabled = sinon.spy(NativeModules.IBGBugReporting, 'setViewHierarchyEnabled');
const didSelectPromptOptionHandler = sinon.spy(NativeModules.IBGBugReporting, 'setDidSelectPromptOptionHandler');
const setFloatingButtonEdge = sinon.spy(NativeModules.IBGBugReporting, 'setFloatingButtonEdge');
const setEnabledAttachmentTypes = sinon.spy(NativeModules.IBGBugReporting, 'setEnabledAttachmentTypes');


beforeEach(() => {
setShakingThresholdForiPhone.resetHistory();
Expand Down Expand Up @@ -258,4 +261,22 @@ describe('Testing BugReporting Module', () => {

});

it('should call the native method setFloatingButtonEdge', () => {

const offsetFromTop = 10;
const edge = Instabug.floatingButtonEdge.left;
BugReporting.setFloatingButtonEdge(edge, offsetFromTop);

expect(setFloatingButtonEdge.calledOnceWithExactly(edge, offsetFromTop)).toBe(true);

});

it('should call the native method setEnabledAttachmentTypes', () => {

BugReporting.setEnabledAttachmentTypes(true, true, false, true);

expect(setEnabledAttachmentTypes.calledOnceWithExactly(true, true, false, true)).toBe(true);

});

});
21 changes: 5 additions & 16 deletions __tests__/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ describe('Instabug Module', () => {
const setIBGLogPrintsToConsole = sinon.spy(NativeModules.Instabug, 'setIBGLogPrintsToConsole');
const setSessionProfilerEnabled = sinon.spy(NativeModules.Instabug, 'setSessionProfilerEnabled');
const setPushNotificationsEnabled = sinon.spy(NativeModules.Instabug, 'setPushNotificationsEnabled');
const setFloatingButtonEdge = sinon.spy(NativeModules.Instabug, 'setFloatingButtonEdge');
const setFloatingButtonEdge = sinon.spy(NativeModules.IBGBugReporting, 'setFloatingButtonEdge');
const setLocale = sinon.spy(NativeModules.Instabug, 'setLocale');
const setColorTheme = sinon.spy(NativeModules.Instabug, 'setColorTheme');
const setPrimaryColor = sinon.spy(NativeModules.Instabug, 'setPrimaryColor');
const appendTags = sinon.spy(NativeModules.Instabug, 'appendTags');
const resetTags = sinon.spy(NativeModules.Instabug, 'resetTags');
const getTags = sinon.spy(NativeModules.Instabug, 'getTags');
const setString = sinon.spy(NativeModules.Instabug, 'setString');
const setEnabledAttachmentTypes = sinon.spy(NativeModules.Instabug, 'setEnabledAttachmentTypes');
const setEnabledAttachmentTypes = sinon.spy(NativeModules.IBGBugReporting, 'setEnabledAttachmentTypes');
const identifyUserWithEmail = sinon.spy(NativeModules.Instabug, 'identifyUserWithEmail');
const logOut = sinon.spy(NativeModules.Instabug, 'logOut');
const logUserEventWithName = sinon.spy(NativeModules.Instabug, 'logUserEventWithName');
Expand Down Expand Up @@ -71,7 +71,6 @@ describe('Instabug Module', () => {
setTrackUserSteps.resetHistory();
setIBGLogPrintsToConsole.resetHistory();
setPushNotificationsEnabled.resetHistory();
setFloatingButtonEdge.resetHistory();
log.resetHistory();
setDebugEnabled.resetHistory();
enable.resetHistory();
Expand Down Expand Up @@ -169,18 +168,8 @@ describe('Instabug Module', () => {

});

it('should not call the native method setPushNotificationsEnabled when platform is android', () => {

Platform.OS = 'android';
Instabug.setPushNotificationsEnabled(true);

expect(setPushNotificationsEnabled.notCalled).toBe(true);

});

it('should call the native method setFloatingButtonEdge', () => {

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

});

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

Platform.OS = 'android';
Instabug.setPushNotificationsEnabled(Instabug.floatingButtonEdge.left, 10);
Instabug.setPushNotificationsEnabled(true);

expect(setFloatingButtonEdge.notCalled).toBe(true);
expect(setPushNotificationsEnabled.notCalled).toBe(true);

});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,25 +544,6 @@ public void run() {
}
});
}

/**
* Sets whether attachments in bug reporting and in-app messaging are enabled or not.
*
* @param screenshot A boolean to enable or disable screenshot attachments.
* @param {boolean} extraScreenShot A boolean to enable or disable extra screenshot attachments.
* @param {boolean} galleryImage A boolean to enable or disable gallery image attachments.
* @param {boolean} screenRecording A boolean to enable or disable screen recording attachments.
*/
@ReactMethod
public void setEnabledAttachmentTypes(boolean screenshot, boolean extraScreenshot, boolean
galleryImage, boolean screenRecording) {
try {
BugReporting.setAttachmentTypesEnabled(screenshot, extraScreenshot, galleryImage,
screenRecording);
} catch (Exception e) {
e.printStackTrace();
}
}

/**
* Gets tags.
Expand Down Expand Up @@ -2079,22 +2060,6 @@ public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
});
}


@ReactMethod
public void setFloatingButtonEdge(final String floatingButtonEdge, final int floatingButtonOffset) {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
BugReporting.setFloatingButtonOffset(floatingButtonOffset);
if (floatingButtonEdge.equals("left"))
BugReporting.setFloatingButtonEdge(InstabugFloatingButtonEdge.LEFT);
else
BugReporting.setFloatingButtonEdge(InstabugFloatingButtonEdge.RIGHT);
}
});
}


private InstabugCustomTextPlaceHolder.Key getStringToKeyConstant(String key) {
switch (key) {
case SHAKE_HINT:
Expand Down
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ const InstabugModule = {
},

/**
* @deprecated use {@link BugReporting.setFloatingButtonEdge}
* Sets the default edge and offset from the top at which the floating button
* will be shown. Different orientations are already handled.
* Default for `floatingButtonEdge` is `rectEdge.maxX`.
Expand All @@ -199,7 +200,7 @@ const InstabugModule = {
* floating button.
*/
setFloatingButtonEdge(floatingButtonEdge, offsetFromTop) {
Instabug.setFloatingButtonEdge(floatingButtonEdge, offsetFromTop);
BugReporting.setFloatingButtonEdge(floatingButtonEdge, offsetFromTop);
},

/**
Expand Down Expand Up @@ -279,6 +280,7 @@ const InstabugModule = {
},

/**
* @deprecated use {@link BugReporting.setEnabledAttachmentTypes}
* Sets whether attachments in bug reporting and in-app messaging are enabled or not.
* @param {boolean} screenshot A boolean to enable or disable screenshot attachments.
* @param {boolean} extraScreenshot A boolean to enable or disable extra
Expand All @@ -294,7 +296,7 @@ const InstabugModule = {
galleryImage,
screenRecording
) {
Instabug.setEnabledAttachmentTypes(
BugReporting.setEnabledAttachmentTypes(
screenshot,
extraScreenshot,
galleryImage,
Expand Down
2 changes: 2 additions & 0 deletions ios/RNInstabug/InstabugBugReportingBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

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

- (void)setFloatingButtonEdge:(CGRectEdge)floatingButtonEdge withTopOffset:(double)floatingButtonOffsetFromTop;

- (void)invokeWithInvocationModeAndOptions:(IBGInvocationMode)invocationMode options:(NSArray *)options;

- (void)setOnInvokeHandler:(RCTResponseSenderBlock)callBack;
Expand Down
2 changes: 2 additions & 0 deletions jest/mockBugReporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ jest.mock('NativeModules', () => {
setEnabled: jest.fn(),
setInvocationEvents: jest.fn(),
setOptions: jest.fn(),
setFloatingButtonEdge: jest.fn(),
setShakingThresholdForiPhone: jest.fn(),
setShakingThresholdForiPad: jest.fn(),
setShakingThresholdForAndroid: jest.fn(),
Expand All @@ -16,6 +17,7 @@ jest.mock('NativeModules', () => {
setAutoScreenRecordingEnabled: jest.fn(),
setAutoScreenRecordingMaxDuration: jest.fn(),
setViewHierarchyEnabled: jest.fn(),
setEnabledAttachmentTypes: jest.fn(),
setDidSelectPromptOptionHandler: jest.fn()
},
Instabug: {}
Expand Down
6 changes: 4 additions & 2 deletions jest/mockInstabug.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ jest.mock('NativeModules', () => {
didSelectPromptOptionHandler: jest.fn(),
setSessionProfilerEnabled: jest.fn(),
setPushNotificationsEnabled: jest.fn(),
setFloatingButtonEdge: jest.fn(),
setLocale: jest.fn(),
setColorTheme: jest.fn(),
setPrimaryColor: jest.fn(),
appendTags: jest.fn(),
resetTags: jest.fn(),
getTags: jest.fn(cb => cb(['tags1', 'tags2'])),
setString: jest.fn(),
setEnabledAttachmentTypes: jest.fn(),
identifyUserWithEmail: jest.fn(),
logOut: jest.fn(),
logUserEventWithName: jest.fn(),
Expand Down Expand Up @@ -52,5 +50,9 @@ jest.mock('NativeModules', () => {
sendJSCrash: jest.fn()

},
IBGBugReporting: {
setFloatingButtonEdge: jest.fn(),
setEnabledAttachmentTypes: jest.fn(),
}
};
});
38 changes: 38 additions & 0 deletions modules/BugReporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,44 @@ export default {
IBGBugReporting.setDidSelectPromptOptionHandler(didSelectPromptOptionHandler);
},

/**
* Sets the default edge and offset from the top at which the floating button
* will be shown. Different orientations are already handled.
* Default for `floatingButtonEdge` is `rectEdge.maxX`.
* Default for `floatingButtonOffsetFromTop` is 50
* @param {rectEdge} floatingButtonEdge `maxX` to show on the right,
* or `minX` to show on the left.
* @param {number} offsetFromTop floatingButtonOffsetFromTop Top offset for
* floating button.
*/
setFloatingButtonEdge(floatingButtonEdge, offsetFromTop) {
IBGBugReporting.setFloatingButtonEdge(floatingButtonEdge, offsetFromTop);
},

/**
* Sets whether attachments in bug reporting and in-app messaging are enabled or not.
* @param {boolean} screenshot A boolean to enable or disable screenshot attachments.
* @param {boolean} extraScreenshot A boolean to enable or disable extra
* screenshot attachments.
* @param {boolean} galleryImage A boolean to enable or disable gallery image
* attachments. In iOS 10+,NSPhotoLibraryUsageDescription should be set in
* info.plist to enable gallery image attachments.
* @param {boolean} screenRecording A boolean to enable or disable screen recording attachments.
*/
setEnabledAttachmentTypes(
screenshot,
extraScreenshot,
galleryImage,
screenRecording
) {
IBGBugReporting.setEnabledAttachmentTypes(
screenshot,
extraScreenshot,
galleryImage,
screenRecording
);
},

/**
* The event used to invoke the feedback form
* @readonly
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "instabug-reactnative",
"version": "8.5.3",
"version": "8.5.4",
"description": "React Native plugin for integrating the Instabug SDK",
"main": "index.js",
"types": "index.d.ts",
Expand Down

0 comments on commit 411dfe3

Please sign in to comment.