Skip to content

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

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:

  • ViewHierarchyAttachmentpublic (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.
  • ScreenshotAttachmentinternal (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

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