From cec15bcdd03647a378c29c752af96534ca47daa8 Mon Sep 17 00:00:00 2001 From: Scott Chacon Date: Thu, 14 Mar 2024 16:35:00 +0100 Subject: [PATCH 1/3] send more context with feedback (OS, browser, index size) --- gitbutler-app/src/app.rs | 9 +++++++++ gitbutler-app/src/commands.rs | 11 +++++++++++ gitbutler-app/src/git/repository.rs | 4 ++++ gitbutler-app/src/main.rs | 1 + .../src/project_repository/repository.rs | 5 +++++ gitbutler-ui/src/lib/backend/cloud.ts | 1 + .../src/lib/components/ShareIssueModal.svelte | 17 +++++++++++++++-- 7 files changed, 46 insertions(+), 2 deletions(-) diff --git a/gitbutler-app/src/app.rs b/gitbutler-app/src/app.rs index d46b6d2fd..77abbc519 100644 --- a/gitbutler-app/src/app.rs +++ b/gitbutler-app/src/app.rs @@ -145,6 +145,15 @@ impl App { .map_err(|e| Error::Other(anyhow::anyhow!(e.to_string()))) } + pub fn git_index_size(&self, project_id: &ProjectId) -> Result { + let project = self.projects.get(project_id)?; + let project_repository = project_repository::Repository::open(&project)?; + let size = project_repository + .git_index_size() + .context("failed to get index size")?; + Ok(size) + } + pub fn git_head(&self, project_id: &ProjectId) -> Result { let project = self.projects.get(project_id)?; let project_repository = project_repository::Repository::open(&project)?; diff --git a/gitbutler-app/src/commands.rs b/gitbutler-app/src/commands.rs index 04477bdad..56a92615b 100644 --- a/gitbutler-app/src/commands.rs +++ b/gitbutler-app/src/commands.rs @@ -103,6 +103,17 @@ pub async fn git_test_fetch( }) } +#[tauri::command(async)] +#[instrument(skip(handle))] +pub async fn git_index_size(handle: tauri::AppHandle, project_id: &str) -> Result { + let app = handle.state::(); + let project_id = project_id.parse().map_err(|_| Error::UserError { + code: Code::Validation, + message: "Malformed project id".to_string(), + })?; + Ok(app.git_index_size(&project_id).expect("git index size")) +} + #[tauri::command(async)] #[instrument(skip(handle))] pub async fn git_head(handle: tauri::AppHandle, project_id: &str) -> Result { diff --git a/gitbutler-app/src/git/repository.rs b/gitbutler-app/src/git/repository.rs index f567c7158..7893c12bf 100644 --- a/gitbutler-app/src/git/repository.rs +++ b/gitbutler-app/src/git/repository.rs @@ -224,6 +224,10 @@ impl Repository { self.0.index().map(Into::into).map_err(Into::into) } + pub fn index_size(&self) -> Result { + Ok(self.0.index()?.len()) + } + pub fn blob_path>(&self, path: P) -> Result { self.0 .blob_path(path.as_ref()) diff --git a/gitbutler-app/src/main.rs b/gitbutler-app/src/main.rs index 80061616f..2f65abd22 100644 --- a/gitbutler-app/src/main.rs +++ b/gitbutler-app/src/main.rs @@ -240,6 +240,7 @@ fn main() { commands::project_flush_and_push, commands::git_test_push, commands::git_test_fetch, + commands::git_index_size, zip::commands::get_logs_archive_path, zip::commands::get_project_archive_path, zip::commands::get_project_data_archive_path, diff --git a/gitbutler-app/src/project_repository/repository.rs b/gitbutler-app/src/project_repository/repository.rs index 2d63c3aa6..4b4e7b15f 100644 --- a/gitbutler-app/src/project_repository/repository.rs +++ b/gitbutler-app/src/project_repository/repository.rs @@ -125,6 +125,11 @@ impl Repository { self.project = project.clone(); } + pub fn git_index_size(&self) -> Result { + let head = self.git_repository.index_size()?; + Ok(head) + } + pub fn get_head(&self) -> Result { let head = self.git_repository.head()?; Ok(head) diff --git a/gitbutler-ui/src/lib/backend/cloud.ts b/gitbutler-ui/src/lib/backend/cloud.ts index f4d9df3a2..ff8b0b00e 100644 --- a/gitbutler-ui/src/lib/backend/cloud.ts +++ b/gitbutler-ui/src/lib/backend/cloud.ts @@ -155,6 +155,7 @@ export function getCloudApiClient( const formData = new FormData(); formData.append('message', params.message); if (params.email) formData.append('email', params.email); + if (params.context) formData.append('context', params.context); if (params.logs) formData.append('logs', params.logs); if (params.repo) formData.append('repo', params.repo); if (params.data) formData.append('data', params.data); diff --git a/gitbutler-ui/src/lib/components/ShareIssueModal.svelte b/gitbutler-ui/src/lib/components/ShareIssueModal.svelte index 6f3906f69..5af6d6fc3 100644 --- a/gitbutler-ui/src/lib/components/ShareIssueModal.svelte +++ b/gitbutler-ui/src/lib/components/ShareIssueModal.svelte @@ -7,6 +7,7 @@ import * as toasts from '$lib/utils/toasts'; import type { User, getCloudApiClient } from '$lib/backend/cloud'; import { page } from '$app/stores'; + import { invoke } from '$lib/backend/ipc'; export let user: User | undefined; export let cloud: ReturnType; @@ -15,6 +16,12 @@ modal.show(); } + function gitIndexLength() { + return invoke('git_index_size', { + projectId: projectId + }); + } + let modal: Modal; let messageInputValue = ''; @@ -41,9 +48,14 @@ : new Blob([file], { type: 'application/zip' }); } - function onSubmit() { + async function onSubmit() { const message = messageInputValue; const email = user?.email ?? emailInputValue; + let context = 'Browser: ' + navigator.userAgent + '\n'; + context += 'URL: ' + window.location.href + '\n'; + const indexLength = await gitIndexLength(); + context += 'Length of index: ' + indexLength + '\n'; + toasts.promise( Promise.all([ sendLogs ? zip.logs().then((path) => readZipFile(path, 'logs.zip')) : undefined, @@ -57,6 +69,7 @@ cloud.feedback.create(user?.access_token, { email, message, + context, logs, data, repo @@ -83,7 +96,7 @@

- If you are having trouble, please share your project and logs with the Gitbutler team. We will + If you are having trouble, please share your project and logs with the GitButler team. We will review it for you and help identify how we can help resolve the issue.

From 7fc51b775eda94cefaf85db31922d3e45512fc83 Mon Sep 17 00:00:00 2001 From: Scott Chacon Date: Thu, 14 Mar 2024 16:41:31 +0100 Subject: [PATCH 2/3] Add GitButler app version --- gitbutler-ui/src/lib/components/ShareIssueModal.svelte | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gitbutler-ui/src/lib/components/ShareIssueModal.svelte b/gitbutler-ui/src/lib/components/ShareIssueModal.svelte index 5af6d6fc3..bec0017a0 100644 --- a/gitbutler-ui/src/lib/components/ShareIssueModal.svelte +++ b/gitbutler-ui/src/lib/components/ShareIssueModal.svelte @@ -8,6 +8,7 @@ import type { User, getCloudApiClient } from '$lib/backend/cloud'; import { page } from '$app/stores'; import { invoke } from '$lib/backend/ipc'; + import { getVersion } from '@tauri-apps/api/app'; export let user: User | undefined; export let cloud: ReturnType; @@ -51,9 +52,14 @@ async function onSubmit() { const message = messageInputValue; const email = user?.email ?? emailInputValue; - let context = 'Browser: ' + navigator.userAgent + '\n'; - context += 'URL: ' + window.location.href + '\n'; + + // put together context information to send with the feedback + let context = ''; + const appVersion = await getVersion(); const indexLength = await gitIndexLength(); + context += 'GitButler Version: ' + appVersion + '\n'; + context += 'Browser: ' + navigator.userAgent + '\n'; + context += 'URL: ' + window.location.href + '\n'; context += 'Length of index: ' + indexLength + '\n'; toasts.promise( From 5afa391dfe6a3eefeda22bdf384c1448c7eb6a46 Mon Sep 17 00:00:00 2001 From: Scott Chacon Date: Thu, 14 Mar 2024 17:36:20 +0100 Subject: [PATCH 3/3] wrong lint order --- gitbutler-ui/src/lib/components/ShareIssueModal.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitbutler-ui/src/lib/components/ShareIssueModal.svelte b/gitbutler-ui/src/lib/components/ShareIssueModal.svelte index bec0017a0..5698c230a 100644 --- a/gitbutler-ui/src/lib/components/ShareIssueModal.svelte +++ b/gitbutler-ui/src/lib/components/ShareIssueModal.svelte @@ -1,14 +1,14 @@