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

feat: Enhance the UIViewController breadcrumbs with more data #1945

Merged
merged 24 commits into from Jul 13, 2022

Conversation

kevinrenskers
Copy link
Contributor

@kevinrenskers kevinrenskers commented Jul 6, 2022

📜 Description

We're adding more UIViewController information in the viewDidAppear breadcrumbs.

  • title
  • beingPresented
  • presentingViewController
  • parentViewController
  • window info, including if this is the window's rootViewController, if the window if the key window, the window's level

💡 Motivation and Context

Closes #1727

Screen Shot 2022-07-07 at 11 04 37

💚 How did you test it?

By running the iOS-Swift sample app.

📝 Checklist

  • I reviewed the submitted code
  • I added tests to verify the changes
  • I updated the docs if needed
  • Review from the native team if needed
  • No breaking changes

🔮 Next steps

@github-actions
Copy link

github-actions bot commented Jul 6, 2022

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 0df8b25

@kevinrenskers
Copy link
Contributor Author

kevinrenskers commented Jul 7, 2022

Question: how would we add unit tests for all these properties? Like the window, presentingViewController, beingPresented, etc. Does it make sense to create such a view hierarchy in a unit test? Can we even add a presentingViewController in the first place?

kevinrenskers and others added 6 commits July 7, 2022 11:36
* master:
  build: Remove trailing-whitespace (#1953)
  ci: Compile iOS13-Swift sample (#1951)
  release: 7.20.0
  meta: Fix changelog (#1950)
  feat: Add sample rate in the baggage header, remove Userid and Transaction (#1936)
  build: Upate Brewfile.lock and Gemfile.lock (#1947)
@kevinrenskers kevinrenskers marked this pull request as ready for review July 8, 2022 10:33
@brustolin
Copy link
Contributor

Question: how would we add unit tests for all these properties? Like the window, presentingViewController, beingPresented, etc. Does it make sense to create such a view hierarchy in a unit test? Can we even add a presentingViewController in the first place?

I find it odd to test this with unit tests, maybe we could test this with an UITest.
Create a viewController with a UILAbel that displays the breadcrumbs, this way you can assert the label content. Or something like this.

@kevinrenskers
Copy link
Contributor Author

Isn't that overkill just to test beingPresented, presentingViewController, and the window stuff? Do we even have UITests in place at the moment? But yeah not sure how else to test it either :/

@brustolin
Copy link
Contributor

Isn't that overkill just to test beingPresented, presentingViewController, and the window stuff? Do we even have UITests in place at the moment? But yeah not sure how else to test it either :/

Yes, we have UI tests. You can find them at iOS-SwiftUITests project.
Since it's a pretty easy test to create, I wouldn't consider it an overkill.
We need to test is somehow, and it looks like unit tests are not the way to go.

@kevinrenskers
Copy link
Contributor Author

Ah, I missed those. Will dig in!

Copy link
Contributor

@brustolin brustolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just need to take a look at CI.
Looks like Sauce Labs have a problem, but there is other tests failing.

@kevinrenskers
Copy link
Contributor Author

The iOS tests failed because of testMultipleListeners again, which should hopefully be solved if we merge master into this branch. It's unrelated to this feature.

@brustolin
Copy link
Contributor

The iOS tests failed because of testMultipleListeners again, which should hopefully be solved if we merge master into this branch. It's unrelated to this feature.

There is also Build / Sample iOS13-Swift action failing

@kevinrenskers
Copy link
Contributor Author

Good point, that's fixed now.

* master:
  feat: Add a new enableAutoBreadcrumbTracking option (#1958)
  fix: Don't send error 429 as network_error (#1957)
  build: Format code only on specific files (#1956)
  Update SentryANRTrackerTests.swift (#1955)
@kevinrenskers
Copy link
Contributor Author

LGTM. Just need to take a look at CI.
Looks like Sauce Labs have a problem, but there is other tests failing.

Can someone take that look at CI? I don't know what's going on there. It's not the test itself that's failing but the whole build itself?

@brustolin
Copy link
Contributor

LGTM. Just need to take a look at CI.
Looks like Sauce Labs have a problem, but there is other tests failing.

Can someone take that look at CI? I don't know what's going on there. It's not the test itself that's failing but the whole build itself?

It is complaining that you added 'import Combine' in ViewController.swift. Do you really need this?

@kevinrenskers
Copy link
Contributor Author

Ah! Good find. Nah, at first I wanted to use Combine to observe changes in the breadcrumbs, but since the sample app runs on iOS 9 (🤯) that didn't work. Forgot to remove the import though.

@kevinrenskers
Copy link
Contributor Author

kevinrenskers commented Jul 12, 2022

Now I'm getting actual test failures in CI, while they complete just fine locally. "Home Screen doesn't exist" - completely unrelated to my changes.

@brustolin
Copy link
Contributor

Now I'm getting actual test failures in CI, while they complete just fine locally. "Home Screen doesn't exist" - completely unrelated to my changes.

Im under the impression Sauce Labs is messing with something.
@philipphofmann Do you have any idea what's happening?

@philipphofmann
Copy link
Member

Im under the impression Sauce Labs is messing with something.
@philipphofmann Do you have any idea what's happening?

After looking at the test logs from SauceLabs, I don't think that SauceLabs is the problem, but rather our tests or the new functionality breaks something.

@kevinrenskers
Copy link
Contributor Author

Some test say that they can't even find the home screen anymore, which it checks by looking for captureMessageButton. And I've not done anything to the existing views 🤔

In another run the newly added test fails. I think it's because of the other that the notifications come in: sometimes the one from the navigation controller comes after the view controller, and thus the message we're checking for doesn't match. This is such a wonky way to test this functionality. But I think I may have fixed the problem by simply checking the breadcrumb before setting the label.

Still, not sure what to do about the ones that fail to even find the home screen.

* master:
  ref: Mark options.sdkInfo as deprecated (#1960)
  feat: Add extra app start span (#1952)
@kevinrenskers
Copy link
Contributor Author

Hooray, tests pass!

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could simplify the UITest a bit.

Samples/iOS-Swift/iOS-Swift/AppDelegate.swift Outdated Show resolved Hide resolved
@@ -20,6 +20,12 @@ class LaunchUITests: XCTestCase {
super.tearDown()
}

func testBreadcrumbData() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding a UITest.

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 💯 @kevinrenskers.

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ups, should be LGTM.

@brustolin
Copy link
Contributor

Just need to fix this:

/sentry-cocoa/Samples/iOS-Swift/iOS-Swift/ViewController.swift:61:46: error: Force Cast Violation: Force casts should be avoided. (force_cast)
/sentry-cocoa/Samples/iOS-Swift/iOS-Swift/ViewController.swift:63:43: error: Force Cast Violation: Force casts should be avoided. (force_cast)
/sentry-cocoa/Samples/iOS-Swift/iOS-Swift/ViewController.swift:62:41: error: Force Unwrapping Violation: Force unwrapping should be avoided. (force_unwrapping)

@kevinrenskers
Copy link
Contributor Author

Just need to fix this:

/sentry-cocoa/Samples/iOS-Swift/iOS-Swift/ViewController.swift:61:46: error: Force Cast Violation: Force casts should be avoided. (force_cast)
/sentry-cocoa/Samples/iOS-Swift/iOS-Swift/ViewController.swift:63:43: error: Force Cast Violation: Force casts should be avoided. (force_cast)
/sentry-cocoa/Samples/iOS-Swift/iOS-Swift/ViewController.swift:62:41: error: Force Unwrapping Violation: Force unwrapping should be avoided. (force_unwrapping)

Too bad we're not getting these warnings within Xcode itself by integrating SwiftLint there as a build step :(

@kevinrenskers kevinrenskers merged commit e65226c into master Jul 13, 2022
@kevinrenskers kevinrenskers deleted the feat/extra-controller-breadcrumb-data branch July 13, 2022 11:06
kevinrenskers added a commit that referenced this pull request Jul 14, 2022
* master:
  ci: Don't run benchmarks on release (#1971)
  Don't track OOMs for simulators (#1970)
  feat: Automatic nest new spans with the ui life cycle function (#1959)
  docs: update some docs/comments to read a little better (#1966)
  ci: benchmarking updates (#1926)
  feat: upload list of slow/frozen rendered frame timestamps during a profile (#1910)
  feat: Enhance the UIViewController breadcrumbs with more data (#1945)

# Conflicts:
#	Sources/SentryCrash/Recording/Monitors/SentryCrashMonitor_System.h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

More information for UIViewController breadcrumbs
4 participants