Skip to content

Commit

Permalink
Add additional logging and additional fallback for installation ID
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz committed Jul 2, 2021
1 parent 00be88c commit c1ab501
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Sentry/GlobalSessionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public GlobalSessionManager(SentryOptions options)

Directory.CreateDirectory(directoryPath);

_options.DiagnosticLogger?.LogDebug(
"Created directory for installation ID file ({0}).",
directoryPath
);

var filePath = Path.Combine(directoryPath, ".installation");

// Read installation ID stored in a file
Expand Down Expand Up @@ -94,6 +99,7 @@ public GlobalSessionManager(SentryOptions options)
{
try
{
// Get MAC address of the first network adapter
var installationId = NetworkInterface
.GetAllNetworkInterfaces()
.Where(nic =>
Expand All @@ -105,7 +111,7 @@ public GlobalSessionManager(SentryOptions options)
if (string.IsNullOrWhiteSpace(installationId))
{
_options.DiagnosticLogger?.LogError(
"Failed to resolve hardware installation ID."
"Failed to find an appropriate network interface for installation ID."
);

return null;
Expand Down Expand Up @@ -145,7 +151,8 @@ public GlobalSessionManager(SentryOptions options)

var id =
TryGetPersistentInstallationId() ??
TryGetHardwareInstallationId();
TryGetHardwareInstallationId() ??
Environment.MachineName;

if (!string.IsNullOrWhiteSpace(id))
{
Expand Down

0 comments on commit c1ab501

Please sign in to comment.