From fed4b25f1bbe531981a4e41609f95313922b9902 Mon Sep 17 00:00:00 2001 From: "Peng.Cao" Date: Thu, 8 Nov 2018 21:32:00 +0800 Subject: [PATCH] add @types/instabug-reactnative support --- types/instabug-reactnative/index.d.ts | 139 ++++++++++++++++++ .../instabug-reactnative-tests.ts | 36 +++++ types/instabug-reactnative/tsconfig.json | 23 +++ types/instabug-reactnative/tslint.json | 1 + 4 files changed, 199 insertions(+) create mode 100644 types/instabug-reactnative/index.d.ts create mode 100644 types/instabug-reactnative/instabug-reactnative-tests.ts create mode 100644 types/instabug-reactnative/tsconfig.json create mode 100644 types/instabug-reactnative/tslint.json diff --git a/types/instabug-reactnative/index.d.ts b/types/instabug-reactnative/index.d.ts new file mode 100644 index 0000000000..36a7d9d789 --- /dev/null +++ b/types/instabug-reactnative/index.d.ts @@ -0,0 +1,139 @@ +// Type definitions for instabug-reactnative 8.0 +// Project: https://github.com/Instabug/instabug-reactnative#readme +// Definitions by: Peng Cao +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export const Instabug: InstabugStatic; +export type Instabug = InstabugStatic; +export type BugReporting = BugReportingStatic; +export default Instabug; + +interface InstabugStatic { + invocationEvent: InvocationEvent; + colorTheme: ColorTheme; + locale: Locale; + strings: Strings; + welcomeMessageMode: WelcomeMessageMode; + startWithToken(token: string, event: string[]): void; + setColorTheme(colorTheme: string): void; + setPrimaryColor(color: number): void; + setFloatingButtonEdge(): void; + setLocale(locale: string): void; + setStringToKey(key: string): void; + setWelcomeMessageMode(welcomeMsg: string): void; + identifyUserWithEmail(email: string, name: string): void; + setUserAttribute(key: string, value: string): void; + getUserAttribute(key: string, callBack: (attribute: string) => void): void; + getAllUserAttributes(callBack: (allAttributes: string[]) => void): void; + removeUserAttribute(key: string): void; + setUserData(key: string): void; + logOut(): void; + logVerbose(info: string): void; + logInfo(info: string): void; + logDebug(info: string): void; + logError(info: string): void; + logWarn(info: string): void; + setUserStepsEnabled(enabled: boolean): void; + setAutoScreenRecordingEnabled(enabled: boolean): void; + setAutoScreenRecordingMaxDuration(ms: number): void; + setViewHierarchyEnabled(enabled: boolean): void; + resetTags(): void; + getTags(callBack: (tags: string) => void): void; + appendTags(tags: string[]): void; + setSessionProfilerEnabled(enabled: boolean): void; + setCrashReportingEnabled(enabled: boolean): void; + setChatNotificationEnabled(enabled: boolean): void; + getUnreadMessagesCount(callBack: (count: number) => void): void; + setOnNewMessageHandler(callBacck: () => void): void; + setPromptOptionsEnabled(chat: boolean, bug: boolean, feedback: boolean): void; + setSurveysEnabled(enabled: boolean): void; + setPostInvocationHandler(): void; +} + +interface WelcomeMessageMode { + beta: string; + live: string; + disabled: string; +} + +interface Strings { + shakeHint: string; + swipeHint: string; + edgeSwipeStartHint: string; + startAlertText: string; + invalidEmailMessage: string; + invalidEmailTitle: string; + invalidCommentMessage: string; + invalidCommentTitle: string; + invocationHeader: string; + talkToUs: string; + reportBug: string; + reportFeedback: string; + emailFieldHint: string; + commentFieldHintForBugReport: string; + commentFieldHintForFeedback: string; + addVideoMessage: string; + addVoiceMessage: string; + addImageFromGallery: string; + addExtraScreenshot: string; + audioRecordingPermissionDeniedTitle: string; + audioRecordingPermissionDeniedMessage: string; + // microphonePermissionAlertSettingsButtonText Instabug.microphonePermissionAlertSettingsButtonText, + recordingMessageToHoldText: string; + recordingMessageToReleaseText: string; + conversationsHeaderTitle: string; + screenshotHeaderTitle: string; + chatsNoConversationsHeadlineText: string; + doneButtonText: string; + okButtonText: string; + cancelButtonText: string; + thankYouText: string; + audio: string; + video: string; + image: string; + chatsHeaderTitle: string; + team: string; + messageNotification: string; + messagesNotificationAndOthers: string; + + // iOS only + // Instabug.strings.collectingDataText +} + +interface Locale { + arabic: string; + chineseSimplified: string; + chineseTraditional: string; + czech: string; + danish: string; + english: string; + french: string; + german: string; + italian: string; + japanese: string; + polish: string; + portugueseBrazil: string; + russian: string; + spanish: string; + swedish: string; + turkish: string; +} + +interface ColorTheme { + light: string; + dark: string; +} + +interface InvocationEvent { + none: string; + shake: string; + screenshot: string; + twoFingersSwipe: string; + floatingButton: string; +} + +interface BugReportingStatic { + setShakingThresholdForAndroid(shakingThreshold: number): void; + setShakingThresholdForiPhone(shakingThreshold: number): void; + setShakingThresholdForiPad(shakingThreshold: number): void; +} diff --git a/types/instabug-reactnative/instabug-reactnative-tests.ts b/types/instabug-reactnative/instabug-reactnative-tests.ts new file mode 100644 index 0000000000..5bc6db997b --- /dev/null +++ b/types/instabug-reactnative/instabug-reactnative-tests.ts @@ -0,0 +1,36 @@ +import Instabug from "instabug-reactnative"; + +Instabug.startWithToken("token: string", [""]); +Instabug.setColorTheme("colorTheme: string"); +Instabug.setPrimaryColor(1); +Instabug.setFloatingButtonEdge(); +Instabug.setLocale("locale: string"); +Instabug.setStringToKey("key: string"); +Instabug.setWelcomeMessageMode("welcomeMsg: string"); +Instabug.identifyUserWithEmail("email: string", "name: string"); +Instabug.setUserAttribute("key: string", "value: string"); +Instabug.getUserAttribute("key: string", (attribute) => 1); +Instabug.getAllUserAttributes((allAttributes) => 1); +Instabug.removeUserAttribute("key: string"); +Instabug.setUserData("key: string"); +Instabug.logOut(); +Instabug.logVerbose("info: string"); +Instabug.logInfo("info: string"); +Instabug.logDebug("info: string"); +Instabug.logError("info: string"); +Instabug.logWarn("info: string"); +Instabug.setUserStepsEnabled(true); +Instabug.setAutoScreenRecordingEnabled(false); +Instabug.setAutoScreenRecordingMaxDuration(10000); +Instabug.setViewHierarchyEnabled(true); +Instabug.resetTags(); +Instabug.getTags((tags) => 1); +Instabug.appendTags([""]); +Instabug.setSessionProfilerEnabled(false); +Instabug.setCrashReportingEnabled(true); +Instabug.setChatNotificationEnabled(false); +Instabug.getUnreadMessagesCount((count) => 1); +Instabug.setOnNewMessageHandler(() => 1); +Instabug.setPromptOptionsEnabled(true, true, true); +Instabug.setSurveysEnabled(false); +Instabug.setPostInvocationHandler(); diff --git a/types/instabug-reactnative/tsconfig.json b/types/instabug-reactnative/tsconfig.json new file mode 100644 index 0000000000..700b862185 --- /dev/null +++ b/types/instabug-reactnative/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "instabug-reactnative-tests.ts" + ] +} diff --git a/types/instabug-reactnative/tslint.json b/types/instabug-reactnative/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/instabug-reactnative/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }