Commit ef5b0bd2 authored by Austin Tankiang's avatar Austin Tankiang Committed by Commit Bot

Add metrics to track Drive pinning success

Bug: 1067346
Change-Id: Ie7c5503754d1e2a1808e11230b9f6c6916c97269
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2426063
Commit-Queue: Austin Tankiang <austinct@chromium.org>
Reviewed-by: default avatarSergei Datsenko <dats@chromium.org>
Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811664}
parent 2d2b7130
...@@ -129,6 +129,20 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. ...@@ -129,6 +129,20 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary> </summary>
</histogram> </histogram>
<histogram name="FileBrowser.DriveHostedFilePinSuccess" enum="BooleanSuccess"
expires_after="M92">
<owner>austinct@chromium.org</owner>
<owner>dats@chromium.org</owner>
<summary>Tracks success rate of pinning hosted files in Drive.</summary>
</histogram>
<histogram name="FileBrowser.DrivePinSuccess" enum="BooleanSuccess"
expires_after="M92">
<owner>austinct@chromium.org</owner>
<owner>dats@chromium.org</owner>
<summary>Tracks success rate of pinning files in Drive.</summary>
</histogram>
<histogram name="FileBrowser.FileSystemProviderMounted" <histogram name="FileBrowser.FileSystemProviderMounted"
enum="FileSystemProviderMountType" expires_after="M89"> enum="FileSystemProviderMountType" expires_after="M89">
<owner>slangley@chromium.org</owner> <owner>slangley@chromium.org</owner>
......
...@@ -254,6 +254,11 @@ class DriveToggleOfflineAction { ...@@ -254,6 +254,11 @@ class DriveToggleOfflineAction {
// Check the result of pinning. // Check the result of pinning.
entryPinned: () => { entryPinned: () => {
error = !!chrome.runtime.lastError; error = !!chrome.runtime.lastError;
metrics.recordBoolean('DrivePinSuccess', !error);
if (this.metadataModel_.getCache([currentEntry], ['hosted'])[0]
.hosted) {
metrics.recordBoolean('DriveHostedFilePinSuccess', !error);
}
if (error && this.value_) { if (error && this.value_) {
this.metadataModel_.get([currentEntry], ['size']).then(results => { this.metadataModel_.get([currentEntry], ['size']).then(results => {
steps.showError(results[0].size); steps.showError(results[0].size);
......
...@@ -109,6 +109,17 @@ function setUp() { ...@@ -109,6 +109,17 @@ function setUp() {
installMockChrome(mockChrome); installMockChrome(mockChrome);
new MockCommandLinePrivate(); new MockCommandLinePrivate();
// Mock metrics.
window.metrics = {
calls: {
DrivePinSuccess: 0,
DriveHostedFilePinSuccess: 0,
},
recordBoolean: function(name) {
window.metrics.calls[name]++;
},
};
// Setup Drive file system. // Setup Drive file system.
volumeManager = new MockVolumeManager(); volumeManager = new MockVolumeManager();
let type = VolumeManagerCommon.VolumeType.DRIVE; let type = VolumeManagerCommon.VolumeType.DRIVE;
...@@ -265,6 +276,9 @@ function testDriveFileEntry(callback) { ...@@ -265,6 +276,9 @@ function testDriveFileEntry(callback) {
assertTrue(metadataModel.properties.pinned); assertTrue(metadataModel.properties.pinned);
assertEquals(1, invalidated); assertEquals(1, invalidated);
assertEquals(1, window.metrics.calls['DrivePinSuccess']);
assertEquals(0, window.metrics.calls['DriveHostedFilePinSuccess']);
// The model is invalidated, as list of actions have changed. // The model is invalidated, as list of actions have changed.
// Recreated the model and check that the actions are updated. // Recreated the model and check that the actions are updated.
model = new ActionsModel( model = new ActionsModel(
...@@ -382,6 +396,9 @@ function testDriveHostedFileEntry(callback) { ...@@ -382,6 +396,9 @@ function testDriveHostedFileEntry(callback) {
assertTrue(!!metadataModel.getCache([testDocument])[0].pinned); assertTrue(!!metadataModel.getCache([testDocument])[0].pinned);
assertTrue(!!metadataModel.getCache([testFile])[0].pinned); assertTrue(!!metadataModel.getCache([testFile])[0].pinned);
assertEquals(2, window.metrics.calls['DrivePinSuccess']);
assertEquals(1, window.metrics.calls['DriveHostedFilePinSuccess']);
model = new ActionsModel( model = new ActionsModel(
volumeManager, metadataModel, shortcutsModel, driveSyncHandler, volumeManager, metadataModel, shortcutsModel, driveSyncHandler,
ui, [testDocument, testFile]); ui, [testDocument, testFile]);
...@@ -489,6 +506,9 @@ function testDriveHostedFileEntryWithoutExtension(callback) { ...@@ -489,6 +506,9 @@ function testDriveHostedFileEntryWithoutExtension(callback) {
assertFalse(!!metadataModel.getCache([testDocument])[0].pinned); assertFalse(!!metadataModel.getCache([testDocument])[0].pinned);
assertTrue(!!metadataModel.getCache([testFile])[0].pinned); assertTrue(!!metadataModel.getCache([testFile])[0].pinned);
assertEquals(1, window.metrics.calls['DrivePinSuccess']);
assertEquals(0, window.metrics.calls['DriveHostedFilePinSuccess']);
model = new ActionsModel( model = new ActionsModel(
volumeManager, metadataModel, shortcutsModel, driveSyncHandler, volumeManager, metadataModel, shortcutsModel, driveSyncHandler,
ui, [testDocument, testFile]); ui, [testDocument, testFile]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment