-
-
Notifications
You must be signed in to change notification settings - Fork 341
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Enhance the UIViewController breadcrumbs with more data (#1945)
We're adding more UIViewController information in the viewDidAppear breadcrumbs
- Loading branch information
1 parent
6ef0767
commit e65226c
Showing
9 changed files
with
87 additions
and
16 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
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
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ import UIKit | |
class AppDelegate: UIResponder, UIApplicationDelegate { | ||
|
||
var window: UIWindow? | ||
|
||
static let defaultDSN = "https://[email protected]/5428557" | ||
|
||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | ||
|
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
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 |
---|---|---|
|
@@ -7,6 +7,7 @@ class ViewController: UIViewController { | |
@IBOutlet weak var anrFullyBlockingButton: UIButton! | ||
@IBOutlet weak var anrFillingRunLoopButton: UIButton! | ||
@IBOutlet weak var framesLabel: UILabel! | ||
@IBOutlet weak var breadcrumbLabel: UILabel! | ||
|
||
private let dispatchQueue = DispatchQueue(label: "ViewController") | ||
|
||
|
@@ -18,6 +19,7 @@ class ViewController: UIViewController { | |
scope.setEnvironment("debug") | ||
scope.setTag(value: "swift", key: "language") | ||
scope.setExtra(value: String(describing: self), key: "currentViewController") | ||
|
||
let user = Sentry.User(userId: "1") | ||
user.email = "[email protected]" | ||
scope.setUser(user) | ||
|
@@ -28,8 +30,8 @@ class ViewController: UIViewController { | |
if let data = "hello".data(using: .utf8) { | ||
scope.add(Attachment(data: data, filename: "log.txt")) | ||
} | ||
|
||
} | ||
|
||
// Also works | ||
let user = Sentry.User(userId: "1") | ||
user.email = "[email protected]" | ||
|
@@ -43,7 +45,6 @@ class ViewController: UIViewController { | |
self.dsnTextField.backgroundColor = UIColor.systemGreen | ||
} | ||
} | ||
|
||
} | ||
|
||
override func viewDidAppear(_ animated: Bool) { | ||
|
@@ -54,6 +55,20 @@ class ViewController: UIViewController { | |
self.framesLabel?.text = "Frames Total:\(PrivateSentrySDKOnly.currentScreenFrames.total) Slow:\(PrivateSentrySDKOnly.currentScreenFrames.slow) Frozen:\(PrivateSentrySDKOnly.currentScreenFrames.frozen)" | ||
} | ||
} | ||
|
||
SentrySDK.configureScope { (scope) in | ||
let dict = scope.serialize() | ||
|
||
guard | ||
let crumbs = dict["breadcrumbs"] as? [[String: Any]], | ||
let breadcrumb = crumbs.last, | ||
let data = breadcrumb["data"] as? [String: String] | ||
else { | ||
return | ||
} | ||
|
||
self.breadcrumbLabel.text = "{ category: \(breadcrumb["category"] ?? "nil"), parentViewController: \(data["parentViewController"] ?? "nil"), beingPresented: \(data["beingPresented"] ?? "nil"), window_isKeyWindow: \(data["window_isKeyWindow"] ?? "nil"), is_window_rootViewController: \(data["is_window_rootViewController"] ?? "nil") }" | ||
} | ||
} | ||
|
||
@IBAction func addBreadcrumb(_ sender: Any) { | ||
|
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
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
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
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