Skip to content

Commit d0a37c6

Browse files
authored
Fix/return removed ap is (#46)
* fix 8.1 type define issue Fix the Android implementation is missing a branch in the `parseInvocationEvent` loop for the `InstabugInvocationEvent.SCREENSHOT` type. It prevents users from using the screenshot invocation on Android React Native apps. * 📝 add removed deprecated APIs and add them to typescript file
1 parent 5ecdc5f commit d0a37c6

File tree

5 files changed

+127
-6
lines changed

5 files changed

+127
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2133,4 +2133,4 @@ public Map<String, Object> getConstants() {
21332133

21342134
return constants;
21352135
}
2136-
}
2136+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ private void parseInvocationEvent(String[] invocationEventValues) {
7878
} else if (invocationEventValues[i].equals("shake")) {
7979
this.invocationEvents.add(InstabugInvocationEvent.SHAKE);
8080

81+
} else if (invocationEventValues[i].equals("screenshot")) {
82+
this.invocationEvents.add(InstabugInvocationEvent.SCREENSHOT);
83+
8184
} else if (invocationEventValues[i].equals("none")) {
8285
this.invocationEvents.add(InstabugInvocationEvent.NONE);
8386
}

index.d.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,10 @@ export function setAutoScreenRecordingEnabled(autoScreenRecordingEnabled: boolea
121121
export function setAutoScreenRecordingMaxDuration(autoScreenRecordingMaxDuration: number): void;
122122
export function setTrackUserSteps(isEnabled: boolean): void;
123123
export function setIBGLogPrintsToConsole(printsToConsole: boolean): void;
124+
export function setCrashReportingEnabled(enableCrashReporter: boolean): void;
124125
export function setDidSelectPromptOptionHandler(didSelectPromptOptionHandler: () => void): void;
125126
export function setSessionProfilerEnabled(sessionProfilerEnabled: boolean): void;
127+
export function getUnreadMessagesCount(messageCountCallback: () => void): void;
126128
export function setPushNotificationsEnabled(isPushNotificationEnabled: boolean): void;
127129
export function setEmailFieldRequiredForActions(
128130
isEmailFieldRequired: boolean,
@@ -138,9 +140,9 @@ export function setPrimaryColor(setPrimaryColor: string): void;
138140
export function appendTags(tags: string[]): void;
139141
export function resetTags(): void;
140142
export function getTags(tagsCallback: () => void): void;
141-
export function setstringToKey(
143+
export function setStringToKey(
142144
string: string,
143-
key: string
145+
key: strings,
144146
): void;
145147
export function setEnabledAttachmentTypes(
146148
screenshot: boolean,
@@ -172,10 +174,15 @@ export function getUserAttribute(
172174
export function removeUserAttribute(key: string): void;
173175
export function getAllUserAttributes(userAttributesCallback: () => void): void;
174176
export function clearAllUserAttributes(): void;
177+
export function setChatNotificationEnabled(isChatNotificationEnabled: boolean): void;
178+
export function setOnNewMessageHandler(onNewMessageHandler: () => void): void;
175179
export function setViewHierarchyEnabled(viewHierarchyEnabled: boolean): void;
180+
export function setSurveysEnabled(surveysEnabled: boolean): void;
176181
export function setDebugEnabled(isDebugEnabled: boolean): void;
177182
export function enable(): void;
178183
export function disable(): void;
184+
export function setEnableInAppNotificationSound(shouldPlaySound: boolean): void;
185+
export function reportJSException(Exception: object): void;
179186
export function isRunningLive(runningLiveCallBack: () => void): void;
180187
export function setVideoRecordingFloatingButtonPosition(position: IBGPosition): void;
181188
export function setShouldShowSurveysWelcomeScreen(shouldShowWelcomeScreen: boolean): void;

index.js

Lines changed: 113 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import {
22
NativeModules,
33
NativeAppEventEmitter,
44
DeviceEventEmitter,
5-
Platform
5+
Platform,
6+
processColor
67
} from 'react-native';
78
let { Instabug } = NativeModules;
89
import InstabugUtils from './utils/InstabugUtils';
@@ -89,6 +90,15 @@ const InstabugModule = {
8990
Instabug.setIBGLogPrintsToConsole(printsToConsole);
9091
},
9192

93+
/**
94+
* @deprecated use {@link CrashReporting.setCrashReportingEnabled}
95+
* Report un-caught exceptions to Instabug dashboard
96+
* We don't send exceptions from __DEV__, since it's way too noisy!
97+
*/
98+
setCrashReportingEnabled: function(enableCrashReporter) {
99+
Instabug.setCrashReportingEnabled(enableCrashReporter);
100+
},
101+
92102
/**
93103
* Sets a block of code to be executed when a prompt option is selected.
94104
* @param {function} didSelectPromptOptionHandler - A block of code that
@@ -125,6 +135,19 @@ const InstabugModule = {
125135
Instabug.setSessionProfilerEnabled(sessionProfilerEnabled);
126136
},
127137

138+
/**
139+
* @deprecated use {@link Replies.getUnreadRepliesCount}
140+
* Returns the number of unread messages the user currently has.
141+
* Use this method to get the number of unread messages the user
142+
* has, then possibly notify them about it with your own UI.
143+
* @param {messageCountCallback} messageCountCallback callback with argument
144+
* Notifications count, or -1 in case the SDK has not been initialized.
145+
*/
146+
147+
getUnreadMessagesCount: function(messageCountCallback) {
148+
Instabug.getUnreadMessagesCount(messageCountCallback);
149+
},
150+
128151
/**
129152
* Enables/disables the use of push notifications in the SDK.
130153
* Defaults to YES.
@@ -197,7 +220,7 @@ const InstabugModule = {
197220
* @param {color} primaryColor A color to set the UI elements of the SDK to.
198221
*/
199222
setPrimaryColor: function(primaryColor) {
200-
Instabug.setPrimaryColor(primaryColor);
223+
Instabug.setPrimaryColor(primaryColor);
201224
},
202225

203226
/**
@@ -471,6 +494,42 @@ const InstabugModule = {
471494
Instabug.clearAllUserAttributes();
472495
},
473496

497+
/**
498+
* @deprecated use {@link Replies.setInAppNotificationsEnabled}
499+
* Enables/disables showing in-app notifications when the user receives a
500+
* new message.
501+
* @param {boolean} isChatNotificationEnabled A boolean to set whether
502+
* notifications are enabled or disabled.
503+
*/
504+
505+
setChatNotificationEnabled: function(isChatNotificationEnabled) {
506+
Instabug.setChatNotificationEnabled(isChatNotificationEnabled);
507+
},
508+
509+
/**
510+
* @deprecated use {@link Replies.setOnNewReplyReceivedCallback}
511+
* Sets a block of code that gets executed when a new message is received.
512+
* @param {function} onNewMessageHandler - A callback that gets
513+
* executed when a new message is received.
514+
*/
515+
516+
setOnNewMessageHandler: function(onNewMessageHandler) {
517+
if (Platform.OS === 'ios') {
518+
Instabug.addListener('IBGonNewMessageHandler');
519+
NativeAppEventEmitter.addListener(
520+
'IBGonNewMessageHandler',
521+
onNewMessageHandler
522+
);
523+
} else {
524+
DeviceEventEmitter.addListener(
525+
'IBGonNewMessageHandler',
526+
onNewMessageHandler
527+
);
528+
}
529+
530+
Instabug.setOnNewMessageHandler(onNewMessageHandler);
531+
},
532+
474533
/**
475534
* @summary Enables/disables inspect view hierarchy when reporting a bug/feedback.
476535
* @param {boolean} viewHierarchyEnabled A boolean to set whether view hierarchy are enabled
@@ -480,6 +539,21 @@ const InstabugModule = {
480539
Instabug.setViewHierarchyEnabled(viewHierarchyEnabled);
481540
},
482541

542+
/**
543+
* @deprecated use {@link Surveys.setEnabled}
544+
* @summary Sets whether surveys are enabled or not.
545+
* If you disable surveys on the SDK but still have active surveys on your Instabug dashboard,
546+
* those surveys are still going to be sent to the device, but are not going to be
547+
* shown automatically.
548+
* To manually display any available surveys, call `Instabug.showSurveyIfAvailable()`.
549+
* Defaults to `true`.
550+
* @param {boolean} surveysEnabled A boolean to set whether Instabug Surveys is enabled or disabled.
551+
*/
552+
553+
setSurveysEnabled: function(surveysEnabled) {
554+
Instabug.setSurveysEnabled(surveysEnabled);
555+
},
556+
483557
/**
484558
* Enable/Disable debug logs from Instabug SDK
485559
* Default state: disabled
@@ -512,6 +586,43 @@ const InstabugModule = {
512586
}
513587
},
514588

589+
/**
590+
* @deprecated use {@link Replies.setInAppNotificationSound}
591+
* Set whether new in app notification received will play a small sound notification
592+
* or not (Default is {@code false})
593+
*
594+
* @param shouldPlaySound desired state of conversation sounds
595+
* @since 4.1.0
596+
*/
597+
598+
setEnableInAppNotificationSound: function(shouldPlaySound) {
599+
if (Platform.OS === 'android') {
600+
Instabug.setEnableInAppNotificationSound(shouldPlaySound);
601+
}
602+
},
603+
604+
/**
605+
* @deprecated use {@link CrashReporting.reportJSException}
606+
* Send handled JS error object
607+
*
608+
* @param errorObject Error object to be sent to Instabug's servers
609+
*/
610+
611+
reportJSException: function(errorObject) {
612+
let jsStackTrace = InstabugUtils.parseErrorStack(errorObject);
613+
var jsonObject = {
614+
message: errorObject.name + ' - ' + errorObject.message,
615+
os: Platform.OS,
616+
platform: 'react_native',
617+
exception: jsStackTrace
618+
};
619+
if (Platform.OS === 'android') {
620+
Instabug.sendHandledJSCrash(JSON.stringify(jsonObject));
621+
} else {
622+
Instabug.sendHandledJSCrash(jsonObject);
623+
}
624+
},
625+
515626
/**
516627
* @summary Checks whether app is development/Beta testing OR live
517628
* Note: This API is iOS only

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.0.23",
3+
"version": "8.1.3",
44
"description": "React Native plugin for integrating the Instabug SDK",
55
"main": "index.js",
66
"types": "index.d.ts",

0 commit comments

Comments
 (0)