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

fix: Do not delete the app state #2382

Merged
merged 5 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

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

- Too long flush duration (#2370)
- Do not delete the app state when OOM tracking is disabled (#2382)
Copy link
Member

Choose a reason for hiding this comment

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

m: Please change this, so we describe what we are fixing instead of how. I think we fixed a bug that we always report cold starts when OOM is enabled.


## 7.30.2

Expand Down
8 changes: 0 additions & 8 deletions Sources/Sentry/SentryAppStateManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ - (void)stop
removeObserver:self
name:SentryNSNotificationCenterWrapper.willTerminateNotificationName
object:nil];

[self deleteAppState];
}
}

Expand All @@ -124,7 +122,6 @@ - (void)dealloc
// In dealloc it's safe to unsubscribe for all, see
// https://developer.apple.com/documentation/foundation/nsnotificationcenter/1413994-removeobserver
[NSNotificationCenter.defaultCenter removeObserver:self];
[self deleteAppState];
}

/**
Expand Down Expand Up @@ -199,11 +196,6 @@ - (void)storeCurrentAppState
[self.fileManager storeAppState:[self buildCurrentAppState]];
}

- (void)deleteAppState
{
[self.fileManager deleteAppState];
}

#endif

@end
2 changes: 0 additions & 2 deletions Sources/Sentry/include/SentryAppStateManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ SENTRY_NO_INIT

- (void)storeCurrentAppState;

- (void)deleteAppState;

- (void)updateAppState:(void (^)(SentryAppState *))block;

#endif
Expand Down
27 changes: 1 addition & 26 deletions Tests/SentryTests/Helper/SentryAppStateManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,39 +65,14 @@ class SentryAppStateManagerTests: XCTestCase {
XCTAssertNil(fixture.fileManager.readAppState())
}

func testStopDeletesAppState() {
func testStopDoesNotDeleteAppState() {
XCTAssertNil(fixture.fileManager.readAppState())

sut.start()
XCTAssertNotNil(fixture.fileManager.readAppState())

sut.stop()
XCTAssertNil(fixture.fileManager.readAppState())
}

func testStopOnlyRunsLogicWhenStartCountBecomesZero() {
XCTAssertNil(fixture.fileManager.readAppState())

sut.start()
XCTAssertNotNil(fixture.fileManager.readAppState())

sut.start()

sut.stop()
XCTAssertNotNil(fixture.fileManager.readAppState())

sut.stop()
XCTAssertNil(fixture.fileManager.readAppState())
}

func testStoreAndDeleteAppState() {
XCTAssertNil(fixture.fileManager.readAppState())

sut.storeCurrentAppState()
XCTAssertNotNil(fixture.fileManager.readAppState())

sut.deleteAppState()
XCTAssertNil(fixture.fileManager.readAppState())
}

func testUpdateAppState() {
Expand Down