Add Interaction.CHANGE_ID_CHANGED reporting event Unfortunately the NAVIGATION event is fired too early and does not include the `changeId`, but it is also very tricky to move it, so instead fire another event that can act as the start of a changeId based user journey. Release-Notes: skip Change-Id: I2635d66b3ddd0bd1f7f5e7f9147b2c6625484f33
diff --git a/polygerrit-ui/app/constants/reporting.ts b/polygerrit-ui/app/constants/reporting.ts index 109ec9b..dded0c6 100644 --- a/polygerrit-ui/app/constants/reporting.ts +++ b/polygerrit-ui/app/constants/reporting.ts
@@ -152,4 +152,7 @@ FILE_LIST_DIFF_EXPANDED = 'file-list-diff-expanded', FILE_LIST_ALL_DIFFS_COLLAPSED = 'file-list-all-diffs-collapsed', FILE_LIST_ALL_DIFFS_EXPANDED = 'file-list-all-diffs-expanded', + // The very first reporting event with `ChangeId` set when visiting a change + // related page. Can be used as a starting point for user journeys. + CHANGE_ID_CHANGED = 'change-id-changed', }
diff --git a/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts b/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts index 84b9481..08c9e36 100644 --- a/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts +++ b/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts
@@ -612,8 +612,9 @@ this.time(Timing.DIFF_VIEW_CONTENT_DISPLAYED); this.time(Timing.DIFF_VIEW_DISPLAYED); this.time(Timing.FILE_LIST_DISPLAYED); - this.reportRepoName = undefined; - this.reportChangeId = undefined; + + this.setRepoName(undefined); + this.setChangeId(undefined); // reset slow rpc list since here start page loads which report these rpcs this.slowRpcList = []; this.hiddenDurationTimer.reset(); @@ -998,12 +999,17 @@ ); } - setRepoName(repoName: string) { + setRepoName(repoName?: string) { this.reportRepoName = repoName; } - setChangeId(changeId: NumericChangeId) { + setChangeId(changeId?: NumericChangeId) { + const originalChangeId = this.reportChangeId; this.reportChangeId = changeId; + + if (!!changeId && changeId !== originalChangeId) { + this.reportInteraction(Interaction.CHANGE_ID_CHANGED, {changeId}); + } } }