Skip to content

Commit 976be2b

Browse files
authored
🎨 Refactor API names to match convention (#60)
* 🎨 Refactor API names to match JS naming conventions
1 parent 5f3b96d commit 976be2b

File tree

4 files changed

+102
-10
lines changed

4 files changed

+102
-10
lines changed

index.js

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ var _isOnReportHandlerSet = false;
3131
*/
3232
const InstabugModule = {
3333
/**
34+
* @deprecated use {@link Instabug.start}
3435
* Starts the SDK.
3536
* This is the main SDK method that does all the magic. This is the only
3637
* method that SHOULD be called.
@@ -41,6 +42,20 @@ const InstabugModule = {
4142
* the SDK's UI.
4243
*/
4344
startWithToken: function(token, invocationEvent) {
45+
this.start(token, invocationEvent);
46+
},
47+
48+
/**
49+
* Starts the SDK.
50+
* This is the main SDK method that does all the magic. This is the only
51+
* method that SHOULD be called.
52+
* Should be called in constructor of the app registery component
53+
* @param {string} token The token that identifies the app, you can find
54+
* it on your dashboard.
55+
* @param {invocationEvent} invocationEvent The event that invokes
56+
* the SDK's UI.
57+
*/
58+
start: function(token, invocationEvent) {
4459
if (Platform.OS === 'ios') Instabug.startWithToken(token, invocationEvent);
4560
},
4661

@@ -257,12 +272,23 @@ const InstabugModule = {
257272
},
258273

259274
/**
275+
* @deprecated use {@link Instabug.setString}
260276
* Overrides any of the strings shown in the SDK with custom ones.
261277
* Allows you to customize any of the strings shown to users in the SDK.
262278
* @param {string} string String value to override the default one.
263279
* @param {strings} key Key of string to override.
264280
*/
265281
setStringToKey: function(string, key) {
282+
this.setString(key, string);
283+
},
284+
285+
/**
286+
* Overrides any of the strings shown in the SDK with custom ones.
287+
* Allows you to customize any of the strings shown to users in the SDK.
288+
* @param {string} string String value to override the default one.
289+
* @param {strings} key Key of string to override.
290+
*/
291+
setString: function(key, string) {
266292
Instabug.setString(string, key);
267293
},
268294

@@ -291,6 +317,7 @@ const InstabugModule = {
291317
},
292318

293319
/**
320+
* @deprecated use {@link Instabug.identifyUser}
294321
* Sets the default value of the user's email and hides the email field from the reporting UI
295322
* and set the user's name to be included with all reports.
296323
* It also reset the chats on device to that email and removes user attributes,
@@ -299,6 +326,18 @@ const InstabugModule = {
299326
* @param {string} name Name of the user to be set.
300327
*/
301328
identifyUserWithEmail: function(email, name) {
329+
this.identifyUser(email, name);
330+
},
331+
332+
/**
333+
* Sets the default value of the user's email and hides the email field from the reporting UI
334+
* and set the user's name to be included with all reports.
335+
* It also reset the chats on device to that email and removes user attributes,
336+
* user data and completed surveys.
337+
* @param {string} email Email address to be set as the user's email.
338+
* @param {string} name Name of the user to be set.
339+
*/
340+
identifyUser: function(email, name) {
302341
if (Platform.OS == 'ios') {
303342
Instabug.identifyUserWithEmail(email, name);
304343
} else if ('android') {
@@ -316,11 +355,21 @@ const InstabugModule = {
316355
},
317356

318357
/**
319-
* @deprecated Logs a user event that happens through the lifecycle of the application.
358+
* @deprecated use {@link Instabug.logUserEvent}
359+
* Logs a user event that happens through the lifecycle of the application.
320360
* Logged user events are going to be sent with each report, as well as at the end of a session.
321361
* @param {string} name Event name.
322362
*/
323363
logUserEventWithName: function(name) {
364+
this.logUserEvent(name);
365+
},
366+
367+
/**
368+
* Logs a user event that happens through the lifecycle of the application.
369+
* Logged user events are going to be sent with each report, as well as at the end of a session.
370+
* @param {string} name Event name.
371+
*/
372+
logUserEvent: function(name) {
324373
Instabug.logUserEventWithName(name);
325374
},
326375

@@ -521,7 +570,6 @@ const InstabugModule = {
521570
* @param {function} onNewMessageHandler - A callback that gets
522571
* executed when a new message is received.
523572
*/
524-
525573
setOnNewMessageHandler: function(onNewMessageHandler) {
526574
if (Platform.OS === 'ios') {
527575
Instabug.addListener('IBGonNewMessageHandler');

modules/BugReporting.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,21 @@ export default {
201201
},
202202

203203
/**
204+
* @deprecated use {@link BugReporting.show}
204205
* Invoke bug reporting with report type and options.
205206
* @param {reportType} type
206207
* @param {option} options
207208
*/
208209
showWithOptions(type, options) {
210+
this.show(type, options);
211+
},
212+
213+
/**
214+
* Invoke bug reporting with report type and options.
215+
* @param {reportType} type
216+
* @param {option} options
217+
*/
218+
show(type, options) {
209219
if (!options) {
210220
options = [];
211221
}

modules/Replies.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,26 @@ export default {
3131
},
3232

3333
/**
34+
* @deprecated use {@link Replies.setOnNewReplyReceivedHandler}
3435
* Sets a block of code that gets executed when a new message is received.
3536
* @param {function} onNewReplyReceivedCallback - A callback that gets
3637
* executed when a new message is received.
3738
*/
3839
setOnNewReplyReceivedCallback(onNewReplyReceivedCallback) {
40+
this.setOnNewReplyReceivedHandler(onNewReplyReceivedCallback);
41+
},
42+
43+
/**
44+
* Sets a block of code that gets executed when a new message is received.
45+
* @param {function} onNewReplyReceivedHandler - A callback that gets
46+
* executed when a new message is received.
47+
*/
48+
setOnNewReplyReceivedHandler(onNewReplyReceivedHandler) {
3949
IBGEventEmitter.addListener(
4050
'IBGOnNewReplyReceivedCallback',
41-
onNewReplyReceivedCallback
51+
onNewReplyReceivedHandler
4252
);
43-
Instabug.setOnNewReplyReceivedCallback(onNewReplyReceivedCallback);
53+
Instabug.setOnNewReplyReceivedCallback(onNewReplyReceivedHandler);
4454
},
4555

4656
/**

modules/Surveys.js

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,51 +73,75 @@ export default {
7373
},
7474

7575
/**
76+
* @deprecated use {@link Surveys.setOnShowHandler}
7677
* @summary Sets a block of code to be executed just before the survey's UI is presented.
7778
* This block is executed on the UI thread. Could be used for performing any UI changes before
7879
* the survey's UI is shown.
7980
* @param {function} willShowSurveyHandler - A block of code that gets executed before
8081
* presenting the survey's UI.
8182
*/
8283
onShowCallback: function(willShowSurveyHandler) {
84+
this.setOnShowHandler(willShowSurveyHandler);
85+
},
86+
87+
/**
88+
* @summary Sets a block of code to be executed just before the survey's UI is presented.
89+
* This block is executed on the UI thread. Could be used for performing any UI changes before
90+
* the survey's UI is shown.
91+
* @param {function} onShowHandler - A block of code that gets executed before
92+
* presenting the survey's UI.
93+
*/
94+
setOnShowHandler: function(onShowHandler) {
8395
if (Platform.OS === 'ios') {
8496
Instabug.addListener('IBGWillShowSurvey');
8597
NativeAppEventEmitter.addListener(
8698
'IBGWillShowSurvey',
87-
willShowSurveyHandler
99+
onShowHandler
88100
);
89101
} else {
90102
DeviceEventEmitter.addListener(
91103
'IBGWillShowSurvey',
92-
willShowSurveyHandler
104+
onShowHandler
93105
);
94106
}
95107

96-
Instabug.setWillShowSurveyHandler(willShowSurveyHandler);
108+
Instabug.setWillShowSurveyHandler(onShowHandler);
97109
},
98110

99111
/**
112+
* @deprecated use {@link Surveys.setOnDismissHandler}
100113
* @summary Sets a block of code to be executed right after the survey's UI is dismissed.
101114
* This block is executed on the UI thread. Could be used for performing any UI
102115
* changes after the survey's UI is dismissed.
103116
* @param {function} didDismissSurveyHandler - A block of code that gets executed after
104117
* the survey's UI is dismissed.
105118
*/
106119
onDismissCallback: function(didDismissSurveyHandler) {
120+
this.setOnDismissHandler(didDismissSurveyHandler);
121+
},
122+
123+
/**
124+
* @summary Sets a block of code to be executed right after the survey's UI is dismissed.
125+
* This block is executed on the UI thread. Could be used for performing any UI
126+
* changes after the survey's UI is dismissed.
127+
* @param {function} onDismissHandler - A block of code that gets executed after
128+
* the survey's UI is dismissed.
129+
*/
130+
setOnDismissHandler: function(onDismissHandler) {
107131
if (Platform.OS === 'ios') {
108132
Instabug.addListener('IBGDidDismissSurvey');
109133
NativeAppEventEmitter.addListener(
110134
'IBGDidDismissSurvey',
111-
didDismissSurveyHandler
135+
onDismissHandler
112136
);
113137
} else {
114138
DeviceEventEmitter.addListener(
115139
'IBGDidDismissSurvey',
116-
didDismissSurveyHandler
140+
onDismissHandler
117141
);
118142
}
119143

120-
Instabug.setDidDismissSurveyHandler(didDismissSurveyHandler);
144+
Instabug.setDidDismissSurveyHandler(onDismissHandler);
121145
},
122146

123147
/**

0 commit comments

Comments
 (0)