This repository has been archived by the owner on Apr 3, 2019. It is now read-only.
fix(devices): handle new user agent string from Sync client lib #1909
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.
Fixes #1889.
Adds handling for user agent strings from the new Sync mobile library.
I was torn between adding a third distinct regex to
lib/userAgent
, thereby creating an ugly chain of if-then-else-if ugliness, or consolidating all of ourdebtregexes into a single ultra-regex. Here you can see the ultra-regex approach in all it's glory: it starts off okay but then somewhere round the middle becomes completely impenetrable, in the customary style of all great regexes.I'm happy to revert to separate expressions and explicit conditions if people find this one too unreadable.
There is one requirement from the linked issue that is not addressed here. Quoting from it:
When we synthesize the device name, I'm not including the form factor as it stands. This is because we coerce the form factor to either
'mobile'
or'tablet'
and have logic in the content server that hangs off that distinction. So the raw form factor from the user agent string, e.g.iPhone 6S
, is not available to us at the moment.We could add an extra column to the
devices
table, sayuaFormFactor
, but that's a bigger change involving other repos and probably not worth blocking this PR on. Even without that part of the device name in place, this PR succeeds at the main aim of parsing the new user agent string. I'll open a separate issue for incorporating form factor in to the device name.@mozilla/fxa-devs r?
/cc @mcomella