2727use Exception ;
2828use OCA \Sentry \Helper \CredentialStoreHelper ;
2929use OCP \Authentication \Exceptions \CredentialsUnavailableException ;
30+ use OCP \Defaults ;
3031use OCP \IConfig ;
3132use OCP \ILogger ;
3233use OCP \IUserSession ;
4344
4445class SentryReporterAdapter implements IMessageReporter, ICollectBreadcrumbs, ISentryReporter {
4546
46- /** @var IUserSession */
47- protected $ userSession ;
48-
49- /** @var CredentialStoreHelper */
50- private $ credentialStoreHelper ;
51-
52- /** @var bool */
53- private $ userScopeSet = false ;
47+ protected IUserSession $ userSession ;
48+ private CredentialStoreHelper $ credentialStoreHelper ;
49+ private IConfig $ config ;
50+ private Defaults $ defaults ;
51+ private bool $ userScopeSet = false ;
5452
5553 /** @var array mapping of log levels */
5654 private const levels = [
@@ -61,15 +59,16 @@ class SentryReporterAdapter implements IMessageReporter, ICollectBreadcrumbs, IS
6159 ILogger::FATAL => Severity::FATAL ,
6260 ];
6361
64- /** @var int */
65- private $ minimumLogLevel ;
62+ private int $ minimumLogLevel ;
6663
6764 public function __construct (IUserSession $ userSession ,
6865 IConfig $ config ,
69- CredentialStoreHelper $ credentialStoreHelper ) {
66+ CredentialStoreHelper $ credentialStoreHelper, Defaults $ defaults ) {
7067 $ this ->userSession = $ userSession ;
68+ $ this ->config = $ config ;
7169 $ this ->minimumLogLevel = (int )$ config ->getSystemValue ('sentry.minimum.log.level ' , ILogger::WARN );
7270 $ this ->credentialStoreHelper = $ credentialStoreHelper ;
71+ $ this ->defaults = $ defaults ;
7372 }
7473
7574 /**
@@ -101,6 +100,9 @@ protected function setSentryScope(array $context): void {
101100 $ scope ->setTag ('app ' , $ context ['app ' ]);
102101 }
103102
103+ $ scope ->setTag ('instance_url ' , $ this ->config ->getSystemValueString ('overwrite.cli.url ' ));
104+ $ scope ->setTag ('instance_name ' , $ this ->defaults ->getName ());
105+
104106 if ($ this ->userScopeSet ) {
105107 // Run the code below just once
106108 return ;
@@ -119,6 +121,7 @@ protected function setSentryScope(array $context): void {
119121 $ scope ->setUser ([
120122 'id ' => $ user ->getUID (),
121123 'username ' => $ username ,
124+ 'email ' => $ user ->getEMailAddress ()
122125 ]);
123126 }
124127 });
0 commit comments