Skip to content

Commit

Permalink
VPN-6429: remove metrics and update expirations (#9671)
Browse files Browse the repository at this point in the history
* VPN-6429 remove metrics and update expirations

* fix mocks for unit tests
  • Loading branch information
mcleinman committed Jun 20, 2024
1 parent fa8fb6e commit 5535adc
Show file tree
Hide file tree
Showing 36 changed files with 285 additions and 1,380 deletions.
7 changes: 1 addition & 6 deletions nebula/ui/components/MZComposerView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,7 @@ ColumnLayout {
text: loader.composerBlock.text
colorScheme: loader.composerBlock.style === MZComposerBlockButton.Primary ? MZTheme.theme.blueButton : MZTheme.theme.redButton

onClicked: {
Glean.sample.addonCtaClicked.record({
addon_id: addon.id
});
loader.composerBlock.click();
}
onClicked: loader.composerBlock.click()
}
}

Expand Down
6 changes: 0 additions & 6 deletions src/addons/addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,12 +477,6 @@ void Addon::updateAddonStatus(Status newStatus) {
QString newStatusSetting = statusMetaEnum.valueToKey(newStatus);

m_settingGroup->set(ADDON_SETTINGS_STATUS_KEY, newStatusSetting);

mozilla::glean::sample::addon_state_changed.record(
mozilla::glean::sample::AddonStateChangedExtra{
._addonId = m_id,
._state = newStatusSetting,
});
}

void Addon::retranslate() {
Expand Down
14 changes: 0 additions & 14 deletions src/authenticationinapp/authenticationinappsession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,11 +918,6 @@ void AuthenticationInAppSession::processErrorObject(const QJsonObject& obj) {
break;
}

mozilla::glean::sample::authentication_inapp_error.record(
mozilla::glean::sample::AuthenticationInappErrorExtra{
._errno = "107",
._validation = QJsonDocument(objValidation).toJson()});

logger.error() << "Unsupported validation parameter";
break;
}
Expand All @@ -948,10 +943,6 @@ void AuthenticationInAppSession::processErrorObject(const QJsonObject& obj) {
break;
}

mozilla::glean::sample::authentication_inapp_error.record(
mozilla::glean::sample::AuthenticationInappErrorExtra{
._errno = "125", ._verificationmethod = verificationMethod});

logger.error() << "Unsupported verification method:"
<< verificationMethod;
break;
Expand Down Expand Up @@ -1117,11 +1108,6 @@ void AuthenticationInAppSession::processErrorObject(const QJsonObject& obj) {
case 998: // An internal validation check failed.
[[fallthrough]];
default:
mozilla::glean::sample::authentication_inapp_error.record(
mozilla::glean::sample::AuthenticationInappErrorExtra{
._errno = QString::number(errorCode),
._error = obj["error"].toString(),
._message = obj["message"].toString()});
logger.error() << "Unsupported error code:" << errorCode;
break;
}
Expand Down
8 changes: 0 additions & 8 deletions src/commands/commandui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,6 @@ int CommandUI::run(QStringList& tokens) {
vpn.setStartMinimized(minimizedOption.m_set ||
(qgetenv("MVPN_MINIMIZED") == "1"));

if (updateOption.m_set) {
mozilla::glean::sample::update_step.record(
mozilla::glean::sample::UpdateStepExtra{
._state =
QVariant::fromValue(Updater::ApplicationRestartedAfterUpdate)
.toString()});
}

#ifndef Q_OS_WIN
// Signal handling for a proper shutdown.
SignalHandler sh;
Expand Down
2 changes: 0 additions & 2 deletions src/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ TIMEREXPR(captivePortalRequest, 10s, 4s, 0ms)
TIMEREXPR(statusIconAnimation, 200ms, 200ms, 0ms)
// How often glean pings are sent
TIMEREXPR(gleanTimeout, 20min, 20min, 0ms)
// How often to check in on the controller state
TIMEREXPR(controllerRecordPeriodicState, 180min, 1min, 0ms)
#undef TIMEREXPR
} // namespace Timers

Expand Down
2 changes: 0 additions & 2 deletions src/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,6 @@ void Controller::handshakeTimeout() {
vpn->serverLatency()->setCooldown(
hop.m_serverPublicKey, Constants::SERVER_UNRESPONSIVE_COOLDOWN_SEC);

emit handshakeFailed(hop.m_serverPublicKey);

if (m_nextStep == Quit || m_nextStep == Disconnect || m_nextStep == Update) {
deactivate();
return;
Expand Down
1 change: 0 additions & 1 deletion src/controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ class Controller : public QObject, public LogSerializer {
void stateChanged();
void timeChanged();
void enableDisconnectInConfirmingChanged();
void handshakeFailed(const QString& serverHostname);
void connectionRetryChanged();
void recordConnectionStartTelemetry();
void recordConnectionEndTelemetry();
Expand Down
5 changes: 0 additions & 5 deletions src/localizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,6 @@ void Localizer::settingsChanged() {
settingsHolder->setPreviousLanguageCode(m_code);
}

if (!code.isEmpty()) {
mozilla::glean::sample::non_default_language_used.record(
mozilla::glean::sample::NonDefaultLanguageUsedExtra{._languageCode =
code});
}
mozilla::glean::settings::using_system_language.set(code.isEmpty());

m_code = code;
Expand Down
8 changes: 0 additions & 8 deletions src/models/subscriptiondata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,6 @@ bool SubscriptionData::fromJsonInternal(const QByteArray& json) {
planIntervalMonths = 1;
} else {
logger.error() << "Unexpected interval type:" << planInterval;

mozilla::glean::sample::unhandled_sub_plan_interval.record(
mozilla::glean::sample::UnhandledSubPlanIntervalExtra{
._interval = planInterval});
return false;
}

Expand All @@ -167,10 +163,6 @@ bool SubscriptionData::fromJsonInternal(const QByteArray& json) {
default:
logger.error() << "Unexpected billing interval:"
<< planIntervalMonthsTotal;

mozilla::glean::sample::unhandled_sub_plan_interval.record(
mozilla::glean::sample::UnhandledSubPlanIntervalExtra{
._interval = planInterval, ._intervalCount = planIntervalCount});
return false;
}

Expand Down
5 changes: 0 additions & 5 deletions src/mozillavpn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1232,11 +1232,6 @@ void MozillaVPN::cancelReauthentication() {
cancelAuthentication();
}

void MozillaVPN::updateViewShown() {
logger.debug() << "Update view shown";
Updater::updateViewShown();
}

void MozillaVPN::scheduleRefreshDataTasks() {
QList<Task*> refreshTasks{
new TaskAccount(ErrorHandler::PropagateError),
Expand Down
1 change: 0 additions & 1 deletion src/mozillavpn.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ class MozillaVPN final : public App {
Q_INVOKABLE void hardResetAndQuit();
Q_INVOKABLE void requestDeleteAccount();
Q_INVOKABLE void cancelReauthentication();
Q_INVOKABLE void updateViewShown();
Q_INVOKABLE static void statusBarCheck();

Q_INVOKABLE void gleanSetDebugViewTag(QString tag);
Expand Down
5 changes: 0 additions & 5 deletions src/profileflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ void ProfileFlow::setState(State state) {

m_state = state;
emit stateChanged(m_state);

mozilla::glean::sample::profile_flow_state_changed.record(
mozilla::glean::sample::ProfileFlowStateChangedExtra{
._state = QVariant::fromValue(state).toString(),
});
}

// Only used for testing and debugging the re-authentication flow
Expand Down
94 changes: 0 additions & 94 deletions src/telemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ Telemetry::Telemetry() {

connect(&m_vpnSessionPingTimer, &QTimer::timeout, this,
&Telemetry::vpnSessionPingTimeout);

#if defined(MZ_WINDOWS) || defined(MZ_LINUX) || defined(MZ_MACOS)
connect(&m_gleanControllerUpTimer, &QTimer::timeout, this,
&Telemetry::periodicStateRecorder);
m_gleanControllerUpTimer.start(
Constants::Timers::controllerRecordPeriodicState());
m_gleanControllerUpTimer.setSingleShot(false);
#endif
}

Telemetry::~Telemetry() { MZ_COUNT_DTOR(Telemetry); }
Expand All @@ -68,54 +60,16 @@ void Telemetry::initialize() {
connect(vpn, &MozillaVPN::stateChanged, this, []() {
int state = MozillaVPN::instance()->state();

if (state > App::StateCustom) {
mozilla::glean::sample::app_step.record(
mozilla::glean::sample::AppStepExtra{
._state = QVariant::fromValue(
static_cast<MozillaVPN::CustomState>(state))
.toString()});
} else {
mozilla::glean::sample::app_step.record(
mozilla::glean::sample::AppStepExtra{
._state = QVariant::fromValue(static_cast<App::State>(state))
.toString()});
}

if (state == MozillaVPN::StateDeviceLimit) {
mozilla::glean::sample::max_device_reached.record();
}

if (state == App::StateOnboarding) {
if (!SettingsHolder::instance()->onboardingStarted()) {
mozilla::glean::outcome::onboarding_started.record();
}
}
});

connect(vpn, &MozillaVPN::authenticationStarted, this,
[]() { mozilla::glean::sample::authentication_started.record(); });

connect(vpn, &MozillaVPN::authenticationAborted, this,
[]() { mozilla::glean::sample::authentication_aborted.record(); });

connect(vpn, &MozillaVPN::authenticationCompleted, this,
[]() { mozilla::glean::sample::authentication_completed.record(); });

Controller* controller = vpn->controller();
Q_ASSERT(controller);

connect(
controller, &Controller::handshakeFailed, this,
[](const QString& publicKey) {
logger.info() << "Send a handshake failure event";
mozilla::glean::sample::connectivity_handshake_timeout.record(
mozilla::glean::sample::ConnectivityHandshakeTimeoutExtra{
._server = publicKey,
._transport = QVariant::fromValue(MozillaVPN::instance()
->networkWatcher()
->getReachability())});
});

connect(controller, &Controller::stateChanged, this, [this]() {
MozillaVPN* vpn = MozillaVPN::instance();
Q_ASSERT(vpn);
Expand All @@ -128,24 +82,6 @@ void Telemetry::initialize() {
} else {
m_connectionStabilityTimer.start(CONNECTION_STABILITY);
}

mozilla::glean::sample::controller_step.record(
mozilla::glean::sample::ControllerStepExtra{
._state = QVariant::fromValue(state).toString()});
// Specific events for on and off state to aid with analysis
if (state == Controller::StateOn) {
mozilla::glean::sample::controller_state_on.record();
}
if (state == Controller::StateOff) {
mozilla::glean::sample::controller_state_off.record();
}
});

connect(controller, &Controller::readyToServerUnavailable, this, []() {
MozillaVPN* vpn = MozillaVPN::instance();
Q_ASSERT(vpn);

mozilla::glean::sample::server_unavailable_error.record();
});

connect(
Expand Down Expand Up @@ -205,18 +141,6 @@ void Telemetry::connectionStabilityEvent() {
Controller* controller = vpn->controller();
Q_ASSERT(controller);
Q_ASSERT(controller->state() == Controller::StateOn);

// We use Controller->currentServer because the telemetry event should record
// the location in use by the Controller and not MozillaVPN::serverData, which
// could have changed in the meantime.
mozilla::glean::sample::connectivity_stable.record(
mozilla::glean::sample::ConnectivityStableExtra{
._latency = QString::number(vpn->connectionHealth()->latency()),
._loss = QString::number(vpn->connectionHealth()->loss()),
._server = vpn->controller()->currentServer().exitServerPublicKey(),
._stddev = QString::number(vpn->connectionHealth()->stddev()),
._transport =
QVariant::fromValue(vpn->networkWatcher()->getReachability())});
}

void Telemetry::vpnSessionPingTimeout() {
Expand All @@ -238,21 +162,3 @@ void Telemetry::stopTimeToFirstScreenTimer() {
mozilla::glean::performance::time_to_main_screen.stopAndAccumulate(
m_timeToFirstScreenTimerId);
}

#if defined(MZ_WINDOWS) || defined(MZ_LINUX) || defined(MZ_MACOS)
void Telemetry::periodicStateRecorder() {
// On mobile this is handled seperately in a background process
MozillaVPN* vpn = MozillaVPN::instance();
Controller* controller = vpn->controller();
Q_ASSERT(controller);

Controller::State controllerState = controller->state();

if (controllerState == Controller::StateOn) {
mozilla::glean::sample::controller_state_on.record();
}
if (controllerState == Controller::StateOff) {
mozilla::glean::sample::controller_state_off.record();
}
}
#endif
6 changes: 0 additions & 6 deletions src/telemetry.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,10 @@ class Telemetry final : public QObject {
private:
void connectionStabilityEvent();
void vpnSessionPingTimeout();
#if defined(MZ_WINDOWS) || defined(MZ_LINUX) || defined(MZ_MACOS)
void periodicStateRecorder();
#endif

private:
QTimer m_connectionStabilityTimer;
QTimer m_vpnSessionPingTimer;
#if defined(MZ_WINDOWS) || defined(MZ_LINUX) || defined(MZ_MACOS)
QTimer m_gleanControllerUpTimer;
#endif

// The Glean timer id for the performance.time_to_main_screen metric.
qint64 m_timeToFirstScreenTimerId = 0;
Expand Down
Loading

0 comments on commit 5535adc

Please sign in to comment.