Skip to content

Commit 1cdf126

Browse files
authored
Merge pull request #3150 from gitbutlerapp/More-feedback-context
send more context with feedback (OS, browser, index size)
2 parents ef9239b + 5afa391 commit 1cdf126

File tree

7 files changed

+52
-2
lines changed

7 files changed

+52
-2
lines changed

gitbutler-app/src/app.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,15 @@ impl App {
145145
.map_err(|e| Error::Other(anyhow::anyhow!(e.to_string())))
146146
}
147147

148+
pub fn git_index_size(&self, project_id: &ProjectId) -> Result<usize, Error> {
149+
let project = self.projects.get(project_id)?;
150+
let project_repository = project_repository::Repository::open(&project)?;
151+
let size = project_repository
152+
.git_index_size()
153+
.context("failed to get index size")?;
154+
Ok(size)
155+
}
156+
148157
pub fn git_head(&self, project_id: &ProjectId) -> Result<String, Error> {
149158
let project = self.projects.get(project_id)?;
150159
let project_repository = project_repository::Repository::open(&project)?;

gitbutler-app/src/commands.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,17 @@ pub async fn git_test_fetch(
103103
})
104104
}
105105

106+
#[tauri::command(async)]
107+
#[instrument(skip(handle))]
108+
pub async fn git_index_size(handle: tauri::AppHandle, project_id: &str) -> Result<usize, Error> {
109+
let app = handle.state::<app::App>();
110+
let project_id = project_id.parse().map_err(|_| Error::UserError {
111+
code: Code::Validation,
112+
message: "Malformed project id".to_string(),
113+
})?;
114+
Ok(app.git_index_size(&project_id).expect("git index size"))
115+
}
116+
106117
#[tauri::command(async)]
107118
#[instrument(skip(handle))]
108119
pub async fn git_head(handle: tauri::AppHandle, project_id: &str) -> Result<String, Error> {

gitbutler-app/src/git/repository.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,10 @@ impl Repository {
224224
self.0.index().map(Into::into).map_err(Into::into)
225225
}
226226

227+
pub fn index_size(&self) -> Result<usize> {
228+
Ok(self.0.index()?.len())
229+
}
230+
227231
pub fn blob_path<P: AsRef<Path>>(&self, path: P) -> Result<Oid> {
228232
self.0
229233
.blob_path(path.as_ref())

gitbutler-app/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ fn main() {
240240
commands::project_flush_and_push,
241241
commands::git_test_push,
242242
commands::git_test_fetch,
243+
commands::git_index_size,
243244
zip::commands::get_logs_archive_path,
244245
zip::commands::get_project_archive_path,
245246
zip::commands::get_project_data_archive_path,

gitbutler-app/src/project_repository/repository.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ impl Repository {
125125
self.project = project.clone();
126126
}
127127

128+
pub fn git_index_size(&self) -> Result<usize, git::Error> {
129+
let head = self.git_repository.index_size()?;
130+
Ok(head)
131+
}
132+
128133
pub fn get_head(&self) -> Result<git::Reference, git::Error> {
129134
let head = self.git_repository.head()?;
130135
Ok(head)

gitbutler-ui/src/lib/backend/cloud.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ export function getCloudApiClient(
155155
const formData = new FormData();
156156
formData.append('message', params.message);
157157
if (params.email) formData.append('email', params.email);
158+
if (params.context) formData.append('context', params.context);
158159
if (params.logs) formData.append('logs', params.logs);
159160
if (params.repo) formData.append('repo', params.repo);
160161
if (params.data) formData.append('data', params.data);

gitbutler-ui/src/lib/components/ShareIssueModal.svelte

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<script lang="ts">
22
import TextArea from './TextArea.svelte';
3+
import { invoke } from '$lib/backend/ipc';
34
import * as zip from '$lib/backend/zip';
45
import Button from '$lib/components/Button.svelte';
56
import Checkbox from '$lib/components/Checkbox.svelte';
67
import Modal from '$lib/components/Modal.svelte';
78
import * as toasts from '$lib/utils/toasts';
9+
import { getVersion } from '@tauri-apps/api/app';
810
import type { User, getCloudApiClient } from '$lib/backend/cloud';
911
import { page } from '$app/stores';
1012
@@ -15,6 +17,12 @@
1517
modal.show();
1618
}
1719
20+
function gitIndexLength() {
21+
return invoke<void>('git_index_size', {
22+
projectId: projectId
23+
});
24+
}
25+
1826
let modal: Modal;
1927
2028
let messageInputValue = '';
@@ -41,9 +49,19 @@
4149
: new Blob([file], { type: 'application/zip' });
4250
}
4351
44-
function onSubmit() {
52+
async function onSubmit() {
4553
const message = messageInputValue;
4654
const email = user?.email ?? emailInputValue;
55+
56+
// put together context information to send with the feedback
57+
let context = '';
58+
const appVersion = await getVersion();
59+
const indexLength = await gitIndexLength();
60+
context += 'GitButler Version: ' + appVersion + '\n';
61+
context += 'Browser: ' + navigator.userAgent + '\n';
62+
context += 'URL: ' + window.location.href + '\n';
63+
context += 'Length of index: ' + indexLength + '\n';
64+
4765
toasts.promise(
4866
Promise.all([
4967
sendLogs ? zip.logs().then((path) => readZipFile(path, 'logs.zip')) : undefined,
@@ -57,6 +75,7 @@
5775
cloud.feedback.create(user?.access_token, {
5876
email,
5977
message,
78+
context,
6079
logs,
6180
data,
6281
repo
@@ -83,7 +102,7 @@
83102
<Modal bind:this={modal} on:close={onClose} title="Share debug data with GitButler team for review">
84103
<div class="flex flex-col gap-4">
85104
<p class="text-color-3">
86-
If you are having trouble, please share your project and logs with the Gitbutler team. We will
105+
If you are having trouble, please share your project and logs with the GitButler team. We will
87106
review it for you and help identify how we can help resolve the issue.
88107
</p>
89108

0 commit comments

Comments
 (0)