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

Reported language doesn't always match reality #1410

Closed
ueman opened this issue Apr 27, 2023 · 9 comments · Fixed by #1724
Closed

Reported language doesn't always match reality #1410

ueman opened this issue Apr 27, 2023 · 9 comments · Fixed by #1724

Comments

@ueman
Copy link
Collaborator

ueman commented Apr 27, 2023

Platform

Flutter Mobile

Obfuscation

Disabled

Debug Info

Disabled

Doctor

Unrelated to the Dart/Flutter version

Version

7.5.0

Steps to Reproduce

  1. Restrict the language manually via the parameters of MaterialApp/CupertinoApp/WidgetsApp as seen in the code snippet. Restrict it to a language different than the device language.
MaterialApp(
  supportedLocales: supportedLocales,
  locale: selectedLocale,
);
  1. Cause an error
  2. Sentry reports the device language, not the manual set one.

Expected Result

I would expect the language to be the one set in the MaterialApp.

Actual Result

Device language is reported.

Are you willing to submit a PR?

None

@ueman ueman changed the title Reported language doesn't necessarily match reality Reported language doesn't always match reality Apr 27, 2023
@marandaneto
Copy link
Contributor

It's not specified if it should be the device's language or the screen's language, maybe we need both.
https://develop.sentry.dev/sdk/event-payloads/contexts/#culture-context
Not sure if it's a bug though, maybe adding a new field for the screen's language makes more sense? I believe both would be important for solving language bugs.

@ueman
Copy link
Collaborator Author

ueman commented May 3, 2023

Not sure if it's a bug though, maybe adding a new field for the screen's language makes more sense? I believe both would be important for solving language bugs.

I agree, that sounds reasonable.

@kahest kahest moved this from Needs Discussion to Backlog in Mobile & Cross Platform SDK May 11, 2023
@buenaflor buenaflor self-assigned this Nov 8, 2023
@buenaflor buenaflor moved this from Backlog to Todo in Mobile & Cross Platform SDK Nov 8, 2023
@buenaflor
Copy link
Contributor

buenaflor commented Nov 9, 2023

One way for us to retrieve the locale would be to use a navigatorKey

// somewhere in the SDK
GlobalKey<NavigatorState> sentryNavigatorKey = GlobalKey<NavigatorState>();

// your app
MaterialApp(
  navigatorKey: sentryNavigatorKey,
//...
)

Then somwhere in the SDK we can do

final context = sentryNavigatorKey.currentContext;
final screenLocale = Localizations.localeOf(context);
// ... add it to context

@ueman what do you think? any concerns with this approach?

@ueman
Copy link
Collaborator Author

ueman commented Nov 9, 2023

No concerns on my side, but that kinda goes against the design philosophy of the SDKs of a very simple configuration. Not sure though if that's a blocker or concern for you.

@buenaflor
Copy link
Contributor

Indeed, ideally adding a navigatorKey shouldn't be needed but I'm not sure if there are other ways to retrieve the BuildContext without user intervention unless I missed something.

@ueman
Copy link
Collaborator Author

ueman commented Nov 9, 2023

Unfortunately, I also don't see any way of doing that.

@buenaflor buenaflor moved this from Todo to In Progress in Mobile & Cross Platform SDK Nov 9, 2023
@denrase
Copy link
Collaborator

denrase commented Nov 13, 2023

We already use a global key to extract the current context for the ScreenshotWidget. Does introducing a more generic SentryWidget which could be used for both and also be extended in the future make sense? Since we are already recommending that users add it around the App widget.

@buenaflor buenaflor moved this from In Progress to Todo in Mobile & Cross Platform SDK Nov 13, 2023
@ueman
Copy link
Collaborator Author

ueman commented Nov 13, 2023

We already use a global key to extract the current context for the ScreenshotWidget. Does introducing a more generic SentryWidget which could be used for both and also be extended in the future make sense? Since we are already recommending that users add it around the App widget.

I think that's too high in the widget tree to get the localization, but it's actually a good hint

@buenaflor
Copy link
Contributor

Just tested it for confirmation and it seems so, it would be too high in the tree.

@github-project-automation github-project-automation bot moved this from Needs Review to Done in Mobile & Cross Platform SDK Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants