Skip to content

Commit

Permalink
test: Fix reporting TTFD for Swift sample (#3385)
Browse files Browse the repository at this point in the history
Some UIViewControllers called report TTFD in onViewWillAppear,
which is before the UIViewController is shown. Now, we report
TTFD onViewDidAppear.

Co-authored-by: Andrew McKnight <andrew.mcknight@sentry.io>
  • Loading branch information
philipphofmann and armcknight committed Nov 8, 2023
1 parent 313b1d9 commit fdb003d
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 35 deletions.
6 changes: 3 additions & 3 deletions Samples/iOS-Swift/iOS-Swift/ErrorsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ class ErrorsViewController: UIViewController {
@IBOutlet weak var imageView: UIImageView!
private let dispatchQueue = DispatchQueue(label: "ErrorsViewController", attributes: .concurrent)
private let diskWriteException = DiskWriteException()

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
SentrySDK.reportFullyDisplayed()
}

Expand Down
5 changes: 2 additions & 3 deletions Samples/iOS-Swift/iOS-Swift/ExtraViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,11 @@ class ExtraViewController: UIViewController {
if let uiTestName = ProcessInfo.processInfo.environment["io.sentry.ui-test.test-name"] {
uiTestNameLabel.text = uiTestName
}

SentrySDK.reportFullyDisplayed()

Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true) { _ in
self.framesLabel?.text = "Frames Total:\(PrivateSentrySDKOnly.currentScreenFrames.total) Slow:\(PrivateSentrySDKOnly.currentScreenFrames.slow) Frozen:\(PrivateSentrySDKOnly.currentScreenFrames.frozen)"
}

SentrySDK.reportFullyDisplayed()
}

override func viewDidAppear(_ animated: Bool) {
Expand All @@ -55,6 +52,8 @@ class ExtraViewController: UIViewController {
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") }"

}

SentrySDK.reportFullyDisplayed()
}

@IBAction func dsnChanged(_ sender: UITextField) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class ProfilingViewController: UIViewController, UITextFieldDelegate {
$0?.delegate = self
}
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
SentrySDK.reportFullyDisplayed()
}

@IBAction func startBenchmark(_ sender: UIButton) {
highlightButton(sender)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ class InfoForBreadcrumbController: UIViewController {

@IBOutlet var button: UIButton!
@IBOutlet var label: UILabel!

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
SentrySDK.reportFullyDisplayed()
}

@IBAction func buttonPressed(_ sender: Any) {
guard let view = self.view,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,8 @@ class NibViewController: UIViewController {
UIAssert.checkForViewControllerLifeCycle(span, viewController: "NibViewController")
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
SentrySDK.reportFullyDisplayed()
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
SentrySDK.reportFullyDisplayed()
}

override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
}

override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ class PermissionsViewController: UIViewController {
locationManager.requestWhenInUseAuthorization()
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
SentrySDK.reportFullyDisplayed()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class SplitViewController: UISplitViewController {
initialize()
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
SentrySDK.reportFullyDisplayed()
}

Expand All @@ -25,13 +25,9 @@ class SplitViewController: UISplitViewController {
}

class SplitRootViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
SentrySDK.reportFullyDisplayed()
}

Expand Down Expand Up @@ -68,13 +64,9 @@ class SecondarySplitViewController: UIViewController {
spanObserver = createTransactionObserver(forCallback: assertTransaction)
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
SentrySDK.reportFullyDisplayed()
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
SentrySDK.reportFullyDisplayed()
}

func assertTransaction(span: Span) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class TableViewController: UITableViewController {
super.viewDidLoad()

spanObserver = createTransactionObserver(forCallback: assertTransaction)
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
SentrySDK.reportFullyDisplayed()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class UIEventBreadcrumbController: UIViewController {
self.lastBreadcrumbLabel.text = breadcrumb.message ?? "#EMPTY#"
}
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
SentrySDK.reportFullyDisplayed()
}

@objc func textFieldFocus(_ sender: Any) {
}
Expand Down

0 comments on commit fdb003d

Please sign in to comment.