Skip to content

$locale collected different from iOS #822

Description

@fphilipe

Version

3.71.2

Steps to Reproduce

We have an iOS and Android app that integrates the respective PostHog SDK.

Our app is available in English and German. In our Mobile Analytics dashboard on PostHog (created using the PostHog template) I see a breakdown of the languages. This breakdown contains many more languages (including country specifier such as ru-RU) than just the two the app runs in.

Digging deeper, I realized that the additional languages only come from Android. On iOS it indeed only reports just the language the app runs in, as can be seen in its source:

if #available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *) {
    if let languageCode = Locale.current.language.languageCode {
        properties["$locale"] = languageCode.identifier
    }
} else {
    if Locale.current.languageCode != nil {
        properties["$locale"] = Locale.current.languageCode
    }
}

On Android on the other hand you collect the language the device is set to:

dynamicContext["\$locale"] = "${Locale.getDefault().language}-${Locale.getDefault().country}"

Expected Result

On Android it should collect just the language that is also used for resource lookup. If my phone is set to de-CH and the app only supports English, I want to see en as the value for the $locale property.

This is how the chart looks filtered by iOS:

Image

Actual Result

This is the same chart filtered by Android:

Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions