This repository has been archived by the owner on Feb 27, 2024. It is now read-only.
forked from Instabug/Instabug-React-Native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
1410 lines (1297 loc) · 45.7 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import {
NativeModules,
NativeAppEventEmitter,
DeviceEventEmitter,
Platform
} from 'react-native';
let { Instabug } = NativeModules;
import InstabugUtils from './utils/InstabugUtils.js';
import BugReporting from './modules/BugReporting.js';
import Surveys from './modules/Surveys.js';
import FeatureRequests from './modules/FeatureRequests.js';
InstabugUtils.captureJsErrors();
/**
* Instabug
* @exports Instabug
*/
const InstabugModule = {
/**
* Starts the SDK.
* This is the main SDK method that does all the magic. This is the only
* method that SHOULD be called.
* Should be called in constructor of the app registery component
* @param {string} token The token that identifies the app, you can find
* it on your dashboard.
* @param {invocationEvent} invocationEvent The event that invokes
* the SDK's UI.
*/
startWithToken: function(token, invocationEvent) {
if (Platform.OS === 'ios') Instabug.startWithToken(token, invocationEvent);
},
/**
* @deprecated Use {@link BugReporting.invoke()} instead.
* Invokes the SDK manually with the default invocation mode.
* Shows a view that asks the user whether they want to start a chat, report
* a problem or suggest an improvement.
*/
invoke: function() {
Instabug.invoke();
},
/**
* @deprecated Use {@link BugReporting.invokeWithInvocationModeAndOptions} instead.
* Invokes the SDK with a specific mode.
* Invokes the SDK and show a specific view, instead of showing a prompt for
* users to choose from.
* @param {invocationMode} invocationMode Specifies which mode the
* SDK is going to start with.
*/
invokeWithInvocationMode: function(invocationMode) {
Instabug.invokeWithInvocationMode(invocationMode);
},
/**
* @deprecated Use {@link BugReporting.dismiss() instead}
* Dismisses any Instabug views that are currently being shown.
*/
dismiss: function() {
Instabug.dismiss();
},
/**
* Attaches user data to each report being sent.
* Each call to this method overrides the user data to be attached.
* Maximum size of the string is 1,000 characters.
* @param {string} userData A string to be attached to each report, with a
* maximum size of 1,000 characters.
*/
setUserData: function(userData) {
Instabug.setUserData(userData);
},
/**
* Enable/Disable screen recording
* @param {boolean} autoScreenRecordingEnabled boolean for enable/disable
* screen recording on crash feature
*/
setAutoScreenRecordingEnabled: function(autoScreenRecordingEnabled) {
Instabug.setAutoScreenRecordingEnabled(autoScreenRecordingEnabled);
},
/**
* Sets auto screen recording maximum duration
*
* @param autoScreenRecordingMaxDuration maximum duration of the screen recording video
* in seconds
* The maximum duration is 30 seconds
*/
setAutoScreenRecordingMaxDuration: function(autoScreenRecordingMaxDuration) {
Instabug.setAutoScreenRecordingMaxDuration(autoScreenRecordingMaxDuration);
},
/**
* Adds custom logs that will be sent with each report.
* @param {string} log Message to be logged.
*/
IBGLog: function(log) {
Instabug.IBGLog(log);
},
/**
* Sets whether the SDK is tracking user steps or not.
* Enabling user steps would give you an insight on the scenario a user has
* performed before encountering a bug or a crash. User steps are attached
* with each report being sent.
* @param {boolean} isUserStepsEnabled A boolean to set user steps tracking
* to being enabled or disabled.
*/
setUserStepsEnabled: function(isUserStepsEnabled) {
if (Platform.OS === 'ios') Instabug.setUserStepsEnabled(isUserStepsEnabled);
},
/**
* Sets whether IBGLog should also print to Xcode's console log or not.
* @param {boolean} printsToConsole A boolean to set whether printing to
* Xcode's console is enabled or not.
*/
setIBGLogPrintsToConsole: function(printsToConsole) {
if (Platform.OS === 'ios')
Instabug.setIBGLogPrintsToConsole(printsToConsole);
},
/**
* Report un-caught exceptions to Instabug dashboard
* We don't send exceptions from __DEV__, since it's way too noisy!
*/
setCrashReportingEnabled: function(enableCrashReporter) {
Instabug.setCrashReportingEnabled(enableCrashReporter);
},
/**
* @deprecated Use {@link BugReporting.onReportSubmitHandler} instead.
* Sets a block of code to be executed before sending each report.
* This block is executed in the background before sending each report. Could
* be used for attaching logs and extra data to reports.
* @param {function} preSendingHandler - A callback that gets executed before sending each bug
* report.
*/
setPreSendingHandler: function(preSendingHandler) {
if (Platform.OS === 'ios') {
Instabug.addListener('IBGpreSendingHandler');
NativeAppEventEmitter.addListener(
'IBGpreSendingHandler',
preSendingHandler
);
} else {
DeviceEventEmitter.addListener('IBGpreSendingHandler', preSendingHandler);
}
Instabug.setPreSendingHandler(preSendingHandler);
},
/**
* Sets a block of code to be executed when a prompt option is selected.
* @param {function} didSelectPromptOptionHandler - A block of code that
* gets executed when a prompt option is selected.
*/
setDidSelectPromptOptionHandler: function(didSelectPromptOptionHandler) {
if (Platform.OS === 'ios') {
Instabug.addListener('IBGDidSelectPromptOptionHandler');
NativeAppEventEmitter.addListener(
'IBGDidSelectPromptOptionHandler',
function(payload) {
didSelectPromptOptionHandler(payload['promptOption']);
}
);
} else {
DeviceEventEmitter.addListener(
'IBGDidSelectPromptOptionHandler',
function(payload) {
didSelectPromptOptionHandler(payload.promptOption);
}
);
}
Instabug.didSelectPromptOptionHandler(didSelectPromptOptionHandler);
},
/**
* @deprecated
* Shows survey with a specific token.
* Does nothing if there are no available surveys with that specific token.
* Answered and cancelled surveys won't show up again.
* @param {string} surveyToken - A String with a survey token.
*
*/
showSurveyWithToken: function(surveyToken) {
Instabug.showSurveyWithToken(surveyToken);
},
/**
* @deprecated
* Returns true if the survey with a specific token was answered before.
* Will return false if the token does not exist or if the survey was not answered before.
* @param {string} surveyToken - A String with a survey token.
* @param {function} surveyTokenCallback callback with argument as the desired value of the whether
* the survey has been responded to or not.
*
*/
hasRespondedToSurveyWithToken: function(surveyToken, surveyTokenCallback) {
Instabug.hasRespondedToSurveyWithToken(surveyToken, surveyTokenCallback);
},
/**
* The session profiler is enabled by default and it attaches to the bug and
* crash reports the following information during the last 60 seconds before the report is sent.
* @param {boolean} sessionProfilerEnabled - A boolean parameter to enable or disable the feature.
*
*/
setSessionProfilerEnabled: function(sessionProfilerEnabled) {
Instabug.setSessionProfilerEnabled(sessionProfilerEnabled);
},
/**
* @deprecated Use {@link BugReporting.onInvokeHandler} instead
* Sets a block of code to be executed just before the SDK's UI is presented.
* This block is executed on the UI thread. Could be used for performing any
* UI changes before the SDK's UI is shown.
* @param {function} preInvocationHandler - A callback that gets executed before invoking the SDK
*/
setPreInvocationHandler: function(preInvocationHandler) {
if (Platform.OS === 'ios') {
Instabug.addListener('IBGpreInvocationHandler');
NativeAppEventEmitter.addListener(
'IBGpreInvocationHandler',
preInvocationHandler
);
} else {
DeviceEventEmitter.addListener(
'IBGpreInvocationHandler',
preInvocationHandler
);
}
Instabug.setPreInvocationHandler(preInvocationHandler);
},
/**
* @deprecated {@link BugReporting.onSDKDismissedHandler} instead
* Sets a block of code to be executed right after the SDK's UI is dismissed.
* This block is executed on the UI thread. Could be used for performing any
* UI changes after the SDK's UI is dismissed.
* @param {function} postInvocationHandler - A callback to get executed after
* dismissing the SDK.
*/
setPostInvocationHandler: function(postInvocationHandler) {
if (Platform.OS === 'ios') {
Instabug.addListener('IBGpostInvocationHandler');
NativeAppEventEmitter.addListener('IBGpostInvocationHandler', function(
payload
) {
postInvocationHandler(payload['dismissType'], payload['reportType']);
});
} else {
DeviceEventEmitter.addListener('IBGpostInvocationHandler', function(
payload
) {
postInvocationHandler(payload.dismissType, payload.reportType);
});
}
Instabug.setPostInvocationHandler(postInvocationHandler);
},
/**
* @deprecated Present a view that educates the user on how to invoke the SDK with the
* currently set invocation event.
*/
showIntroMessage: function() {
Instabug.showIntroMessage();
},
/**
* Sets the default value of the user's email and hides the email field
* from the reporting UI.
* Defaults to an empty string.
* @param {string} userEmail An email address to be set as the user's email.
*/
setUserEmail: function(userEmail) {
Instabug.setUserEmail(userEmail);
},
/**
* Sets the default value of the user's name to be included with all reports.
* Defaults to an empty string.
* @param {string} userName Name of the user to be set.
*/
setUserName: function(userName) {
Instabug.setUserName(userName);
},
/**
* @deprecated Enables/disables screenshot view when reporting a bug/improvement.
* By default, screenshot view is shown when reporting a bug, but not when
* sending feedback.
* @param {boolean} willSkipScreenshotAnnotation sets whether screenshot view is
* shown or not. Passing YES will show screenshot view for both feedback and
* bug reporting, while passing NO will disable it for both.
*/
setWillSkipScreenshotAnnotation: function(willSkipScreenshotAnnotation) {
Instabug.setWillSkipScreenshotAnnotation(willSkipScreenshotAnnotation);
},
/**
* Returns the number of unread messages the user currently has.
* Use this method to get the number of unread messages the user
* has, then possibly notify them about it with your own UI.
* @param {messageCountCallback} messageCountCallback callback with argument
* Notifications count, or -1 in case the SDK has not been initialized.
*/
getUnreadMessagesCount: function(messageCountCallback) {
Instabug.getUnreadMessagesCount(messageCountCallback);
},
/**
* @deprecated Use {@link setInvocationEvents} instead.
* Sets the event that invoke the feedback form.
* Default is set by `Instabug.startWithToken`.
* @param {invocationEvent} invocationEvent Event that invokes the
* feedback form.
*/
setInvocationEvent: function(invocationEvent) {
Instabug.setInvocationEvent(invocationEvent);
},
/**
* Enables/disables the use of push notifications in the SDK.
* Defaults to YES.
* @param {boolean} isPushNotificationEnabled A boolean to indicate whether push
* notifications are enabled or disabled.
*/
setPushNotificationsEnabled: function(isPushNotificationEnabled) {
if (Platform.OS === 'ios')
Instabug.setPushNotificationsEnabled(isPushNotificationEnabled);
},
/**
* @deprecated Sets whether users are required to enter an email address or not when
* sending reports.
* Defaults to YES.
* @param {boolean} isEmailFieldRequired A boolean to indicate whether email
* field is required or not.
*/
setEmailFieldRequired: function(isEmailFieldRequired) {
Instabug.setEmailFieldRequired(isEmailFieldRequired);
},
/**
* @deprecated use {@link BugReporting.setInvocationOptions}
* Sets whether users are required to enter an email address or not when
* sending reports.
* Defaults to YES.
* @param {boolean} isEmailFieldRequired A boolean to indicate whether email
* field is required or not.
* @param {actionTypes} actionTypes An enum that indicates which action
* types will have the isEmailFieldRequired
*/
setEmailFieldRequiredForActions: function(isEmailFieldRequired, actionTypes) {
Instabug.setEmailFieldRequiredForActions(isEmailFieldRequired, actionTypes);
},
/**
* @deprecated Sets whether users are required to enter a comment or not when sending reports.
* Defaults to NO.
* @param {boolean} isCommentFieldRequired A boolean to indicate whether comment
* field is required or not.
*/
setCommentFieldRequired: function(isCommentFieldRequired) {
Instabug.setCommentFieldRequired(isCommentFieldRequired);
},
/**
* @deprecated since version 2.3.0. Use {@link setShakingThresholdForiPhone}
* and {@link setShakingThresholdForiPad} instead.
* Sets the threshold value of the shake gesture for iPhone/iPod Touch and iPad.
* Default for iPhone is 2.5.
* Default for iPad is 0.6.
* @param {number} iPhoneShakingThreshold Threshold for iPhone.
* @param {number} iPadShakingThreshold Threshold for iPad.
*/
setShakingThresholdForIPhone: function(
iPhoneShakingThreshold,
iPadShakingThreshold
) {
if (Platform.OS === 'ios')
Instabug.setShakingThresholdForIPhone(
iPhoneShakingThreshold,
iPadShakingThreshold
);
},
/**
* @deprecated
* Sets the threshold value of the shake gesture for iPhone/iPod Touch
* Default for iPhone is 2.5.
* @param {number} iPhoneShakingThreshold Threshold for iPhone.
*/
setShakingThresholdForiPhone: function(iPhoneShakingThreshold) {
if (Platform.OS === 'ios')
Instabug.setShakingThresholdForiPhone(iPhoneShakingThreshold);
},
/**
* @deprecated
* Sets the threshold value of the shake gesture for iPad.
* Default for iPad is 0.6.
* @param {number} iPadShakingThreshold Threshold for iPad.
*/
setShakingThresholdForiPad: function(iPadShakingThreshold) {
if (Platform.OS === 'ios')
Instabug.setShakingThresholdForiPad(iPadShakingThreshold);
},
/**
* @deprecated
* Sets the threshold value of the shake gesture for android devices.
* Default for android is an integer value equals 350.
* you could increase the shaking difficulty level by
* increasing the `350` value and vice versa
* @param {number} androidThreshold Threshold for android devices.
*/
setShakingThresholdForAndroid: function(androidThreshold) {
if (Platform.OS === 'android')
Instabug.setShakingThresholdForAndroid(androidThreshold);
},
/**
* 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: function(floatingButtonEdge, offsetFromTop) {
if (Platform.OS === 'ios')
Instabug.setFloatingButtonEdge(floatingButtonEdge, offsetFromTop);
},
/**
* Sets the SDK's locale.
* Use to change the SDK's UI to different language.
* Defaults to the device's current locale.
* @param {locale} locale A locale to set the SDK to.
*/
setLocale: function(locale) {
if (Platform.OS === 'ios') {
Instabug.setLocale(locale);
} else if (Platform.OS === 'android') {
Instabug.changeLocale(locale);
}
},
/**
* @deprecated Sets whether the intro message that gets shown on launching the app is
* enabled or not.
* Defaults to YES.
* @param {boolean} isIntroMessageEnabled A boolean to indicate whether the
* intro message is enabled or not.
*/
setIntroMessageEnabled: function(isIntroMessageEnabled) {
Instabug.setIntroMessageEnabled(isIntroMessageEnabled);
},
/**
* Sets the color theme of the SDK's whole UI.
* the SDK's UI to.
* @param colorTheme
*/
setColorTheme: function(colorTheme) {
Instabug.setColorTheme(colorTheme);
},
/**
* Sets the primary color of the SDK's UI.
* Sets the color of UI elements indicating interactivity or call to action.
* To use, import processColor and pass to it with argument the color hex
* as argument.
* @param {color} primaryColor A color to set the UI elements of the SDK to.
*/
setPrimaryColor: function(primaryColor) {
if (Platform.OS == 'ios') {
Instabug.setPrimaryColor(primaryColor);
}
},
/**
* Appends a set of tags to previously added tags of reported feedback,
* bug or crash.
* @param {string[]} tags An array of tags to append to current tags.
*/
appendTags: function(tags) {
Instabug.appendTags(tags);
},
/**
* Manually removes all tags of reported feedback, bug or crash.
*/
resetTags: function() {
Instabug.resetTags();
},
/**
* Gets all tags of reported feedback, bug or crash.
* @param {tagsCallback} tagsCallback callback with argument tags of reported feedback, bug or crash.
*/
getTags: function(tagsCallback) {
Instabug.getTags(tagsCallback);
},
/**
* Overrides any of the strings shown in the SDK with custom ones.
* Allows you to customize any of the strings shown to users in the SDK.
* @param {string} string String value to override the default one.
* @param {strings} key Key of string to override.
*/
setStringToKey: function(string, key) {
Instabug.setString(string, key);
},
/**
* @deprecated since version 2.3.0. Use {@link setEnabledAttachmentTypes} instead.
* 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} voiceNote A boolean to enable or disable voice note attachments.
* In iOS 10+, NSMicrophoneUsageDescription should be set in info.plist to enable
* voiceNote attachments.
* @param {boolean} screenRecording A boolean to enable or disable screen recording attachments.
*/
setAttachmentTypesEnabled: function(
screenshot,
extraScreenshot,
galleryImage,
voiceNote,
screenRecording
) {
Instabug.setEnabledAttachmentTypes(
screenshot,
extraScreenshot,
galleryImage,
screenRecording
);
},
/**
* 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: function(
screenshot,
extraScreenshot,
galleryImage,
screenRecording
) {
Instabug.setEnabledAttachmentTypes(
screenshot,
extraScreenshot,
galleryImage,
screenRecording
);
},
/**
* Enables/disables showing in-app notifications when the user receives a
* new message.
* @param {boolean} isChatNotificationEnabled A boolean to set whether
* notifications are enabled or disabled.
*/
setChatNotificationEnabled: function(isChatNotificationEnabled) {
Instabug.setChatNotificationEnabled(isChatNotificationEnabled);
},
/**
* Sets a block of code that gets executed when a new message is received.
* @param {function} onNewMessageHandler - A callback that gets
* executed when a new message is received.
*/
setOnNewMessageHandler: function(onNewMessageHandler) {
if (Platform.OS === 'ios') {
Instabug.addListener('IBGonNewMessageHandler');
NativeAppEventEmitter.addListener(
'IBGonNewMessageHandler',
onNewMessageHandler
);
} else {
DeviceEventEmitter.addListener(
'IBGonNewMessageHandler',
onNewMessageHandler
);
}
Instabug.setOnNewMessageHandler(onNewMessageHandler);
},
/**
* Checks if a notification is from Instabug.
* If you are using push notifications, use this method to check whether an
* incoming notification is from Instabug or not. If this method returns YES,
* you should call didReceiveRemoteNotification: to let the Instabug handle
* the notification. Otherwise, handle the notification on your own.
* @param {Object} dict Notification's userInfo
* @param {function} isInstabugNotificationCallback callback with
* argument isInstabugNotification
*/
isInstabugNotification: function(dict, isInstabugNotificationCallback) {
if (Platform.OS === 'ios')
Instabug.isInstabugNotification(dict, isInstabugNotificationCallback);
},
/**
* Sets the default value of the user's email and hides the email field from the reporting UI
* and set the user's name to be included with all reports.
* It also reset the chats on device to that email and removes user attributes,
* user data and completed surveys.
* @param {string} email Email address to be set as the user's email.
* @param {string} name Name of the user to be set.
*/
identifyUserWithEmail: function(email, name) {
if (Platform.OS == 'ios') {
Instabug.identifyUserWithEmail(email, name);
} else if ('android') {
Instabug.identifyUser(name, email);
}
},
/**
* Sets the default value of the user's email to nil and show email field and remove user name
* from all reports
* It also reset the chats on device and removes user attributes, user data and completed surveys.
*/
logOut: function() {
Instabug.logOut();
},
/**
* @deprecated since version 2.7.0, you can now add categories from the dashboard.
* Sets an array of report categories to be shown for users to select from before reporting a
* bug or sending feedback.
* Use this method to give users a list of choices of categories their bug report or feedback
* might be related to. Selected category will be shown as a tag on your dashboard.
* @param {Array} titles titles to be shown in the list.
*/
setReportCategories: function(...titles) {
if (Platform.OS == 'ios') {
Instabug.setReportCategories(titles, null);
} else if (Platform.OS == 'android') {
Instabug.setReportCategories(titles);
}
},
/**
* @deprecated
* Sets whether the extended bug report mode should be disabled, enabled with
* required fields or enabled with optional fields.
* @param {extendedBugReportMode} extendedBugReportMode An enum to disable
* the extended bug report mode, enable it
* with required or with optional fields.
*/
setExtendedBugReportMode: function(extendedBugReportMode) {
Instabug.setExtendedBugReportMode(extendedBugReportMode);
},
/**
* @deprecated Logs a user event that happens through the lifecycle of the application.
* Logged user events are going to be sent with each report, as well as at the end of a session.
* @param {string} name Event name.
*/
logUserEventWithName: function(name) {
Instabug.logUserEventWithName(name);
},
/**
* Logs a user event that happens through the lifecycle of the application.
* Logged user events are going to be sent with each report, as well as at the end of a session.
* @param {string} name Event name.
* @param {Object} params An optional dictionary or parameters to be associated with the event.
*/
logUserEventWithNameAndParams: function(name, params) {
Instabug.logUserEventWithNameAndParams(name, params);
},
/**
* Appends a log message to Instabug internal log
* <p>
* These logs are then sent along the next uploaded report.
* All log messages are timestamped <br/>
* Logs aren't cleared per single application run.
* If you wish to reset the logs,
* use {@link #clearLogs()} ()}
* </p>
* Note: logs passed to this method are <b>NOT</b> printed to Logcat
*
* @param message the message
*/
logVerbose: function(message) {
if (!message) return;
if (Platform.OS === 'android') {
Instabug.log('v', message);
} else {
Instabug.logVerbose(message);
}
},
/**
* Appends a log message to Instabug internal log
* <p>
* These logs are then sent along the next uploaded report.
* All log messages are timestamped <br/>
* Logs aren't cleared per single application run.
* If you wish to reset the logs,
* use {@link #clearLogs()} ()}
* </p>
* Note: logs passed to this method are <b>NOT</b> printed to Logcat
*
* @param message the message
*/
logInfo: function(message) {
if (!message) return;
if (Platform.OS === 'android') {
Instabug.log('i', message);
} else {
Instabug.logInfo(message);
}
},
/**
* Appends a log message to Instabug internal log
* <p>
* These logs are then sent along the next uploaded report.
* All log messages are timestamped <br/>
* Logs aren't cleared per single application run.
* If you wish to reset the logs,
* use {@link #clearLogs()} ()}
* </p>
* Note: logs passed to this method are <b>NOT</b> printed to Logcat
*
* @param message the message
*/
logDebug: function(message) {
if (!message) return;
if (Platform.OS === 'android') {
Instabug.log('d', message);
} else {
Instabug.logDebug(message);
}
},
/**
* Appends a log message to Instabug internal log
* <p>
* These logs are then sent along the next uploaded report.
* All log messages are timestamped <br/>
* Logs aren't cleared per single application run.
* If you wish to reset the logs,
* use {@link #clearLogs()} ()}
* </p>
* Note: logs passed to this method are <b>NOT</b> printed to Logcat
*
* @param message the message
*/
logError: function(message) {
if (!message) return;
if (Platform.OS === 'android') {
Instabug.log('e', message);
} else {
Instabug.logError(message);
}
},
/**
* Appends a log message to Instabug internal log
* <p>
* These logs are then sent along the next uploaded report.
* All log messages are timestamped <br/>
* Logs aren't cleared per single application run.
* If you wish to reset the logs,
* use {@link #clearLogs()} ()}
* </p>
* Note: logs passed to this method are <b>NOT</b> printed to Logcat
*
* @param message the message
*/
logWarn: function(message) {
if (!message) return;
if (Platform.OS === 'android') {
Instabug.log('w', message);
} else {
Instabug.logWarn(message);
}
},
/**
* Clear all Instabug logs, console logs, network logs and user steps.
*/
clearLogs: function() {
Instabug.clearLogs();
},
/**
* Sets whether user steps tracking is visual, non visual or disabled.
* User Steps tracking is enabled by default if it's available
* in your current plan.
*
* @param {reproStepsMode} reproStepsMode An enum to set user steps tracking
* to be enabled, non visual or disabled.
*/
setReproStepsMode: function(reproStepsMode) {
Instabug.setReproStepsMode(reproStepsMode);
},
/**
* Sets user attribute to overwrite it's value or create a new one if it doesn't exist.
*
* @param key the attribute
* @param value the value
*/
setUserAttribute: function(key, value) {
if (!key || !value || typeof key !== 'string' || typeof value !== 'string')
throw new TypeError('Invalid param, Expected String');
Instabug.setUserAttribute(key, value);
},
/**
* Returns the user attribute associated with a given key.
aKey
* @param {string} key The attribute key as string
* @param {function} userAttributeCallback callback with argument as the desired user attribute value
*/
getUserAttribute: function(key, userAttributeCallback) {
Instabug.getUserAttribute(key, userAttributeCallback);
},
/**
* Removes user attribute if exists.
*
* @param key the attribute key as string
* @see #setUserAttribute(String, String)
*/
removeUserAttribute: function(key) {
if (!key || typeof key !== 'string')
throw new TypeError('Invalid param, Expected String');
Instabug.removeUserAttribute(key);
},
/**
* @summary Returns all user attributes.
* @param {function} userAttributesCallback callback with argument A new dictionary containing
* all the currently set user attributes, or an empty dictionary if no user attributes have been set.
*/
getAllUserAttributes: function(userAttributesCallback) {
Instabug.getAllUserAttributes(userAttributesCallback);
},
/**
* Clears all user attributes if exists.
*/
clearAllUserAttributes: function() {
Instabug.clearAllUserAttributes();
},
/**
* @summary Enables/disables inspect view hierarchy when reporting a bug/feedback.
* @param {boolean} viewHierarchyEnabled A boolean to set whether view hierarchy are enabled
* or disabled.
*/
setViewHierarchyEnabled: function(viewHierarchyEnabled) {
Instabug.setViewHierarchyEnabled(viewHierarchyEnabled);
},
/**
* @summary Sets whether surveys are enabled or not.
* If you disable surveys on the SDK but still have active surveys on your Instabug dashboard,
* those surveys are still going to be sent to the device, but are not going to be
* shown automatically.
* To manually display any available surveys, call `Instabug.showSurveyIfAvailable()`.
* Defaults to `true`.
* @param {boolean} surveysEnabled A boolean to set whether Instabug Surveys is enabled or disabled.
*/
setSurveysEnabled: function(surveysEnabled) {
Instabug.setSurveysEnabled(surveysEnabled);
},
/**
* @deprecated
* @summary Shows one of the surveys that were not shown before, that also have conditions
* that match the current device/user.
* Does nothing if there are no available surveys or if a survey has already been shown
* in the current session.
*/
showSurveysIfAvailable: function() {
Instabug.showSurveysIfAvailable();
},
/**
* @deprecated
* @summary Sets a block of code to be executed just before the survey's UI is presented.
* This block is executed on the UI thread. Could be used for performing any UI changes before
* the survey's UI is shown.
* @param {function} willShowSurveyHandler - A block of code that gets executed before
* presenting the survey's UI.
*/
setWillShowSurveyHandler: function(willShowSurveyHandler) {
if (Platform.OS === 'ios') {
Instabug.addListener('IBGWillShowSurvey');
NativeAppEventEmitter.addListener(
'IBGWillShowSurvey',
willShowSurveyHandler
);
} else {
DeviceEventEmitter.addListener(
'IBGWillShowSurvey',
willShowSurveyHandler
);
}
Instabug.setWillShowSurveyHandler(willShowSurveyHandler);
},
/**
* @deprecated
* @summary Sets a block of code to be executed right after the survey's UI is dismissed.
* This block is executed on the UI thread. Could be used for performing any UI
* changes after the survey's UI is dismissed.
* @param {function} didDismissSurveyHandler - A block of code that gets executed after
* the survey's UI is dismissed.
*/
setDidDismissSurveyHandler: function(didDismissSurveyHandler) {
if (Platform.OS === 'ios') {
Instabug.addListener('IBGDidDismissSurvey');
NativeAppEventEmitter.addListener(
'IBGDidDismissSurvey',
didDismissSurveyHandler
);
} else {
DeviceEventEmitter.addListener(
'IBGDidDismissSurvey',
didDismissSurveyHandler
);
}
Instabug.setDidDismissSurveyHandler(didDismissSurveyHandler);
},
/**
* @deprecated
* Enable/Disable prompt options when SDK invoked. When only a single option is enabled it
* becomes the default
* invocation option that SDK gets invoked with and prompt options screen will not show. When
* none is enabled, Bug
* reporting becomes the default invocation option.
*
* @param {boolean} chat whether Talk to us is enable or not
* @param {boolean} bug whether Report a Problem is enable or not
* @param {boolean} feedback whether General Feedback is enable or not
* */
setPromptOptionsEnabled: function(chat, bug, feedback) {
Instabug.setPromptOptionsEnabled(chat, bug, feedback);
},
/**
* Enable/Disable debug logs from Instabug SDK
* Default state: disabled
*
* @param isDebugEnabled whether debug logs should be printed or not into LogCat
*/
setDebugEnabled: function(isDebugEnabled) {
if (Platform.OS === 'android') {
Instabug.setDebugEnabled(isDebugEnabled);
}
},
/**
* Enables all Instabug functionality
* It works on android only
*/
enable: function() {
if (Platform.OS === 'android') {
Instabug.enable();
}
},
/**
* Disables all Instabug functionality