Skip to content

Add capture(error:attachAllThreads:block:) combined API to SentrySDK #8538

Open

Description

@masinette

Currently, the public SentrySDK API exposes attachAllThreads and scope block mutation as separate methods with no way to use both together:

// Scope block only
@discardableResult public static func capture(
  error: Error,
  block: @escaping (Scope) -> Void
) -> SentryId


// attachAllThreads only
@discardableResult public static func capture(
  error: Error,
  attachAllThreads: Bool
) -> SentryId

There is no public method that combines both parameters.

Requested API:

@discardableResult public static func capture(
  error: Error,
  attachAllThreads: Bool,
  block: @escaping (Scope) -> Void
) -> SentryId

Motivation:

When capturing errors where full thread stack traces are needed for specific events only (rather than globally via SentryOptions.attachAllThreads), there is currently no clean way to also mutate the scope for that same call. The only workarounds are:

Enabling attachAllThreads globally at init, which may not be desirable for performance reasons.
Using configureScope before the capture call, which sets data globally and requires manual cleanup.

Expected behaviour:

The method would behave identically to the existing capture(error:block:) variant (cloning the current scope and applying mutations only to the captured event) while also forwarding the attachAllThreads flag to the underlying client.

Activity

  1. linear-code commented on Jul 23, 2026

    @linear-code
  2. sergiisukhanov commented on Jul 23, 2026

    @sergiisukhanov

    Thanks a lot @masinette for raising an issue. 🙏

    I would like to add: this relates to all four .capture( options (not .capture(error: Error, ...) only):

    • .capture(error: Error, ...)
    • .capture(event: Event, ...)
    • .capture(message: String, ...)
    • .capture(exception: exception, ...)

    It would be great to have these four public methods 😃

    @discardableResult public static func capture(
      error: Error,
      attachAllThreads: Bool,
      block: @escaping (Scope) -> Void
    ) -> SentryId
    
    @discardableResult public static func capture(
      event: Event,
      attachAllThreads: Bool,
      block: @escaping (Scope) -> Void
    ) -> SentryId
    
    @discardableResult public static func capture(
      message: String,
      attachAllThreads: Bool,
      block: @escaping (Scope) -> Void
    ) -> SentryId
    
    @discardableResult public static func capture(
      exception: NSException,
      attachAllThreads: Bool,
      block: @escaping (Scope) -> Void
    ) -> SentryId
  3. sergiisukhanov commented on Jul 23, 2026

    @sergiisukhanov

    In addition: it would be really great to have this change as 9.14.1: on top of 9.14.0 release (since 9.14.0 is the latest stable release).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions