From 8b10b74a1ac609e8543e943f580f7ef630d5f37c Mon Sep 17 00:00:00 2001 From: Pe-te Date: Thu, 14 Jun 2018 14:57:57 +0200 Subject: [PATCH 1/2] Replaced generic phone model by device model For android devices we see the specific device model in the backend, for iOS devices we only see generic "iPad" or "iPhone". Here we replace the generic string in the user agent with the real device model (e.g. iPhone8,4), which lets the backend properly display "iPhone SE". --- MatomoTracker/URLSessionDispatcher.swift | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/MatomoTracker/URLSessionDispatcher.swift b/MatomoTracker/URLSessionDispatcher.swift index 78322968..30fa4732 100644 --- a/MatomoTracker/URLSessionDispatcher.swift +++ b/MatomoTracker/URLSessionDispatcher.swift @@ -36,7 +36,16 @@ final class URLSessionDispatcher: Dispatcher { let currentUserAgent = webView.stringByEvaluatingJavaScript(from: "navigator.userAgent") ?? "" #elseif os(iOS) let webView = UIWebView(frame: .zero) - let currentUserAgent = webView.stringByEvaluatingJavaScript(from: "navigator.userAgent") ?? "" + var currentUserAgent = webView.stringByEvaluatingJavaScript(from: "navigator.userAgent") ?? "" + if let regex = try? NSRegularExpression(pattern: "\\((iPad|iPhone);", options: .caseInsensitive) { + let deviceModel = Device.makeCurrentDevice().platform + currentUserAgent = regex.stringByReplacingMatches( + in: currentUserAgent, + options: .withTransparentBounds, + range: NSRange(location: 0, length: currentUserAgent.count), + withTemplate: "(\(deviceModel);" + ) + } #elseif os(tvOS) let currentUserAgent = "" #endif From e800fa564023cd49ab3d4fe00d37118e99295e5e Mon Sep 17 00:00:00 2001 From: Pe-te Date: Wed, 20 Jun 2018 17:46:03 +0200 Subject: [PATCH 2/2] Replaced generic phone model by device model --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ad4634a..c06e746d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 5.1.2 +* **bugfix** Replaced generic phone model by device model. [#254](https://github.com/matomo-org/matomo-sdk-ios/pull/253) + ## 5.1.1 * **bugfix** Fixed Xcode build settings for Carthage support. [#224](https://github.com/matomo-org/matomo-sdk-ios/pull/244) (by @phranck)