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

Wrong value in "In Foreground" for every sentry event #3991

Closed
ljql2001 opened this issue May 16, 2024 · 1 comment · Fixed by #4005
Closed

Wrong value in "In Foreground" for every sentry event #3991

ljql2001 opened this issue May 16, 2024 · 1 comment · Fixed by #4005

Comments

@ljql2001
Copy link

ljql2001 commented May 16, 2024

Platform

iOS

Environment

Develop

Installed

CocoaPods

Version

8.24.0

Did it work on previous versions?

I don't know. We are starting at this version.

Steps to Reproduce

When app enters background and foreground, the context[@"app"][@"in_foreground"] field is wrong in every event.

The value seems to remain the same value no matter it is YES or NO since app starts.

As I debug the codes, this issue seems to come from LN 634 in SentryClient.m: SentryAppState *appState = [manager loadPreviousAppState];

Expected Result

The value of context[@"app"][@"in_foreground"] field is correct when app enters background and foreground.

Actual Result

The value seems to remain the same value no matter it is YES or NO since app starts.

Are you willing to submit a PR?

No

@philipphofmann
Copy link
Member

That's a good catch thanks. The culprit is here

SentryAppStateManager *manager = [SentryDependencyContainer sharedInstance].appStateManager;
SentryAppState *appState = [manager loadPreviousAppState];
BOOL inForeground = [appState isActive];

This is an easy fix.

philipphofmann pushed a commit that referenced this issue May 23, 2024
Replaced source of truth for app state from SentryAppStateManager instance to SentryUIApplication.

Fixes GH-3991
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants