From 0353f1685ac27374a3b5df7490d50e637e20e00c Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Wed, 4 Aug 2021 20:32:52 -0400
Subject: [PATCH] Add uuid to mac crash report

---
 indra/newview/llappviewermacosx-objc.h  |  1 +
 indra/newview/llappviewermacosx-objc.mm | 14 ++++++++++++++
 indra/newview/llappviewermacosx.cpp     |  5 +++++
 indra/newview/llappviewermacosx.h       | 14 ++++++++------
 4 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/indra/newview/llappviewermacosx-objc.h b/indra/newview/llappviewermacosx-objc.h
index c6dcec8e34e..9ac36b6c4d3 100644
--- a/indra/newview/llappviewermacosx-objc.h
+++ b/indra/newview/llappviewermacosx-objc.h
@@ -31,6 +31,7 @@
 #include <vector>
 
 //Why?  Because BOOL
+void setCrashUserMetadataWrapper(const std::string& userid, const std::string& username);
 void launchApplication(const std::string* app_name, const std::vector<std::string>* args);
 
 #endif // LL_LLAPPVIEWERMACOSX_OBJC_H
diff --git a/indra/newview/llappviewermacosx-objc.mm b/indra/newview/llappviewermacosx-objc.mm
index 8ffc978aab9..57ab7841dcb 100644
--- a/indra/newview/llappviewermacosx-objc.mm
+++ b/indra/newview/llappviewermacosx-objc.mm
@@ -33,6 +33,20 @@
 
 #include "llappviewermacosx-objc.h"
 
+#if defined(USE_SENTRY)
+#import "Sentry.h"
+#endif
+
+void setCrashUserMetadataWrapper(const std::string& userid, const std::string& username)
+{
+#if defined(USE_SENTRY)
+    SentryUser *user = [[SentryUser alloc] init];
+    user.userId = @(userid.c_str());
+    user.username = @(username.c_str());
+    [SentrySDK setUser:user];
+#endif
+}
+
 void launchApplication(const std::string* app_name, const std::vector<std::string>* args)
 {
     @autoreleasepool
diff --git a/indra/newview/llappviewermacosx.cpp b/indra/newview/llappviewermacosx.cpp
index 68d4c6c8042..ed293a92054 100644
--- a/indra/newview/llappviewermacosx.cpp
+++ b/indra/newview/llappviewermacosx.cpp
@@ -227,6 +227,11 @@ bool LLAppViewerMacOSX::init()
     return success;
 }
 
+void LLAppViewerMacOSX::setCrashUserMetadata(const LLUUID& user_id, const std::string& avatar_name)
+{
+    setCrashUserMetadataWrapper(user_id.asString(), avatar_name);
+}
+
 // MacOSX may add and addition command line arguement for the process serial number.
 // The option takes a form like '-psn_0_12345'. The following method should be able to recognize
 // and either ignore or return a pair of values for the option.
diff --git a/indra/newview/llappviewermacosx.h b/indra/newview/llappviewermacosx.h
index d5a80864be3..e96cee0f3ad 100644
--- a/indra/newview/llappviewermacosx.h
+++ b/indra/newview/llappviewermacosx.h
@@ -31,23 +31,25 @@
 #include "llappviewer.h"
 #endif
 
-class LLAppViewerMacOSX : public LLAppViewer
+class LLAppViewerMacOSX final : public LLAppViewer
 {
 public:
 	LLAppViewerMacOSX();
-	virtual ~LLAppViewerMacOSX();
+    ~LLAppViewerMacOSX() override;
 
 	//
 	// Main application logic
 	//
-	virtual bool init();			// Override to do application initialization
+    bool init();			// Override to do application initialization
 
+    void setCrashUserMetadata(const LLUUID& user_id, const std::string& avatar_name) override;
+    
 protected:
-	virtual bool restoreErrorTrap();
-	virtual void initCrashReporting(bool reportFreeze);
+    bool restoreErrorTrap() override;
+    void initCrashReporting(bool reportFreeze) override;
 
 	std::string generateSerialNumber();
-	virtual bool initParseCommandLine(LLCommandLineParser& clp);
+    bool initParseCommandLine(LLCommandLineParser& clp) override;
 };
 
 #endif // LL_LLAPPVIEWERMACOSX_H
-- 
GitLab