Add reporting calls for investigating auto-closing comments issues
We have gotten various user reports of draft comments getting auto-
closed without the user clicking `save`. We cannot explain this issue.
And it is not reliably reproducable. So let's add some logging such
that console logs become more meaningful for such bug reports.
Google-Bug-Id: b/228974289
Release-Notes: skip
Change-Id: I675bc55bb96702571843b373fbf40b2c72ff9406
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
index 129c37a..f3de0af 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
@@ -57,6 +57,7 @@
import {debounceTime} from 'rxjs/operators';
import {configModelToken} from '../../../models/config/config-model';
import {changeModelToken} from '../../../models/change/change-model';
+import {Interaction} from '../../../constants/reporting';
const UNSAVED_MESSAGE = 'Unable to save draft';
@@ -276,6 +277,11 @@
override disconnectedCallback() {
// Clean up emoji dropdown.
if (this.textarea) this.textarea.closeDropdown();
+ if (this.editing) {
+ this.reporting.reportInteraction(
+ Interaction.COMMENTS_AUTOCLOSE_EDITING_DISCONNECTED
+ );
+ }
super.disconnectedCallback();
}
@@ -833,6 +839,10 @@
this.unresolved = this.comment.unresolved ?? true;
if (isUnsaved(this.comment)) this.editing = true;
if (isDraftOrUnsaved(this.comment)) {
+ this.reporting.reportInteraction(
+ Interaction.COMMENTS_AUTOCLOSE_FIRST_UPDATE,
+ {editing: this.editing, unsaved: isUnsaved(this.comment)}
+ );
this.collapsed = false;
} else {
this.collapsed = !!this.initiallyCollapsed;
@@ -997,6 +1007,9 @@
await this.rawSave(messageToSave, {showToast: true});
}
}
+ this.reporting.reportInteraction(
+ Interaction.COMMENTS_AUTOCLOSE_EDITING_FALSE_SAVE
+ );
this.editing = false;
} catch (e) {
this.unableToSave = true;