Skip to content

Expose AddToTransactions flag on derived SentryAttachment types (ViewHierarchyAttachment, ScreenshotAttachment) #5380

Closed as not planned

Description

@jamescrosswell

Background

Follow-up from #5182 (review).

That PR adds an AddToTransactions flag to the base SentryAttachment via an overloaded constructor:

public SentryAttachment(
    AttachmentType type,
    IAttachmentContent content,
    string fileName,
    string? contentType,
    bool addToTransactions)

As @Flash0ver asked, the derived attachment types don't currently expose this flag — their constructors call base(...) without it, so addToTransactions is always false. There are two subclasses:

  • ViewHierarchyAttachment — public (core Sentry). Its single ctor takes only IAttachmentContent and hard-codes the base call, so there's no way for a consumer to opt a view-hierarchy attachment into transactions.
  • ScreenshotAttachment — internal (Sentry.Maui.Internal). Not part of the public API, but the flag could still be plumbed internally if we want screenshots addable to transactions.

Proposal

Offer the addToTransactions flag on the derived attachment types too, so it can be set consistently:

  • Add an overloaded ViewHierarchyAttachment ctor that accepts bool addToTransactions and forwards it to base(...).
  • Plumb the flag through ScreenshotAttachment internally as needed (no public surface change required since it's internal).

This is additive (a new overload), so it is not a breaking change and doesn't need to wait for a major.

Acceptance criteria

  • ViewHierarchyAttachment exposes a way to set addToTransactions
  • ScreenshotAttachment can set addToTransactions where appropriate
  • Existing (default false) behavior is preserved for callers that don't pass the flag

Activity

  1. added
    public APIAdditions/modifications to, or removals from, the public API surface area.
    on Jul 13, 2026
  2. linear-code commented on Jul 13, 2026

    @linear-code
  3. jamescrosswell commented on Jul 13, 2026

    @jamescrosswell
    CollaboratorAuthor

    Superseded — will be addressed directly in #5182 rather than as a follow-up.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETPull requests that update .net codeAttachmentsFeatureNew feature or requestState: Unreproduciblepublic APIAdditions/modifications to, or removals from, the public API surface area.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions