Skip to content

Commit

Permalink
Merge branch 'feature/privacy' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
nsagnett committed Jan 19, 2021
2 parents 0626977 + 9e391c0 commit a493f5a
Show file tree
Hide file tree
Showing 15 changed files with 374 additions and 106 deletions.
2 changes: 1 addition & 1 deletion ATInternet-Apple-SDK-AppExtension.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "ATInternet-Apple-SDK-AppExtension"
s.version = '2.21.2'
s.version = '2.22.0'
s.summary = "AT Internet mobile analytics solution for Apple devices"
s.homepage = "https://github.com/at-internet/atinternet-apple-sdk"
s.documentation_url = 'https://developers.atinternet-solutions.com/apple-en/getting-started-apple-en/operating-principle-apple-en/'
Expand Down
2 changes: 1 addition & 1 deletion ATInternet-Apple-SDK.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "ATInternet-Apple-SDK"
s.version = '2.21.2'
s.version = '2.22.0'
s.summary = "AT Internet mobile analytics solution for Apple devices"
s.homepage = "https://github.com/at-internet/atinternet-apple-sdk"
s.documentation_url = 'https://developers.atinternet-solutions.com/apple-en/getting-started-apple-en/operating-principle-apple-en/'
Expand Down
14 changes: 14 additions & 0 deletions ATInternetTracker/ATInternetTracker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,12 @@
CCB990A425488A220059D252 /* Crypt.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCB990A025488A220059D252 /* Crypt.swift */; };
CCB990A525488A220059D252 /* Crypt.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCB990A025488A220059D252 /* Crypt.swift */; };
CCB990A625488A220059D252 /* Crypt.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCB990A025488A220059D252 /* Crypt.swift */; };
CCC4374925AF223300D3815F /* Privacy.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCC4374825AF223300D3815F /* Privacy.swift */; };
CCC4374A25AF223300D3815F /* Privacy.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCC4374825AF223300D3815F /* Privacy.swift */; };
CCC4374B25AF223300D3815F /* Privacy.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCC4374825AF223300D3815F /* Privacy.swift */; };
CCC4374C25AF223300D3815F /* Privacy.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCC4374825AF223300D3815F /* Privacy.swift */; };
CCC4374D25AF223300D3815F /* Privacy.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCC4374825AF223300D3815F /* Privacy.swift */; };
CCC4374E25AF223300D3815F /* Privacy.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCC4374825AF223300D3815F /* Privacy.swift */; };
CCC9F5FA23B63A580055516B /* AVInsights.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCC9F5F923B63A580055516B /* AVInsights.swift */; };
CCC9F5FB23B63A580055516B /* AVInsights.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCC9F5F923B63A580055516B /* AVInsights.swift */; };
CCC9F5FC23B63A580055516B /* AVInsights.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCC9F5F923B63A580055516B /* AVInsights.swift */; };
Expand Down Expand Up @@ -667,6 +673,7 @@
CC9A55A521CA23A900A78AB3 /* ECommerce.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ECommerce.swift; sourceTree = "<group>"; };
CCB990A025488A220059D252 /* Crypt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Crypt.swift; sourceTree = "<group>"; };
CCBE56C623151D2200FF043D /* referential.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = referential.json; sourceTree = "<group>"; };
CCC4374825AF223300D3815F /* Privacy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Privacy.swift; sourceTree = "<group>"; };
CCC9F5F923B63A580055516B /* AVInsights.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AVInsights.swift; sourceTree = "<group>"; };
CCC9F60023B63C100055516B /* AVMedia.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AVMedia.swift; sourceTree = "<group>"; };
CCE8902D2182F7CF000BBC4F /* EventsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = EventsTests.swift; path = Tests/EventsTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -789,6 +796,7 @@
4F47A4581D3542A400702747 /* Tool.swift */,
4F47A4591D3542A400702747 /* Tracker.swift */,
CCB990A025488A220059D252 /* Crypt.swift */,
CCC4374825AF223300D3815F /* Privacy.swift */,
);
name = Core;
sourceTree = "<group>";
Expand Down Expand Up @@ -1297,6 +1305,7 @@
CC704B9821B6D21000114A86 /* UpdateCart.swift in Sources */,
4F47A4D11D35446700702747 /* CustomTreeStructure.swift in Sources */,
4F47A5151D35446700702747 /* Screen.swift in Sources */,
CCC4374925AF223300D3815F /* Privacy.swift in Sources */,
CC1FE8B0215A0DFC006FE401 /* LiveMedium.swift in Sources */,
4F47A4721D3542A400702747 /* Hit.swift in Sources */,
4F47A50D1D35446700702747 /* Publisher.swift in Sources */,
Expand Down Expand Up @@ -1412,6 +1421,7 @@
4F47A4E31D35446700702747 /* IdentifiedVisitor.swift in Sources */,
CC704B4D21B672BA00114A86 /* AddProduct.swift in Sources */,
4F47A4EF1D35446700702747 /* LiveVideo.swift in Sources */,
CCC4374B25AF223300D3815F /* Privacy.swift in Sources */,
4F47A4FB1D35446700702747 /* NuggAd.swift in Sources */,
4F47A5481D35458E00702747 /* DefaultTrackerDelegate.swift in Sources */,
CC704B3F21B65B5E00114A86 /* EcommerceObjectProperties.swift in Sources */,
Expand Down Expand Up @@ -1461,6 +1471,7 @@
CC704B9421B6D16700114A86 /* RemoveProduct.swift in Sources */,
4F47A4DC1D35446700702747 /* Event.swift in Sources */,
4F47A4C81D35446700702747 /* Campaign.swift in Sources */,
CCC4374C25AF223300D3815F /* Privacy.swift in Sources */,
4F47A48D1D3542A400702747 /* TechnicalContext.swift in Sources */,
CC1FE8B3215A0DFC006FE401 /* LiveMedium.swift in Sources */,
4F47A53E1D35451A00702747 /* Hash.m in Sources */,
Expand Down Expand Up @@ -1568,6 +1579,7 @@
4F47A4D61D35446700702747 /* CustomVar.swift in Sources */,
CC704B4C21B672BA00114A86 /* AddProduct.swift in Sources */,
4F47A4F21D35446700702747 /* Location.swift in Sources */,
CCC4374A25AF223300D3815F /* Privacy.swift in Sources */,
4F47A5021D35446700702747 /* OnAppAd.swift in Sources */,
4F47A4871D3542A400702747 /* Storage.swift in Sources */,
CC704B3E21B65B5E00114A86 /* EcommerceObjectProperties.swift in Sources */,
Expand Down Expand Up @@ -1630,6 +1642,7 @@
4F47A8071D3D17BD00702747 /* BusinessObject.swift in Sources */,
4F47A8221D3D17FC00702747 /* Publisher.swift in Sources */,
CC704B7921B6C48200114A86 /* DisplayPageProduct.swift in Sources */,
CCC4374D25AF223300D3815F /* Privacy.swift in Sources */,
4F47A83F1D3D192C00702747 /* Context.swift in Sources */,
4F47A8421D3D192C00702747 /* Hit.swift in Sources */,
CCC9F5FE23B63A580055516B /* AVInsights.swift in Sources */,
Expand Down Expand Up @@ -1729,6 +1742,7 @@
CC704BA421B6D2AE00114A86 /* TransactionConfirmation.swift in Sources */,
4FF5944D1D3F66860004D336 /* Campaign.swift in Sources */,
4FF5943D1D3F66400004D336 /* DefaultTrackerDelegate.swift in Sources */,
CCC4374E25AF223300D3815F /* Privacy.swift in Sources */,
4FF594561D3F669B0004D336 /* LiveAudio.swift in Sources */,
4FF5941E1D3F61C50004D336 /* CartTests.swift in Sources */,
4FF5944B1D3F66810004D336 /* Audio.swift in Sources */,
Expand Down
1 change: 1 addition & 0 deletions ATInternetTracker/Sources/ATInternet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public class ATInternet: NSObject {
}

/// Disable user identification.
@available(*, deprecated, message: "")
@objc public class var optOut: Bool {
get {
return TechnicalContext.optOut
Expand Down
2 changes: 1 addition & 1 deletion ATInternetTracker/Sources/Builder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class Builder: Operation {


// Get the parameters from the buffer (formatted as &p=v)
var formattedParams = prepareQuery()
var formattedParams = Privacy.apply(parameters: prepareQuery())

// Hit slicing error
var err = false
Expand Down
2 changes: 1 addition & 1 deletion ATInternetTracker/Sources/Crypt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class Crypt: NSObject {

guard let sealData = encryptedData else { return nil }

return sealData?.base64EncodedString()
return sealData.base64EncodedString()
}

@available(iOS 13.0, *)
Expand Down
99 changes: 4 additions & 95 deletions ATInternetTracker/Sources/Event.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,16 @@ public class Events: BusinessObject {

for e in self.eventLists {

var data = toFlatten(src: e.data, lowercase: true)
var data = Tool.toFlatten(src: e.data, lowercase: true)
if e.data.count != 0 {
eventsArr.append(["name" : e.name.lowercased(), "data" : toObject(src: data)])
eventsArr.append(["name" : e.name.lowercased(), "data" : Tool.toObject(src: data)])
}

let additionalEvents = e.getAdditionalEvents()

for ev in additionalEvents {
data = toFlatten(src: ev.data, lowercase: true)
eventsArr.append(["name" : ev.name.lowercased(), "data" : toObject(src: data)])
data = Tool.toFlatten(src: ev.data, lowercase: true)
eventsArr.append(["name" : ev.name.lowercased(), "data" : Tool.toObject(src: data)])
}

}
Expand Down Expand Up @@ -145,95 +145,4 @@ public class Events: BusinessObject {

return pageContext
}

private func toFlatten(src: [String : Any], lowercase: Bool) -> [String: (Any, String)] {
var dst = [String : (Any, String)]()
doFlatten(src: src, prefix: "", dst: &dst, lowercase: lowercase)
return dst
}

private func doFlatten(src: [String: Any], prefix: String, dst: inout [String : (Any, String)], lowercase: Bool) {
for (k,v) in src {
let key = prefix == "" ? k : prefix + "_" + k
if v is [String : Any] {
doFlatten(src: v as! [String : Any], prefix: key, dst: &dst, lowercase: lowercase)
} else {
let parts = key.components(separatedBy: "_")
var finalPrefix = ""
var s = ""
let last = parts.count - 1

for (i, part) in parts.enumerated() {
let t = splitPrefixKey(key: part)

if t.0 != "" {
finalPrefix = t.0
}

if i > 0 {
s.append("_")
}
s.append(lowercase ? t.1.lowercased() : t.1)

/// test -> test_$ on existing key if the current key is not complete
if i != last && dst[s] != nil {
dst[s + "_$"] = dst.removeValue(forKey: s)
continue
}
///

/// test -> test_$ on current key if the current key is complete
if i == last && dst[s] == nil && containsKeyPrefix(keys: dst.keys, prefix: s) {
s.append("_$")
}
///
}

dst[s] = (v, lowercase ? finalPrefix.lowercased() : finalPrefix)
}
}
}

private func toObject(src: [String : (Any, String)]) -> [String: Any] {
return src.reduce(into: [:]) { (acc, arg1) in
let (key, (value, prefix)) = arg1
let parts = key.components(separatedBy: "_")

var path = ""
for (i, part) in parts.enumerated() {
if i != 0 {
path += "_"
}

if i == parts.count - 1 {
acc.setValue(value: value, forKeyPath: path + prefix + part)
return
}

path += part
}
}
}

private func splitPrefixKey(key: String) -> (String, String) {
if key.count < 2 || key[key.index(key.startIndex, offsetBy: 1)] != ":" {
return ("", key)
}

if key.count < 4 || key[key.index(key.startIndex, offsetBy: 3)] != ":" {
return (key[0..<2], key[2...])
}

return (key[0..<4], key[4...])
}

private func containsKeyPrefix(keys: Dictionary<String, (Any, String)>.Keys, prefix: String) -> Bool {
for (_, key) in keys.enumerated() {
if key.hasPrefix(prefix) {
return true
}
}
return false
}

}
2 changes: 1 addition & 1 deletion ATInternetTracker/Sources/Info-iOS-Extension.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.21.2</string>
<string>2.22.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion ATInternetTracker/Sources/Info-iOS.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.21.2</string>
<string>2.22.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion ATInternetTracker/Sources/Info-tvOS.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.18.2</string>
<string>1.19.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion ATInternetTracker/Sources/Info-watchOS.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.18.2</string>
<string>1.19.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
Loading

0 comments on commit a493f5a

Please sign in to comment.