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: Track timezone changes as breadcrumbs #1930
Conversation
|
This currently is very very simple: it just sends a breadcrumb with the action Also the issue says "Ideally we persist previous runs breadcrumbs so steps from a previous run can help diagnose issues related to time changing." but I am not sure what is meant by that. |
What would be important to you as a developer?
I added a comment #1763 (comment). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First glance. Thanks for tackling this, @kevinrenskers.
* master: release: 7.19.0
* master: build(deps): bump fastlane from 2.206.2 to 2.207.0 (#1937) fixing sample not compiling (#1935) style: Configure the root of the project to use four spaces for indentation (#1934) meta: Add LOGAF scale to Contributing (#1933) meta: Mention draft PRs in Contributing (#1932) meta: Add sut to contributing (#1931)
…ng instantiated when it's missing on disk
Provide a default value to deal with test crashes, until we can properly fix the tests
The feature works perfectly fine in the sample apps. Initially the timezone is nil, so we store it, no breadcrumb gets sent. From then on, every time the app starts it can detect timezone changes, and while the app is alive it'll also react to timezone changes, and sent breadcrumbs. However, the test is problematic. First of all, because updating the app state doesn't work when there is no app state stored on disk yet. And there are other weird things going on with the file manager and the app state manager. Dhiogo can say more about that I think. I made the test pass consistently by adding a default value in Also, this code only runs on iOS because the app state manager doesn't compile for macOS. Ideally this feature should work on macOS. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done, not bad for not using ObjC for 6 years 😁👏 . Let's have a chat about how to test this at our meeting today.
@@ -42,6 +43,8 @@ SENTRY_NO_INIT | |||
|
|||
@property (nonatomic, assign) BOOL isANROngoing; | |||
|
|||
@property (nonatomic, copy) NSNumber *_Nullable timezoneOffset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m
: We use three different data types. In the constructor, timezoneOffset
is NSTimeInterval
, here it is NSNumber
and [NSTimeZone localTimeZone].secondsFromGMT]
is NSInteger
. Can we please align these. I would suggest to use NSInteger
everywhere and renaming this to secondsFromGMT
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, the NSTimeInterval was from a different property I used for a while, that's easily changed to NSInteger.
But changing the NSNumber to NSInteger.. can NSInteger be null? I really need to refresh my knowledge of optionals in Obj-C 😅 I made it an NSNumber specifically because of the optionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and renaming this to secondsFromGMT
I think timezoneOffset
is a lot more clear. secondsFromGMT
doesn't really tell you that this about a timezone thing.
Tests/SentryTests/Integrations/Breadcrumbs/SentrySystemEventBreadcrumbsTest.swift
Outdated
Show resolved
Hide resolved
I would be fine with this tradeoff for now. |
Ok, got further along but The idea is that I want to clear the stored timezone offset (from the filemanager), so that we always start with a clean slate. Then our mocked current date provider will say the timezone offset is 0, we initialize the SentrySystemEventBreadcrumbs (which will write the offset to disk), then we change the offset to another number and post the notification. That all works in isolation, but not when running all the tests. Any ideas? |
d4e51ad
to
8ce9385
Compare
Tests are fixed, and more tests are added. I think this is ready for review now! |
Getting a random SentryANRTrackerTests failure in the Catalyst on Xcode 12 tests. |
Don't worry about these in this PR. It seems they are flaky and we should fix them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job, just a few missing tests for SentryFileManager.
Tests/SentryTests/Integrations/Breadcrumbs/SentrySystemEventBreadcrumbsTest.swift
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
📜 Description
When the timezone changes, the system sends a notification. We track this event as a breadcrumb.
💡 Motivation and Context
Close #1763
💚 How did you test it?
Unit test. Also ran the sample app, changed my device's timezone, and confirmed that a breadcrumb was posted to Sentry: https://sentry.io/organizations/sentry-sdks/issues/2895893229/?project=5428557#breadcrumbs
📝 Checklist
🔮 Next steps