Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a crash experienced when trying to report a crash. #3086

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ElementX/Sources/Application/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
notificationManager = NotificationManager(notificationCenter: UNUserNotificationCenter.current(),
appSettings: appSettings)

Self.setupSentry(appSettings: appSettings)

Self.setupServiceLocator(appSettings: appSettings, appHooks: appHooks)
Self.setupSentry(appSettings: appSettings)

ServiceLocator.shared.analytics.signpost.start()
ServiceLocator.shared.analytics.startIfEnabled()

windowManager.delegate = self
Expand Down
19 changes: 12 additions & 7 deletions ElementX/Sources/Services/Analytics/Signposter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,14 @@ class Signposter {
static let subsystem = "ElementX"
static let category = "PerformanceTests"

private var appStartupTransaction: Span
// MARK: - App Startup

init() {
private var appStartupTransaction: Span?

// We have a manual start method because we need to configure the ServiceLocator *before* we configure
// Sentry but this class is created in the AnalyticsService and so spans and transactions are dropped
// until Sentry has been configured. Therefore doing this in the init doesn't work.
func start() {
appStartupTransaction = SentrySDK.startTransaction(name: Name.appStartup, operation: Name.appStarted)
}

Expand All @@ -55,7 +60,7 @@ class Signposter {
func beginLogin() {
loginState = signposter.beginInterval(Name.login)
loginTransaction = SentrySDK.startTransaction(name: "\(Name.login)", operation: "\(Name.login)")
loginSpan = appStartupTransaction.startChild(operation: "\(Name.login)", description: "\(Name.login)")
loginSpan = appStartupTransaction?.startChild(operation: "\(Name.login)", description: "\(Name.login)")
}

func endLogin() {
Expand All @@ -80,14 +85,14 @@ class Signposter {
private var firstSyncSpan: Span?

func beginFirstSync(serverName: String) {
appStartupTransaction.setTag(value: serverName, key: Name.homeserver)
appStartupTransaction?.setTag(value: serverName, key: Name.homeserver)

firstSyncState = signposter.beginInterval(Name.firstSync)

firstSyncTransaction = SentrySDK.startTransaction(name: "\(Name.firstSync)", operation: "\(Name.firstSync)")
firstSyncTransaction?.setTag(value: serverName, key: Name.homeserver)

firstSyncSpan = appStartupTransaction.startChild(operation: "\(Name.firstSync)", description: "\(Name.firstSync)")
firstSyncSpan = appStartupTransaction?.startChild(operation: "\(Name.firstSync)", description: "\(Name.firstSync)")
}

func endFirstSync() {
Expand All @@ -111,12 +116,12 @@ class Signposter {
func beginFirstRooms() {
firstRoomsState = signposter.beginInterval(Name.firstRooms)
firstRoomsTransaction = SentrySDK.startTransaction(name: "\(Name.firstRooms)", operation: "\(Name.firstRooms)")
firstRoomsSpan = appStartupTransaction.startChild(operation: "\(Name.firstRooms)", description: "\(Name.firstRooms)")
firstRoomsSpan = appStartupTransaction?.startChild(operation: "\(Name.firstRooms)", description: "\(Name.firstRooms)")
}

func endFirstRooms() {
defer {
appStartupTransaction.finish()
appStartupTransaction?.finish()
}

guard let firstRoomsState else { return }
Expand Down
Loading