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

Replaced generic phone model by device model #253

Merged
merged 2 commits into from
Jun 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
11 changes: 10 additions & 1 deletion MatomoTracker/URLSessionDispatcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down