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

Add FXIOS-10617 [ToS] Add Glean usage profile id #23254

Merged
merged 13 commits into from
Nov 27, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import Common
import Foundation
import Glean
import Shared

enum SendDataType {
Expand Down Expand Up @@ -80,6 +81,16 @@ class SendDataSetting: BoolSetting {
self.settingDidChange = { [weak self] value in
// AdjustHelper.setEnabled($0)
DefaultGleanWrapper.shared.setUpload(isEnabled: value)

if !value {
self?.prefs?.removeObjectForKey(PrefsKeys.Usage.profileId)

// set dummy uuid to make sure the previous one is deleted
if let uuid = UUID(uuidString: "beefbeef-beef-beef-beef-beeefbeefbee") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL amazing!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't knew Winnie liked beef that much

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c0ffee (and decaf) were already taken and I couldn't come up with other fun stuff.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL. I like beef and I cannot lie 😇
But seriously, that string actually came from @badboy

GleanMetrics.Usage.profileId.set(uuid)
}
}

Experiments.setTelemetrySetting(value)
self?.shouldSendData?(value)
}
Expand Down
17 changes: 16 additions & 1 deletion firefox-ios/Client/Telemetry/TelemetryWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,25 @@ class TelemetryWrapper: TelemetryWrapperProtocol, FeatureFlaggable {
GleanMetrics.Search.defaultEngine.set(defaultEngine?.engineID ?? "unavailable")

// Get the legacy telemetry ID and record it in Glean for the deletion-request ping
if let uuidString = UserDefaults.standard.string(forKey: "telemetry-key-prefix-clientId"), let uuid = UUID(uuidString: uuidString) {
if let uuidString = UserDefaults.standard.string(forKey: "telemetry-key-prefix-clientId"),
let uuid = UUID(uuidString: uuidString) {
GleanMetrics.LegacyIds.clientId.set(uuid)
}

// Set or generate profile id used for usage reporting
if profile.prefs.boolForKey(AppConstants.prefSendUsageData) ?? true {
thatswinnie marked this conversation as resolved.
Show resolved Hide resolved
if let uuidString = profile.prefs.stringForKey(PrefsKeys.Usage.profileId),
let uuid = UUID(uuidString: uuidString) {
GleanMetrics.Usage.profileId.set(uuid)
} else {
let uuid = GleanMetrics.Usage.profileId.generateAndSet()
profile.prefs.setString(uuid.uuidString, forKey: PrefsKeys.Usage.profileId)
}
} else if let uuid = UUID(uuidString: "beefbeef-beef-beef-beef-beeefbeefbee") {
// set dummy uuid to make sure the previous one is deleted
GleanMetrics.Usage.profileId.set(uuid)
}

glean.registerPings(GleanMetrics.Pings.shared)

// Initialize Glean telemetry
Expand Down
22 changes: 22 additions & 0 deletions firefox-ios/Client/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,28 @@ app:
- [email protected]
expires: "2025-01-01"

# Usage reporting
usage:
profile_id:
type: uuid
lifetime: user
description: |
A UUID uniquely identifying the profile,
not shared with other telemetry data.
bugs:
- https://github.com/mozilla-mobile/firefox-ios/pull/23254
data_reviews:
- https://github.com/mozilla-mobile/firefox-ios/pull/23254
data_sensitivity:
- technical
- highly_sensitive
notification_emails:
- [email protected]
thatswinnie marked this conversation as resolved.
Show resolved Hide resolved
- [email protected]
expires: never
send_in_pings:
- usage-reporting

# Downloads
downloads:
download_now_button_tapped:
Expand Down
4 changes: 4 additions & 0 deletions firefox-ios/Shared/Prefs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ public struct PrefsKeys {

// Represents whether or not the user has seen the photon main menu once, at least.
public static let PhotonMainMenuShown = "PhotonMainMenuShown"

public struct Usage {
public static let profileId = "profileId"
}
}

public protocol Prefs {
Expand Down
Loading