phptek / silverstripe-sentry

Flexible Sentry compatible bug aggregation client for Silverstripe applications.
BSD 3-Clause "New" or "Revised" License
12 stars 22 forks source link

User info is not recognised as user info #85

Closed jonom closed 1 year ago

jonom commented 1 year ago

This might just be me, but for some reason Sentry isn't connecting the dots on the user information. It's visible as context info, but not as a user tag, which means I can't (easily) see if an issue is affecting multiple users. I couldn't see anything obvious in the module code about why this might happen. There's even a fancy question mark on the user context info 🤷‍♂️

image Screen Shot 2023-05-08 at 9 32 41 AM

phptek commented 1 year ago

I'd have to do some digging, but it doesn't look like Member data is being sent as a tag in Log/SentryLogger::factory(). Also, (and this may surprise you) I've never known what that question-mark means, especially when all the data is sent and available in the "User" section.

Have you tried hacking the module's defaultTags() method to include user-data? This is where all the tags are collected and pushed to Sentry. If that works, maybe I'll mod the module. I don't think there was a reason user data wasn't made a tag, other than that there was already a specific place to set user data alongside tagged data as a Sentry context ala:

        $adaptor = (new SentryAdaptor($client))
            ->setContext('env', $env)
            ->setContext('tags', $tags)
            ->setContext('extra', $extra)
            ->setContext('user', $user);
jonom commented 1 year ago

Looks like the issue is here - the array keys of the user data are incompatible with Sentry\UserDataBag so are added as metadata only when parsed here.

image

jonom commented 1 year ago

Or here, rather. Maybe was a change in Sentry API at some point?

jonom commented 1 year ago

Bingo! I'll open a PR.

image