From bee109d71260521c9a781400560fb3e2387d26f8 Mon Sep 17 00:00:00 2001 From: Miranda Wilson Date: Fri, 9 Feb 2024 13:21:56 +0000 Subject: [PATCH 1/3] Add percent progress to event (close #875) --- .../Media/Controllers/MediaTrackingImpl.swift | 2 +- .../Events/MediaPercentProgressEvent.swift | 9 +++++++++ Tests/Media/TestMediaController.swift | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Sources/Core/Media/Controllers/MediaTrackingImpl.swift b/Sources/Core/Media/Controllers/MediaTrackingImpl.swift index 59079b4e1..8c1c3148f 100644 --- a/Sources/Core/Media/Controllers/MediaTrackingImpl.swift +++ b/Sources/Core/Media/Controllers/MediaTrackingImpl.swift @@ -136,7 +136,7 @@ class MediaTrackingImpl: MediaTracking { addEntitiesAndTrack(event: event) } if shouldSendPercentProgress() { - addEntitiesAndTrack(event: MediaPercentProgressEvent()) + addEntitiesAndTrack(event: MediaPercentProgressEvent(percentProgress: self.player.percentProgress)) } // update state for events after this one diff --git a/Sources/Core/Media/Events/MediaPercentProgressEvent.swift b/Sources/Core/Media/Events/MediaPercentProgressEvent.swift index b46447f1b..ec73060a5 100644 --- a/Sources/Core/Media/Events/MediaPercentProgressEvent.swift +++ b/Sources/Core/Media/Events/MediaPercentProgressEvent.swift @@ -16,11 +16,20 @@ import Foundation /** Media player event fired when a percentage boundary set in the `boundaries` list in `MediaTrackingConfiguration` is reached. */ class MediaPercentProgressEvent: SelfDescribingAbstract { + let percentProgress: Int? + override var schema: String { return MediaSchemata.eventSchema("percent_progress") } override var payload: [String : Any] { + if let percentProgress = percentProgress { + return ["percentProgress": percentProgress] + } return [:] } + + public init(percentProgress: Int?) { + self.percentProgress = percentProgress + } } diff --git a/Tests/Media/TestMediaController.swift b/Tests/Media/TestMediaController.swift index b1c7ef3ab..56009c0e4 100644 --- a/Tests/Media/TestMediaController.swift +++ b/Tests/Media/TestMediaController.swift @@ -409,6 +409,25 @@ class TestMediaController: XCTestCase { XCTAssertEqual(3, trackedEvents.filter { $0.schema?.contains("percent_progress") ?? false }.count) } + func testProgressEventsShouldHavePercentValue() { + let configuration = MediaTrackingConfiguration(id: "media", + player: MediaPlayerEntity(duration: 100)) + .boundaries([5]) + let media = mediaController?.startMediaTracking(configuration: configuration) + + media?.track(MediaPlayEvent()) + for i in 1..<10 { + media?.update(player: MediaPlayerEntity(currentTime: Double(i))) + } + + waitForEventsToBeTracked() + + XCTAssertEqual(2, trackedEvents.count) + let progressEvents = trackedEvents.filter { $0.schema?.contains("percent_progress") ?? false } + XCTAssertEqual(1, progressEvents.count) + XCTAssertEqual(5, progressEvents[0].payload["percentProgress"] as? Int) + } + func testDoesntSendProgressEventsIfPaused() { let configuration = MediaTrackingConfiguration(id: "media", player: MediaPlayerEntity(duration: 100)) From 0a7926039d094ad6118beed2e988d45d266299db Mon Sep 17 00:00:00 2001 From: Miranda Wilson Date: Tue, 13 Feb 2024 12:00:05 +0000 Subject: [PATCH 2/3] Make EmitterEvent constructor public (close #876) * Add public to constructor * Add objc annotation --- Sources/Snowplow/Emitter/EmitterEvent.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/Snowplow/Emitter/EmitterEvent.swift b/Sources/Snowplow/Emitter/EmitterEvent.swift index 76f444a2c..c5e9139a9 100644 --- a/Sources/Snowplow/Emitter/EmitterEvent.swift +++ b/Sources/Snowplow/Emitter/EmitterEvent.swift @@ -18,7 +18,8 @@ public class EmitterEvent: NSObject { private(set) var payload: Payload private(set) var storeId: Int64 - init(payload: Payload, storeId: Int64) { + @objc + public init(payload: Payload, storeId: Int64) { self.payload = payload self.storeId = storeId } From c2a6d5650cdb6053810e6ecca81f620779b7bde4 Mon Sep 17 00:00:00 2001 From: Miranda Wilson Date: Tue, 13 Feb 2024 14:59:35 +0000 Subject: [PATCH 3/3] Prepare for v6.0.1 release --- CHANGELOG | 5 +++++ Examples | 2 +- SnowplowTracker.podspec | 2 +- Sources/Core/TrackerConstants.swift | 2 +- VERSION | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index acdf8625a..97273a437 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +Version 6.0.1 (2024-02-14) +-------------------------- +Make EmitterEvent constructor public (#876) +Add percent progress to event (#875) + Version 6.0.0 (2024-02-01) -------------------------- - Add screen engagement tracking of time spent and list items scrolled on a screen (#851) diff --git a/Examples b/Examples index 1f45399ac..eadc74917 160000 --- a/Examples +++ b/Examples @@ -1 +1 @@ -Subproject commit 1f45399ac1076b930d5e0b58a7e82733a9025204 +Subproject commit eadc74917e7c73f8851a4e44a3b38a607b0033b3 diff --git a/SnowplowTracker.podspec b/SnowplowTracker.podspec index 6703f926d..5a6527878 100644 --- a/SnowplowTracker.podspec +++ b/SnowplowTracker.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "SnowplowTracker" - s.version = "6.0.0" + s.version = "6.0.1" s.summary = "Snowplow event tracker for iOS, macOS, tvOS, watchOS for apps and games." s.description = <<-DESC Snowplow is a mobile and event analytics platform with a difference: rather than tell our users how they should analyze their data, we deliver their event-level data in their own data warehouse, on their own Amazon Redshift or Postgres database, so they can analyze it any way they choose. Snowplow mobile is used by data-savvy games companies and app developers to better understand their users and how they engage with their games and applications. Snowplow is open source using the business-friendly Apache License, Version 2.0 and scales horizontally to many billions of events. diff --git a/Sources/Core/TrackerConstants.swift b/Sources/Core/TrackerConstants.swift index dbc1811f9..a20506218 100644 --- a/Sources/Core/TrackerConstants.swift +++ b/Sources/Core/TrackerConstants.swift @@ -14,7 +14,7 @@ import Foundation // --- Version -let kSPRawVersion = "6.0.0" +let kSPRawVersion = "6.0.1" #if os(iOS) let kSPVersion = "ios-\(kSPRawVersion)" #elseif os(tvOS) diff --git a/VERSION b/VERSION index 09b254e90..5fe607230 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.0.0 +6.0.1