From 48d9dccd74d9a29bf15020bbff2dcf659d0fe6f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matu=CC=81s=CC=8C=20Tomlein?= Date: Wed, 10 Jul 2024 07:24:31 +0200 Subject: [PATCH 1/2] Fix remote configuration attempting to serialize a logger class after new configuration is fetched (close #900) --- .../Configurations/TrackerConfiguration.swift | 4 --- .../TestRemoteConfiguration.swift | 26 +++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Sources/Snowplow/Configurations/TrackerConfiguration.swift b/Sources/Snowplow/Configurations/TrackerConfiguration.swift index 5fcf85001..718fb22d4 100644 --- a/Sources/Snowplow/Configurations/TrackerConfiguration.swift +++ b/Sources/Snowplow/Configurations/TrackerConfiguration.swift @@ -588,7 +588,6 @@ public class TrackerConfiguration: SerializableConfiguration, TrackerConfigurati coder.encode(devicePlatform.rawValue, forKey: "devicePlatform") coder.encode(base64Encoding, forKey: "base64Encoding") coder.encode(logLevel.rawValue, forKey: "logLevel") - coder.encode(loggerDelegate, forKey: "loggerDelegate") coder.encode(sessionContext, forKey: "sessionContext") coder.encode(applicationContext, forKey: "applicationContext") coder.encode(platformContext, forKey: "platformContext") @@ -618,9 +617,6 @@ public class TrackerConfiguration: SerializableConfiguration, TrackerConfigurati if let logLevel = LogLevel(rawValue: coder.decodeInteger(forKey: "logLevel")) { self.logLevel = logLevel } - if let loggerDelegate = coder.decodeObject(forKey: "loggerDelegate") as? LoggerDelegate { - self.loggerDelegate = loggerDelegate - } sessionContext = coder.decodeBool(forKey: "sessionContext") applicationContext = coder.decodeBool(forKey: "applicationContext") platformContext = coder.decodeBool(forKey: "platformContext") diff --git a/Tests/Configurations/TestRemoteConfiguration.swift b/Tests/Configurations/TestRemoteConfiguration.swift index c362e54db..0e1ce415c 100644 --- a/Tests/Configurations/TestRemoteConfiguration.swift +++ b/Tests/Configurations/TestRemoteConfiguration.swift @@ -122,6 +122,30 @@ class TestRemoteConfiguration: XCTestCase { XCTAssertNil(configBundle?.trackerConfiguration) } + func testCacheTrackerConfigurationWithoutLoggerDelegate() { + let bundle = ConfigurationBundle(namespace: "namespace", + networkConfiguration: NetworkConfiguration(endpoint: "endpoint")) + bundle.trackerConfiguration = TrackerConfiguration() + .appId("my-test-app") + .loggerDelegate(MockLoggerDelegate()) + + let remoteBundle = RemoteConfigurationBundle(schema: "", configurationVersion: 1) + remoteBundle.configurationBundle = [bundle] + let remoteConfig = RemoteConfiguration(endpoint: generateRemoteConfigEndpoint(), method: .get) + var cache = RemoteConfigurationCache(remoteConfiguration: remoteConfig) + cache.clear() + cache.write(remoteBundle) + + Thread.sleep(forTimeInterval: 1) // wait the config is written on cache. + + cache = RemoteConfigurationCache(remoteConfiguration: remoteConfig) + let config = cache.read() + + let configBundle = config?.configurationBundle[0] + XCTAssertTrue(configBundle?.trackerConfiguration?.appId == "my-test-app") + XCTAssertNil(configBundle?.trackerConfiguration?.loggerDelegate) + } + func testCacheEmitterConfiguration() { let bundle = ConfigurationBundle(namespace: "namespace", networkConfiguration: NetworkConfiguration(endpoint: "endpoint")) @@ -401,6 +425,7 @@ class TestRemoteConfiguration: XCTestCase { let bundle1 = ConfigurationBundle(namespace: "ns1") bundle1.trackerConfiguration = TrackerConfiguration() .appId("app-1") + .loggerDelegate(MockLoggerDelegate()) bundle1.subjectConfiguration = SubjectConfiguration() .domainUserId("duid1") .userId("u1") @@ -421,6 +446,7 @@ class TestRemoteConfiguration: XCTestCase { XCTAssertEqual("app-1", finalBundle?.trackerConfiguration?.appId) XCTAssertEqual("u1", finalBundle?.subjectConfiguration?.userId) XCTAssertEqual("duid2", finalBundle?.subjectConfiguration?.domainUserId) + XCTAssertNotNil(finalBundle?.trackerConfiguration?.loggerDelegate) } private func generateRemoteConfigEndpoint() -> String { From e5a131494f6dff48ab6778b5adeeba8409912fd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matu=CC=81s=CC=8C=20Tomlein?= Date: Wed, 10 Jul 2024 07:27:07 +0200 Subject: [PATCH 2/2] Prepare for 6.0.6 release --- CHANGELOG | 4 ++++ Examples | 2 +- SnowplowTracker.podspec | 2 +- Sources/Core/TrackerConstants.swift | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 11887c0ce..0ceabb9f2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +Version 6.0.6 (2024-07-10) +-------------------------- +Fix remote configuration attempting to serialize a logger class after new configuration is fetched (#900) + Version 6.0.5 (2024-07-03) -------------------------- Stop sending if events fail to be removed from the event store diff --git a/Examples b/Examples index c1bc80746..2bdba1b90 160000 --- a/Examples +++ b/Examples @@ -1 +1 @@ -Subproject commit c1bc80746c5cdacadd24f055dc3f50cdd5d22c0a +Subproject commit 2bdba1b90b8305de448c9c938618013cb1ed3907 diff --git a/SnowplowTracker.podspec b/SnowplowTracker.podspec index c8657e7ae..4dbc1550f 100644 --- a/SnowplowTracker.podspec +++ b/SnowplowTracker.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "SnowplowTracker" - s.version = "6.0.5" + s.version = "6.0.6" 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 3e39762cb..a2102a4ea 100644 --- a/Sources/Core/TrackerConstants.swift +++ b/Sources/Core/TrackerConstants.swift @@ -14,7 +14,7 @@ import Foundation // --- Version -let kSPRawVersion = "6.0.5" +let kSPRawVersion = "6.0.6" #if os(iOS) let kSPVersion = "ios-\(kSPRawVersion)" #elseif os(tvOS)