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: Track timezone changes as breadcrumbs #1930

Merged
merged 34 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
cd2e0c0
feat: Add automatic timezone change reporting as a breadcrumb
kevinrenskers Jul 4, 2022
69c98c5
Add a test for the new breadcrumb
kevinrenskers Jul 4, 2022
b035930
Format code
getsentry-bot Jul 4, 2022
1434409
Add changelog entry
kevinrenskers Jul 4, 2022
1ecd302
Indent with 4 spaces for all source files
kevinrenskers Jul 4, 2022
543bedb
Fix testTimezoneChangeBreadcrumb by using the Swiftified name
kevinrenskers Jul 4, 2022
b90c52d
Actually fix the tests
kevinrenskers Jul 4, 2022
4112017
Improve the start method's logic, prevent duplicate call in case of iOS
kevinrenskers Jul 4, 2022
ab971ed
Undo indentation change, it'll be in a separate PR
kevinrenskers Jul 4, 2022
de3547d
Merge branch 'master' into feat/timezone-change-breadcrumbs
kevinrenskers Jul 4, 2022
81102cc
Feature complete, but test is flaky
kevinrenskers Jul 5, 2022
4118523
Format code
getsentry-bot Jul 5, 2022
57d86c1
Merge branch 'master' into feat/timezone-change-breadcrumbs
kevinrenskers Jul 5, 2022
694ed71
timezoneOffset is nullable and shouldn't stop SentryAppState from bei…
kevinrenskers Jul 5, 2022
9d5b0ac
Only run the code in iOS, because it doesn't compile for macOS
kevinrenskers Jul 5, 2022
82fe669
Format code
getsentry-bot Jul 5, 2022
f453208
Deal with timezoneOffset == nil
kevinrenskers Jul 5, 2022
8d13cd4
Commit first set of suggestions
kevinrenskers Jul 5, 2022
b83f59c
Format code
getsentry-bot Jul 5, 2022
1a4f01e
Add more tests
kevinrenskers Jul 5, 2022
a0b6087
It works, but tests need to be fixed
kevinrenskers Jul 5, 2022
cb42c7e
Format code
getsentry-bot Jul 5, 2022
6c7b428
Don't cache fileManager, as it can change when the hub changes
kevinrenskers Jul 5, 2022
9f9e79a
Use currentDateProvider
kevinrenskers Jul 5, 2022
c585e80
Format code
getsentry-bot Jul 5, 2022
f808338
Undo
kevinrenskers Jul 5, 2022
4f7edd3
Tests compile again
kevinrenskers Jul 5, 2022
97acf8d
Fix warning
kevinrenskers Jul 5, 2022
bc9d991
testTimezoneChangeBreadcrumb is still problematic
kevinrenskers Jul 5, 2022
8ce9385
Added more tests, and the whole suit runs successfully
kevinrenskers Jul 6, 2022
70b982e
Format code
getsentry-bot Jul 6, 2022
0ad0783
Add more filemanager tests
kevinrenskers Jul 6, 2022
0996314
Format code
getsentry-bot Jul 6, 2022
2571228
One more test
kevinrenskers Jul 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Add main thread ID to profiling payload (#1918)
- Add App Hangs tracking (#1906)
- Track timezone changes as breadcrumbs (#1930)
kevinrenskers marked this conversation as resolved.
Show resolved Hide resolved

### Fixes

Expand Down
6 changes: 6 additions & 0 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1583,7 +1583,9 @@
63AA75921EB8AEDB00D153DE /* Tests */,
7D826E3C2390840E00EED93D /* Utils */,
);
indentWidth = 4;
philipphofmann marked this conversation as resolved.
Show resolved Hide resolved
sourceTree = "<group>";
tabWidth = 4;
};
6327C5D41EB8A783004E799B /* Products */ = {
isa = PBXGroup;
Expand Down Expand Up @@ -1718,8 +1720,10 @@
63FE6FB920DA4C1000CDBAE8 /* SentryCrash */,
63AA75C61EB8B06100D153DE /* Sentry */,
);
indentWidth = 4;
path = Sources;
sourceTree = "<group>";
tabWidth = 4;
};
63AA75921EB8AEDB00D153DE /* Tests */ = {
isa = PBXGroup;
Expand All @@ -1730,8 +1734,10 @@
63AA76AA1EB9D5CD00D153DE /* Configuration */,
63AA75931EB8AEDB00D153DE /* SentryTests */,
);
indentWidth = 4;
path = Tests;
sourceTree = "<group>";
tabWidth = 4;
};
63AA75931EB8AEDB00D153DE /* SentryTests */ = {
isa = PBXGroup;
Expand Down
19 changes: 15 additions & 4 deletions Sources/Sentry/SentrySystemEventBreadcrumbs.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ - (void)start
[SentryLog logWithMessage:@"NO iOS -> [SentrySystemEventsBreadcrumbs.start] does nothing."
andLevel:kSentryLevelDebug];
brustolin marked this conversation as resolved.
Show resolved Hide resolved
#endif

[self initTimezoneObserver];
}

- (void)stop
Expand Down Expand Up @@ -160,6 +162,16 @@ - (void)initKeyboardVisibilityObserver
object:nil];
}

- (void)initScreenshotObserver
{
// it's only about the action, but not the SS itself
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(systemEventTriggered:)
name:UIApplicationUserDidTakeScreenshotNotification
object:nil];
}
#endif

- (void)systemEventTriggered:(NSNotification *)notification
{
SentryBreadcrumb *crumb = [[SentryBreadcrumb alloc] initWithLevel:kSentryLevelInfo
Expand All @@ -169,14 +181,13 @@ - (void)systemEventTriggered:(NSNotification *)notification
[SentrySDK addBreadcrumb:crumb];
}

- (void)initScreenshotObserver
- (void)initTimezoneObserver
{
// it's only about the action, but not the SS itself
// Posted when the timezone of the device changed
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(systemEventTriggered:)
name:UIApplicationUserDidTakeScreenshotNotification
name:NSSystemTimeZoneDidChangeNotification
object:nil];
}
#endif

@end
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,14 @@ class SentrySystemEventBreadcrumbsTest: XCTestCase {
NotificationCenter.default.post(Notification(name: UIApplication.userDidTakeScreenshotNotification))
assertBreadcrumbAction(scope: scope, action: "UIApplicationUserDidTakeScreenshotNotification")
}

func testTimezoneChangeBreadcrumb() {
kevinrenskers marked this conversation as resolved.
Show resolved Hide resolved
let scope = Scope()
sut = fixture.getSut(scope: scope, currentDevice: nil)

NotificationCenter.default.post(Notification(name: NSSystemTimeZoneDidChangeNotification))
assertBreadcrumbAction(scope: scope, action: "NSSystemTimeZoneDidChangeNotification")
}

private func assertBreadcrumbAction(scope: Scope, action: String) {
let ser = scope.serialize()
Expand Down