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

class SendAnonymousUsageDataSetting: BoolSetting {
Expand Down Expand Up @@ -54,6 +55,11 @@ class SendAnonymousUsageDataSetting: BoolSetting {
self.settingDidChange = { [weak self] value in
// AdjustHelper.setEnabled($0)
DefaultGleanWrapper.shared.setUpload(isEnabled: value)

if !value {
self?.prefs?.removeObjectForKey(PrefsKeys.Usage.profileId)
thatswinnie marked this conversation as resolved.
Show resolved Hide resolved
}

Experiments.setTelemetrySetting(value)
self?.shouldSendUsageData?(value)
}
Expand Down
8 changes: 8 additions & 0 deletions firefox-ios/Client/Telemetry/TelemetryWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ class TelemetryWrapper: TelemetryWrapperProtocol, FeatureFlaggable {
GleanMetrics.LegacyIds.clientId.set(uuid)
}

// Set or generate profile id used for usage reporting
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)
}
thatswinnie marked this conversation as resolved.
Show resolved Hide resolved

glean.registerPings(GleanMetrics.Pings.shared)

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

# DAU reporting
thatswinnie marked this conversation as resolved.
Show resolved Hide resolved
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/
data_reviews:
- https://github.com/mozilla-mobile/firefox-ios/pull/
thatswinnie marked this conversation as resolved.
Show resolved Hide resolved
data_sensitivity:
- technical
- highly_sensitive
notification_emails:
- [email protected]
thatswinnie marked this conversation as resolved.
Show resolved Hide resolved
expires: never
send_in_pings:
- dau-reporting
thatswinnie marked this conversation as resolved.
Show resolved Hide resolved

# 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