Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Added Send Crash Reports setting

  • Loading branch information
mahmoud-adam85 authored and Tim Palade committed Mar 26, 2018
1 parent b5681e2 commit 68230dd4db703b19bd2490d0ccb981579bc0a224
@@ -60,6 +60,7 @@
1EAFE56E205FFE82006A36B4 /* AdBlockerSettingsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EAFE568205FFE82006A36B4 /* AdBlockerSettingsTableViewController.swift */; };
1EAFE56F205FFE82006A36B4 /* HumanWebSettingsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EAFE569205FFE82006A36B4 /* HumanWebSettingsTableViewController.swift */; };
1EAFE570205FFE82006A36B4 /* RegionalSettingsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EAFE56A205FFE82006A36B4 /* RegionalSettingsTableViewController.swift */; };
1EEA368120613C17003B6AD5 /* SendCrashReportsTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EEA368020613C17003B6AD5 /* SendCrashReportsTableViewController.swift */; };
2805F5A61B8BCA7A00268FD1 /* ReadingList.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4D567181ADECE2700F1EFE7 /* ReadingList.framework */; };
28078A471B1507EF0053B46A /* ReadingList.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4D567181ADECE2700F1EFE7 /* ReadingList.framework */; };
280CB1371C20E0A3005AF147 /* BookmarksSynchronizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 280CB1361C20E0A3005AF147 /* BookmarksSynchronizer.swift */; };
@@ -1477,6 +1478,7 @@
1EAFE568205FFE82006A36B4 /* AdBlockerSettingsTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdBlockerSettingsTableViewController.swift; sourceTree = "<group>"; };
1EAFE569205FFE82006A36B4 /* HumanWebSettingsTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HumanWebSettingsTableViewController.swift; sourceTree = "<group>"; };
1EAFE56A205FFE82006A36B4 /* RegionalSettingsTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RegionalSettingsTableViewController.swift; sourceTree = "<group>"; };
1EEA368020613C17003B6AD5 /* SendCrashReportsTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SendCrashReportsTableViewController.swift; sourceTree = "<group>"; };
280CB1361C20E0A3005AF147 /* BookmarksSynchronizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BookmarksSynchronizer.swift; path = Sync/Synchronizers/Bookmarks/BookmarksSynchronizer.swift; sourceTree = SOURCE_ROOT; };
28126F471C2F948E006466CC /* SQLiteBookmarksHelpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLiteBookmarksHelpers.swift; sourceTree = "<group>"; };
28126F6D1C2F94F9006466CC /* SQLiteBookmarksModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SQLiteBookmarksModel.swift; sourceTree = "<group>"; };
@@ -2524,6 +2526,7 @@
1EAFE569205FFE82006A36B4 /* HumanWebSettingsTableViewController.swift */,
1EAFE566205FFE82006A36B4 /* LimitMobileDataUsageTableViewController.swift */,
1EAFE56A205FFE82006A36B4 /* RegionalSettingsTableViewController.swift */,
1EEA368020613C17003B6AD5 /* SendCrashReportsTableViewController.swift */,
);
path = "Custom Settings";
sourceTree = "<group>";
@@ -5997,6 +6000,7 @@
E66C5B481BDA81050051AA93 /* UIImage+ImageEffects.m in Sources */,
4F69309A2048185600FB0B2E /* TopSitesDataSource.swift in Sources */,
E4CD9F6D1A77DD2800318571 /* ReaderModeStyleViewController.swift in Sources */,
1EEA368120613C17003B6AD5 /* SendCrashReportsTableViewController.swift in Sources */,
4F3046B8204FF65800C99162 /* LocationManager.swift in Sources */,
D0FCF7F51FE45842004A7995 /* UserScriptManager.swift in Sources */,
E4A960061ABB9C450069AD6F /* ReaderModeUtils.swift in Sources */,
@@ -89,8 +89,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIViewControllerRestorati

// Need to get "settings.sendUsageData" this way so that Sentry can be initialized
// before getting the Profile.
/* Cliqz: Use `getSendCrashReportsPref()` instead of `SendUsageData`
let sendUsageData = NSUserDefaultsPrefs(prefix: "profile").boolForKey(AppConstants.PrefSendUsageData) ?? true
Sentry.shared.setup(sendUsageData: sendUsageData)
*/
let sendCrashReports = SettingsPrefs.shared.getSendCrashReportsPref()
Sentry.shared.setup(sendUsageData: sendCrashReports)

// Set the Firefox UA for browsing.
setUserAgent()
@@ -25,6 +25,7 @@ class SettingsPrefs {
static let LogTelemetryPrefKey = "showTelemetry"
static let ShowTopSitesPrefKey = "showFreshTabTopSites"
static let ShowNewsPrefKey = "showFreshTabNews"
static let SendCrashReports = "sendCrashReports"

static let SearchBackendOptions = ["DE", "US", "FR"]

@@ -194,6 +195,19 @@ class SettingsPrefs {
return self.getBoolPref(SettingsPrefs.ShowNewsPrefKey) ?? true
}

func getSendCrashReportsPref() -> Bool {
// Need to get "settings.sendCrashReports" this way so that Sentry can be initialized before getting the Profile.
let defaultValue = true
if let sendCrashReportsPref = LocalDataStore.objectForKey(SettingsPrefs.SendCrashReports) as? Bool {
return sendCrashReportsPref
}
return defaultValue
}

func updateSendCrashReportsPref(_ newValue: Bool) {
LocalDataStore.setObject(newValue, forKey: SettingsPrefs.SendCrashReports)

}
// MARK: - Private helper metods
fileprivate func getBoolPref(_ forKey: String) -> Bool? {

@@ -188,6 +188,20 @@ class ReportWebsiteSetting: ShowCliqzPageSetting {
}
}

class SendCrashReportsSetting: CliqzOnOffSetting {
override func getTitle() -> String {
return NSLocalizedString("Send Crash Reports", tableName: "Cliqz", comment: "[Settings] Send Crash Reports")
}

override func isOn() -> Bool {
return SettingsPrefs.shared.getSendCrashReportsPref()
}

override func getSubSettingViewController() -> SubSettingsTableViewController {
return SendCrashReportsTableViewController()
}
}

class MyOffrzSetting: ShowCliqzPageSetting {

override func getTitle() -> String {
@@ -133,6 +133,7 @@ class CliqzAppSettingsTableViewController: AppSettingsTableViewController {
SupportSetting(delegate: settingsDelegate),
CliqzTipsAndTricksSetting(),
ReportWebsiteSetting(),
SendCrashReportsSetting(settings: self),
MyOffrzSetting()
]

@@ -0,0 +1,32 @@
//
// SendCrashReportsTableViewController.swift
// Client
//
// Created by Mahmoud Adam on 3/20/18.
// Copyright © 2018 Cliqz. All rights reserved.
//
import UIKit

class SendCrashReportsTableViewController: ToggleSubSettingsTableViewController {
// MARK:- Abstract methods Implementation
override func getViewName() -> String {
return "crash_reports"
}

override func getToggles() -> [Bool] {
return [SettingsPrefs.shared.getAutoForgetTabPref()]
}

override func getToggleTitles() -> [String] {
return [self.title ?? ""]
}

override func getSectionFooters() -> [String] {
return [NSLocalizedString("We use opensource software Sentry (http://sentry.io) for our crash reports. these reports do not contain any personal data.", tableName: "Cliqz", comment: "[Settings -> Send Crash Reports] Footer text")]
}

override func saveToggles(isOn: Bool, atIndex: Int) {
SettingsPrefs.shared.updateSendCrashReportsPref(isOn)
}
}

0 comments on commit 68230dd

Please sign in to comment.