Skip to content

Commit

Permalink
v3.1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-troshkov committed Sep 11, 2024
1 parent 0c0ba7f commit e0e90c3
Show file tree
Hide file tree
Showing 13 changed files with 286 additions and 167 deletions.
2 changes: 1 addition & 1 deletion PianoAnalytics-AppExtension.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'PianoAnalytics-AppExtension'
s.version = '3.1.6'
s.version = '3.1.7'
s.summary = 'Piano Analytics solution for extension Apple devices'
s.homepage = 'https://github.com/at-internet/piano-analytics-apple'
s.documentation_url = 'https://developers.atinternet-solutions.com/piano-analytics'
Expand Down
2 changes: 1 addition & 1 deletion PianoAnalytics.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'PianoAnalytics'
s.version = '3.1.6'
s.version = '3.1.7'
s.summary = 'Piano Analytics library for Apple devices'
s.homepage = 'https://github.com/at-internet/piano-analytics-apple'
s.documentation_url = 'https://developers.atinternet-solutions.com/piano-analytics'
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ If you are new to Cocoapods, please refer to [CocoaPods documentation](https://g
or
```swift
pa.sendEvent(Event(PA.EventName.Page.Display, properties: Set([
try! Property("page", "name"),
try! Property("enabled", true),
try! Property("count", "1", forceType: .int)
try! Property(PA.PropertyName.Page.Page, "name"),
try! Property(PA.PropertyName.Page.Duration, true),
try! Property(PA.PropertyName.Page.Position, "1", forceType: .int)
])))
```
Expand Down
340 changes: 235 additions & 105 deletions Sources/PianoAnalytics/Core/Constants.swift

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Sources/PianoAnalytics/PianoAnalytics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public final class PianoAnalytics {
// MARK: PUBLIC SECTION

/// SDK version
public static let sdkVersion = "3.1.6"
public static let sdkVersion = "3.1.7"

/// Send event
///
Expand Down
16 changes: 8 additions & 8 deletions Sources/PianoAnalytics/Property.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,35 +60,35 @@ public final class Property {
try self.init(name: name, value: value, forceType: forceType)
}

convenience init(_ name: String, _ value: Int, forceType: PA.PropertyType? = nil) throws {
public convenience init(_ name: String, _ value: Int, forceType: PA.PropertyType? = nil) throws {
try self.init(name: name, value: value, forceType: forceType)
}

convenience init(_ name: String, _ value: Int64, forceType: PA.PropertyType? = nil) throws {
public convenience init(_ name: String, _ value: Int64, forceType: PA.PropertyType? = nil) throws {
try self.init(name: name, value: value, forceType: forceType)
}

convenience init(_ name: String, _ value: Double, forceType: PA.PropertyType? = nil) throws {
public convenience init(_ name: String, _ value: Double, forceType: PA.PropertyType? = nil) throws {
try self.init(name: name, value: value, forceType: forceType)
}

convenience init(_ name: String, _ value: String, forceType: PA.PropertyType? = nil) throws {
public convenience init(_ name: String, _ value: String, forceType: PA.PropertyType? = nil) throws {
try self.init(name: name, value: value, forceType: forceType)
}

convenience init(_ name: String, _ value: Date) throws {
public convenience init(_ name: String, _ value: Date) throws {
try self.init(name: name, value: Int64(value.timeIntervalSince1970), forceType: .date)
}

convenience init(_ name: String, _ value: [Int], forceType: PA.PropertyType? = nil) throws {
public convenience init(_ name: String, _ value: [Int], forceType: PA.PropertyType? = nil) throws {
try self.init(name: name, value: value, forceType: forceType)
}

convenience init(_ name: String, _ value: [Double], forceType: PA.PropertyType? = nil) throws {
public convenience init(_ name: String, _ value: [Double], forceType: PA.PropertyType? = nil) throws {
try self.init(name: name, value: value, forceType: forceType)
}

convenience init(_ name: String, _ value: [String], forceType: PA.PropertyType? = nil) throws {
public convenience init(_ name: String, _ value: [String], forceType: PA.PropertyType? = nil) throws {
try self.init(name: name, value: value, forceType: forceType)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ final class InternalContextPropertiesStep: Step {

// MARK: Constants

static let DeviceTimestampUtcProperty = "device_timestamp_utc"
static let DeviceTimestampUtcProperty = PA.PropertyName.Device.TimestampUTC
static let ConnectionTypeProperty = PA.PropertyName.Connection.ConnectionType
static let DeviceScreenPropertiesFormat = "device_screen%@"
static let DeviceScreenDiagonalProperty = String(format: DeviceScreenPropertiesFormat, "_diagonal")
static let AppIdProperty = PA.PropertyName.App.Id
static let AppVersionProperty = PA.PropertyName.App.Version
static let ManufacturerProperty = "device_manufacturer"
static let ModelProperty = "device_model"
static let OsProperty = "os"
static let ManufacturerProperty = PA.PropertyName.Device.Manufacturer
static let ModelProperty = PA.PropertyName.Device.Model
static let OsProperty = PA.PropertyName.OS.OS
static let OsPropertiesFormat = "os_%@"
static let EventCollectionPropertiesFormat = "event_collection_%@"
static let BrowserLanguagePropertiesFormat = "browser_language%@"
Expand Down
4 changes: 2 additions & 2 deletions Sources/PianoAnalytics/Steps/PrivacyStep.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ final class PrivacyStep: Step {

// MARK: Constants

private static let VisitorPrivacyConsentProperty = "visitor_privacy_consent"
private static let VisitorPrivacyModeProperty = "visitor_privacy_mode"
private static let VisitorPrivacyConsentProperty = PA.PropertyName.Visitor.PrivacyConsent
private static let VisitorPrivacyModeProperty = PA.PropertyName.Visitor.PrivacyMode
private static let PagePropertiesFormat = "page_%@"

// MARK: Package methods
Expand Down
2 changes: 1 addition & 1 deletion Sources/PianoAnalytics/Steps/VisitorIDStep.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ final class VisitorIDStep: Step {
// MARK: Constants

private static let OptOut: String = "opt-out"
private static let VisitorIdTypeProperty: String = "visitor_id_type"
private static let VisitorIdTypeProperty: String = PA.PropertyName.Visitor.IdType

// MARK: Private methods

Expand Down
46 changes: 23 additions & 23 deletions Tests/PianoAnalyticsTests/PrivacyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,15 @@ class PrivacyTests: XCTestCase {
"customprop3andmore1": "3a1",
"customprop3andmore2": "3a2"
]),
Event("click.exit", data: [
"click": "click exit",
"click_chapter1": "click chapter 1",
"click_chapter2": "click chapter 2",
"click_chapter3": "click chapter 3",
"page": "page name",
"page_chapter1": "chapter 1",
"page_chapter2": "chapter 2",
"page_chapter3": "chapter 3",
Event(PA.EventName.Click.Exit, data: [
PA.PropertyName.Click.Click: "click exit",
PA.PropertyName.Click.Chapter1: "click chapter 1",
PA.PropertyName.Click.Chapter2: "click chapter 2",
PA.PropertyName.Click.Chapter3: "click chapter 3",
PA.PropertyName.Page.Page: "page name",
PA.PropertyName.Page.Chapter1: "chapter 1",
PA.PropertyName.Page.Chapter2: "chapter 2",
PA.PropertyName.Page.Chapter3: "chapter 3",
"customprop1_sub1": "11",
"customprop1_sub1_deep1": "111",
"customprop1_sub1_deep2": "112",
Expand Down Expand Up @@ -195,15 +195,15 @@ class PrivacyTests: XCTestCase {
"customprop3andmore1": "3a1",
"customprop3andmore2": "3a2"
]),
Event("click.navigation", data: [
"click": "click navigation",
"click_chapter1": "click chapter 1",
"click_chapter2": "click chapter 2",
"click_chapter3": "click chapter 3",
"page": "page name",
"page_chapter1": "chapter 1",
"page_chapter2": "chapter 2",
"page_chapter3": "chapter 3",
Event(PA.EventName.Click.Navigation, data: [
PA.PropertyName.Click.Click: "click navigation",
PA.PropertyName.Click.Chapter1: "click chapter 1",
PA.PropertyName.Click.Chapter2: "click chapter 2",
PA.PropertyName.Click.Chapter3: "click chapter 3",
PA.PropertyName.Page.Page: "page name",
PA.PropertyName.Page.Chapter1: "chapter 1",
PA.PropertyName.Page.Chapter2: "chapter 2",
PA.PropertyName.Page.Chapter3: "chapter 3",
"customprop1_sub1": "11",
"customprop1_sub1_deep1": "111",
"customprop1_sub1_deep2": "112",
Expand Down Expand Up @@ -233,11 +233,11 @@ class PrivacyTests: XCTestCase {
"customprop3andmore1": "3a1",
"customprop3andmore2": "3a2"
]),
Event("page.display", data: [
"page": "page name",
"page_chapter1": "chapter 1",
"page_chapter2": "chapter 2",
"page_chapter3": "chapter 3",
Event(PA.EventName.Page.Display, data: [
PA.PropertyName.Page.Page: "page name",
PA.PropertyName.Page.Chapter1: "chapter 1",
PA.PropertyName.Page.Chapter2: "chapter 2",
PA.PropertyName.Page.Chapter3: "chapter 3",
"customprop1_sub1": "11",
"customprop1_sub1_deep1": "111",
"customprop1_sub1_deep2": "112",
Expand Down
12 changes: 6 additions & 6 deletions Tests/PianoAnalyticsTests/PropertiesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ class PropertiesTests: XCTestCase {

self.pa.setProperty(key: "event_collection_platform", value: "1")
self.pa.setProperty(key: "event_collection_version", value: "2")
self.pa.setProperty(key: "device_timestamp_utc", value: "3")
self.pa.setProperty(key: PA.PropertyName.Device.TimestampUTC, value: "3")
self.pa.sendEvent(Event("toto", data: [:]), config: nil, p: TestProtocol { built, _ in
localBuilt1 = built
expectation.fulfill()
Expand All @@ -358,8 +358,8 @@ class PropertiesTests: XCTestCase {
XCTAssertNotEqual(events1.first?.data["event_collection_platform"] as? String, nil)
XCTAssertNotEqual(events1.first?.data["event_collection_version"] as? String, "2")
XCTAssertNotEqual(events1.first?.data["event_collection_version"] as? String, nil)
XCTAssertNotEqual(events1.first?.data["device_timestamp_utc"] as? String, "3")
XCTAssertNotEqual(events1.first?.data["device_timestamp_utc"] as? TimeInterval, nil)
XCTAssertNotEqual(events1.first?.data[PA.PropertyName.Device.TimestampUTC] as? String, "3")
XCTAssertNotEqual(events1.first?.data[PA.PropertyName.Device.TimestampUTC] as? TimeInterval, nil)
}

// MARK: - SET PROPERTIES
Expand Down Expand Up @@ -632,7 +632,7 @@ class PropertiesTests: XCTestCase {
let expectation = self.expectation(description: "Before send")
var localBuilt1: BuiltModel?

self.pa.setProperties(["event_collection_platform": "1", "event_collection_version": "2", "device_timestamp_utc": "3"])
self.pa.setProperties(["event_collection_platform": "1", "event_collection_version": "2", PA.PropertyName.Device.TimestampUTC: "3"])
self.pa.sendEvent(Event("toto", data: [:]), config: nil, p: TestProtocol { built, _ in
localBuilt1 = built
expectation.fulfill()
Expand All @@ -645,8 +645,8 @@ class PropertiesTests: XCTestCase {
XCTAssertNotEqual(events1.first?.data["event_collection_platform"] as? String, nil)
XCTAssertNotEqual(events1.first?.data["event_collection_version"] as? String, "2")
XCTAssertNotEqual(events1.first?.data["event_collection_version"] as? String, nil)
XCTAssertNotEqual(events1.first?.data["device_timestamp_utc"] as? String, "3")
XCTAssertNotEqual(events1.first?.data["device_timestamp_utc"] as? TimeInterval, nil)
XCTAssertNotEqual(events1.first?.data[PA.PropertyName.Device.TimestampUTC] as? String, "3")
XCTAssertNotEqual(events1.first?.data[PA.PropertyName.Device.TimestampUTC] as? TimeInterval, nil)
}

// MARK: - DELETE PROPERTY
Expand Down
11 changes: 0 additions & 11 deletions Tests/PianoAnalyticsTests/PropertyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,3 @@ class PropertyTests: XCTestCase {
XCTAssertEqual(set.first?.value as? Int, 1)
}
}

func nnn() {

pa.sendEvent(
Event(PA.EventName.Page.Display, properties: Set([
try! Property("page", "name"),
try! Property("enabled", true),
try! Property("count", "1", forceType: .int)
]))
)
}
2 changes: 1 addition & 1 deletion Tests/PianoAnalyticsTests/SendTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class SendTests: XCTestCase {
self.pa.getModel { m in
model = m
}
self.pa.sendEvent(Event("page.display"), config: nil, p: PianoAnalyticsCallbacks { _, _ in
self.pa.sendEvent(Event(PA.EventName.Page.Display), config: nil, p: PianoAnalyticsCallbacks { _, _ in
expectation.fulfill()
})
waitForExpectations(timeout: 5, handler: nil)
Expand Down

0 comments on commit e0e90c3

Please sign in to comment.