Repository navigation
fix(fingerprint): send the device language as language-region - #8
Merged
Merged
Conversation
The device locale is reported as a BCP 47 tag, a Java Locale.toString() string (I18nManager on Android, e.g. en_ES_#u-fw-mon-mu-celsius) or an Apple identifier with keywords (en_GB@rg=eszzzz). The SDK now reduces whichever source it reads to language or language-REGION (en-ES, en-GB, zh-CN, es-419), the same form the browser side of a click reports.
|
🎉 This PR is included in version 1.6.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The SDK sends the device language as
languageorlanguage-REGION, whatever form the platform reports it in.FingerprintCollector.getLanguage()reads iOSSettingsManager(AppleLocale/AppleLanguages[0]), AndroidI18nManager.localeIdentifier, ornavigator.language. Those come in several shapes, and the newnormalizeLanguageTag(src/languageTag.ts) reduces each to the same form:en_ES_#u-fw-mon-mu-celsius(JavaLocale.toString(), regional preferences set)en-ESen-ES-u-fw-mon-mu-celsius(BCP 47 with extensions)en-ESzh_CN_#Hans,zh-Hans-CNzh-CNen_GB@rg=eszzzz,en_US@calendar=japanese(Apple identifiers with keywords)en-GB,en-USen_US.UTF-8en-USes-419,fil_PH,enes-419,fil-PH,enScript, variant, extension and keyword parts are dropped. A value that doesn't start with a 2–3 letter language moves on to the next source, then
en-US. This is the same form the browser side of a click reports, and the same normalization the LinkForty server applies.The install request, the
fp_langparameter on a direct open, and the fingerprint query string all read the language fromFingerprintCollector.collect(), so all three send the normalized value.CI
.github/workflows/test.ymlbuilds the package and runs the Vitest suite on every pull request and push tomain..github/workflows/release.ymlruns the suite after the build and beforesemantic-release, so a release is only published when the tests pass.Tests
__tests__/languageTag.test.ts: every shape above, plus junk and non-string input. Locallynpm run buildis clean andnpm testpasses 53 tests in 4 files.