Skip to content

Commit 792dc64

Browse files
authored
[MOB-10149] Extract enums to ArgsRegistry (#781)
* Extract enums to `ArgsRegistry` * Disable Enum checks in TypeScript Validator
1 parent e477bed commit 792dc64

File tree

6 files changed

+214
-191
lines changed

6 files changed

+214
-191
lines changed

src/modules/APM.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
Platform,
44
} from 'react-native';
55
import Trace from '../models/Trace';
6+
import ArgsRegistry from '../utils/ArgsRegistry';
67
let { Instabug, IBGAPM } = NativeModules;
78

89

@@ -128,12 +129,5 @@ export default {
128129
* @readonly
129130
* @enum {number}
130131
*/
131-
logLevel: {
132-
none: Instabug.logLevelNone,
133-
error: Instabug.logLevelError,
134-
warning: Instabug.logLevelWarning,
135-
info: Instabug.logLevelInfo,
136-
debug: Instabug.logLevelDebug,
137-
verbose: Instabug.logLevelVerbose,
138-
},
132+
logLevel: ArgsRegistry.logLevel,
139133
};

src/modules/BugReporting.js

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import {
22
NativeModules,
33
Platform
44
} from 'react-native';
5-
let { Instabug, IBGBugReporting } = NativeModules;
5+
import ArgsRegistry from '../utils/ArgsRegistry';
6+
let { IBGBugReporting } = NativeModules;
67
import IBGEventEmitter from '../utils/IBGEventEmitter';
78
import InstabugConstants from '../utils/InstabugConstants';
89

@@ -224,57 +225,33 @@ export default {
224225
* @readonly
225226
* @enum {number}
226227
*/
227-
invocationEvent: {
228-
none: Instabug.invocationEventNone,
229-
shake: Instabug.invocationEventShake,
230-
screenshot: Instabug.invocationEventScreenshot,
231-
twoFingersSwipe: Instabug.invocationEventTwoFingersSwipeLeft,
232-
floatingButton: Instabug.invocationEventFloatingButton
233-
},
228+
invocationEvent: ArgsRegistry.invocationEvent,
234229

235230
/**
236231
* The extended bug report mode
237232
* @readonly
238233
* @enum {number}
239234
*/
240-
extendedBugReportMode: {
241-
enabledWithRequiredFields: Instabug.enabledWithRequiredFields,
242-
enabledWithOptionalFields: Instabug.enabledWithOptionalFields,
243-
disabled: Instabug.disabled
244-
},
235+
extendedBugReportMode: ArgsRegistry.extendedBugReportMode,
245236

246237
/**
247238
* Type of the report either feedback or bug.
248239
* @readonly
249240
* @enum {number}
250241
*/
251-
reportType: {
252-
bug: Instabug.bugReportingReportTypeBug,
253-
feedback: Instabug.bugReportingReportTypeFeedback,
254-
question: Instabug.bugReportingReportTypeQuestion
255-
},
242+
reportType: ArgsRegistry.reportType,
256243

257244
/**
258245
* Options added while invoking bug reporting.
259246
* @readonly
260247
* @enum {number}
261248
*/
262-
option: {
263-
emailFieldHidden: Instabug.optionEmailFieldHidden,
264-
emailFieldOptional: Instabug.optionEmailFieldOptional,
265-
commentFieldRequired: Instabug.optionCommentFieldRequired,
266-
disablePostSendingDialog: Instabug.optionDisablePostSendingDialog
267-
},
249+
option: ArgsRegistry.option,
268250

269251
/**
270-
* Instabug floating buttons positions.
252+
* Instabug record buttons positions.
271253
* @readonly
272254
* @enum {number}
273255
*/
274-
position: {
275-
bottomRight: Instabug.bottomRight,
276-
topRight: Instabug.topRight,
277-
bottomLeft: Instabug.bottomLeft,
278-
topLeft: Instabug.topLeft
279-
},
256+
position: ArgsRegistry.position,
280257
};

src/modules/FeatureRequests.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { NativeModules } from "react-native";
2-
let { Instabug, IBGFeatureRequests} = NativeModules;
2+
import ArgsRegistry from "../utils/ArgsRegistry";
3+
let { IBGFeatureRequests} = NativeModules;
34

45
/**
56
* FeatureRequests
@@ -41,8 +42,5 @@ export default {
4142
* @readonly
4243
* @enum {number}
4344
*/
44-
actionTypes: {
45-
requestNewFeature: Instabug.requestNewFeature,
46-
addCommentToFeature: Instabug.addCommentToFeature
47-
}
45+
actionTypes: ArgsRegistry.actionTypes,
4846
}

src/modules/Instabug.js

Lines changed: 13 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import NetworkLogger from './NetworkLogger';
44
import IBGEventEmitter from '../utils/IBGEventEmitter';
55
import InstabugConstants from '../utils/InstabugConstants';
66
import InstabugUtils, { stringifyIfNotString } from '../utils/InstabugUtils';
7+
import ArgsRegistry from '../utils/ArgsRegistry';
78
let { Instabug } = NativeModules;
89

910
var _currentScreen = null;
@@ -616,214 +617,83 @@ export default {
616617
* @readonly
617618
* @enum {number}
618619
*/
619-
invocationEvent: {
620-
none: Instabug.invocationEventNone,
621-
shake: Instabug.invocationEventShake,
622-
screenshot: Instabug.invocationEventScreenshot,
623-
twoFingersSwipe: Instabug.invocationEventTwoFingersSwipeLeft,
624-
floatingButton: Instabug.invocationEventFloatingButton,
625-
},
620+
invocationEvent: ArgsRegistry.invocationEvent,
626621

627622
/**
628623
* The user steps option.
629624
* @readonly
630625
* @enum {number}
631626
*/
632-
reproStepsMode: {
633-
enabled: Instabug.reproStepsEnabled,
634-
disabled: Instabug.reproStepsDisabled,
635-
enabledWithNoScreenshots: Instabug.reproStepsEnabledWithNoScreenshots,
636-
},
627+
reproStepsMode: ArgsRegistry.reproStepsMode,
637628

638629
/**
639630
* Type of SDK dismiss
640631
* @readonly
641632
* @enum {number}
642633
*/
643-
dismissType: {
644-
submit: Instabug.dismissTypeSubmit,
645-
cancel: Instabug.dismissTypeCancel,
646-
addAttachment: Instabug.dismissTypeAddAttachment,
647-
},
634+
dismissType: ArgsRegistry.dismissType,
648635

649636
/**
650637
* Verbosity level of the SDK debug logs. This has nothing to do with IBGLog,
651638
* and only affect the logs used to debug the SDK itself.
652639
* @readonly
653640
* @enum {number}
654641
*/
655-
sdkDebugLogsLevel: {
656-
sdkDebugLogsLevelVerbose: Instabug.sdkDebugLogsLevelVerbose,
657-
sdkDebugLogsLevelDebug: Instabug.sdkDebugLogsLevelDebug,
658-
sdkDebugLogsLevelError: Instabug.sdkDebugLogsLevelError,
659-
sdkDebugLogsLevelNone: Instabug.sdkDebugLogsLevelNone,
660-
},
642+
sdkDebugLogsLevel: ArgsRegistry.sdkDebugLogsLevel,
661643

662644
/**
663645
* The extended bug report mode
664646
* @readonly
665647
* @enum {number}
666648
*/
667-
extendedBugReportMode: {
668-
enabledWithRequiredFields: Instabug.enabledWithRequiredFields,
669-
enabledWithOptionalFields: Instabug.enabledWithOptionalFields,
670-
disabled: Instabug.disabled,
671-
},
649+
extendedBugReportMode: ArgsRegistry.extendedBugReportMode,
672650

673651
/**
674652
* The supported locales
675653
* @readonly
676654
* @enum {number}
677655
*/
678-
locale: {
679-
arabic: Instabug.localeArabic,
680-
azerbaijani: Instabug.localeAzerbaijani,
681-
chineseSimplified: Instabug.localeChineseSimplified,
682-
chineseTraditional: Instabug.localeChineseTraditional,
683-
czech: Instabug.localeCzech,
684-
danish: Instabug.localeDanish,
685-
dutch: Instabug.localeDutch,
686-
english: Instabug.localeEnglish,
687-
french: Instabug.localeFrench,
688-
german: Instabug.localeGerman,
689-
italian: Instabug.localeItalian,
690-
japanese: Instabug.localeJapanese,
691-
polish: Instabug.localePolish,
692-
portugueseBrazil: Instabug.localePortugueseBrazil,
693-
russian: Instabug.localeRussian,
694-
spanish: Instabug.localeSpanish,
695-
swedish: Instabug.localeSwedish,
696-
turkish: Instabug.localeTurkish,
697-
korean: Instabug.localeKorean,
698-
},
656+
locale: ArgsRegistry.locale,
699657

700658
/**
701659
* The color theme of the different UI elements
702660
* @readonly
703661
* @enum {number}
704662
*/
705-
colorTheme: {
706-
light: Instabug.colorThemeLight,
707-
dark: Instabug.colorThemeDark,
708-
},
663+
colorTheme: ArgsRegistry.colorTheme,
709664

710665
/**
711666
* Rectangle edges
712667
* @readonly
713668
* @enum {number}
714669
*/
715-
floatingButtonEdge: {
716-
left: Instabug.rectMinXEdge,
717-
right: Instabug.rectMaxXEdge,
718-
},
670+
floatingButtonEdge: ArgsRegistry.floatingButtonEdge,
719671

720672
/**
721673
* Instabug floating buttons positions.
722674
* @readonly
723675
* @enum {number}
724676
*/
725-
IBGPosition: {
726-
bottomRight: Instabug.bottomRight,
727-
topRight: Instabug.topRight,
728-
bottomLeft: Instabug.bottomLeft,
729-
topLeft: Instabug.topLeft,
730-
},
677+
IBGPosition: ArgsRegistry.position,
731678

732679
/**
733680
* The welcome message mode.
734681
* @readonly
735682
* @enum {number}
736683
*/
737-
welcomeMessageMode: {
738-
live: Instabug.welcomeMessageModeLive,
739-
beta: Instabug.welcomeMessageModeBeta,
740-
disabled: Instabug.welcomeMessageModeDisabled,
741-
},
684+
welcomeMessageMode: ArgsRegistry.welcomeMessageMode,
742685

743686
/**
744687
* Instabug action types.
745688
* @readonly
746689
* @enum {number}
747690
*/
748-
actionTypes: {
749-
allActions: Instabug.allActions,
750-
reportBug: Instabug.reportBugAction,
751-
requestNewFeature: Instabug.requestNewFeature,
752-
addCommentToFeature: Instabug.addCommentToFeature,
753-
},
691+
actionTypes: ArgsRegistry.actionTypes,
754692

755693
/**
756694
* Instabug strings
757695
* @readonly
758696
* @enum {number}
759697
*/
760-
strings: {
761-
shakeHint: Instabug.shakeHint,
762-
swipeHint: Instabug.swipeHint,
763-
edgeSwipeStartHint: Instabug.edgeSwipeStartHint,
764-
startAlertText: Instabug.startAlertText,
765-
invalidEmailMessage: Instabug.invalidEmailMessage,
766-
invalidEmailTitle: Instabug.invalidEmailTitle,
767-
invalidCommentMessage: Instabug.invalidCommentMessage,
768-
invalidCommentTitle: Instabug.invalidCommentTitle,
769-
invocationHeader: Instabug.invocationHeader,
770-
reportQuestion: Instabug.reportQuestion,
771-
reportBug: Instabug.reportBug,
772-
reportFeedback: Instabug.reportFeedback,
773-
emailFieldHint: Instabug.emailFieldHint,
774-
commentFieldHintForBugReport: Instabug.commentFieldHintForBugReport,
775-
commentFieldHintForFeedback: Instabug.commentFieldHintForFeedback,
776-
commentFieldHintForQuestion: Instabug.commentFieldHintForQuestion,
777-
videoPressRecord: Instabug.videoPressRecord,
778-
addVideoMessage: Instabug.addVideoMessage,
779-
addVoiceMessage: Instabug.addVoiceMessage,
780-
addImageFromGallery: Instabug.addImageFromGallery,
781-
addExtraScreenshot: Instabug.addExtraScreenshot,
782-
audioRecordingPermissionDeniedTitle: Instabug.audioRecordingPermissionDeniedTitle,
783-
audioRecordingPermissionDeniedMessage: Instabug.audioRecordingPermissionDeniedMessage,
784-
microphonePermissionAlertSettingsButtonText:
785-
Instabug.microphonePermissionAlertSettingsButtonTitle,
786-
recordingMessageToHoldText: Instabug.recordingMessageToHoldText,
787-
recordingMessageToReleaseText: Instabug.recordingMessageToReleaseText,
788-
conversationsHeaderTitle: Instabug.conversationsHeaderTitle,
789-
screenshotHeaderTitle: Instabug.screenshotHeaderTitle,
790-
okButtonText: Instabug.okButtonTitle,
791-
cancelButtonText: Instabug.cancelButtonTitle,
792-
thankYouText: Instabug.thankYouText,
793-
audio: Instabug.audio,
794-
video: Instabug.video,
795-
image: Instabug.image,
796-
team: Instabug.team,
797-
messagesNotification: Instabug.messagesNotification,
798-
messagesNotificationAndOthers: Instabug.messagesNotificationAndOthers,
799-
conversationTextFieldHint: Instabug.conversationTextFieldHint,
800-
collectingDataText: Instabug.collectingDataText,
801-
thankYouAlertText: Instabug.thankYouAlertText,
802-
welcomeMessageBetaWelcomeStepTitle: Instabug.welcomeMessageBetaWelcomeStepTitle,
803-
welcomeMessageBetaWelcomeStepContent: Instabug.welcomeMessageBetaWelcomeStepContent,
804-
welcomeMessageBetaHowToReportStepTitle: Instabug.welcomeMessageBetaHowToReportStepTitle,
805-
welcomeMessageBetaHowToReportStepContent: Instabug.welcomeMessageBetaHowToReportStepContent,
806-
welcomeMessageBetaFinishStepTitle: Instabug.welcomeMessageBetaFinishStepTitle,
807-
welcomeMessageBetaFinishStepContent: Instabug.welcomeMessageBetaFinishStepContent,
808-
welcomeMessageLiveWelcomeStepTitle: Instabug.welcomeMessageLiveWelcomeStepTitle,
809-
welcomeMessageLiveWelcomeStepContent: Instabug.welcomeMessageLiveWelcomeStepContent,
810-
surveysStoreRatingThanksTitle: Instabug.surveysStoreRatingThanksTitle,
811-
surveysStoreRatingThanksSubtitle: Instabug.surveysStoreRatingThanksSubtitle,
812-
reportBugDescription: Instabug.reportBugDescription,
813-
reportFeedbackDescription: Instabug.reportFeedbackDescription,
814-
reportQuestionDescription: Instabug.reportQuestionDescription,
815-
requestFeatureDescription: Instabug.requestFeatureDescription,
816-
discardAlertTitle: Instabug.discardAlertTitle,
817-
discardAlertMessage: Instabug.discardAlertMessage,
818-
discardAlertCancel: Instabug.discardAlertCancel,
819-
discardAlertAction: Instabug.discardAlertAction,
820-
addAttachmentButtonTitleStringName: Instabug.addAttachmentButtonTitleStringName,
821-
reportReproStepsDisclaimerBody: Instabug.reportReproStepsDisclaimerBody,
822-
reportReproStepsDisclaimerLink: Instabug.reportReproStepsDisclaimerLink,
823-
reproStepsProgressDialogBody: Instabug.reproStepsProgressDialogBody,
824-
reproStepsListHeader: Instabug.reproStepsListHeader,
825-
reproStepsListDescription: Instabug.reproStepsListDescription,
826-
reproStepsListEmptyStateDescription: Instabug.reproStepsListEmptyStateDescription,
827-
reproStepsListItemTitle: Instabug.reproStepsListItemTitle,
828-
},
698+
strings: ArgsRegistry.strings,
829699
};

0 commit comments

Comments
 (0)