Set up Analytics to track data per session (#780)

This commit is contained in:
Nicolas Mauri
2023-04-18 09:33:32 +02:00
committed by GitHub
parent d01349a60e
commit 5b7ec6c9e2
58 changed files with 953 additions and 375 deletions
@@ -39,13 +39,27 @@ class BugReportService: NSObject, BugReportServiceProtocol {
self.session = session
super.init()
// enable SentrySDK
// set build version for logger
MXLogger.buildVersion = InfoPlistReader.main.bundleShortVersionString
}
// MARK: - BugReportServiceProtocol
var isRunning: Bool {
SentrySDK.isEnabled
}
var crashedLastRun: Bool {
SentrySDK.crashedLastRun
}
func start() {
guard !isRunning else { return }
SentrySDK.start { options in
#if DEBUG
options.enabled = false
#endif
options.dsn = sentryURL.absoluteString
options.dsn = self.sentryURL.absoluteString
// Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
// We recommend adjusting this value in production.
@@ -61,19 +75,22 @@ class BugReportService: NSObject, BugReportServiceProtocol {
self?.lastCrashEventId = event.eventId.sentryIdString
}
}
// also enable logging crashes, to send them with bug reports
MXLogger.logCrashes(true)
// set build version for logger
MXLogger.buildVersion = InfoPlistReader.main.bundleShortVersionString
MXLog.info("Started.")
}
// MARK: - BugReportServiceProtocol
var crashedLastRun: Bool {
SentrySDK.crashedLastRun
func stop() {
guard isRunning else { return }
SentrySDK.close()
MXLogger.logCrashes(false)
MXLog.info("Stopped.")
}
func reset() {
lastCrashEventId = nil
MXLog.info("Reset.")
}
func crash() {
SentrySDK.crash()
}
@@ -33,10 +33,18 @@ struct SubmitBugReportResponse: Decodable {
// sourcery: AutoMockable
protocol BugReportServiceProtocol {
var isRunning: Bool { get }
var crashedLastRun: Bool { get }
func start()
func stop()
func reset()
func crash()
func submitBugReport(_ bugReport: BugReport,
progressListener: ProgressListener?) async throws -> SubmitBugReportResponse
}