You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Network logging
Network logging is opt-in and disabled by default. When enabled, HTTP requests appear in Bugfender as logs tagged bf_network.
Bugfender.setNetworkLoggingEnabled(true);// Optional:Bugfender.setNetworkLoggingCaptureBodies(false);Bugfender.setNetworkLoggingCaptureErrorResponseBodies(true);Bugfender.setNetworkLoggingURLFilter(['https://api.example.com/*'],['*/secrets/*']);Bugfender.setNetworkLoggingMaxRequestsPerMinute(60);// Optional: redact sensitive headers/bodies before they are loggedBugfender.setNetworkLoggingRequestObfuscationHandler((url,headers,body)=>({
url,headers: { ...headers,authorization: '[REDACTED]'},
body,}));Bugfender.setNetworkLoggingResponseObfuscationHandler((headers,body)=>({
headers,body: body ? body.replace(/"token":"[^"]*"/g,'"token":"[REDACTED]"') : null,}));
You can also enable it at init time with networkLoggingEnabled, networkLoggingCaptureBodies, and networkLoggingCaptureErrorResponseBodies.
Platform notes:
iOS: URLSession traffic is captured (including Capacitor HTTP when it uses URLSession). Requires Bugfender iOS SDK 3.0.1+.
Android: OkHttp traffic is captured via the android-okhttp adapter. Requires Bugfender Android SDK 4.x. Note: Capacitor's built-in CapacitorHttp uses HttpURLConnection on Android and is not observed; apps should use OkHttp (or the example's sendInstrumentedNetworkRequest helper) for network logs.
Web / Electron: Uses @bugfender/sdk (≥ 4.0.0), which intercepts fetch and XMLHttpRequest.
Configure exception filtering to ignore certain exceptions from being reported as crashes. Can be: - A function: (info) => info.message.includes('Script error') - An array of patterns: ['Script error', /^ResizeObserver/i] - An object with both: { filter: (info) => ..., patterns: [...] }
version
string
App version identifier
networkLoggingEnabled
boolean
Enable network request/response capture. Defaults to false. Web/JS: requires init before use.
networkLoggingCaptureBodies
boolean
When network logging is enabled, capture request/response bodies (full mode). Defaults to false.
networkLoggingCaptureErrorResponseBodies
boolean
Capture only error response bodies for HTTP status >= 400 (without full body capture). Defaults to false.
maximumLocalStorageSize
number
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
boolean
Logs all logs written via Logcat. Defaults to false. Android only.
ExceptionInfo
Information about an exception that can be used to determine if it should be ignored
The type of handler that caught the error (e.g., 'Error', 'UnhandledRejection')
Error
Prop
Type
name
string
message
string
stack
string
RegExp
Prop
Type
Description
source
string
Returns a copy of the text of the regular expression pattern. Read-only. The regExp argument is a Regular expression object. It can be a variable name or a literal.
global
boolean
Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only.
ignoreCase
boolean
Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only.
multiline
boolean
Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only.
Text can be either: - string with the content - unknown[] array compatible with console.* signature
url
string
The log's origin URL. This attribute is ignored on Android & iOS
Type Aliases
ExceptionFilter
Configuration for ignoring exceptions.
Can be:
A function that receives exception info and returns boolean
An array of patterns (strings or RegExp) to match against the error message
A combination of both (function and patterns)
ExceptionFilterFunction | ExceptionPattern[] | { /** Function to determine if exception should be ignored / filter?: ExceptionFilterFunction; /* Patterns to match against error message */ patterns?: ExceptionPattern[]; }
ExceptionFilterFunction
A function that determines whether an exception should be ignored.
Return true to ignore the exception, false to report it.