npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bugfender/capacitor

v5.0.0

Published

Remote logging with Bugfender

Downloads

2,888

Readme

@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.

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 logged
Bugfender.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.

API

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

init(...)

init(options: SDKOptions) => Promise<void>

| Param | Type | | ------------- | ------------------------------------------------- | | options | SDKOptions |


forceSendOnce()

forceSendOnce() => void

getDeviceURL()

getDeviceURL() => Promise<string>

Returns: Promise<string>


getSessionURL()

getSessionURL() => Promise<string>

Returns: Promise<string>


getUserFeedback(...)

getUserFeedback(options?: UserFeedbackOptions | undefined) => Promise<UserFeedbackResult>

| Param | Type | | ------------- | ------------------------------------------------------------------- | | options | UserFeedbackOptions |

Returns: Promise<UserFeedbackResult>


log(...)

log(obj: unknown, ...objs: unknown[]) => void

| Param | Type | | ---------- | ---------------------- | | obj | unknown | | objs | unknown[] |


log(...)

log(msg: string, ...subst: unknown[]) => void

| Param | Type | | ----------- | ---------------------- | | msg | string | | subst | unknown[] |


warn(...)

warn(obj: unknown, ...objs: unknown[]) => void

| Param | Type | | ---------- | ---------------------- | | obj | unknown | | objs | unknown[] |


warn(...)

warn(msg: string, ...subst: unknown[]) => void

| Param | Type | | ----------- | ---------------------- | | msg | string | | subst | unknown[] |


error(...)

error(obj: unknown, ...objs: unknown[]) => void

| Param | Type | | ---------- | ---------------------- | | obj | unknown | | objs | unknown[] |


error(...)

error(msg: string, ...subst: unknown[]) => void

| Param | Type | | ----------- | ---------------------- | | msg | string | | subst | unknown[] |


trace(...)

trace(obj: unknown, ...objs: unknown[]) => void

| Param | Type | | ---------- | ---------------------- | | obj | unknown | | objs | unknown[] |


trace(...)

trace(msg: string, ...subst: unknown[]) => void

| Param | Type | | ----------- | ---------------------- | | msg | string | | subst | unknown[] |


info(...)

info(obj: unknown, ...objs: unknown[]) => void

| Param | Type | | ---------- | ---------------------- | | obj | unknown | | objs | unknown[] |


info(...)

info(msg: string, ...subst: unknown[]) => void

| Param | Type | | ----------- | ---------------------- | | msg | string | | subst | unknown[] |


fatal(...)

fatal(obj: unknown, ...objs: unknown[]) => void

| Param | Type | | ---------- | ---------------------- | | obj | unknown | | objs | unknown[] |


fatal(...)

fatal(msg: string, ...subst: unknown[]) => void

| Param | Type | | ----------- | ---------------------- | | msg | string | | subst | unknown[] |


removeDeviceKey(...)

removeDeviceKey(key: string) => void

| Param | Type | | --------- | ------------------- | | key | string |


sendLog(...)

sendLog(log: LogEntry) => void

| Param | Type | | --------- | --------------------------------------------- | | log | LogEntry |


sendIssue(...)

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

| Param | Type | | ----------- | ------------------- | | title | string | | text | string |

Returns: Promise<string>


sendCrash(...)

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

| Param | Type | | ----------- | ------------------- | | title | string | | text | string |

Returns: Promise<string>


sendUserFeedback(...)

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

| Param | Type | | ----------- | ------------------- | | title | string | | text | string |

Returns: Promise<string>


setDeviceKey(...)

setDeviceKey(key: string, value: DeviceKeyValue) => void

| Param | Type | | ----------- | --------------------------------------------------------- | | key | string | | value | DeviceKeyValue |


setForceEnabled(...)

setForceEnabled(state: boolean) => void

| Param | Type | | ----------- | -------------------- | | state | boolean |


setSDKType(...)

setSDKType(sdkType: string, version: number) => void

| Param | Type | | ------------- | ------------------- | | sdkType | string | | version | number |


setNetworkLoggingEnabled(...)

setNetworkLoggingEnabled(enabled: boolean) => void

Enable or disable network logging (default: false).

| Param | Type | | ------------- | -------------------- | | enabled | boolean |


setNetworkLoggingCaptureBodies(...)

setNetworkLoggingCaptureBodies(capture: boolean) => void

Full mode: capture request/response bodies (default: false).

| Param | Type | | ------------- | -------------------- | | capture | boolean |


setNetworkLoggingCaptureErrorResponseBodies(...)

setNetworkLoggingCaptureErrorResponseBodies(capture: boolean) => void

Error-only body mode: capture response body only for HTTP status >= 400 (default: false).

| Param | Type | | ------------- | -------------------- | | capture | boolean |


setNetworkLoggingRequestObfuscationHandler(...)

setNetworkLoggingRequestObfuscationHandler(handler: ((url: string, headers: Record<string, string>, body: string | null) => { url: string; headers: Record<string, string>; body: string | null; }) | null) => void

Request obfuscation — (url, headers, body) => { url, headers, body }.

| Param | Type | | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | handler | ((url: string, headers: Record<string, string>, body: string | null) => { url: string; headers: Record<string, string>; body: string | null; }) | null |


setNetworkLoggingResponseObfuscationHandler(...)

setNetworkLoggingResponseObfuscationHandler(handler: ((headers: Record<string, string>, body: string | null) => { headers: Record<string, string>; body: string | null; }) | null) => void

Response obfuscation — (headers, body) => { headers, body }.

| Param | Type | | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | handler | ((headers: Record<string, string>, body: string | null) => { headers: Record<string, string>; body: string | null; }) | null |


setNetworkLoggingURLFilter(...)

setNetworkLoggingURLFilter(allowlist: string[] | null, denylist: string[] | null) => void

URL filtering: allowlist / denylist. Null = no filter.

| Param | Type | | --------------- | ----------------------------- | | allowlist | string[] | null | | denylist | string[] | null |


setNetworkLoggingMaxRequestsPerMinute(...)

setNetworkLoggingMaxRequestsPerMinute(count: number | null) => void

Rate limit. Null = no limit.

| Param | Type | | ----------- | --------------------------- | | count | number | null |


Interfaces

SDKOptions

| Prop | Type | Description | | ---------------------------------------------- | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | appKey | string | The app key to log into | | apiURL | string | Base URL to Bugfender API | | build | string | App build identifier | | baseURL | string | Base URL to Bugfender web dashboard | | debug | boolean | Set SDK in debug mode | | deviceName | string | Device name, this will be shown on the dashboard devices list. Defaults to browser + OS. | | overrideConsoleMethods | boolean | Override default window.console so it also logs to Bugfender. Defaults to true. | | printToConsole | boolean | Print also with window.console when Bugfender logging methods are called. Defaults to true. | | logBrowserEvents | boolean | Register a handler for most common browser events to report them to Bugfender. Defaults to true. | | logUIEvents | boolean | Register a handler for most common UI events to report them to Bugfender. Defaults to true. | | registerErrorHandler | boolean | Register error handler for uncaught errors that reports a crash to Bugfender. Defaults to true. | | ignoreException | ExceptionFilter | Configure exception filtering to ignore certain exceptions from being reported as crashes. Can be: - A function: (info) =&gt; info.message.includes('Script error') - An array of patterns: ['Script error', /^ResizeObserver/i] - An object with both: { filter: (info) =&gt; ..., 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

| Prop | Type | Description | | -------------- | --------------------------------------- | ---------------------------------------------------------------------------------------------------- | | message | string | The error message | | error | Error | The error object, if available | | stack | string | The stack trace, if available | | filename | string | The filename/URL where the error occurred | | line | number | The line number where the error occurred | | handler | string | 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. | | lastIndex | number | |

| Method | Signature | Description | | ----------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | | exec | (string: string) => RegExpExecArray | null | Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. | | test | (string: string) => boolean | Returns a Boolean value that indicates whether or not a pattern exists in a searched string. | | compile | () => this | |

RegExpExecArray

| Prop | Type | | ----------- | ------------------- | | index | number | | input | string |

UserFeedbackResultSuccess

| Prop | Type | Description | | ----------------- | ------------------- | ------------------------------- | | isSent | true | The user has sent the feedback. | | feedbackURL | string | Bugfender URL for the feedback. |

UserFeedbackResultCancel

| Prop | Type | Description | | ------------ | ------------------ | ------------------------------------------------- | | isSent | false | The user has closed the modal without sending it. |

UserFeedbackOptions

Options object for Bugfender.getUserFeedback with customised modal strings.

| Prop | Type | Description | | ------------------------- | ------------------- | ----------------------------------------------------------- | | title | string | Default: Feedback. | | hint | string | Default: Please insert your feedback here and click send. | | subjectPlaceholder | string | Default: Subject…. | | feedbackPlaceholder | string | Default: Your feedback…. | | submitLabel | string | Default: Send. | | closeLabel | string | Default: Close. iOS only. |

LogEntry

Log Entry object interface

| Prop | Type | Description | | ------------ | --------------------------------------------- | --------------------------------------------------------------------------------------------------------- | | line | number | The line number where the log was triggered from | | level | LogLevel | The log's level based on LogLevel constant | | tag | string | The log's tag | | method | string | The method name where the log was triggered from | | file | string | The file name where the log was triggered from | | text | string | unknown[] | 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.

(info: ExceptionInfo): boolean

ExceptionPattern

A pattern that can be used to match exception messages. Can be a string (exact or substring match) or a RegExp.

string | RegExp

UserFeedbackResult

UserFeedbackResultSuccess | UserFeedbackResultCancel

DeviceKeyValue

string | number | boolean

Record

Construct a type with a set of properties K of type T

{ [P in K]: T; }

Enums

LogLevel

| Members | Value | | ------------- | -------------- | | Debug | 0 | | Warning | 1 | | Error | 2 | | Trace | 3 | | Info | 4 | | Fatal | 5 |