Skip to content

Expose onBeforeReportSend callback#235

Merged
FranAguilera merged 4 commits intomainfrom
franjam/crash-hook-rn
Mar 19, 2026
Merged

Expose onBeforeReportSend callback#235
FranAguilera merged 4 commits intomainfrom
franjam/crash-hook-rn

Conversation

@FranAguilera
Copy link
Copy Markdown
Contributor

@FranAguilera FranAguilera commented Mar 13, 2026

What

Resolves BIT-7610

Brings parity to RN with available callback in the native sdk (see related PR here)

Example below

crashReporting: {
      UNSTABLE_enableJsErrors: true, // Existing

      // Added now
      UNSTABLE_onBeforeReportSend: (report) => {
        console.log('Issue callback triggered:', report);
      },
}

Verification

@FranAguilera FranAguilera force-pushed the franjam/crash-hook-rn branch 5 times, most recently from 7724a3d to 80b091e Compare March 19, 2026 13:14
@FranAguilera FranAguilera changed the title Prototyping crash hook callback Expose UNSTABLE_onBeforeReportSend Mar 19, 2026
@FranAguilera FranAguilera changed the title Expose UNSTABLE_onBeforeReportSend Expose onBeforeReportSend callback Mar 19, 2026
@FranAguilera FranAguilera force-pushed the franjam/crash-hook-rn branch 4 times, most recently from 22b11ab to 4994f68 Compare March 19, 2026 14:26
@FranAguilera FranAguilera requested a review from Copilot March 19, 2026 14:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR exposes a new React Native UNSTABLE_onBeforeReportSend callback that fires before an issue report is sent, aligning RN behavior with the native SDKs.

Changes:

  • Adds a JS-facing UNSTABLE_onBeforeReportSend crash reporting option and wires it to native-emitted events.
  • Implements native issue report callbacks on iOS/Android and forwards them to JS via event emitters.
  • Updates documentation and example apps to demonstrate the new callback.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/react-native/src/index.tsx Adds new public types/options and registers an event listener to invoke UNSTABLE_onBeforeReportSend.
packages/react-native/src/NativeBdReactNative.ts Extends the TurboModule spec with addListener/removeListeners to support RN event emitter semantics.
packages/react-native/ios/Logger.swift Configures Capture’s issue callback and posts a notification containing report metadata.
packages/react-native/ios/BdReactNative.mm Bridges notifications to JS events via RCTEventEmitter.
packages/react-native/ios/BdReactNative.h Switches module base class to RCTEventEmitter for both old/new architecture.
packages/react-native/android/src/main/java/com/bdreactnative/BdReactNativeModule.kt Configures Capture issue callback and emits issue report events to JS.
packages/react-native/README.md Documents UNSTABLE_onBeforeReportSend and adds usage examples.
examples/expo/src/lib/bitdrift.ts Demonstrates callback usage and logging of report metadata.
examples/HermesSample/lib/bitdrift.ts Demonstrates callback usage and logging of report metadata.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread packages/react-native/src/index.tsx
Comment thread packages/react-native/ios/Logger.swift Outdated
@FranAguilera FranAguilera force-pushed the franjam/crash-hook-rn branch from 4994f68 to edcbea5 Compare March 19, 2026 14:59
@FranAguilera FranAguilera marked this pull request as ready for review March 19, 2026 15:00
@FranAguilera FranAguilera requested a review from Copilot March 19, 2026 15:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a React Native-facing onBeforeReportSend (issue report) callback by bridging native issue report callbacks to JS via an event emitter, bringing parity with native SDK behavior.

Changes:

  • Introduces JS types and init-time wiring to subscribe to a native “before report send” event and enable native callback bridging only when needed.
  • Implements native-side callback plumbing on iOS (NotificationCenter → RCTEventEmitter) and Android (IssueReportCallback → DeviceEventEmitter), plus required event-emitter contract methods.
  • Updates README and sample apps to demonstrate the new callback.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/react-native/src/index.tsx Adds public callback/types, subscribes to issue-report events, and maps JS options to native options with a bridge enable flag.
packages/react-native/src/NativeBdReactNative.ts Extends TurboModule spec/options to include internal enable flag + event emitter contract methods.
packages/react-native/ios/Logger.swift Wires Capture issue callback to a NotificationCenter notification and threads it via a dedicated queue.
packages/react-native/ios/BdReactNative.mm Converts the notification into an RN event (RCTEventEmitter) and forwards the new enable flag into Logger start.
packages/react-native/ios/BdReactNative.h Makes the module an RCTEventEmitter to support JS event subscriptions.
packages/react-native/android/src/main/java/com/bdreactnative/BdReactNativeModule.kt Adds issue callback configuration and emits issue reports to JS; adds addListener/removeListeners no-ops.
packages/react-native/README.md Documents the new callback option in usage/config sections.
examples/expo/src/lib/bitdrift.ts Demonstrates the callback in the Expo example.
examples/HermesSample/lib/bitdrift.ts Demonstrates the callback in the Hermes sample.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread packages/react-native/src/index.tsx Outdated
Comment thread packages/react-native/src/index.tsx
Comment thread packages/react-native/README.md
FranAguilera and others added 2 commits March 19, 2026 16:11
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Fran Aguilera <fran.aguilera12@gmail.com>
@FranAguilera FranAguilera force-pushed the franjam/crash-hook-rn branch 3 times, most recently from 6256c16 to d59f870 Compare March 19, 2026 15:30
@FranAguilera FranAguilera force-pushed the franjam/crash-hook-rn branch from d59f870 to 6934551 Compare March 19, 2026 15:40
@FranAguilera FranAguilera enabled auto-merge (squash) March 19, 2026 15:50
@FranAguilera FranAguilera disabled auto-merge March 19, 2026 15:52
@FranAguilera FranAguilera merged commit b23b799 into main Mar 19, 2026
8 of 11 checks passed
@FranAguilera FranAguilera deleted the franjam/crash-hook-rn branch March 19, 2026 16:27
@github-actions github-actions bot locked and limited conversation to collaborators Mar 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants