From 64ab58e091a62e7908138e226e9cedde25251cf4 Mon Sep 17 00:00:00 2001 From: Justin D'Arcangelo Date: Tue, 23 May 2017 12:04:31 -0400 Subject: [PATCH] Bug 1354096 - Stop using Adjust for UI telemetry (#62) --- Blockzilla/Adjust-Focus.plist | 41 ---------------------- Blockzilla/Adjust-Klar.plist | 41 ---------------------- Blockzilla/AdjustIntegration.swift | 46 +------------------------ Blockzilla/AppDelegate.swift | 3 +- Blockzilla/BrowserViewController.swift | 4 --- Blockzilla/OpenUtils.swift | 4 --- Blockzilla/SettingsViewController.swift | 20 ++--------- Cartfile.resolved | 2 +- 8 files changed, 5 insertions(+), 156 deletions(-) diff --git a/Blockzilla/Adjust-Focus.plist b/Blockzilla/Adjust-Focus.plist index 6560e0a17f..d63b12bba9 100644 --- a/Blockzilla/Adjust-Focus.plist +++ b/Blockzilla/Adjust-Focus.plist @@ -4,46 +4,5 @@ AppToken XXX - Events - - Browse - hjuag8 - Search - jf1b59 - Clear - hy183e - OpenInFirefox - t7m1ru - OpenInSafari - ns4a3y - EnableBlockAds - 1pmsby - DisableBlockAds - 34xb7g - EnableBlockAnalytics - oimjge - DisableBlockAnalytics - pppabq - EnableBlockFonts - 1zb5ah - DisableBlockFonts - nfi1np - EnableBlockOther - fr308r - DisableBlockOther - vp5tjk - EnableBlockSocial - 9l4fiy - DisableBlockSocial - ha6nkv - EnableSafariIntegration - ec8kb7 - DisableSafariIntegration - i0zoki - OpenSystemShare - n4k5jo - OpenFirefoxInstall - 5qb7ma - diff --git a/Blockzilla/Adjust-Klar.plist b/Blockzilla/Adjust-Klar.plist index efc1b62c69..d63b12bba9 100644 --- a/Blockzilla/Adjust-Klar.plist +++ b/Blockzilla/Adjust-Klar.plist @@ -4,46 +4,5 @@ AppToken XXX - Events - - Browse - 58bwsk - Search - pxtu4v - Clear - n9hwgu - OpenInFirefox - usp0gb - OpenInSafari - 5elufs - EnableBlockAds - frnano - DisableBlockAds - uqm3k4 - EnableBlockAnalytics - au3px7 - DisableBlockAnalytics - 4t3lka - EnableBlockFonts - 5fbqr5 - DisableBlockFonts - oymwmb - EnableBlockOther - tz19iu - DisableBlockOther - vzlgmg - EnableBlockSocial - 6ddntz - DisableBlockSocial - ohnn42 - EnableSafariIntegration - w67hjo - DisableSafariIntegration - 8a1gtl - OpenSystemShare - b42cgh - OpenFirefoxInstall - 6r6cx6 - diff --git a/Blockzilla/AdjustIntegration.swift b/Blockzilla/AdjustIntegration.swift index a74431254a..62a16081b3 100644 --- a/Blockzilla/AdjustIntegration.swift +++ b/Blockzilla/AdjustIntegration.swift @@ -5,30 +5,7 @@ import Foundation import AdjustSdk -enum AdjustEventName: String { - case browse = "Browse" // When the user opens a url - case search = "Search" // When the user does a search - case clear = "Clear" // When the user erases the browsing history - case openFirefox = "OpenInFirefox" // When the user opens the page in Firefox - case openSafari = "OpenInSafari" // When the user opens the page in Safari - case openFirefoxInstall = "OpenFirefoxInstall" // When the user opens the App Store page for Firefox - case openSystemShare = "OpenSystemShare" // When the user opens the system share menu - case enableSafariIntegration = "EnableSafariIntegration" // When the user enables the Safari blocklist - case disableSafariIntegration = "DisableSafariIntegration" // When the user disables the Safari blocklist - case enableBlockAds = "EnableBlockAds" // When the user enables Block Ad Trackers - case disableBlockAds = "DisableBlockAds" // When the user disables Block Ad Trackers - case enableBlockAnalytics = "EnableBlockAnalytics" // When the user enables Block Analytics Trackers - case disableBlockAnalytics = "DisableBlockAnalytics" // When the user disabled Block Analytics Trackers - case enableBlockSocial = "EnableBlockSocial" // When the user enables Block Social Trackers - case disableBlockSocial = "DisableBlockSocial" // When the user disables Block Social Trackers - case enableBlockOther = "EnableBlockOther" // When the user enables Block Other Content Trackers - case disableBlockOther = "DisableBlockOther" // When the user disables Block Other Content Trackers - case enableBlockFonts = "EnableBlockFonts" // When the user enables Block Web Fonts - case disableBlockFonts = "DisableBlockFonts" // When the user disables Block Web Fonts -} - private let AdjustAppTokenKey = "AppToken" -private let AdjustEventsKey = "Events" private enum AdjustEnvironment: String { case sandbox = "sandbox" @@ -38,29 +15,18 @@ private enum AdjustEnvironment: String { private struct AdjustSettings { var appToken: String var environment: AdjustEnvironment - var events: [AdjustEventName: String] init?(contentsOf url: URL) { - guard let config = NSDictionary(contentsOf: url), let appToken = config.object(forKey: AdjustAppTokenKey) as? String, let events = config.object(forKey: AdjustEventsKey) as? [String: String] else { + guard let config = NSDictionary(contentsOf: url), let appToken = config.object(forKey: AdjustAppTokenKey) as? String else { return nil } - var eventMappings = [AdjustEventName: String]() - for (name, token) in events { - guard let eventName = AdjustEventName(rawValue: name) else { - assertionFailure("Event <\(name)> from settings plist not found in enum") - continue - } - eventMappings[eventName] = token - } - self.appToken = appToken #if DEBUG self.environment = AdjustEnvironment.sandbox #else self.environment = AdjustEnvironment.production #endif - self.events = eventMappings } } @@ -89,14 +55,4 @@ class AdjustIntegration { Adjust.setEnabled(newValue) } } - - public static func track(eventName: AdjustEventName) { - if Adjust.isEnabled() { - guard let settings = adjustSettings, let eventToken = settings.events[eventName] else { - assertionFailure("Adjust not initialized or event <\(eventName.rawValue)> was not found in the settings") - return - } - Adjust.trackEvent(ADJEvent(eventToken: eventToken)) - } - } } diff --git a/Blockzilla/AppDelegate.swift b/Blockzilla/AppDelegate.swift index aee9ba7adf..0ec07d7d1a 100644 --- a/Blockzilla/AppDelegate.swift +++ b/Blockzilla/AppDelegate.swift @@ -3,7 +3,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import UIKit -import AdjustSdk import Telemetry @UIApplicationMain @@ -44,7 +43,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { telemetryConfig.isUploadEnabled = false #else telemetryConfig.updateChannel = "release" - telemetryConfig.isCollectionEnabled = true + telemetryConfig.isCollectionEnabled = Settings.getToggle(.sendAnonymousUsageData) telemetryConfig.isUploadEnabled = Settings.getToggle(.sendAnonymousUsageData) #endif diff --git a/Blockzilla/BrowserViewController.swift b/Blockzilla/BrowserViewController.swift index 979814e9e5..2008c2eaf8 100644 --- a/Blockzilla/BrowserViewController.swift +++ b/Blockzilla/BrowserViewController.swift @@ -196,7 +196,6 @@ class BrowserViewController: UIViewController { }) Telemetry.default.recordEvent(category: TelemetryEventCategory.action, method: TelemetryEventMethod.click, object: TelemetryEventObject.eraseButton) - AdjustIntegration.track(eventName: .clear) } fileprivate func showSettings() { @@ -253,11 +252,9 @@ extension BrowserViewController: URLBarDelegate { var url = URIFixup.getURL(entry: text) if url == nil { Telemetry.default.recordEvent(category: TelemetryEventCategory.action, method: TelemetryEventMethod.typeQuery, object: TelemetryEventObject.searchBar) - AdjustIntegration.track(eventName: .search) url = searchEngineManager.activeEngine.urlForQuery(text) } else { Telemetry.default.recordEvent(category: TelemetryEventCategory.action, method: TelemetryEventMethod.typeURL, object: TelemetryEventObject.searchBar) - AdjustIntegration.track(eventName: .browse) } submit(url: url!) @@ -520,7 +517,6 @@ extension BrowserViewController: OverlayViewDelegate { func overlayView(_ overlayView: OverlayView, didSearchForQuery query: String) { if let url = searchEngineManager.activeEngine.urlForQuery(query) { Telemetry.default.recordEvent(category: TelemetryEventCategory.action, method: TelemetryEventMethod.typeQuery, object: TelemetryEventObject.searchBar) - AdjustIntegration.track(eventName: .search) submit(url: url) } diff --git a/Blockzilla/OpenUtils.swift b/Blockzilla/OpenUtils.swift index 60b55b23c0..9ca9e316e9 100644 --- a/Blockzilla/OpenUtils.swift +++ b/Blockzilla/OpenUtils.swift @@ -20,19 +20,16 @@ class OpenUtils { } Telemetry.default.recordEvent(category: TelemetryEventCategory.action, method: TelemetryEventMethod.open, object: TelemetryEventObject.menu, value: "firefox") - AdjustIntegration.track(eventName: .openFirefox) app.openURL(firefoxURL) } private static func openFirefoxInstall() { Telemetry.default.recordEvent(category: TelemetryEventCategory.action, method: TelemetryEventMethod.openAppStore, object: TelemetryEventObject.menu, value: "firefox") - AdjustIntegration.track(eventName: .openFirefoxInstall) UIApplication.shared.openURL(AppInfo.config.firefoxAppStoreURL) } private static func openInSafari(url: URL) { Telemetry.default.recordEvent(category: TelemetryEventCategory.action, method: TelemetryEventMethod.open, object: TelemetryEventObject.menu, value: "default") - AdjustIntegration.track(eventName: .openSafari) app.openURL(url) } @@ -55,7 +52,6 @@ class OpenUtils { alert.addAction(UIAlertAction(title: UIConstants.strings.openMore, style: .default) { _ in Telemetry.default.recordEvent(category: TelemetryEventCategory.action, method: TelemetryEventMethod.share, object: TelemetryEventObject.menu) - AdjustIntegration.track(eventName: .openSystemShare) let controller = UIActivityViewController(activityItems: [url], applicationActivities: nil) controller.popoverPresentationController?.sourceView = anchor diff --git a/Blockzilla/SettingsViewController.swift b/Blockzilla/SettingsViewController.swift index f9e7299e06..b1468f7772 100644 --- a/Blockzilla/SettingsViewController.swift +++ b/Blockzilla/SettingsViewController.swift @@ -278,23 +278,6 @@ class SettingsViewController: UIViewController, UITableViewDataSource, UITableVi let telemetryEvent = TelemetryEvent(category: TelemetryEventCategory.action, method: TelemetryEventMethod.change, object: "setting", value: toggle.setting.rawValue) telemetryEvent.addExtra(key: "to", value: sender.isOn) Telemetry.default.recordEvent(telemetryEvent) - - switch toggle.setting { - case .safari: - AdjustIntegration.track(eventName: sender.isOn ? .enableSafariIntegration : .disableSafariIntegration) - case .blockAds: - AdjustIntegration.track(eventName: sender.isOn ? .enableBlockAds : .disableBlockAds) - case .blockAnalytics: - AdjustIntegration.track(eventName: sender.isOn ? .enableBlockAnalytics : .disableBlockAnalytics) - case .blockSocial: - AdjustIntegration.track(eventName: sender.isOn ? .enableBlockSocial : .disableBlockSocial) - case .blockOther: - AdjustIntegration.track(eventName: sender.isOn ? .enableBlockOther : .disableBlockOther) - case .blockFonts: - AdjustIntegration.track(eventName: sender.isOn ? .enableBlockFonts : .disableBlockFonts) - default: - break - } Settings.set(sender.isOn, forToggle: toggle.setting) Utils.reloadSafariContentBlocker() @@ -304,7 +287,8 @@ class SettingsViewController: UIViewController, UITableViewDataSource, UITableVi // First check if the user changed the anonymous usage data setting and follow that choice right // here. Otherwise it will be delayed until the application restarts. if toggle.setting == .sendAnonymousUsageData { - AdjustIntegration.enabled = sender.isOn + Telemetry.default.configuration.isCollectionEnabled = sender.isOn + Telemetry.default.configuration.isUploadEnabled = sender.isOn } switch toggle.setting { diff --git a/Cartfile.resolved b/Cartfile.resolved index 2f6a43a4bd..65f1df0389 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -3,5 +3,5 @@ github "SnapKit/SnapKit" "3.2.0" github "adjust/ios_sdk" "v4.10.2" github "cezheng/Fuzi" "1.0.1" github "mozilla-mobile/AutocompleteTextField" "ddff214d4e7df7a13e828f4af1b6d480dbec31cd" -github "mozilla-mobile/telemetry-ios" "880be6572879a27efe996ee00305ec4891357a22" +github "mozilla-mobile/telemetry-ios" "97daf6d1b5b5b6548a4bead0a14795a3c6509db7" github "swisspol/GCDWebServer" "3.3.3"