Skip to content

Commit 5ecdc5f

Browse files
authored
[MOB-3147] Remove Deprecated APIs And Update Typescript with new modules (#45)
* 🔥 Removing Deprecated Apis * 📝 Adjusts index.d.ts file according to new module changes (also removes deprecated methods)
1 parent 4731fdf commit 5ecdc5f

File tree

2 files changed

+37
-201
lines changed

2 files changed

+37
-201
lines changed

index.d.ts

Lines changed: 37 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
55

66
export namespace BugReporting {
7+
function setEnabled(isEnabled: boolean): void;
78
function setInvocationEvents(invocationEvents: invocationEvent[]): void;
89
function invoke(): void;
910
function setInvocationOptions(invocationOptions: invocationOptions[]): void;
@@ -14,7 +15,6 @@ export namespace BugReporting {
1415
function onInvokeHandler(preInvocationHandler: () => void): void;
1516
function onReportSubmitHandler(preSendingHandler: () => void): void;
1617
function onSDKDismissedHandler(postInvocationHandler: () => void): void;
17-
function dismiss(): void;
1818
function setPromptOptionsEnabled(
1919
chat: boolean,
2020
bug: boolean,
@@ -24,6 +24,10 @@ export namespace BugReporting {
2424
function setShakingThresholdForiPad(iPadShakingThreshold: number): void;
2525
function setShakingThresholdForAndroid(androidThreshold: number): void;
2626
function setExtendedBugReportMode(extendedBugReportMode: extendedBugReportMode): void;
27+
function setReportTypes(types: reportType): void;
28+
function showWithOptions(
29+
type: reportType,
30+
options: option[]): void;
2731
enum invocationEvent {
2832
none,
2933
shake,
@@ -49,6 +53,24 @@ export namespace BugReporting {
4953
enabledWithOptionalFields,
5054
disabled
5155
}
56+
enum reportType {
57+
bug,
58+
feedback
59+
}
60+
enum option {
61+
emailFieldHidden,
62+
emailFieldOptional,
63+
commentFieldRequired,
64+
disablePostSendingDialog
65+
}
66+
}
67+
export namespace Chats {
68+
function setEnabled(isEnabled: boolean): void;
69+
function show(): void;
70+
}
71+
export namespace CrashReporting {
72+
function setEnabled(isEnabled: boolean): void;
73+
function reportJSException(Exception: object): void;
5274
}
5375
export namespace FeatureRequests {
5476
function setEmailFieldRequired(
@@ -63,7 +85,17 @@ export namespace FeatureRequests {
6385
addCommentToFeature
6486
}
6587
}
88+
export namespace Replies {
89+
function setEnabled(isEnabled: boolean): void;
90+
function hasChats(callback: () => void): void;
91+
function show(): void;
92+
function setOnNewReplyReceivedCallback(onNewReplyReceivedCallback: () => void): void;
93+
function getUnreadRepliesCount(messageCountCallback: () => void): void;
94+
function setInAppNotificationsEnabled(inAppNotificationsEnabled: boolean): void;
95+
function setInAppNotificationSound(shouldPlaySound: boolean): void;
96+
}
6697
export namespace Surveys {
98+
function setEnabled(isEnabled: boolean): void;
6799
function showSurveyIfAvailable(): void;
68100
function setThresholdForReshowingSurveyAfterDismiss(
69101
sessionCount: number,
@@ -84,52 +116,23 @@ export function startWithToken(
84116
token: string,
85117
invocationEvent: invocationEvent[]
86118
): void;
87-
export function invoke(): void;
88-
export function invokeWithInvocationMode(invocationMode: invocationMode): void;
89-
export function dismiss(): void;
90119
export function setUserData(userData: string): void;
91120
export function setAutoScreenRecordingEnabled(autoScreenRecordingEnabled: boolean): void;
92-
export function setAutoScreenRecosetAutoScreenRecordingMaxDurationrdingEnabled(autoScreenRecordingMaxDuration: number): void;
93-
export function IBGLog(log: string): void;
94-
export function setUserStepsEnabled(isUserStepsEnabled: boolean): void;
121+
export function setAutoScreenRecordingMaxDuration(autoScreenRecordingMaxDuration: number): void;
122+
export function setTrackUserSteps(isEnabled: boolean): void;
95123
export function setIBGLogPrintsToConsole(printsToConsole: boolean): void;
96-
export function setCrashReportingEnabled(enableCrashReporter: boolean): void;
97-
export function setPreSendingHandler(preSendingHandler: () => void): void;
98124
export function setDidSelectPromptOptionHandler(didSelectPromptOptionHandler: () => void): void;
99-
export function showSurveyWithToken(surveyToken: string): void;
100-
export function hasRespondedToSurveyWithToken(
101-
surveyToken: string,
102-
surveyTokenCallback: () => void
103-
): void;
104125
export function setSessionProfilerEnabled(sessionProfilerEnabled: boolean): void;
105-
export function setPreInvocationHandler(preInvocationHandler: () => void): void;
106-
export function setPostInvocationHandler(postInvocationHandler: () => void): void;
107-
export function showIntroMessage(): void;
108-
export function setUserEmail(userEmail: string): void;
109-
export function setUserName(userName: string): void;
110-
export function setWillSkipScreenshotAnnotation(setWillSkipScreenshotAnnotation: boolean): void;
111-
export function getUnreadMessagesCount(messageCountCallback: () => void): void;
112-
export function setInvocationEvent(invocationEvent: invocationEvent): void;
113126
export function setPushNotificationsEnabled(isPushNotificationEnabled: boolean): void;
114-
export function setEmailFieldRequired(isEmailFieldRequired: boolean): void;
115127
export function setEmailFieldRequiredForActions(
116128
isEmailFieldRequired: boolean,
117129
actionTypes: actionTypes
118130
): void;
119-
export function setCommentFieldRequired(isCommentFieldRequired: boolean): void;
120-
export function setShakingThresholdForIPhone(
121-
iPhoneShakingThreshold: number,
122-
iPadShakingThreshold: number
123-
): void;
124-
export function setShakingThresholdForiPhone(iPhoneShakingThreshold: number): void;
125-
export function setShakingThresholdForiPad(iPadShakingThreshold: number): void;
126-
export function setShakingThresholdForAndroid(androidThreshold: number): void;
127131
export function setFloatingButtonEdge(
128132
floatingButtonEdge: number,
129133
offsetFromTop: number
130134
): void;
131135
export function setLocale(locale: locale): void;
132-
export function setIntroMessageEnabled(isIntroMessageEnabled: boolean): void;
133136
export function setColorTheme(colorTheme: colorTheme): void;
134137
export function setPrimaryColor(setPrimaryColor: string): void;
135138
export function appendTags(tags: string[]): void;
@@ -139,32 +142,17 @@ export function setstringToKey(
139142
string: string,
140143
key: string
141144
): void;
142-
export function setAttachmentTypesEnabled(
143-
screenshot: boolean,
144-
extraScreenshot: boolean,
145-
galleryImage: boolean,
146-
voiceNote: boolean,
147-
screenRecording: boolean
148-
): void;
149145
export function setEnabledAttachmentTypes(
150146
screenshot: boolean,
151147
extraScreenshot: boolean,
152148
galleryImage: boolean,
153149
screenRecording: boolean
154150
): void;
155-
export function setChatNotificationEnabled(isChatNotificationEnabled: boolean): void;
156-
export function setOnNewMessageHandler(onNewMessageHandler: () => void): void;
157-
export function isInstabugNotification(
158-
dict: any,
159-
isInstabugNotificationCallback: () => void
160-
): void;
161151
export function identifyUserWithEmail(
162152
email: string,
163153
name: string
164154
): void;
165155
export function logOut(): void;
166-
export function setReportCategories(...titles: string[]): void;
167-
export function setExtendedBugReportMode(extendedBugReportMode: extendedBugReportMode): void;
168156
export function logUserEventWithName(name: string, params?: any): void;
169157
export function logVerbose(message: string): void;
170158
export function logInfo(message: string): void;
@@ -185,36 +173,20 @@ export function removeUserAttribute(key: string): void;
185173
export function getAllUserAttributes(userAttributesCallback: () => void): void;
186174
export function clearAllUserAttributes(): void;
187175
export function setViewHierarchyEnabled(viewHierarchyEnabled: boolean): void;
188-
export function setSurveysEnabled(surveysEnabled: boolean): void;
189-
export function showSurveysIfAvailable(): void;
190-
export function setWillShowSurveyHandler(willShowSurveyHandler: () => void): void;
191-
export function setDidDismissSurveyHandler(didDismissSurveyHandler: () => void): void;
192-
export function setPromptOptionsEnabled(
193-
chat: boolean,
194-
bug: boolean,
195-
feedback: boolean
196-
): void;
197176
export function setDebugEnabled(isDebugEnabled: boolean): void;
198177
export function enable(): void;
199178
export function disable(): void;
200179
export function isRunningLive(runningLiveCallBack: () => void): void;
201-
export function setSuccessDialogEnabled(enabled: boolean): void;
202-
export function setEnableInAppNotificationSound(shouldPlaySound: boolean): void;
203-
export function reportJSException(errorObject: any): void;
204180
export function setVideoRecordingFloatingButtonPosition(position: IBGPosition): void;
205-
export function setThresholdForReshowingSurveyAfterDismiss(
206-
sessionCount: number,
207-
daysCount: number
208-
): void;
209-
export function setAutoShowingSurveysEnabled(autoShowingSurveysEnabled: boolean): void;
210-
export function showFeatureRequests(): void;
211181
export function setShouldShowSurveysWelcomeScreen(shouldShowWelcomeScreen: boolean): void;
212182
export function showWelcomeMessage(welcomeMessageMode: welcomeMessageMode): void;
213183
export function setWelcomeMessageMode(welcomeMessageMode: welcomeMessageMode): void;
214184
export function addFileAttachment(
215185
filePath: string,
216186
fileName: string
217187
): void;
188+
export function show(): void;
189+
export function onReportSubmitHandler(preSendingHandler: () => void): void;
218190
export function callPrivateApi(
219191
apiName: string,
220192
param: any

index.js

Lines changed: 0 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,6 @@ const InstabugModule = {
6767
Instabug.setAutoScreenRecordingMaxDuration(autoScreenRecordingMaxDuration);
6868
},
6969

70-
/**
71-
* @deprecated use {@link Instabug.setTrackUserSteps}
72-
* Sets whether the SDK is tracking user steps or not.
73-
* Enabling user steps would give you an insight on the scenario a user has
74-
* performed before encountering a bug or a crash. User steps are attached
75-
* with each report being sent.
76-
* @param {boolean} isUserStepsEnabled A boolean to set user steps tracking
77-
* to being enabled or disabled.
78-
*/
79-
setUserStepsEnabled: function(isUserStepsEnabled) {
80-
if (Platform.OS === 'ios') Instabug.setUserStepsEnabled(isUserStepsEnabled);
81-
},
82-
8370
/**
8471
* Sets whether the SDK is tracking user steps or not.
8572
* Enabling user steps would give you an insight on the scenario a user has
@@ -102,15 +89,6 @@ const InstabugModule = {
10289
Instabug.setIBGLogPrintsToConsole(printsToConsole);
10390
},
10491

105-
/**
106-
* @deprecated use {@link CrashReporting.setCrashReportingEnabled}
107-
* Report un-caught exceptions to Instabug dashboard
108-
* We don't send exceptions from __DEV__, since it's way too noisy!
109-
*/
110-
setCrashReportingEnabled: function(enableCrashReporter) {
111-
Instabug.setCrashReportingEnabled(enableCrashReporter);
112-
},
113-
11492
/**
11593
* Sets a block of code to be executed when a prompt option is selected.
11694
* @param {function} didSelectPromptOptionHandler - A block of code that
@@ -147,37 +125,6 @@ const InstabugModule = {
147125
Instabug.setSessionProfilerEnabled(sessionProfilerEnabled);
148126
},
149127

150-
/**
151-
* Sets the default value of the user's email and hides the email field
152-
* from the reporting UI.
153-
* Defaults to an empty string.
154-
* @param {string} userEmail An email address to be set as the user's email.
155-
*/
156-
setUserEmail: function(userEmail) {
157-
Instabug.setUserEmail(userEmail);
158-
},
159-
160-
/**
161-
* Sets the default value of the user's name to be included with all reports.
162-
* Defaults to an empty string.
163-
* @param {string} userName Name of the user to be set.
164-
*/
165-
setUserName: function(userName) {
166-
Instabug.setUserName(userName);
167-
},
168-
169-
/**
170-
* @deprecated use {@link Replies.getUnreadRepliesCount}
171-
* Returns the number of unread messages the user currently has.
172-
* Use this method to get the number of unread messages the user
173-
* has, then possibly notify them about it with your own UI.
174-
* @param {messageCountCallback} messageCountCallback callback with argument
175-
* Notifications count, or -1 in case the SDK has not been initialized.
176-
*/
177-
getUnreadMessagesCount: function(messageCountCallback) {
178-
Instabug.getUnreadMessagesCount(messageCountCallback);
179-
},
180-
181128
/**
182129
* Enables/disables the use of push notifications in the SDK.
183130
* Defaults to YES.
@@ -311,40 +258,6 @@ const InstabugModule = {
311258
);
312259
},
313260

314-
/**
315-
* @deprecated use {@link Replies.setInAppNotificationsEnabled}
316-
* Enables/disables showing in-app notifications when the user receives a
317-
* new message.
318-
* @param {boolean} isChatNotificationEnabled A boolean to set whether
319-
* notifications are enabled or disabled.
320-
*/
321-
setChatNotificationEnabled: function(isChatNotificationEnabled) {
322-
Instabug.setChatNotificationEnabled(isChatNotificationEnabled);
323-
},
324-
325-
/**
326-
* @deprecated use {@link Replies.setOnNewReplyReceivedCallback}
327-
* Sets a block of code that gets executed when a new message is received.
328-
* @param {function} onNewMessageHandler - A callback that gets
329-
* executed when a new message is received.
330-
*/
331-
setOnNewMessageHandler: function(onNewMessageHandler) {
332-
if (Platform.OS === 'ios') {
333-
Instabug.addListener('IBGonNewMessageHandler');
334-
NativeAppEventEmitter.addListener(
335-
'IBGonNewMessageHandler',
336-
onNewMessageHandler
337-
);
338-
} else {
339-
DeviceEventEmitter.addListener(
340-
'IBGonNewMessageHandler',
341-
onNewMessageHandler
342-
);
343-
}
344-
345-
Instabug.setOnNewMessageHandler(onNewMessageHandler);
346-
},
347-
348261
/**
349262
* Sets the default value of the user's email and hides the email field from the reporting UI
350263
* and set the user's name to be included with all reports.
@@ -567,20 +480,6 @@ const InstabugModule = {
567480
Instabug.setViewHierarchyEnabled(viewHierarchyEnabled);
568481
},
569482

570-
/**
571-
* @deprecated use {@link Surveys.setEnabled}
572-
* @summary Sets whether surveys are enabled or not.
573-
* If you disable surveys on the SDK but still have active surveys on your Instabug dashboard,
574-
* those surveys are still going to be sent to the device, but are not going to be
575-
* shown automatically.
576-
* To manually display any available surveys, call `Instabug.showSurveyIfAvailable()`.
577-
* Defaults to `true`.
578-
* @param {boolean} surveysEnabled A boolean to set whether Instabug Surveys is enabled or disabled.
579-
*/
580-
setSurveysEnabled: function(surveysEnabled) {
581-
Instabug.setSurveysEnabled(surveysEnabled);
582-
},
583-
584483
/**
585484
* Enable/Disable debug logs from Instabug SDK
586485
* Default state: disabled
@@ -626,41 +525,6 @@ const InstabugModule = {
626525
}
627526
},
628527

629-
/**
630-
* @deprecated use {@link Replies.setInAppNotificationSound}
631-
* Set whether new in app notification received will play a small sound notification
632-
* or not (Default is {@code false})
633-
*
634-
* @param shouldPlaySound desired state of conversation sounds
635-
* @since 4.1.0
636-
*/
637-
setEnableInAppNotificationSound: function(shouldPlaySound) {
638-
if (Platform.OS === 'android') {
639-
Instabug.setEnableInAppNotificationSound(shouldPlaySound);
640-
}
641-
},
642-
643-
/**
644-
* @deprecated use {@link CrashReporting.reportJSException}
645-
* Send handled JS error object
646-
*
647-
* @param errorObject Error object to be sent to Instabug's servers
648-
*/
649-
reportJSException: function(errorObject) {
650-
let jsStackTrace = InstabugUtils.parseErrorStack(errorObject);
651-
var jsonObject = {
652-
message: errorObject.name + ' - ' + errorObject.message,
653-
os: Platform.OS,
654-
platform: 'react_native',
655-
exception: jsStackTrace
656-
};
657-
if (Platform.OS === 'android') {
658-
Instabug.sendHandledJSCrash(JSON.stringify(jsonObject));
659-
} else {
660-
Instabug.sendHandledJSCrash(jsonObject);
661-
}
662-
},
663-
664528
/**
665529
* Sets the default position at which the Instabug screen recording button will be shown.
666530
* Different orientations are already handled.

0 commit comments

Comments
 (0)