Temporary metrics for related change clicks
To understand user behavior when clicking on related changes,
we report interaction - related-change-click with
sectionName: eg. Relation chain
index: eg. 1 - index in chain
countChanges: eg. 3 - number of changes in chain
currentChangeIndex: eg. 2 - index of current change in chain
Change-Id: Id230930830c7847fab90705bf37d7c83b002978b
diff --git a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.ts b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.ts
index 4ad99d5..ba0ca43 100644
--- a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.ts
+++ b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.ts
@@ -113,6 +113,8 @@
private readonly restApiService = appContext.restApiService;
+ private readonly reportingService = appContext.reportingService;
+
clear() {
this.loading = true;
this.hidden = true;
@@ -440,6 +442,25 @@
_computeNonVisibleChangesNote(n: number) {
return `(+ ${pluralize(n, 'non-visible change')})`;
}
+
+ // TODO(milutin): Temporary for data collection, remove when data collected
+ _reportClick(e: Event) {
+ const target = e.target as HTMLAnchorElement | undefined;
+ const section = target?.parentElement?.parentElement;
+ const sectionName = section?.getElementsByTagName('h4')[0]?.innerText;
+ const sectionLinks = [...(section?.getElementsByTagName('a') ?? [])];
+ const currentChange = section
+ ?.getElementsByClassName('arrowToCurrentChange')[0]
+ ?.nextElementSibling?.nextElementSibling?.getElementsByTagName('a')[0];
+
+ if (!target || !currentChange) return;
+ this.reportingService.reportInteraction('related-change-click', {
+ sectionName,
+ index: sectionLinks.indexOf(target) + 1,
+ countChanges: sectionLinks.length,
+ currentChangeIndex: sectionLinks.indexOf(currentChange) + 1,
+ });
+ }
}
declare global {
diff --git a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_html.ts b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_html.ts
index 0f42028..8cb0638 100644
--- a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_html.ts
+++ b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list_html.ts
@@ -117,6 +117,7 @@
href$="[[_computeChangeURL(related._change_number, related.project, related._revision_number)]]"
class$="[[_computeLinkClass(related)]]"
title$="[[related.commit.subject]]"
+ on-click="_reportClick"
>
[[related.commit.subject]]
</a>
@@ -149,6 +150,7 @@
href$="[[_computeChangeURL(related._number, related.project)]]"
class$="[[_computeLinkClass(related)]]"
title$="[[related.project]]: [[related.branch]]: [[related.subject]]"
+ on-click="_reportClick"
>
[[related.project]]: [[related.branch]]: [[related.subject]]
</a>
@@ -176,6 +178,7 @@
href$="[[_computeChangeURL(change._number, change.project)]]"
class$="[[_computeLinkClass(change)]]"
title$="[[change.project]]: [[change.branch]]: [[change.subject]]"
+ on-click="_reportClick"
>
[[change.project]]: [[change.branch]]: [[change.subject]]
</a>
@@ -204,6 +207,7 @@
href$="[[_computeChangeURL(change._number, change.project)]]"
class$="[[_computeLinkClass(change)]]"
title$="[[change.branch]]: [[change.subject]]"
+ on-click="_reportClick"
>
[[change.branch]]: [[change.subject]]
</a>