[iOS] Omitting Transaction Captures / Snapshots

I have made a custom UI that pops up to submit user feedback. After the feedback is submitted, an event is immediately captured and sent to Sentry. However, every transaction shows the UIViewController that was made specifically to take the bug report, which is not helpful in finding out which was the top-most view controller on the stack where the user encountered an issue.

Is there a way to pop off the most-recent view controller in this case? If not, any ideas for a workaround? I tried capturing the event prior to the “bug report” UI popping up, but that UI is still registered as the most recent transaction when the user feedback is attached to that event.

Hi @borninla,

I’m not 100% sure what you mean by transaction. So either you are talking about breadcrumbs or the stacktrace I guess.

If you want to get rid of some breadcrumbs use beforeBreadcrumb.

If you want to get rid of some frames on the event it gets a bit trickier. You can use beforeSend and modify the frames of the stacktrace if you want. Something like this could work

SentrySDK.start { options in
    options.dsn = "Your_DSN"
    options.beforeSend = { event in
        // first we need find the current thread
        if let thread = event.threads?.first(where: { thread in thread.current?.boolValue ?? false}) {
            if var frames = thread.stacktrace?.frames {
                // The top most frame is the last one
                let indexOfTopMostFrame = frames.count - 1
                if (indexOfTopMostFrame >= 0) {
                    frames.remove(at: frames.count - 1)
                    thread.stacktrace?.frames = frames
                }
            }
        }
        
        return event
    }
}

In case you mean something else, please clarify what exactly you mean by transaction.

I hope this helps.

1 Like

I was talking about the stacktrace and your solution was exactly what I was looking for. I assumed Sentry’s “transaction” to be semantically related to capturing the frame at the top of the stack. Many thanks!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.