Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VPN-5900 (part 2): Don't send Android daemon metrics when switching server #8793

Merged
merged 2 commits into from
Dec 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class VPNService : android.net.VpnService() {
override fun onTick(millisUntilFinished: Long) {}
override fun onFinish() {
Log.i(tag, "Sending daemon_timer ping")
if (isSuperDooperMetricsActive) {
if (shouldRecordMetrics) {
Pings.daemonsession.submit(
Pings.daemonsessionReasonCodes.daemonTimer,
)
Expand All @@ -60,6 +60,17 @@ class VPNService : android.net.VpnService() {
return this.mConfig?.optBoolean("isSuperDooperFeatureActive", false) ?: false
}

private val isChangingServers: Boolean
get() {
// could be user choosing new server or silent switching
return (this.mConfig?.optInt("reason") ?: 0) == 1
}

private val shouldRecordMetrics: Boolean
get() {
return isSuperDooperMetricsActive && !isChangingServers
}

private val isUsingShortTimerSessionPing: Boolean
get() {
return this.mConfig?.optBoolean("isUsingShortTimerSessionPing", false) ?: false
Expand Down Expand Up @@ -338,7 +349,7 @@ class VPNService : android.net.VpnService() {
Log.i(tag, "Setting Glean debug tag for daemon.")
Glean.setDebugViewTag(gleanTag)
}
if (isSuperDooperMetricsActive) {
if (shouldRecordMetrics) {
val installationIdString = json.getString("installationId")
installationIdString?.let {
try {
Expand Down Expand Up @@ -421,7 +432,7 @@ class VPNService : android.net.VpnService() {
// Clear the notification message, so the content
// is not "disconnected" in case we connect from a non-client.
CannedNotification(mConfig)?.let { mNotificationHandler.hide(it) }
if (isSuperDooperMetricsActive) {
if (shouldRecordMetrics) {
Session.daemonSessionEnd.set()
Pings.daemonsession.submit(
Pings.daemonsessionReasonCodes.daemonEnd,
Expand Down
Loading