Add metrics when users switch patchsets using selector

Change-Id: Iba597473aacb1d755ad37022d07f92931ecb9973
This commit is contained in:
Dhruv Srivastava
2020-06-10 16:26:06 +02:00
parent cdfd5e3237
commit 0a4a19398a

View File

@@ -25,6 +25,7 @@ import {PolymerElement} from '@polymer/polymer/polymer-element.js';
import {htmlTemplate} from './gr-patch-range-select_html.js';
import {PatchSetBehavior} from '../../../behaviors/gr-patch-set-behavior/gr-patch-set-behavior.js';
import {GrCountStringFormatter} from '../../shared/gr-count-string-formatter/gr-count-string-formatter.js';
import {appContext} from '../../../services/app-context.js';
// Maximum length for patch set descriptions.
const PATCH_DESC_MAX_LENGTH = 500;
@@ -78,6 +79,11 @@ class GrPatchRangeSelect extends mixinBehaviors( [
];
}
constructor() {
super();
this.reporting = appContext.reportingService;
}
_getShaForPatch(patch) {
return patch.sha.substring(0, 10);
}
@@ -285,8 +291,14 @@ class GrPatchRangeSelect extends mixinBehaviors( [
const target = dom(e).localTarget;
if (target === this.$.patchNumDropdown) {
if (detail.patchNum === e.detail.value) return;
this.reporting.reportInteraction('right-patchset-changed',
{previous: detail.patchNum, current: e.detail.value});
detail.patchNum = e.detail.value;
} else {
if (detail.basePatchNum === e.detail.value) return;
this.reporting.reportInteraction('left-patchset-changed',
{previous: detail.basePatchNum, current: e.detail.value});
detail.basePatchNum = e.detail.value;
}