Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
devinreams committed Aug 27, 2018
2 parents 24f4f55 + 125c674 commit 04115ba
Show file tree
Hide file tree
Showing 22 changed files with 200 additions and 50 deletions.
1 change: 1 addition & 0 deletions Cartfile
Expand Up @@ -9,3 +9,4 @@ github "mozilla-mobile/MappaMundi" "master"
github "mozilla/application-services" "0.2.1"
github "mozilla-lockbox/lockbox-ios-fxa-sync" "c41fac5a33519e8d9e7fdeb1a57a6ac231fdb832"
github "adjust/ios_sdk" ~> 4.14.1
github "getsentry/sentry-cocoa" "4.1.0"
3 changes: 2 additions & 1 deletion Cartfile.resolved
Expand Up @@ -6,7 +6,8 @@ github "ReactiveX/RxSwift" "4.2.0"
github "RxSwiftCommunity/RxDataSources" "3.0.2"
github "RxSwiftCommunity/RxOptional" "3.5.0"
github "SwiftyJSON/SwiftyJSON" "3.1.4"
github "adjust/ios_sdk" "v4.14.1"
github "adjust/ios_sdk" "v4.14.3"
github "getsentry/sentry-cocoa" "4.1.0"
github "jrendel/SwiftKeychainWrapper" "3.0.1"
github "mozilla-lockbox/lockbox-ios-fxa-sync" "c41fac5a33519e8d9e7fdeb1a57a6ac231fdb832"
github "mozilla-mobile/MappaMundi" "981095dff1c014a458624820ac8f2cda39c92144"
Expand Down
9 changes: 9 additions & 0 deletions Lockbox.xcodeproj/project.pbxproj
Expand Up @@ -172,6 +172,8 @@
D8783613207C080300C19BC7 /* ExternalLinkAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8783612207C080300C19BC7 /* ExternalLinkAction.swift */; };
D8783615207D303E00C19BC7 /* ExternalLinkStoreSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8783614207D303E00C19BC7 /* ExternalLinkStoreSpec.swift */; };
D8783617207D70D100C19BC7 /* PreferredBrowserSettingPresenterSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8783616207D70D100C19BC7 /* PreferredBrowserSettingPresenterSpec.swift */; };
D88177BD212F2DB100436B3D /* Sentry.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D88177BC212F2DB100436B3D /* Sentry.framework */; };
D88177BF212F30F600436B3D /* SentryManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = D88177BE212F30F600436B3D /* SentryManager.swift */; };
D88C40C6209CF27E0022696B /* AutoLockStoreSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = D88C40C5209CF27E0022696B /* AutoLockStoreSpec.swift */; };
D895605C20967C5300CC7E47 /* AutoLockStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = D895605B20967C5300CC7E47 /* AutoLockStore.swift */; };
D8C9C520207DC53B007874E1 /* PreferredBrowserSettingViewSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8C9C51F207DC53B007874E1 /* PreferredBrowserSettingViewSpec.swift */; };
Expand Down Expand Up @@ -409,6 +411,8 @@
D8783612207C080300C19BC7 /* ExternalLinkAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExternalLinkAction.swift; sourceTree = "<group>"; };
D8783614207D303E00C19BC7 /* ExternalLinkStoreSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExternalLinkStoreSpec.swift; sourceTree = "<group>"; };
D8783616207D70D100C19BC7 /* PreferredBrowserSettingPresenterSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferredBrowserSettingPresenterSpec.swift; sourceTree = "<group>"; };
D88177BC212F2DB100436B3D /* Sentry.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Sentry.framework; path = Carthage/Build/iOS/Sentry.framework; sourceTree = "<group>"; };
D88177BE212F30F600436B3D /* SentryManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryManager.swift; sourceTree = "<group>"; };
D88C40C5209CF27E0022696B /* AutoLockStoreSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoLockStoreSpec.swift; sourceTree = "<group>"; };
D895605B20967C5300CC7E47 /* AutoLockStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoLockStore.swift; sourceTree = "<group>"; };
D8C9C51F207DC53B007874E1 /* PreferredBrowserSettingViewSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferredBrowserSettingViewSpec.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -446,6 +450,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
D88177BD212F2DB100436B3D /* Sentry.framework in Frameworks */,
D8551EBE211954E00056B24A /* AdjustSdk.framework in Frameworks */,
D8551EBC211950BF0056B24A /* iAd.framework in Frameworks */,
D8551EBA211950AF0056B24A /* AdSupport.framework in Frameworks */,
Expand Down Expand Up @@ -557,6 +562,7 @@
isa = PBXGroup;
children = (
7AA5408D5D52952F11E20EEC /* BiometryManager.swift */,
D88177BE212F30F600436B3D /* SentryManager.swift */,
);
path = Helpers;
sourceTree = "<group>";
Expand Down Expand Up @@ -678,6 +684,7 @@
7D1B1A8A1F98F86400C1F5FF /* Frameworks */ = {
isa = PBXGroup;
children = (
D88177BC212F2DB100436B3D /* Sentry.framework */,
D8551EBD211954E00056B24A /* AdjustSdk.framework */,
D8551EBB211950BF0056B24A /* iAd.framework */,
D8551EB9211950AF0056B24A /* AdSupport.framework */,
Expand Down Expand Up @@ -1013,6 +1020,7 @@
"$(SRCROOT)/Carthage/Build/iOS/Deferred.framework",
"$(SRCROOT)/Carthage/Build/iOS/FxAClient.framework",
"$(SRCROOT)/Carthage/Build/iOS/AdjustSdk.framework",
"$(SRCROOT)/Carthage/Build/iOS/Sentry.framework",
);
outputPaths = (
"$(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/RxCocoa.framework",
Expand Down Expand Up @@ -1136,6 +1144,7 @@
7DA4C6862028F85A00B61DD8 /* ItemListPresenter.swift in Sources */,
7AA54C8928B257655856C516 /* AppDelegate.swift in Sources */,
7AA540D7395F48BD6983CC3E /* Dispatcher.swift in Sources */,
D88177BF212F30F600436B3D /* SentryManager.swift in Sources */,
D8D029282064441600CC01C6 /* AutoLockSettingsView.swift in Sources */,
D831FEE0204C92CD00EAE19A /* SettingListPresenter.swift in Sources */,
4C7F3C7D20B3C32A00C4C414 /* UIButton+.swift in Sources */,
Expand Down
39 changes: 24 additions & 15 deletions Lockbox.xcodeproj/xcshareddata/xcschemes/lockbox.xcscheme
Expand Up @@ -20,29 +20,38 @@
ReferencedContainer = "container:Lockbox.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "NO"
buildForRunning = "NO"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2C2EC55120ADA85A00AF8C44"
BuildableName = "LockboxXCUITests.xctest"
BlueprintName = "LockboxXCUITests"
ReferencedContainer = "container:Lockbox.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<PreActions>
<ExecutionAction
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
<ActionContent
title = "Run Script"
scriptText = "xcrun simctl shutdown all&#10;xcrun simctl erase all"
shellToInvoke = "/bin/bash">
</ActionContent>
</ExecutionAction>
</PreActions>
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2C2EC55120ADA85A00AF8C44"
BuildableName = "LockboxXCUITests.xctest"
BlueprintName = "LockboxXCUITests"
ReferencedContainer = "container:Lockbox.xcodeproj">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "BaseTestCase">
</Test>
</SkippedTests>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
Expand Down
29 changes: 26 additions & 3 deletions Lockbox.xcodeproj/xcshareddata/xcschemes/uispecs.xcscheme
Expand Up @@ -9,9 +9,23 @@
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7D5DF8721F87F2600039B23E"
BuildableName = "Firefox Lockbox.app"
BlueprintName = "Firefox Lockbox"
ReferencedContainer = "container:Lockbox.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2C2EC55120ADA85A00AF8C44"
Expand Down Expand Up @@ -49,6 +63,15 @@
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2C2EC55120ADA85A00AF8C44"
BuildableName = "LockboxXCUITests.xctest"
BlueprintName = "LockboxXCUITests"
ReferencedContainer = "container:Lockbox.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
Expand Down
22 changes: 11 additions & 11 deletions Lockbox.xcodeproj/xcshareddata/xcschemes/unitspecs.xcscheme
Expand Up @@ -14,23 +14,23 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7D1B1AC31F99028D00C1F5FF"
BuildableName = "LockboxTests.xctest"
BlueprintName = "LockboxTests"
BlueprintIdentifier = "7D5DF8721F87F2600039B23E"
BuildableName = "Firefox Lockbox.app"
BlueprintName = "Firefox Lockbox"
ReferencedContainer = "container:Lockbox.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "NO"
buildForRunning = "NO"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2C2EC55120ADA85A00AF8C44"
BuildableName = "LockboxXCUITests.xctest"
BlueprintName = "LockboxXCUITests"
BlueprintIdentifier = "7D1B1AC31F99028D00C1F5FF"
BuildableName = "LockboxTests.xctest"
BlueprintName = "LockboxTests"
ReferencedContainer = "container:Lockbox.xcodeproj">
</BuildableReference>
</BuildActionEntry>
Expand Down
3 changes: 3 additions & 0 deletions buddybuild_prebuild.sh
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
echo "Setting SentryDSN to $SENTRY_DSN"
/usr/libexec/PlistBuddy -c "Set SentryDSN $SENTRY_DSN" "lockbox-ios/Common/Resources/Info.plist"
1 change: 1 addition & 0 deletions lockbox-ios/Action/TelemetryAction.swift
Expand Up @@ -40,6 +40,7 @@ enum TelemetryEventObject: String {
case settingsItemListSort = "settings_item_list_sort"
case settingsFaq = "settings_faq"
case settingsProvideFeedback = "settings_provide_feedback"
case settingsGetSupport = "settings_get_support"
case loginWelcome = "login_welcome"
case loginFxa = "login_fxa"
case loginOnboardingConfirmation = "login_onboarding_confirmation"
Expand Down
8 changes: 3 additions & 5 deletions lockbox-ios/Common/AppDelegate.swift
Expand Up @@ -16,8 +16,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

let keychainWrapper = KeychainWrapper.standard

func application(_ application: UIApplication, willFinishLaunchingWithOptions
launchOptions: [UIApplicationLaunchOptionsKey: Any]? = nil) -> Bool {
if !isRunningTest {
Expand Down Expand Up @@ -47,7 +45,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
if !firstRun {
self.checkForUpgrades()
}
keychainWrapper.set(Constant.app.appVersionCode, forKey: KeychainKey.appVersionCode.rawValue)
UserDefaults.standard.set(Constant.app.appVersionCode, forKey: UserDefaultKey.appVersionCode.rawValue)

let navBarImage = UIImage.createGradientImage(
frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height),
Expand All @@ -67,7 +65,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

UITextField.appearance().tintColor = .black

setupAdjust()

Dispatcher.shared.dispatch(action: LifecycleAction.startup)
Expand Down Expand Up @@ -97,7 +95,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
extension AppDelegate {
func checkForUpgrades() {
let current = Constant.app.appVersionCode
let previous = keychainWrapper.integer(forKey: KeychainKey.appVersionCode.rawValue) ?? 1
let previous = UserDefaults.standard.integer(forKey: UserDefaultKey.appVersionCode.rawValue)

if previous < current {
// At the moment, this can be quite simple, since we don't have many migrations,
Expand Down
39 changes: 39 additions & 0 deletions lockbox-ios/Common/Helpers/SentryManager.swift
@@ -0,0 +1,39 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import Foundation
import Sentry

class Sentry {
private let SentryDSNKey = "SentryDSN"

public static let shared = Sentry()

init() {
}

func setup(sendUsageData: Bool) {
if isSimulator() || !sendUsageData {
return
}

guard let dsn = Bundle.main.object(forInfoDictionaryKey: SentryDSNKey) as? String, !dsn.isEmpty else {
return
}

do {
Client.shared = try Client(dsn: dsn)
try Client.shared?.startCrashHandler()

// https://docs.sentry.io/clients/cocoa/advanced/#breadcrumbs
Client.shared?.enableAutomaticBreadcrumbTracking()
} catch let error {
print("\(error)")
}
}

private func isSimulator() -> Bool {
return ProcessInfo.processInfo.environment["SIMULATOR_ROOT"] != nil
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions lockbox-ios/Common/Resources/Constants.swift
Expand Up @@ -13,6 +13,7 @@ struct Constant {
static let faqURL = "https://lockbox.firefox.com/faq.html"
static let privacyURL = "https://lockbox.firefox.com/privacy.html"
static let provideFeedbackURL = "https://qsurvey.mozilla.com/s3/Lockbox-Input?ver=\(appVersion ?? "1.1")"
static let getSupportURL = "https://discourse.mozilla.org/c/test-pilot/lockbox"
static let useLockboxFAQ = faqURL + "#how-do-i-use-firefox-lockbox"
static let enableSyncFAQ = faqURL + "#how-do-i-enable-sync-on-firefox"
static let editExistingEntriesFAQ = faqURL + "#how-do-i-edit-existing-entries"
Expand Down Expand Up @@ -73,6 +74,7 @@ struct Constant {
static let settingsConfigurationSectionHeader = NSLocalizedString("settings.configuration.header", value: "CONFIGURATION", comment: "Configuration label in settings")
static let settingsTitle = NSLocalizedString("settings.title", value: "Settings", comment: "Title on settings screen")
static let settingsProvideFeedback = NSLocalizedString("settings.provideFeedback", value: "Send Feedback", comment: "Send feedback option in settings")
static let settingsGetSupport = NSLocalizedString("settings.getSupport", value: "Ask a Question", comment: "Support link to Discourse discussion forum")
static let faq = NSLocalizedString("settings.faq", value: "FAQ", comment: "FAQ option in settings")
static let settingsAccount = NSLocalizedString("settings.account", value: "Account", comment: "Account option in settings")
static let settingsAutoLock = NSLocalizedString("settings.autoLock", value: "Auto Lock", comment: "Auto Lock option in settings")
Expand Down
2 changes: 2 additions & 0 deletions lockbox-ios/Common/Resources/Info.plist
Expand Up @@ -33,6 +33,8 @@
<string>$(DEVELOPMENT_TEAM)</string>
<key>NSFaceIDUsageDescription</key>
<string>Firefox Lockbox will use Face ID to sign you in to the app.</string>
<key>SentryDSN</key>
<string>$(SENTRY_DSN)</string>
<key>UIAppFonts</key>
<array>
<string>FiraSans-Bold.ttf</string>
Expand Down
14 changes: 13 additions & 1 deletion lockbox-ios/Presenter/RootPresenter.swift
Expand Up @@ -51,6 +51,7 @@ class RootPresenter {
fileprivate let lifecycleStore: LifecycleStore
fileprivate let telemetryActionHandler: TelemetryActionHandler
fileprivate let biometryManager: BiometryManager
fileprivate let sentryManager: Sentry

var fxa: FirefoxAccount?

Expand All @@ -63,7 +64,8 @@ class RootPresenter {
userDefaultStore: UserDefaultStore = .shared,
lifecycleStore: LifecycleStore = .shared,
telemetryActionHandler: TelemetryActionHandler = TelemetryActionHandler.shared,
biometryManager: BiometryManager = BiometryManager()
biometryManager: BiometryManager = BiometryManager(),
sentryManager: Sentry = Sentry.shared
) {
self.view = view
self.dispatcher = dispatcher
Expand All @@ -75,6 +77,7 @@ class RootPresenter {
self.lifecycleStore = lifecycleStore
self.telemetryActionHandler = telemetryActionHandler
self.biometryManager = biometryManager
self.sentryManager = sentryManager

// todo: update tests with populated oauth and profile info
Observable.combineLatest(self.accountStore.oauthInfo, self.accountStore.profile)
Expand Down Expand Up @@ -120,6 +123,7 @@ class RootPresenter {
self.dispatcher.dispatch(action: OnboardingStatusAction(onboardingInProgress: false))
self.startTelemetry()
self.startAdjust()
self.startSentry()
}

func onViewReady() {
Expand Down Expand Up @@ -281,4 +285,12 @@ extension RootPresenter {
Adjust.setEnabled(enabled)
}).disposed(by: self.disposeBag)
}

fileprivate func startSentry() {
self.userDefaultStore.recordUsageData
.take(1)
.subscribe(onNext: { enabled in
self.sentryManager.setup(sendUsageData: enabled)
}).disposed(by: self.disposeBag)
}
}
7 changes: 7 additions & 0 deletions lockbox-ios/Presenter/SettingListPresenter.swift
Expand Up @@ -70,6 +70,13 @@ class SettingListPresenter {
title: Constant.string.settingsProvideFeedback,
returnRoute: SettingRouteAction.list),
accessibilityId: "sendFeedbackSettingOption"),
SettingCellConfiguration(
text: Constant.string.settingsGetSupport,
routeAction: ExternalWebsiteRouteAction(
urlString: Constant.app.getSupportURL,
title: Constant.string.settingsGetSupport,
returnRoute: SettingRouteAction.list),
accessibilityId: "getSupportSettingOption"),
SettingCellConfiguration(
text: Constant.string.faq,
routeAction: ExternalWebsiteRouteAction(
Expand Down
4 changes: 2 additions & 2 deletions lockbox-ios/Store/AccountStore.swift
Expand Up @@ -12,9 +12,9 @@ import WebKit
enum KeychainKey: String {
// note: these additional keys are holdovers from the previous Lockbox-owned style of
// authentication
case email, displayName, avatarURL, accountJSON, appVersionCode
case email, displayName, avatarURL, accountJSON

static let allValues: [KeychainKey] = [.accountJSON, .email, .displayName, .avatarURL, .appVersionCode]
static let allValues: [KeychainKey] = [.accountJSON, .email, .displayName, .avatarURL]
}

class AccountStore {
Expand Down

0 comments on commit 04115ba

Please sign in to comment.