getsentry / sentry-cocoa

The official Sentry SDK for iOS, tvOS, macOS, watchOS.
https://sentry.io/for/cocoa/
MIT License
801 stars 316 forks source link

Expose device identifier #3281

Open lhunath opened 1 year ago

lhunath commented 1 year ago

Problem Statement

Sentry uses some internal logic to combine device information into a hash called the deviceAppHash, exposed as app.device in the crash reports.

Unfortunately, there is no way for the developer to access this identifier directly. Effectively, this is a private data point internal to Sentry.

I would like to gain access to this identifier. It is quite useful when we want to direct our developers to the crash logs for a specific user's device. Naively, I was building this link as such:

"See Sentry: https://hubstaff.sentry.io/issues/?query=app.device%3A\(UIDevice.current.identifierForVendor?.uuidString)"

But this doesn't work since Sentry hashes the identifier (alongside potentially some other information).

Ideally Sentry shouldn't manage private data on the user which is hidden from the developer.

Solution Brainstorm

The device identifier is generated in Sources/SentryCrash/Recording/Monitors/SentryCrashMonitor_System.m, stored in a private g_systemData, copied into eventContext->System.deviceAppHash, written to the crash report's device_app_hash in Sources/SentryCrash/Recording/SentryCrashReport.c.

Suggest exposing the identifier in SentrySDK or SentryClient.

Are you willing to submit a PR?

No response

brustolin commented 1 year ago

Thanks @lhunath for the suggestions. This may be related to #3278.

Ideally Sentry shouldn't manage private data on the user which is hidden from the developer.

We don't manage private data on the user. The device hash holds no PII, it is just a calculated hash that identifies events coming from the same app+device with no identification at all.

lhunath commented 1 year ago

Thanks @brustolin, I was not referring to PII, I was referring to managing data on the user's device which is kept private/internal and hidden from the developer despite being elementary to the crash report.

bruno-garcia commented 1 year ago

The Id will show up on crash reports in Sentry so making them available programatically for the app developer makes sense to me.