diff --git a/Code/Supporting Files/Info.plist b/Code/Supporting Files/Info.plist
index a0243c2a..0af61fe8 100644
--- a/Code/Supporting Files/Info.plist
+++ b/Code/Supporting Files/Info.plist
@@ -80,5 +80,15 @@
UIUserInterfaceStyle
Dark
+ mixpanel
+
+ apiKey
+ >$(MIXPANEL)
+
+ bugsnag
+
+ apiKey
+ >$(BUGSNAG)
+
diff --git a/Code/Utilities/Analytics.swift b/Code/Utilities/Analytics.swift
index 5e22888b..131d5dd3 100644
--- a/Code/Utilities/Analytics.swift
+++ b/Code/Utilities/Analytics.swift
@@ -15,18 +15,19 @@ typealias AnalyticsValue = MixpanelType
enum Analytics {
- private static var isRegistered: Bool = false
-
static func initialize() {
FirebaseApp.app()?.isDataCollectionDefaultEnabled = true
Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(true)
- if let apiKey = Environment.variable(.mixpanel) {
+ if
+ let plist = Bundle.main.infoDictionary,
+ let mixpanel = plist["mixpanel"] as? [String: String],
+ let apiKey = mixpanel["apiKey"]
+ {
Mixpanel.initialize(token: apiKey)
- isRegistered = true
- trace(.success, components: "Starting Mixpanel...")
+ trace(.success, components: "Initializing Mixpanel...")
} else {
- trace(.failure, components: "Failed to start Mixpanel. No API key provided in the '\(Environment.Variable.mixpanel.rawValue)' env variable.")
+ trace(.failure, components: "Failed to initialize Mixpanel. No API key found in Info.plist")
}
}
@@ -46,7 +47,6 @@ enum Analytics {
}
private static func track(_ name: String, properties: [String: AnalyticsValue]? = nil) {
- guard isRegistered else { return }
mixpanel.track(event: name, properties: properties)
}
}
diff --git a/Code/Utilities/ErrorReporting.swift b/Code/Utilities/ErrorReporting.swift
index 22b9f995..c3fae84a 100644
--- a/Code/Utilities/ErrorReporting.swift
+++ b/Code/Utilities/ErrorReporting.swift
@@ -11,21 +11,11 @@ import CodeServices
enum ErrorReporting {
- private static var isRegistered: Bool = false
-
static func initialize() {
- if let apiKey = Environment.variable(.bugsnag) {
- Bugsnag.start(withApiKey: apiKey)
- isRegistered = true
- trace(.success, components: "Starting Bugsnag...")
- } else {
- trace(.failure, components: "Failed to start BugSnag. No API key provided in the '\(Environment.Variable.bugsnag.rawValue)' env variable.")
- }
+ Bugsnag.start()
}
static func breadcrumb(_ breadcrumb: Breadcrumb) {
- guard isRegistered else { return }
-
Bugsnag.leaveBreadcrumb(withMessage: breadcrumb.rawValue)
}
@@ -53,8 +43,6 @@ enum ErrorReporting {
}
private static func capture(_ error: Swift.Error, reason: String? = nil, file: String = #file, function: String = #function, line: Int = #line, buildUserInfo: (inout [String: Any]) -> Void) {
- guard isRegistered else { return }
-
let swiftError = error as NSError
var userInfo: [String: Any] = [:]