forked from Electric-Coin-Company/zashi-ios
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add crash reporter to secant (Electric-Coin-Company#531)
* [Electric-Coin-Company#525] Adds functions to configure, testCrash and check if it can start. This adds a build phase where a dummy file is added to the project to make the build and Plist copy happy. When building in the CI there will be a script to replace this Plist file with the real one that then will be copied to the bundle Crashlytics will be "off" by default and then be turned on when starting up to be an Opt-Out thing. This is the only way it can be turned off later. reference: https://firebase.google.com/docs/crashlytics/customize-crash-reports?platform=ios#enable_opt-in_reporting The app will start with crash reporting turned off and will set it up on by default on the application's code. Then if the user wants to opt-out of crash reporting, it can. Otherwise, it won't be possible. Adds opting out of crash reporting as a stored user preference. This adds a value inside UserPreferencesStorage and its live and mock counterparts. also creates a builer for `CrashReporterClient` that has a Dependency to `@Dependency(\.userStoredPreferences)` and sets the references for the client to set the appropriate values into the user storage `UserPreferencesStorage` as been adapted to be a TCA Dependency. `SettingsStore` now as a `Toogle()` to turn off and on crash reporting. But it doesn't work yet because I haven't found out how to make a TCA Binding that can rely on an initial value that is not hardcoded but injected from somewhere else. See https://www.pointfree.co/episodes/ep158-safer-conciser-forms-part-1 https://www.pointfree.co/episodes/ep158-safer-conciser-forms-part-2 Adds Test Crash button and enable crash reporting Adds upload-symbols run script phase Closes Electric-Coin-Company#525 Add a custom build environment variable "UPLOAD_CRASHLYTICS_SYMBOLS" that will let Xcode skip the upload_symbols script for debug builds Fix Initialization tests * bump build
- Loading branch information
Francisco Gindre
authored
Feb 15, 2023
1 parent
f946de1
commit 26dd0ea
Showing
18 changed files
with
487 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
secant/Dependencies/CrashReporter/CrashReporterLiveKey.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// CrashReporterLiveKey.swift | ||
// secant-testnet | ||
// | ||
// Created by Francisco Gindre on 2/2/23. | ||
// | ||
import ComposableArchitecture | ||
import FirebaseCore | ||
import FirebaseCrashlytics | ||
extension CrashReporterClient: DependencyKey { | ||
static let liveValue: CrashReporterClient = CrashReporterClient( | ||
configure: { canConfigure in | ||
let fileName = "GoogleService-Info.plist" | ||
|
||
// checks whether the crash reporter's config file is a dummy_file purposedly placed by the build job or the real one. | ||
// this does not check the integrity of the Plist file for Firebase. | ||
// that's a problem for the library itself. | ||
guard | ||
let configFile = Bundle.main.url(forResource: fileName, withExtension: nil), | ||
let properties = NSDictionary(contentsOf: configFile), | ||
properties["IS_DUMMY_FILE"] == nil, | ||
canConfigure | ||
else { | ||
return | ||
} | ||
|
||
FirebaseApp.configure() | ||
Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(true) | ||
}, | ||
testCrash: { | ||
fatalError("Crash was triggered to test the crash reporter") | ||
}, | ||
optIn: { | ||
Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(true) | ||
}, | ||
optOut: { | ||
Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(false) | ||
|
||
} | ||
) | ||
} |
16 changes: 16 additions & 0 deletions
16
secant/Dependencies/CrashReporter/CrashReporterTestKey.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// CrashReporterTestKey.swift | ||
// secant-testnet | ||
// | ||
// Created by Francisco Gindre on 2/2/23. | ||
// | ||
|
||
import ComposableArchitecture | ||
extension CrashReporterClient: TestDependencyKey { | ||
static let testValue: CrashReporterClient = CrashReporterClient( | ||
configure: { _ in }, | ||
testCrash: {}, | ||
optIn: {}, | ||
optOut: {} | ||
) | ||
} |
31 changes: 31 additions & 0 deletions
31
secant/Dependencies/CrashReporter/CrashReportingInterface.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// CrashReportingInterface.swift | ||
// secant-testnet | ||
// | ||
// Created by Francisco Gindre on 2/2/23. | ||
// | ||
import ComposableArchitecture | ||
import Foundation | ||
|
||
extension DependencyValues { | ||
var crashReporter: CrashReporterClient { | ||
get { self[CrashReporterClient.self] } | ||
set { self[CrashReporterClient.self] = newValue } | ||
} | ||
} | ||
|
||
struct CrashReporterClient { | ||
/// Configures the crash reporter if possible. | ||
/// if it can't be configured this will fail silently | ||
var configure: (Bool) -> Void | ||
|
||
/// this will test the crash reporter | ||
/// - Note: depending of the crash reporter this may or may not crash your app. | ||
var testCrash: () -> Void | ||
|
||
/// this will tell the crash reporter that the user a has decided to opt-in crash reporting | ||
var optIn: () -> Void | ||
|
||
/// this will tell the crash reporter that the user has decided to opt-out of crash reporting | ||
var optOut: () -> Void | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
secant/Dependencies/UserPreferencesStorage/UserPreferencesStorageInterface.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// UserPreferencesStorageInterface.swift | ||
// secant-testnet | ||
// | ||
// Created by Francisco Gindre on 2/6/23. | ||
// | ||
|
||
import Foundation | ||
import ComposableArchitecture | ||
|
||
extension DependencyValues { | ||
var userStoredPreferences: UserPreferencesStorageClient { | ||
get { self [UserPreferencesStorageClient.self] } | ||
set { self[UserPreferencesStorageClient.self] = newValue } | ||
} | ||
} | ||
|
||
struct UserPreferencesStorageClient { | ||
var activeAppSessionFrom: () -> TimeInterval | ||
var setActiveAppSessionFrom: (TimeInterval) async -> Void | ||
|
||
var currency: () -> String | ||
var setCurrenty: (String) async -> Void | ||
|
||
var isFiatConverted: () -> Bool | ||
var setIsFiatConverted: (Bool) async -> Void | ||
|
||
var isRecoveryPhraseTestCompleted: () -> Bool | ||
var setIsRecoveryPhraseTestCompleted: (Bool) async -> Void | ||
|
||
var isSessionAutoshielded: () -> Bool | ||
var setIsSessionAutoshielded: (Bool) async -> Void | ||
|
||
var isUserOptedOutOfCrashReporting: () -> Bool | ||
var setIsUserOptedOutOfCrashReporting: (Bool) async -> Void | ||
|
||
var removeAll: () async -> Void | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.