Skip to content

Commit

Permalink
Merge branch 'release/7.148.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
miasma13 committed Dec 4, 2024
2 parents bef27c0 + 75dff24 commit 6683ba0
Show file tree
Hide file tree
Showing 38 changed files with 1,288 additions and 61 deletions.
1 change: 1 addition & 0 deletions Core/FeatureFlag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public enum FeatureFlag: String {

/// https://app.asana.com/0/1208592102886666/1208613627589762/f
case crashReportOptInStatusResetting

case isPrivacyProLaunchedROW
case isPrivacyProLaunchedROWOverride

Expand Down
23 changes: 20 additions & 3 deletions Core/PixelEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import NetworkProtection
extension Pixel {

public enum Event {


case appInstall
case appLaunch
case refreshPressed
case pullToRefresh
Expand Down Expand Up @@ -80,14 +81,16 @@ extension Pixel {
case browsingMenuShare
case browsingMenuCopy
case browsingMenuPrint
case browsingMenuListPrint
case browsingMenuFindInPage
case browsingMenuZoom
case browsingMenuDisableProtection
case browsingMenuEnableProtection
case browsingMenuReportBrokenSite
case browsingMenuFireproof
case browsingMenuAutofill

case browsingMenuAIChat

case addressBarShare
case addressBarSettings
case addressBarCancelPressedOnNTP
Expand Down Expand Up @@ -895,9 +898,13 @@ extension Pixel {
case appDidShowUITime(time: BucketAggregation)
case appDidBecomeActiveTime(time: BucketAggregation)

// MARK: AI Chat
case openAIChatBefore10min
case openAIChatAfter10min
case aiChatNoRemoteSettingsFound(settings: String)

// MARK: Lifecycle
case appDidTransitionToUnexpectedState

}

}
Expand All @@ -908,6 +915,7 @@ extension Pixel.Event {

public var name: String {
switch self {
case .appInstall: return "m_install"
case .appLaunch: return "ml"
case .refreshPressed: return "m_r"
case .pullToRefresh: return "m_pull-to-reload"
Expand Down Expand Up @@ -959,6 +967,7 @@ extension Pixel.Event {
case .browsingMenuToggleBrowsingMode: return "mb_dm"
case .browsingMenuCopy: return "mb_cp"
case .browsingMenuPrint: return "mb_pr"

case .browsingMenuFindInPage: return "mb_fp"
case .browsingMenuZoom: return "m_menu_page_zoom_taps"
case .browsingMenuDisableProtection: return "mb_wla"
Expand All @@ -968,6 +977,8 @@ extension Pixel.Event {
case .browsingMenuAutofill: return "m_nav_autofill_menu_item_pressed"

case .browsingMenuShare: return "m_browsingmenu_share"
case .browsingMenuAIChat: return "m_aichat_menu_tab_icon"
case .browsingMenuListPrint: return "m_browsing_menu_list_print"

case .addressBarShare: return "m_addressbar_share"
case .addressBarSettings: return "m_addressbar_settings"
Expand Down Expand Up @@ -1787,6 +1798,12 @@ extension Pixel.Event {
case .appDidShowUITime(let time): return "m_debug_app-did-show-ui-time-\(time)"
case .appDidBecomeActiveTime(let time): return "m_debug_app-did-become-active-time-\(time)"

// MARK: AI Chat
case .openAIChatAfter10min: return "m_aichat_open_after_10_min"
case .openAIChatBefore10min: return "m_aichat_open_before_10_min"
case .aiChatNoRemoteSettingsFound(let settings):
return "m_aichat_no_remote_settings_found-\(settings.lowercased())"

// MARK: Lifecycle
case .appDidTransitionToUnexpectedState: return "m_debug_app-did-transition-to-unexpected-state"

Expand Down
20 changes: 19 additions & 1 deletion Core/StatisticsLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,18 @@ public class StatisticsLoader {
private let parser = AtbParser()
private let atbPresenceFileMarker = BoolFileMarker(name: .isATBPresent)
private let inconsistencyMonitoring: StatisticsStoreInconsistencyMonitoring
private let pixelFiring: PixelFiring.Type

init(statisticsStore: StatisticsStore = StatisticsUserDefaults(),
returnUserMeasurement: ReturnUserMeasurement = KeychainReturnUserMeasurement(),
usageSegmentation: UsageSegmenting = UsageSegmentation(),
inconsistencyMonitoring: StatisticsStoreInconsistencyMonitoring = StorageInconsistencyMonitor()) {
inconsistencyMonitoring: StatisticsStoreInconsistencyMonitoring = StorageInconsistencyMonitor(),
pixelFiring: PixelFiring.Type = Pixel.self) {
self.statisticsStore = statisticsStore
self.returnUserMeasurement = returnUserMeasurement
self.usageSegmentation = usageSegmentation
self.inconsistencyMonitoring = inconsistencyMonitoring
self.pixelFiring = pixelFiring
}

public func load(completion: @escaping Completion = {}) {
Expand Down Expand Up @@ -94,6 +97,7 @@ public class StatisticsLoader {
completion()
return
}
self.fireInstallPixel()
self.statisticsStore.installDate = Date()
self.statisticsStore.atb = atb.version
self.returnUserMeasurement.installCompletedWithATB(atb)
Expand All @@ -102,6 +106,20 @@ public class StatisticsLoader {
}
}

private func fireInstallPixel() {
let formattedLocale = Locale.current.localeIdentifierAsJsonFormat
let isReinstall = String(statisticsStore.variant == VariantIOS.returningUser.name)
let parameters = [
"locale": formattedLocale,
"reinstall": isReinstall
]
pixelFiring.fire(.appInstall, withAdditionalParameters: parameters, includedParameters: [.appVersion], onComplete: { error in
if let error {
Logger.general.error("Install pixel failed with error: \(error.localizedDescription, privacy: .public)")
}
})
}

private func createATBFileMarker() {
atbPresenceFileMarker?.mark()
}
Expand Down
Loading

0 comments on commit 6683ba0

Please sign in to comment.