MeasurementProtocolManager
public class MeasurementProtocolManager
Undocumented
-
Undocumented
Declaration
Swift
let dataNotAvailible: String
-
Google Analytic tracking ID
Declaration
Swift
private(set) var trackingID: String
-
Create unique user identifier and save it to UserDefaules, in case was generated, retrive from UserDefaules
Declaration
Swift
lazy var clientID: String { get set }
-
Contains array of the general params, that relevant for every hit event
Declaration
Swift
lazy var generalParams: [String] { get set }
-
Retrieve current device resolution in format “
width
xheight
”Declaration
Swift
lazy var screenSize: String { get set }
-
Retrieve current device language
Declaration
Swift
lazy var userLanguage: String? { get set }
-
Retrieve application bundle identifier
Declaration
Swift
lazy var bundleIdentifier: String? { get set }
-
Retrieve application bundle name
Declaration
Swift
lazy var bundleName: String { get set }
-
Retrieve application version
Declaration
Swift
lazy var applicationVersion: String { get set }
-
Initialize application with Google Tracking ID
Declaration
Swift
init(trackingID: String)
Parameters
trackingID
Identifier to send Google Analytics events
-
Send event with Hit Type and custom parameters
Declaration
Swift
func send(hitType: String, customParameters: [String: String]? = nil)
Parameters
hitType
string of the hit type
customParameters
event custom parameters
-
Send event with Screen Hit Type and custom parameters
Declaration
Swift
func screenView(screenName: String, customParameters: [String: String]? = nil)
-
Send event with Event Hit Type and custom parameters
Declaration
Swift
func event(category: String, action: String, label: String?, customParameters: [String: String]? = nil)
-
Send event with Exception Hit Type and custom parameters
Declaration
Swift
func exception(description: String, isFatal: Bool, customParameters: [String: String]? = nil)
-
Transfer analytics parameters in dictianary to format url format to prepare analytics Url request
Declaration
Swift
func transferDictParamsToUrlParams(customParameters: [String : String]) -> [String]
Parameters
customParameters
Analytics parameters in dictionary
Return Value
Array of string in format “
key=value
” -
Returns parameter for future URL String
Declaration
Swift
func urlParam(with key: String, value: String) -> String
Parameters
key
String that will be used as key for param
value
String that will be used as value for param
Return Value
Returns URL parameter in format
"key=value"
-
Send request with hit event to Google Analytics
Declaration
Swift
func sendRequest(with url: URL)
Parameters
url
URL of the hit event
-
Creates url for hit type event
Declaration
Swift
func hitURL(for hitType: String, customParameters: [String: String]?) -> URL?
Parameters
hitType
hit type Event
customParameters
additional parameters that must be passed with url
Return Value
URL instance if url can be created otherwise nil
-
Check if hit type string is api correct
Declaration
Swift
func isAllowedHitType(hitType: String) -> Bool
Parameters
hitType
string representation of hit event type
Return Value
true if hit event exist otherwise false
-
Combine url params array to one string
Declaration
Swift
func urlParamsString(from urlParams: [String]) -> String?
Parameters
urlParams
array of url params in format
["a=1", "b=2"]
Return Value
Return cobined string in format “
a=1&b=2
” -
Convert url string with url params string to url with encoding
CharacterSet.urlHostAllowed
Declaration
Swift
func stringToURLWithEncoding(with urlParamsString: String) -> URL?
Parameters
urlParamsString
string of url params in format “
a=1&b=2
”Return Value
URL instance in case can be created otherwise nil