add @types/instabug-reactnative support

This commit is contained in:
Peng.Cao
2018-11-08 21:32:00 +08:00
parent 26d2add0db
commit fed4b25f1b
4 changed files with 199 additions and 0 deletions

139
types/instabug-reactnative/index.d.ts vendored Normal file
View File

@@ -0,0 +1,139 @@
// Type definitions for instabug-reactnative 8.0
// Project: https://github.com/Instabug/instabug-reactnative#readme
// Definitions by: Peng Cao <https://github.com/pengcao1>
// 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;
}

View File

@@ -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();

View File

@@ -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"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }