Home

Awesome

@bugfender/capacitor

Remote logging, crash reporting and in-app user feedback with Bugfender and Capacitor.

This module is a plugin for Capacitor since version 4. You can use @bugfender/capacitor in Ionic projects for iOS, Android, web and electron platforms.

Installation

npm install @bugfender/capacitor @bugfender/sdk @bugfender/common
npx cap sync

Usage

Import Bugfender like this:

import { Bugfender } from '@bugfender/capacitor';

Note: in an Ionic/Capacitor project, always import @bugfender/capacitor instead of @bugfender/sdk. This will enable the native features of the SDK that you wouldn't get otherwise.

API

Please check the following URL for a complete API reference: https://js.bugfender.com.

<docgen-index> </docgen-index> <docgen-api> <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->

init(...)

init(options: SDKOptions) => Promise<void>
ParamType
options<code><a href="#sdkoptions">SDKOptions</a></code>

forceSendOnce()

forceSendOnce() => void

getDeviceURL()

getDeviceURL() => Promise<string>

Returns: <code>Promise<string></code>


getSessionURL()

getSessionURL() => Promise<string>

Returns: <code>Promise<string></code>


getUserFeedback(...)

getUserFeedback(options?: UserFeedbackOptions | undefined) => Promise<UserFeedbackResult>
ParamType
options<code><a href="#userfeedbackoptions">UserFeedbackOptions</a></code>

Returns: <code>Promise<<a href="#userfeedbackresult">UserFeedbackResult</a>></code>


log(...)

log(obj: unknown, ...objs: unknown[]) => void
ParamType
obj<code>unknown</code>
objs<code>unknown[]</code>

log(...)

log(msg: string, ...subst: unknown[]) => void
ParamType
msg<code>string</code>
subst<code>unknown[]</code>

warn(...)

warn(obj: unknown, ...objs: unknown[]) => void
ParamType
obj<code>unknown</code>
objs<code>unknown[]</code>

warn(...)

warn(msg: string, ...subst: unknown[]) => void
ParamType
msg<code>string</code>
subst<code>unknown[]</code>

error(...)

error(obj: unknown, ...objs: unknown[]) => void
ParamType
obj<code>unknown</code>
objs<code>unknown[]</code>

error(...)

error(msg: string, ...subst: unknown[]) => void
ParamType
msg<code>string</code>
subst<code>unknown[]</code>

trace(...)

trace(obj: unknown, ...objs: unknown[]) => void
ParamType
obj<code>unknown</code>
objs<code>unknown[]</code>

trace(...)

trace(msg: string, ...subst: unknown[]) => void
ParamType
msg<code>string</code>
subst<code>unknown[]</code>

info(...)

info(obj: unknown, ...objs: unknown[]) => void
ParamType
obj<code>unknown</code>
objs<code>unknown[]</code>

info(...)

info(msg: string, ...subst: unknown[]) => void
ParamType
msg<code>string</code>
subst<code>unknown[]</code>

fatal(...)

fatal(obj: unknown, ...objs: unknown[]) => void
ParamType
obj<code>unknown</code>
objs<code>unknown[]</code>

fatal(...)

fatal(msg: string, ...subst: unknown[]) => void
ParamType
msg<code>string</code>
subst<code>unknown[]</code>

removeDeviceKey(...)

removeDeviceKey(key: string) => void
ParamType
key<code>string</code>

sendLog(...)

sendLog(log: LogEntry) => void
ParamType
log<code><a href="#logentry">LogEntry</a></code>

sendIssue(...)

sendIssue(title: string, text: string) => Promise<string>
ParamType
title<code>string</code>
text<code>string</code>

Returns: <code>Promise<string></code>


sendCrash(...)

sendCrash(title: string, text: string) => Promise<string>
ParamType
title<code>string</code>
text<code>string</code>

Returns: <code>Promise<string></code>


sendUserFeedback(...)

sendUserFeedback(title: string, text: string) => Promise<string>
ParamType
title<code>string</code>
text<code>string</code>

Returns: <code>Promise<string></code>


setDeviceKey(...)

setDeviceKey(key: string, value: DeviceKeyValue) => void
ParamType
key<code>string</code>
value<code><a href="#devicekeyvalue">DeviceKeyValue</a></code>

setForceEnabled(...)

setForceEnabled(state: boolean) => void
ParamType
state<code>boolean</code>

Interfaces

SDKOptions

PropTypeDescription
appKey<code>string</code>The app key to log into
apiURL<code>string</code>Base URL to Bugfender API
build<code>string</code>App build identifier
baseURL<code>string</code>Base URL to Bugfender web dashboard
debug<code>boolean</code>Set SDK in debug mode
deviceName<code>string</code>Device name, this will be shown on the dashboard devices list. Defaults to browser + OS.
overrideConsoleMethods<code>boolean</code>Override default window.console so it also logs to Bugfender. Defaults to true.
printToConsole<code>boolean</code>Print also with window.console when Bugfender logging methods are called. Defaults to true.
logBrowserEvents<code>boolean</code>Register a handler for most common browser events to report them to Bugfender. Defaults to true.
logUIEvents<code>boolean</code>Register a handler for most common UI events to report them to Bugfender. Defaults to true.
registerErrorHandler<code>boolean</code>Register error handler for uncaught errors that reports a crash to Bugfender. Defaults to true.
version<code>string</code>App version identifier
maximumLocalStorageSize<code>number</code>Set the maximum size to store local log files in bytes. Range accepted is from 1MB to 50MB. Defaults to 5MB. iOS & Android only.
enableLogcatLogging<code>boolean</code>Logs all logs written via Logcat. Defaults to false. Android only.

UserFeedbackResultSuccess

PropTypeDescription
isSent<code>true</code>The user has sent the feedback.
feedbackURL<code>string</code>Bugfender URL for the feedback.

UserFeedbackResultCancel

PropTypeDescription
isSent<code>false</code>The user has closed the modal without sending it.

UserFeedbackOptions

Options object for Bugfender.getUserFeedback with customised modal strings.

PropTypeDescription
title<code>string</code>Default: Feedback.
hint<code>string</code>Default: Please insert your feedback here and click send.
subjectPlaceholder<code>string</code>Default: Subject….
feedbackPlaceholder<code>string</code>Default: Your feedback….
submitLabel<code>string</code>Default: Send.
closeLabel<code>string</code>Default: Close. iOS only.

LogEntry

Log Entry object interface

PropTypeDescription
line<code>number</code>The line number where the log was triggered from
level<code><a href="#loglevel">LogLevel</a></code>The log's level based on <a href="#loglevel">LogLevel</a> constant
tag<code>string</code>The log's tag
method<code>string</code>The method name where the log was triggered from
file<code>string</code>The file name where the log was triggered from
text<code>string | unknown[]</code>Text can be either: - string with the content - unknown[] array compatible with console.* signature
url<code>string</code>The log's origin URL. This attribute is ignored on Android & iOS

Type Aliases

UserFeedbackResult

<code><a href="#userfeedbackresultsuccess">UserFeedbackResultSuccess</a> | <a href="#userfeedbackresultcancel">UserFeedbackResultCancel</a></code>

DeviceKeyValue

<code>string | number | boolean</code>

Enums

LogLevel

MembersValue
Debug<code>0</code>
Warning<code>1</code>
Error<code>2</code>
Trace<code>3</code>
Info<code>4</code>
Fatal<code>5</code>
</docgen-api>