-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
Feat: Automatic user IDs on native crashes & .NET events #728
Conversation
e98a20f
to
0be2cce
Compare
c9ad8ca
to
b6424d4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So in summary:
- For Android, Cocoa (iOS and macOS) we fetch the ID from the native SDKs (which is great because they initialize first)
- For Native (Windows & Linux) we set the ID from the C# layer.
This is great!
@@ -27,4 +27,9 @@ | |||
Overwrite="true"/> | |||
</Target> | |||
|
|||
<ItemGroup> | |||
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL that this exists. @bruno-garcia would that help with some of the issues we had with some of the .NET SDK internals we did not want to make public like inside of SentryOptions
for SentryUnityOptions
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is the same as adding [assembly: InternalsVisibleToAttribute(..)
in C#. Just another way.
_defaultUserId = value; | ||
if (_defaultUserId is null) | ||
{ | ||
DiagnosticLogger?.LogWarning("Couldn't set the default user ID - the value is NULL."); | ||
} | ||
else | ||
{ | ||
DiagnosticLogger?.LogDebug("Setting '{0}' as the default user ID.", _defaultUserId); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_defaultUserId = value; | |
if (_defaultUserId is null) | |
{ | |
DiagnosticLogger?.LogWarning("Couldn't set the default user ID - the value is NULL."); | |
} | |
else | |
{ | |
DiagnosticLogger?.LogDebug("Setting '{0}' as the default user ID.", _defaultUserId); | |
} | |
if (value is null) | |
{ | |
DiagnosticLogger?.LogWarning("Couldn't set the default user ID - the value is NULL."); | |
} | |
else | |
{ | |
_defaultUserId = value; | |
DiagnosticLogger?.LogDebug("Setting '{0}' as the default user ID.", _defaultUserId); | |
} |
Should this not set the id if it logs that it can't?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the goal to reset to null as it'll be needed later to "unset"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this not set the id if it logs that it can't?
this is a setter - doesn't feel right to ignore the value being passed (i.e. not set)
@@ -27,4 +27,9 @@ | |||
Overwrite="true"/> | |||
</Target> | |||
|
|||
<ItemGroup> | |||
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is the same as adding [assembly: InternalsVisibleToAttribute(..)
in C#. Just another way.
_defaultUserId = value; | ||
if (_defaultUserId is null) | ||
{ | ||
DiagnosticLogger?.LogWarning("Couldn't set the default user ID - the value is NULL."); | ||
} | ||
else | ||
{ | ||
DiagnosticLogger?.LogDebug("Setting '{0}' as the default user ID.", _defaultUserId); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the goal to reset to null as it'll be needed later to "unset"?
@@ -36,6 +37,9 @@ public static void Configure(SentryUnityOptions options) | |||
options.DiagnosticLogger?.LogWarning("Attaching screenshots on WebGL is disabled - " + | |||
"it currently produces blank screenshots mid-frame."); | |||
} | |||
|
|||
// Use AnalyticsSessionInfo.userId as the default UserID in native & dotnet | |||
options.DefaultUserId = AnalyticsSessionInfo.userId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is an ID that can be used to link the user across apps/services, we shouldn't be using it here.
We purposely on some GUIDs we create so that we can have some consistency in detecting "number ofusers impacted" but the goal is never to do actual user tracking. For that reason we've dropped "Android ID" also, for example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JS will default to the connection IP Address, and there's no native so we might be better off without anything here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
we don't have sentry-js (yet)
-
therefore setting this here only affects c# events
-
I'm setting it here because that's what feeled right - each
nativeplatform integration defines the source for the DefaultUserId value -
If this is an ID that can be used to link the user across apps/services, we shouldn't be using it here.
I really don't think so. It's an installation ID.
https://docs.unity3d.com/ScriptReference/Analytics.AnalyticsSessionInfo-userId.html
A random GUID uniquely identifying sessions played on the same instance of your game or app.
Unity generates the userId GUID immediately after installation. The userId value is only regenerated if the user re-installs the game.
since this is already approved I'm merging to avoid conflicts in #747 - if we need to make changes based on those unresolved conversations, let's do them in the other PR. |
closes #606