Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Set sentry user id

Ilya04fb56c21852
diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rs
index f826c53e1..189938185 100644
--- a/apps/desktop/src-tauri/src/lib.rs
+++ b/apps/desktop/src-tauri/src/lib.rs
@@ -1858,6 +1858,7 @@ pub async fn run() {
send_feedback_request,
windows::position_traffic_lights,
reupload_rendered_video,
+ set_sentry_user,
])
.events(tauri_specta::collect_events![
RecordingOptionsChanged,
@@ -2370,3 +2371,16 @@ async fn reupload_rendered_video(
}
}
}
+
+#[tauri::command]
+#[specta::specta]
+fn set_sentry_user(app: AppHandle, user_id: Option<String>) {
+ let _ = app.run_on_main_thread(|| {
+ sentry::configure_scope(|scope| {
+ scope.set_user(Some(sentry::User {
+ id: user_id,
+ ..Default::default()
+ }));
+ });
+ });
+}
diff --git a/apps/desktop/src/store.ts b/apps/desktop/src/store.ts
index 02b673f75..b9b6a1375 100644
--- a/apps/desktop/src/store.ts
+++ b/apps/desktop/src/store.ts
@@ -1,10 +1,11 @@
import { Store } from "@tauri-apps/plugin-store";
-import type {
- AuthStore,
- ProjectConfiguration,
- HotkeysStore,
- GeneralSettingsStore,
+import {
+ type AuthStore,
+ type ProjectConfiguration,
+ type HotkeysStore,
+ type GeneralSettingsStore,
+ commands,
} from "~/utils/tauri";
let _store: Promise<Store> | undefined;
@@ -41,6 +42,7 @@ export const authStore = {
const s = await store();
await s.set("auth", value);
await s.save();
+ commands.setSentryUser(value?.user_id ?? null);
},
listen: (fn: (data?: AuthStore | undefined) => void) =>
store().then((s) => s.onKeyChange<AuthStore>("presets", fn)),
diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.ts
index f4d6004b8..8cb1cfc4e 100644
--- a/apps/desktop/src/utils/tauri.ts
+++ b/apps/desktop/src/utils/tauri.ts
@@ -163,6 +163,9 @@ async positionTrafficLights(controlsInset: [number, number] | null) : Promise<vo
},
async reuploadRenderedVideo(videoId: string, project: ProjectConfiguration) : Promise<UploadResult> {
return await TAURI_INVOKE("reupload_rendered_video", { videoId, project });
+},
+async setSentryUser(userId: string | null) : Promise<void> {
+ await TAURI_INVOKE("set_sentry_user", { userId });
}
}