Bug 1743328 - Add telemetry to figure out install-from-DMG prompt outcomes. r=mstange

Differential Revision: https://phabricator.services.mozilla.com/D132326
This commit is contained in:
Jonathan Watt 2021-12-03 19:45:03 +00:00
Родитель c30c452a2e
Коммит 65ad33ee19
3 изменённых файлов: 58 добавлений и 0 удалений

Просмотреть файл

@ -18,6 +18,7 @@ metrics_yamls = [
"browser/base/content/metrics.yaml",
"gfx/metrics.yaml",
"toolkit/components/processtools/metrics.yaml",
"toolkit/xre/metrics.yaml",
"browser/modules/metrics.yaml",
"browser/components/metrics.yaml",
]

Просмотреть файл

@ -8,6 +8,7 @@
#include <CoreFoundation/CoreFoundation.h>
#include <CoreServices/CoreServices.h>
#include <IOKit/IOKitLib.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mount.h>
#include <sys/param.h>
@ -16,6 +17,7 @@
#include "MacLaunchHelper.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/glean/GleanMetrics.h"
#include "mozilla/intl/Localization.h"
#include "mozilla/Telemetry.h"
#include "nsCocoaFeatures.h"
@ -25,6 +27,7 @@
#include "nsILocalFileMac.h"
#include "nsIMacDockSupport.h"
#include "nsObjCExceptions.h"
#include "prenv.h"
#include "nsString.h"
#ifdef MOZ_UPDATER
# include "nsUpdateDriver.h"
@ -253,6 +256,7 @@ static void ShowInstallFailedDialog() {
*/
static void LaunchTask(NSString* aPath, NSArray* aArguments) {
if (@available(macOS 10.13, *)) {
setenv("MOZ_INSTALLED_AND_RELAUNCHED_FROM_DMG", "1", 1);
NSTask* task = [[NSTask alloc] init];
[task setExecutableURL:[NSURL fileURLWithPath:aPath]];
if (aArguments) {
@ -327,6 +331,8 @@ static bool InstallFromDmg(NSString* aBundlePath, NSString* aDestPath) {
installSuccessful = true;
}
bool triedElevatedInstall = false;
#ifdef MOZ_UPDATER
// The installation may have been unsuccessful if the user did not have the
// rights to write to the Applications directory. Check for this situation and
@ -346,10 +352,17 @@ static bool InstallFromDmg(NSString* aBundlePath, NSString* aDestPath) {
NSArray* arguments = @[ @"-dmgInstall", aBundlePath, aDestPath ];
LaunchElevatedDmgInstall(updaterBinPath, arguments);
installSuccessful = [fileManager fileExistsAtPath:aDestPath];
triedElevatedInstall = true;
}
#endif
if (!installSuccessful) {
if (!triedElevatedInstall) {
glean::startup::run_from_dmg_install_outcome.Get("non_privileged_install_failed"_ns)
.Set(true);
} else {
glean::startup::run_from_dmg_install_outcome.Get("privileged_install_failed"_ns).Set(true);
}
return false;
}
@ -452,6 +465,10 @@ bool MaybeInstallFromDmgAndRelaunch() {
Telemetry::ScalarSet(Telemetry::ScalarID::STARTUP_IS_RUN_FROM_DMG, isFromDmg);
if (!isFromDmg) {
if (getenv("MOZ_INSTALLED_AND_RELAUNCHED_FROM_DMG")) {
unsetenv("MOZ_INSTALLED_AND_RELAUNCHED_FROM_DMG");
glean::startup::run_from_dmg_install_outcome.Get("installed_and_relaunched"_ns).Set(true);
}
return false;
}
@ -466,6 +483,8 @@ bool MaybeInstallFromDmgAndRelaunch() {
NSFileManager* fileManager = [NSFileManager defaultManager];
BOOL isDir;
if (![fileManager fileExistsAtPath:applicationsDir isDirectory:&isDir] || !isDir) {
glean::startup::run_from_dmg_install_outcome.Get("root_applications_dir_missing"_ns)
.Set(true);
return false;
}
@ -480,12 +499,17 @@ bool MaybeInstallFromDmgAndRelaunch() {
if ([fileManager fileExistsAtPath:destPath]) {
if (AskUserIfWeShouldLaunchExistingInstall()) {
LaunchInstalledApp(destPath);
glean::startup::run_from_dmg_install_outcome.Get("user_accepted_launch_existing"_ns)
.Set(true);
return true;
}
glean::startup::run_from_dmg_install_outcome.Get("user_declined_launch_existing"_ns)
.Set(true);
return false;
}
if (!AskUserIfWeShouldInstall()) {
glean::startup::run_from_dmg_install_outcome.Get("user_declined_install_prompt"_ns).Set(true);
return false;
}

33
toolkit/xre/metrics.yaml Normal file
Просмотреть файл

@ -0,0 +1,33 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# This file defines the metrics that are recorded by the Glean SDK. They are
# automatically converted to platform-specific code at build time using the
# `glean_parser` PyPI package.
---
$schema: moz://mozilla.org/schemas/glean/metrics/2-0-0
startup:
run_from_dmg_install_outcome:
type: labeled_boolean
labels:
- root_applications_dir_missing
- user_accepted_launch_existing
- user_declined_launch_existing
- user_declined_install_prompt
- non_privileged_install_failed
- privileged_install_failed
- installed_and_relaunched
description: >
The outcome after the app detected that it was running from DMG and
should offer to install and relaunch itself.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1743328
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1743328#c1
notification_emails:
- jwatt@jwatt.org
- mbalfanz@mozilla.com
expires: "100"