-
-
Notifications
You must be signed in to change notification settings - Fork 372
Flush Logs on WillTerminate or WillResignActive Notifications
#6909
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
Merged
+319
−26
Merged
Changes from 29 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
be66378
Flush logs when app terminates or resigns active
denrase fd55fdf
Merge branch 'main' into feat/flush-logs-on-app-state-change
denrase 115a625
fix deadlock issue
denrase 71f478e
Merge branch 'main' into feat/flush-logs-on-app-state-change
denrase 162273e
rename group name
denrase 3f4813d
move into existing confitional block
denrase aa1fbc9
Use dispatch_queue_set_specific/dispatch_get_specific to get corrrect…
denrase 6cdd1b0
cleanup queu specific key
denrase 8e36044
check client for nil
denrase d502009
Merge branch 'main' into feat/flush-logs-on-app-state-change
denrase d22d16e
Listen to notifications directly in integration
denrase 539d652
move integration to swift class
denrase e214d5e
use dedicated queue for log batcher
denrase b493f18
Merge branch 'main' into feat/flush-logs-on-app-state-change
denrase 13de622
update
denrase e270fa1
cleanup
denrase 19df878
cleanup
denrase 0f74c74
Merge branch 'main' into feat/flush-logs-on-app-state-change
denrase 6daca9e
Merge branch 'main' into feat/flush-logs-on-app-state-change
denrase e3f2df8
update cl
denrase dd00065
fix build issue :facepalm
denrase f2e5b8b
update changelog
denrase f9a7ed8
Merge branch 'main' into feat/flush-logs-on-app-state-change
philprime d828f69
remove kIntegrationOptionEnableLogs
denrase 3b22387
use dsnForTestCase
denrase 0682b5b
update test setup
denrase fda13c2
Call with QOS_CLASS_DEFAULT instead of DISPATCH_QUEUE_PRIORITY_DEFAULT
denrase 2edc82f
Merge branch 'main' into feat/flush-logs-on-app-state-change
denrase 7a57e7a
fix incorrect import of NSApplication in macCatalyst environments
denrase 8c0be55
Merge branch 'main' into feat/flush-logs-on-app-state-change
denrase 5b10643
Let the batcher create it’s own serial default queue
denrase 4349653
add sdk debug message
denrase 97b6ff7
remove fixture
denrase dd6fb88
dont call clearTestState
denrase bf0d498
don’t use SentryDependencyContainer.sharedInstance
denrase 7184c36
revert changes in session tracker
denrase File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
File renamed without changes.
File renamed without changes.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,82 @@ | ||
| @_implementationOnly import _SentryPrivate | ||
|
|
||
| #if (os(iOS) || os(tvOS) || (swift(>=5.9) && os(visionOS))) && !SENTRY_NO_UIKIT | ||
| import UIKit | ||
| private typealias CrossPlatformApplication = UIApplication | ||
| #elseif os(macOS) | ||
| import AppKit | ||
| private typealias CrossPlatformApplication = NSApplication | ||
| #endif | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| #if ((os(iOS) || os(tvOS) || (swift(>=5.9) && os(visionOS))) && !SENTRY_NO_UIKIT) || os(macOS) | ||
|
|
||
| protocol NotificationCenterProvider { | ||
| var notificationCenterWrapper: SentryNSNotificationCenterWrapper { get } | ||
| } | ||
|
|
||
| final class FlushLogsIntegration<Dependencies: NotificationCenterProvider>: NSObject, SwiftIntegration { | ||
denrase marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| private let notificationCenter: SentryNSNotificationCenterWrapper | ||
|
|
||
| init?(with options: Options, dependencies: Dependencies) { | ||
| guard options.enableLogs else { | ||
| return nil | ||
| } | ||
|
|
||
| self.notificationCenter = dependencies.notificationCenterWrapper | ||
|
|
||
| super.init() | ||
|
|
||
| notificationCenter.addObserver( | ||
| self, | ||
| selector: #selector(willResignActive), | ||
| name: CrossPlatformApplication.willResignActiveNotification, | ||
| object: nil | ||
| ) | ||
|
|
||
| notificationCenter.addObserver( | ||
| self, | ||
| selector: #selector(willTerminate), | ||
| name: CrossPlatformApplication.willTerminateNotification, | ||
| object: nil | ||
| ) | ||
| } | ||
|
|
||
| func uninstall() { | ||
| notificationCenter.removeObserver( | ||
| self, | ||
| name: CrossPlatformApplication.willResignActiveNotification, | ||
| object: nil | ||
| ) | ||
|
|
||
| notificationCenter.removeObserver( | ||
| self, | ||
| name: CrossPlatformApplication.willTerminateNotification, | ||
| object: nil | ||
| ) | ||
| } | ||
|
|
||
| deinit { | ||
| uninstall() | ||
| } | ||
|
|
||
| @objc private func willResignActive() { | ||
| guard let client = SentrySDKInternal.currentHub().getClient() else { | ||
| return | ||
denrase marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| client.captureLogs() | ||
| } | ||
|
|
||
| @objc private func willTerminate() { | ||
| guard let client = SentrySDKInternal.currentHub().getClient() else { | ||
| return | ||
| } | ||
| client.captureLogs() | ||
| } | ||
|
|
||
| static var name: String { | ||
| "FlushLogsIntegration" | ||
| } | ||
| } | ||
|
|
||
| #endif | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.