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

Include concrete device model in user agent (PSG-754) #1576

Closed
wants to merge 1 commit into from

Conversation

Johennes
Copy link
Contributor

@Johennes Johennes commented Sep 19, 2022

Fixes element-hq/element-ios#6742

Pull Request Checklist

@Johennes Johennes requested review from a team and Anderas and removed request for a team September 19, 2022 19:07
@@ -649,6 +651,27 @@ - (void)setRequestParametersInJSON:(BOOL)requestParametersInJSON
{
httpManager.requestSerializer = [AFHTTPRequestSerializer serializer];
}

// Overwrite user agent to include concrete device model (code copied from AlamoFire)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code below is copied from AFHTTPRequestSerializer. I decided to keep this in the ObjC part because this way it's an exact copy and possibly easier to maintain than a Swift port.

@@ -14,6 +14,7 @@ PODS:
- AFNetworking/Serialization (4.0.1)
- AFNetworking/UIKit (4.0.1):
- AFNetworking/NSURLSession
- DeviceKit (4.7.0)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the best option I found for converting Apple's device identifiers into human readable strings. It's MIT, relatively small, well-maintained and somewhat popular so I hope this is an ok choice.

@Johennes Johennes force-pushed the johannes/concrete-device-model-user-agent branch from c928c60 to 9695758 Compare September 20, 2022 06:11
@codecov
Copy link

codecov bot commented Sep 20, 2022

Codecov Report

Base: 12.49% // Head: 36.98% // Increases project coverage by +24.48% 🎉

Coverage data is based on head (9695758) compared to base (3f0584c).
Patch coverage: 31.57% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff              @@
##           develop    #1576       +/-   ##
============================================
+ Coverage    12.49%   36.98%   +24.48%     
============================================
  Files          521      522        +1     
  Lines        85000    85019       +19     
  Branches     36193    37544     +1351     
============================================
+ Hits         10624    31441    +20817     
+ Misses       73990    52614    -21376     
- Partials       386      964      +578     
Impacted Files Coverage Δ
MatrixSDK/Utils/MXHTTPClientExtensions.swift 0.00% <0.00%> (ø)
MatrixSDK/Utils/MXHTTPClient.m 46.08% <50.00%> (+15.69%) ⬆️
MatrixSDK/Utils/MXLRUCache.m 14.08% <0.00%> (-26.77%) ⬇️
MatrixSDK/Utils/Media/MXMediaManager.m 1.88% <0.00%> (+0.47%) ⬆️
MatrixSDK/Contrib/Swift/MXRestClient.swift 2.40% <0.00%> (+0.79%) ⬆️
...gations/LocationSharing/MXBeaconAggregations.swift 4.44% <0.00%> (+1.26%) ⬆️
MatrixSDKTests/MXBackgroundSyncServiceTests.swift 1.84% <0.00%> (+1.84%) ⬆️
MatrixSDK/Contrib/Swift/MXSession.swift 9.02% <0.00%> (+2.25%) ⬆️
MatrixSDK/Crypto/Recovery/MXRecoveryService.m 2.64% <0.00%> (+2.64%) ⬆️
MatrixSDK/Utils/Logs/MXLog.swift 53.57% <0.00%> (+2.67%) ⬆️
... and 183 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Johennes Johennes requested review from a team and ismailgulek and removed request for Anderas and a team September 22, 2022 06:25
@Johennes
Copy link
Contributor Author

Rolling the reviewer assignment dice again because I think Andy is busy with the releases.

Copy link
Contributor

@ismailgulek ismailgulek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM but I'd like to check with @manuroe that should this change be at the sdk or at the app side (can be done via MXSDKOptions.additionalHTTPHeaders)?

@manuroe
Copy link
Contributor

manuroe commented Sep 23, 2022

Changes LGTM but I'd like to check with @manuroe that should this change be at the sdk or at the app side (can be done via MXSDKOptions.additionalHTTPHeaders)?

Good point. If possible, we would prefer this customisation only at the app level for apps that require it.

@Johennes
Copy link
Contributor Author

Sounds good. Closing this in favor of element-hq/element-ios#6761.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include concrete device model in user agent
3 participants