import { exec } from "./IBGCordova"; import registry from "./ArgsRegistry"; import bugReporting from "./BugReporting"; import ArgsRegistry from "./ArgsRegistry"; namespace Instabug { export const welcomeMessageMode = registry.welcomeMessageMode; export const floatingButtonEdge = registry.floatingButtonEdge; export const colorTheme = registry.colorTheme; export const strings = registry.strings; export const reproStepsMode = registry.reproStepsMode; export const locale = registry.locale; /** * @deprecated This method is deprecated and will be removed in a future version. Use `init` instead. * 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 AppRegistry component * * @param token the token that identifies the app, you can find * it on your dashboard. * @param invocationEvents an array of invocationEvents that invoke * the SDK's UI. * @param success callback on function success. * @param error callback on function error. */ export const start = ( token: string, invocationEvents: bugReporting.invocationEvents[], success?: () => void, error?: (err: any) => void ) => { exec("IBGPlugin", "start", [token, invocationEvents], success, error); }; /** * Initializes the Instabug SDK with additional configurations. * * @param token The token that identifies the app, available on your dashboard. * @param invocationEvents An array of invocation events that trigger the SDK's UI. * @param logLevel The level of detail in logs that you want to print. * @param success Callback on function success. * @param error Callback on function error. */ export const init = ( token: string, invocationEvents: bugReporting.invocationEvents[], logLevel: ArgsRegistry.logLeve, success?: () => void, error?: (err: any) => void ) => { exec( "IBGPlugin", // Plugin name "init", // Action name [token, invocationEvents, logLevel], // Arguments success, error ); }; /** * Shows default Instabug prompt. * * @param success callback on function success. * @param error callback on function error. */ export const show = (success?: () => void, error?: (err: any) => void) => { exec("IBGPlugin", "show", [], success, error); }; /** * 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 a color hex to set the UI elements of the SDK to. * @param success callback on function success. * @param error callback on function error. */ export const setPrimaryColor = ( color: string, success?: () => void, error?: (err: any) => void ) => { exec("IBGPlugin", "setPrimaryColor", [color], success, error); }; /** * 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 userEvent the user event name. * @param success callback on function success. * @param error callback on function error. */ export const logUserEventWithName = ( userEvent: string, success?: () => void, error?: (err: any) => void ) => { exec("IBGPlugin", "logUserEventWithName", [userEvent], success, error); }; /** * 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. * * @deprecated This method is deprecated and will be removed in a future version. * Use `setReproStepsConfig` instead. * * @param reproStepsMode an enum to set user steps tracking * to be enabled, non visual or disabled. * @param success callback on function success. * @param error callback on function error. */ export const setReproStepsMode = ( reproStepsMode: registry.reproStepsMode | `${registry.reproStepsMode}`, success?: () => void, error?: (err: any) => void ) => { exec("IBGPlugin", "setReproStepsMode", [reproStepsMode], success, error); }; /** * Configures user steps tracking for bug, crash, and session replay issue types separately. * User Steps tracking is enabled by default if it's available * in your current plan. * * @param bugMode an enum to set user steps tracking for bug issues. * @param crashMode an enum to set user steps tracking for crash issues. * @param success callback on function success. * @param error callback on function error. */ export const setReproStepsConfig = ( bugMode: registry.reproStepsMode | `${registry.reproStepsMode}`, crashMode: registry.reproStepsMode | `${registry.reproStepsMode}`, success?: () => void, error?: (err: any) => void ) => { exec("IBGPlugin", "setReproStepsConfig", [bugMode, crashMode], success, error); }; /** * 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 isEnabled a boolean to enable or disable the feature. * @param success callback on function success. * @param error callback on function error. */ export const setSessionProfilerEnabled = ( isEnabled: boolean, success?: () => void, error?: (err: any) => void ) => { exec("IBGPlugin", "setSessionProfilerEnabled", [isEnabled], success, error); }; /** * Sets the welcome message mode to live, beta or disabled. * @param mode an enum to set the welcome message mode. * @param success callback on function success. * @param error callback on function error. */ export const setWelcomeMessageMode = ( mode: registry.welcomeMessageMode, success?: () => void, error?: (err: any) => void ) => { exec("IBGPlugin", "setWelcomeMessageMode", [mode], success, error); }; /** * Shows the welcome message in a specific mode. * @param mode an enum to set the mode to show the welcome message with. * @param success callback on function success. * @param error callback on function error. */ export const showWelcomeMessage = ( mode: registry.welcomeMessageMode, success?: () => void, error?: (err: any) => void ) => { exec("IBGPlugin", "showWelcomeMessage", [mode], success, error); }; /** * 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 data a string to be attached to each report, with a * maximum size of 1,000 characters. * @param success callback on function success. * @param error callback on function error. */ export const setUserData = ( data: string, success?: () => void, error?: (err: any) => void ) => { exec("IBGPlugin", "setUserData", [data], success, error); }; /** * Add file to be attached to the bug report. * * @param filePath the path of the file to be attached. * @param success callback on function success. * @param error callback on function error. */ export const addFile = ( filePath: string, success?: () => void, error?: (err: any) => void ) => { exec("IBGPlugin", "addFile", [filePath], success, error); }; /** * Appends a log message to Instabug internal log *
* These logs are then sent along the next uploaded report.
* All log messages are timestamped
* Logs aren't cleared per single application run.
* If you wish to reset the logs,
* use {@link #clearLogs()} ()}
*