send user info to sentry

This commit is contained in:
Nikita Galaiko 2023-02-22 12:55:25 +01:00
parent 93975be057
commit 4d3f64d6d9
No known key found for this signature in database
GPG Key ID: EBAB54E845BA519D
2 changed files with 28 additions and 0 deletions

View File

@ -89,6 +89,9 @@ fn set_user(handle: tauri::AppHandle, user: users::User) -> Result<(), Error> {
message: "Failed to save user".to_string(),
}
})?;
sentry::configure_scope(|scope| scope.set_user(Some(user.clone().into())));
Ok(())
}
@ -104,6 +107,9 @@ fn delete_user(handle: tauri::AppHandle) -> Result<(), Error> {
message: "Failed to delete user".to_string(),
}
})?;
sentry::configure_scope(|scope| scope.set_user(None));
Ok(())
}
@ -402,6 +408,17 @@ fn main() {
users_storage.clone(),
);
users_storage
.get()
.and_then(|user| match user {
Some(user) => {
sentry::configure_scope(|scope| scope.set_user(Some(user.clone().into())));
Ok(())
}
None => Ok(()),
})
.expect("Failed to set user");
let (tx, rx): (mpsc::Sender<events::Event>, mpsc::Receiver<events::Event>) =
mpsc::channel();

View File

@ -11,3 +11,14 @@ pub struct User {
pub updated_at: String,
pub access_token: String,
}
impl Into<sentry::User> for User {
fn into(self) -> sentry::User {
sentry::User {
id: Some(self.id.to_string()),
username: Some(self.name),
email: Some(self.email),
..Default::default()
}
}
}