Skip to content

Commit 17c686f

Browse files
Merge pull request #916 from tchapgouv/voip-bug-report
Add bug report button after voip calls
2 parents 6b5a80a + cfd8909 commit 17c686f

File tree

5 files changed

+122
-11
lines changed

5 files changed

+122
-11
lines changed

modules/tchap-translations/tchap_translations.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,5 +713,13 @@
713713
"widget|error_need_kick_permission": {
714714
"en": "You need to be able to kick users to do that.",
715715
"fr": "Vous devez avoir l’autorisation de retirer des utilisateurs pour faire ceci."
716+
},
717+
"Report a problem": {
718+
"en": "Report a problem",
719+
"fr": "Signaler un problème"
720+
},
721+
"tchap_voip_bug_report_prefill": {
722+
"en": "I had a problem during a Tchap call.\nDetails: ...",
723+
"fr": "J'ai eu un problème pendant un appel Tchap.\nDétails : ..."
716724
}
717725
}

patches/bug-reporting/matrix-react-sdk+3.92.0.patch

Lines changed: 68 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
diff --git a/node_modules/matrix-react-sdk/src/components/views/dialogs/BugReportDialog.tsx b/node_modules/matrix-react-sdk/src/components/views/dialogs/BugReportDialog.tsx
2-
index 5d826f2..5163137 100644
2+
index 5d826f2..51baf28 100644
33
--- a/node_modules/matrix-react-sdk/src/components/views/dialogs/BugReportDialog.tsx
44
+++ b/node_modules/matrix-react-sdk/src/components/views/dialogs/BugReportDialog.tsx
5-
@@ -32,6 +32,7 @@ import DialogButtons from "../elements/DialogButtons";
5+
@@ -32,6 +32,8 @@ import DialogButtons from "../elements/DialogButtons";
66
import { sendSentryReport } from "../../../sentry";
77
import defaultDispatcher from "../../../dispatcher/dispatcher";
88
import { Action } from "../../../dispatcher/actions";
99
+import { MatrixClientPeg } from '../../../MatrixClientPeg'; // :TCHAP:
10+
+import TchapUtils from "../../../../../../src/tchap/util/TchapUtils"; // :TCHAP:
1011

1112
interface IProps {
1213
onFinished: (success: boolean) => void;
13-
@@ -96,12 +97,21 @@ export default class BugReportDialog extends React.Component<IProps, IState> {
14+
@@ -96,12 +98,21 @@ export default class BugReportDialog extends React.Component<IProps, IState> {
1415
};
1516

1617
private onSubmit = (): void => {
@@ -32,7 +33,7 @@ index 5d826f2..5163137 100644
3233

3334
const userText =
3435
(this.state.text.length > 0 ? this.state.text + "\n\n" : "") +
35-
@@ -111,11 +121,24 @@ export default class BugReportDialog extends React.Component<IProps, IState> {
36+
@@ -111,11 +122,34 @@ export default class BugReportDialog extends React.Component<IProps, IState> {
3637
this.setState({ busy: true, progress: null, err: null });
3738
this.sendProgressCallback(_t("bug_reporting|preparing_logs"));
3839

@@ -43,13 +44,23 @@ index 5d826f2..5163137 100644
4344
- labels: this.props.label ? [this.props.label] : [],
4445
+ // :TCHAP: customise report : add email, prefix with "tchap-web"
4546
+ const client = MatrixClientPeg.get();
47+
+ const customFields = {};
4648
+ client.getThreePids().then(result => {
47-
+ const customFields = {};
4849
+ result.threepids.forEach(threepid => {
4950
+ return customFields[threepid.medium] = threepid.address;
5051
+ });
5152
+ return customFields;
5253
+ }).then(customFields => {
54+
+ // is this a voip report ? Add it in "context" field
55+
+ if (this.props.label === "voip-feedback") {
56+
+ customFields.context = "voip";
57+
+ }
58+
+
59+
+ return TchapUtils.isCurrentlyUsingBluetooth().then(isCurrentlyUsingBluetooth => {
60+
+ customFields.audio_input = isCurrentlyUsingBluetooth ? "headset_bluetooth" : "device";
61+
+ return customFields;
62+
+ })
63+
+ }).then(customFields => {
5364
+ return sendBugReport(SdkConfig.get().bug_report_endpoint_url, {
5465
+ userText,
5566
+ sendLogs: true,
@@ -62,15 +73,15 @@ index 5d826f2..5163137 100644
6273
}).then(
6374
() => {
6475
if (!this.unmounted) {
65-
@@ -150,6 +173,7 @@ export default class BugReportDialog extends React.Component<IProps, IState> {
76+
@@ -150,6 +184,7 @@ export default class BugReportDialog extends React.Component<IProps, IState> {
6677
sendLogs: true,
6778
progressCallback: this.downloadProgressCallback,
6879
labels: this.props.label ? [this.props.label] : [],
6980
+ customApp: 'tchap-web', // :TCHAP: we don't add email here. You know your own email already.
7081
});
7182

7283
this.setState({
73-
@@ -214,6 +238,53 @@ export default class BugReportDialog extends React.Component<IProps, IState> {
84+
@@ -214,6 +249,53 @@ export default class BugReportDialog extends React.Component<IProps, IState> {
7485
);
7586
}
7687

@@ -124,7 +135,7 @@ index 5d826f2..5163137 100644
124135
return (
125136
<BaseDialog
126137
className="mx_BugReportDialog"
127-
@@ -281,5 +352,6 @@ export default class BugReportDialog extends React.Component<IProps, IState> {
138+
@@ -281,5 +363,6 @@ export default class BugReportDialog extends React.Component<IProps, IState> {
128139
/>
129140
</BaseDialog>
130141
);
@@ -144,6 +155,55 @@ index 1eb0379..90955dd 100644
144155
};
145156

146157
/**
158+
diff --git a/node_modules/matrix-react-sdk/src/components/views/messages/LegacyCallEvent.tsx b/node_modules/matrix-react-sdk/src/components/views/messages/LegacyCallEvent.tsx
159+
index 3c8241d..cdd9a83 100644
160+
--- a/node_modules/matrix-react-sdk/src/components/views/messages/LegacyCallEvent.tsx
161+
+++ b/node_modules/matrix-react-sdk/src/components/views/messages/LegacyCallEvent.tsx
162+
@@ -28,6 +28,10 @@ import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";
163+
import { formatPreciseDuration } from "../../../DateUtils";
164+
import Clock from "../audio_messages/Clock";
165+
166+
+import Modal from "matrix-react-sdk/src/Modal"; // :TCHAP:
167+
+import BugReportDialog from "matrix-react-sdk/src/components/views/dialogs/BugReportDialog"; // :TCHAP:
168+
+import "../../../../../../res/css/views/messages/TchapLegacyCallEvent.pcss"; // :TCHAP:
169+
+
170+
const MAX_NON_NARROW_WIDTH = (450 / 70) * 100;
171+
172+
interface IProps {
173+
@@ -192,6 +196,7 @@ export default class LegacyCallEvent extends React.PureComponent<IProps, IState>
174+
return (
175+
<div className="mx_LegacyCallEvent_content">
176+
{text}
177+
+ {this.renderBugReportButton()}
178+
{this.props.timestamp}
179+
</div>
180+
);
181+
@@ -264,6 +269,25 @@ export default class LegacyCallEvent extends React.PureComponent<IProps, IState>
182+
);
183+
}
184+
185+
+ private onReportBugClick = (): void => {
186+
+ Modal.createDialog(BugReportDialog, {
187+
+ initialText: _t("tchap_voip_bug_report_prefill"),
188+
+ label: "voip-feedback",
189+
+ });
190+
+ };
191+
+
192+
+ private renderBugReportButton(): JSX.Element {
193+
+ return (
194+
+ <AccessibleButton
195+
+ className="mx_LegacyCallEvent_content_button mx_LegacyCallEvent_content_button_reportBug"
196+
+ onClick={this.onReportBugClick}
197+
+ kind="primary"
198+
+ >
199+
+ <span> {_t("Report a problem")} </span>
200+
+ </AccessibleButton>
201+
+ );
202+
+ }
203+
+
204+
public render(): React.ReactNode {
205+
const event = this.props.mxEvent;
206+
const sender = event.sender ? event.sender.name : event.getSender();
147207
diff --git a/node_modules/matrix-react-sdk/src/rageshake/submit-rageshake.ts b/node_modules/matrix-react-sdk/src/rageshake/submit-rageshake.ts
148208
index d15f3d9..7c7f6d8 100644
149209
--- a/node_modules/matrix-react-sdk/src/rageshake/submit-rageshake.ts

patches/patches.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717
},
1818
"bug-reporting": {
1919
"package": "matrix-react-sdk",
20-
"github-issue":"https://github.com/tchapgouv/tchap-web-v4/issues/527, https://github.com/tchapgouv/tchap-web-v4/issues/526",
21-
"comments" : "add email in rageshake",
20+
"github-issue":"https://github.com/tchapgouv/tchap-web-v4/issues/527, https://github.com/tchapgouv/tchap-web-v4/issues/526, https://github.com/tchapgouv/tchap-product/issues/267",
21+
"comments" : "add email in rageshake + voip",
2222
"files": [
2323
"src/components/views/dialogs/BugReportDialog.tsx",
2424
"src/rageshake/submit-rageshake.ts",
25-
"src/components/views/elements/AccessibleButton.tsx"
25+
"src/components/views/elements/AccessibleButton.tsx",
26+
"src/components/views/messages/LegacyCallEvent.tsx"
2627
]
2728
},
2829
"content-scanner": {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.mx_LegacyCallEvent_wrapper {
2+
.mx_LegacyCallEvent {
3+
&.mx_LegacyCallEvent_voice {
4+
.mx_LegacyCallEvent_content_button_reportBug span::before {
5+
mask-image: url("~matrix-react-sdk/res/img/element-icons/warning-badge.svg");
6+
}
7+
}
8+
}
9+
}

src/tchap/util/TchapUtils.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,4 +238,37 @@ export default class TchapUtils {
238238
}
239239
return false;
240240
}
241+
242+
/**
243+
* Whether the user is currently using a bluetooth audio input (bluetooth headset for example).
244+
* In Chrome we can get the information sometimes, and in Firefox and Edge we don't know.
245+
* @returns true if we are sure user is currently using a bluetooth audio input. False if no blutooth, or we don't know.
246+
*/
247+
static async isCurrentlyUsingBluetooth(): Promise<boolean> {
248+
if (!navigator.mediaDevices?.enumerateDevices) {
249+
console.log("enumerateDevices() not supported. Cannot know if there is a bluetooth device.");
250+
return false;
251+
} else {
252+
// List cameras and microphones.
253+
return navigator.mediaDevices
254+
.enumerateDevices()
255+
.then((devices) => {
256+
let hasBluetooth = false;
257+
devices.forEach((device) => {
258+
console.log(`${device.kind}: ${device.label} id = ${device.deviceId}`);
259+
if (device.kind === "audioinput") {
260+
if (device.label.toLowerCase().includes("bluetooth")) {
261+
hasBluetooth = true;
262+
}
263+
}
264+
});
265+
return hasBluetooth;
266+
})
267+
.catch((err) => {
268+
console.error(`${err.name}: ${err.message}`);
269+
return false;
270+
});
271+
}
272+
}
273+
241274
}

0 commit comments

Comments
 (0)