@bugfender/rn-bugfender

中文文档
6.0.0发布于 2026/07/27ISCTypeScriptESM + CJS近 30 天下载 2899

React Native bindings for Bugfender SDK

原始使用文档
文档目录7 节
  1. Expo compatibility
  2. Adding Bugfender to your project
  3. Usage
  4. Example
  5. Network logging
  6. Changelog
  7. Cocoapods Troubleshooting

React Native plugin for Bugfender

Bugfender module for React Native and React Native for the Web. It depends on the iOS, Android and Javascript Bugfender SDKs.

This version has been tested in React Native with both the Old and New Architecture. The New Architecture is still experimental, and therefore subject to break in new React Native versions.

Expo compatibility

Bugfender works with Expo in the "bare workflow". The Expo Go application (used in the managed workflow) can not run the Bugfender SDK because it contains native code.

Adding Bugfender to your project

$ cd path_to_your_project

Add the bugfender plugin from npm

$ npm install @bugfender/rn-bugfender @bugfender/sdk @bugfender/common

After installing, close and relaunch your app with npm run ios or npm run android.

Usage

import { Bugfender, LogLevel } from '@bugfender/rn-bugfender';

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

Note: always import @bugfender/rn-bugfender instead of @bugfender/sdk. This will enable the native features of the SDK that you wouldn't get otherwise.

Example

import { Bugfender, LogLevel } from '@bugfender/rn-bugfender';

// Init Bugfender with your APP key
Bugfender.init({
  appKey: '<YOUR APP KEY>',
  // apiURL: 'https://api.bugfender.com',
  // baseURL: 'https://dashboard.bugfender.com',
  // overrideConsoleMethods: true,
  // printToConsole: true,
  // logUIEvents: true,
  // registerErrorHandler: true,
  // deviceName: 'Anonymous',
  // maximumLocalStorageSize: 5 * 1024 * 1024, // Native specific
  // enableLogcatLogging: false, // Android specific
  // networkLoggingEnabled: false,
  // networkLoggingCaptureBodies: false,
  // networkLoggingCaptureErrorResponseBodies: false,
  // logBrowserEvents: true, // Web specific
  // build: '42', // Web specific
  // version: '1.0', // Web specific
});

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 React Native fetch).
  • Android: React Native fetch/XHR is instrumented via OkHttp (android-okhttp 4.x adapter).
  • Web: Uses @bugfender/sdk (≥ 4.0.0), which intercepts fetch and XMLHttpRequest.
  • Requires native Bugfender Android SDK 4.x (this package pulls com.bugfender.sdk:android:4.+).

Changelog

The changelog of the Bugfender Web SDK can be found in ReleaseNotes under the react-native tag. For all the Bugfender product changes please visit the general release notes.

Cocoapods Troubleshooting

We often get questions about CocoaPods install failing. Whilst this has nothing to do with Bugfender, you may encounter this problem while installing the pod.

To reinstall the pods, you can do:

bundle exec pod install

Or, for the New Architecture:

RCT_NEW_ARCH_ENABLED=1 bundle exec pod install

You can find more details here: https://reactnative.dev/docs/environment-setup

版本与发布记录

@bugfender/rn-bugfender 共发布 33 个版本,首次发布于 2018/09/03;过去 12 个月发布了 3 个版本。

版本发布日期距今
6.0.0latest2026/07/273 个月前
5.0.12026/01/199 个月前
5.0.02026/01/089 个月前
4.0.02025/01/021.8 年前
3.0.02024/09/042 年前
2.2.12023/08/103 年前

其他发布通道:alpha → 2.0.0-alpha.0,beta → 2.2.0。

关于 @bugfender/rn-bugfender 的常见问题

@bugfender/rn-bugfender 是什么?

React Native bindings for Bugfender SDK

如何安装 @bugfender/rn-bugfender?

在项目目录运行 npm install @bugfender/rn-bugfender,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@bugfender/common(^1.0.0)、@bugfender/sdk(^4.0.1)、react(*)、react-native(*)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bugfender/rn-bugfender 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bugfender/rn-bugfender 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@bugfender/rn-bugfender 可以商用吗?

@bugfender/rn-bugfender 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bugfender/rn-bugfender 的下载量有多少?

根据 npm 官方下载统计,@bugfender/rn-bugfender 在 2026/10/09 – 2026/11/07 这 30 天内被下载 2,899 次,日均约 97 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bugfender/rn-bugfender 还在维护吗?

最新版本 6.0.0 发布于 2026/07/27(3 个月前);至今共发布 33 个版本,其中过去 12 个月发布了 3 个;首次发布于 2018/09/03。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。