Skip to content

Commit 812ccfc

Browse files
committed
send iab_consent parameter to visitanalytics
1 parent 89311ba commit 812ccfc

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

UserReport/UserReport/Models/MediaSettings.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ internal struct MediaSettings {
1919
var settings: UserReportSettings = UserReportSettings()
2020

2121
var sections: Dictionary<String, String>?
22+
23+
var hardcodedConsent: String?
2224
}
2325

2426
/**
@@ -61,6 +63,10 @@ extension MediaSettings: Serialization {
6163
if let sections = dict["sections"] as? Dictionary<String, String> {
6264
self.sections = sections
6365
}
66+
67+
if let hardcodedConsent = dict["hardcodedConsent"] as? String {
68+
self.hardcodedConsent = hardcodedConsent
69+
}
6470
}
6571

6672
}

UserReport/UserReport/Network/Network.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,20 @@ internal class Network {
7878
}
7979

8080
func trackScreenView(info: Info, tCode: String, completion: @escaping ((Result<Empty>) -> Void)) {
81-
//https://visitanalytics.userreport.com/hit.gif?t=[kitTcode]&rnd=%RANDOM%&d=IDFA&med=app_name&idfv=identifierForVendor
81+
//https://visitanalytics.userreport.com/hit.gif?t=[kitTcode]&rnd=%RANDOM%&d=IDFA&med=app_name&idfv=identifierForVendor&iab_consent=hardcodedConsent
8282
let appName = Bundle.main.infoDictionary![kCFBundleNameKey as String] as! String
8383

8484
let tCode = "t=\(tCode)&"
8585
let random = arc4random_uniform(UInt32.max)
8686
let idfa = info.user?.idfa ?? ""
8787
let idForVendor = UIDevice.current.identifierForVendor!.uuidString
88-
let url = URL(string: "\(self.server.audiences)/hit.gif?\(tCode)rnd=\(random)&d=\(idfa)&med=\(appName)&idfv=\(idForVendor)")
88+
var urlString = "\(self.server.audiences)/hit.gif?\(tCode)rnd=\(random)&d=\(idfa)&med=\(appName)&idfv=\(idForVendor)"
89+
90+
if let consent = info.mediaSettings?.hardcodedConsent {
91+
urlString.append("&iab_consent=\(consent)")
92+
}
93+
94+
let url = URL(string: urlString)
8995
self.userAgent { (userAgent) in
9096
let headers = ["User-Agent": userAgent]
9197
self.sendRequest(httpMethod: HTTPMethod.GET, url: url, headers: headers, body: nil, emptyReponse: true, completion: completion)

0 commit comments

Comments
 (0)