Skip to content

Commit

Permalink
Fix mozilla-mobile#5730 - Private mode telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
garvankeeley committed Nov 21, 2019
1 parent 46b6676 commit c236537
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Client/Frontend/Browser/Tab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ class Tab: NSObject {
self.isPrivate = isPrivate

debugTabCount += 1

UnifiedTelemetry.recordEvent(category: .action, method: .add, object: .tab, value: isPrivate ? .privateTab : .normalTab)
}

class func toRemoteTab(_ tab: Tab) -> RemoteTab? {
Expand Down
2 changes: 2 additions & 0 deletions Client/Frontend/Browser/TabDisplayManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class TabDisplayManager: NSObject {
isPrivate = isOn
UserDefaults.standard.set(isPrivate, forKey: "wasLastSessionPrivate")

UnifiedTelemetry.recordEvent(category: .action, method: .tap, object: .privateBrowsingButton)

searchedTabs = nil
refreshStore()

Expand Down
3 changes: 3 additions & 0 deletions Client/Telemetry/UnifiedTelemetry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ extension UnifiedTelemetry {
case dismissedOnboarding = "dismissed-onboarding"
case dismissedOnboardingEmailLogin = "dismissed-onboarding-email-login"
case dismissedOnboardingSignUp = "dismissed-onboarding-sign-up"
case privateBrowsingButton = "private-browsing-button"
}

public enum EventValue: String {
Expand Down Expand Up @@ -221,6 +222,8 @@ extension UnifiedTelemetry {
case themeModeAutomatically = "theme-automatically"
case themeLight = "theme-light"
case themeDark = "theme-dark"
case privateTab = "private-tab"
case normalTab = "normal-tab"
}

public static func recordEvent(category: EventCategory, method: EventMethod, object: EventObject, value: EventValue, extras: [String: Any?]? = nil) {
Expand Down

0 comments on commit c236537

Please sign in to comment.