Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sentry LastEventId by Type #1045

Closed
hajimeku opened this issue Oct 25, 2022 · 6 comments
Closed

Sentry LastEventId by Type #1045

hajimeku opened this issue Oct 25, 2022 · 6 comments

Comments

@hajimeku
Copy link

Hey!
I am trying to find a way on how I could integrate https://docs.sentry.io/platforms/unity/enriching-events/user-feedback/ into my application.

I figured out that I could do
var eventId = SentrySdk.LastEventId;
And then send this eventId to CaptureUserFeedback

The problem I have now is that I would like to only do this for specific uncaught exceptions or crashes the user might have experienced. Is there any way to detect this?
If I cant detect this the last eventId is usually some texture not being able to load from an avatar for example.

@mattjohnsonpint
Copy link
Contributor

mattjohnsonpint commented Oct 25, 2022

You can use the BeforeSend hook to examine captured events on their way to be sent to Sentry, and retain the event ID based on whatever logic you choose.

First set up programmatic configuration, then set up a BeforeSend hook such as:

options.BeforeSend = sentryEvent =>
{
    // Whatever logic you want 
    if (sentryEvent.Exception is SomeException)
    {
        // Save the EventId property somewhere in your own code that you can access later
        SomeClass.LastSentryEventId = sentryEvent.EventId;
    }

    // Return the original event so it still gets sent to Sentry
    return sentryEvent;
};

@mattjohnsonpint
Copy link
Contributor

Also, I just noticed that even though we documented its usage, the Exception property is hidden from some IDEs. Fixing that with getsentry/sentry-dotnet#2011 for the next release. It is safe to use either way.

@hajimeku
Copy link
Author

thanks Matt! This will solve my issue

@hajimeku
Copy link
Author

hajimeku commented Oct 25, 2022

I'm trying to make sense of how I should use this feature.
Is it common that this is used as a bug-reporting tool?

I tried to use
SentrySdk.CaptureUserFeedback(SentryId.Empty, "testmail@azerion.com", "There is a comment here", "Apollo");

But have not received any user feedback.

@hajimeku hajimeku reopened this Oct 25, 2022
@mattjohnsonpint
Copy link
Contributor

Instead of SentryId.Empty, pass the actual ID of the associated event.

See also: https://docs.sentry.io/platforms/dotnet/enriching-events/user-feedback/

@hajimeku
Copy link
Author

This solved it yea! We thought it would only be an extra piece of information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants