Logs: BeforeLogs Sync with Native

Open
#5,158 7 comments 1 reaction 1 assignee View on GitHub

@lucas-zimerman is already working on this.

Since Sep 10, 2025.

Assessment

This issue has not been assessed yet.

Description

Improvement Logs React-Native
Description

I created this issue to talk about the best solution to be followed for the following problem.

Problem:
  • Users can't filter logs on beforeLogs that were created by the native SDKs.
  • Each SDK has their cache flow logic, having two queues for flushing (one in JavaScript and another on the native side)

Solution 1:

  • Move logs from beforelog on the Native side to the JavaScript and always return null/empty on the native side.
  • Drop the logs on the native side so we keep a single queue on the JavaScript side.
Problems:
  • Native side will send internal logs that logs are being dropped by beforelog.
  • Sentry JavaScript exposes _INTERNAL_captureSerializedLog that could be used to skip the log processing on the JavaScript SDK, but doesn't expose a way of converting Log to serializedLog, requiring code duplication.

Solution 2:

  • When beforeLog is called on the native layer, call the JavaScript beforeLog with the Native log and wait for the JavaScript response with the changes done by the end user.
Problems:
  • Doesn't fix the two queues for sending Logs.
  • Native layer always having to wait for a response from the JavaScript layer when calling BeforeLog.

It would be nice to have some feedback on which solution seems like the better path forward, or if there’s a third alternative I might be missing.

Dominant language
TypeScript
Stars
1.8k
Forks
367
Avg merge
1d 6h
Merged PRs (30d)
94

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from getsentry/sentry-react-native

All issues in getsentry/sentry-react-native

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.