diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 540ab27..b7e76a5 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -36,7 +36,7 @@ jobs: with: xcode-version: latest-stable - uses: actions/checkout@v2 - - run: xcodebuild -scheme SegmentConsent test -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13' + - run: xcodebuild -scheme SegmentConsent test -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 15' build_and_test_tvos: needs: cancel_previous diff --git a/Package.resolved b/Package.resolved index 8a5ecc8..a727a04 100644 --- a/Package.resolved +++ b/Package.resolved @@ -5,8 +5,17 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/segmentio/analytics-swift.git", "state" : { - "revision" : "efc111b5fccaebd1063ef0db6d206c252da387ec", - "version" : "1.4.8" + "revision" : "338be8f55c83309f10d2cfd0193505117b4ab2d5", + "version" : "1.6.0" + } + }, + { + "identity" : "jsonsafeencoding-swift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/segmentio/jsonsafeencoding-swift.git", + "state" : { + "revision" : "af6a8b360984085e36c6341b21ecb35c12f47ebd", + "version" : "2.0.0" } }, { @@ -14,8 +23,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/segmentio/Sovran-Swift.git", "state" : { - "revision" : "64f3b5150c282a34af4578188dce2fd597e600e3", - "version" : "1.1.0" + "revision" : "24867f3e4ac62027db9827112135e6531b6f4051", + "version" : "1.1.2" } } ], diff --git a/Package.swift b/Package.swift index 4439af5..a2e6294 100644 --- a/Package.swift +++ b/Package.swift @@ -8,7 +8,7 @@ let package = Package( platforms: [ .macOS("10.15"), .iOS("13.0"), - .tvOS("11.0") + .tvOS("13.0") ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. @@ -19,7 +19,7 @@ let package = Package( dependencies: [ // Dependencies declare other packages that this package depends on. // .package(url: /* package url */, from: "1.0.0"), - .package(url: "https://github.com/segmentio/analytics-swift.git", from: "1.4.8") + .package(url: "https://github.com/segmentio/analytics-swift.git", from: "1.6.0") ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. diff --git a/Sources/SegmentConsent-Tests/ConsentBlockerTests.swift b/Sources/SegmentConsent-Tests/ConsentBlockerTests.swift index e2ee5b0..c84d785 100644 --- a/Sources/SegmentConsent-Tests/ConsentBlockerTests.swift +++ b/Sources/SegmentConsent-Tests/ConsentBlockerTests.swift @@ -17,7 +17,7 @@ final class ConsentBlockerTests: XCTestCase { } func testBlockWhenPartialConsentAvailable() { - let analytics = Analytics(configuration: Configuration(writeKey: "test").trackApplicationLifecycleEvents(false)) + let analytics = Analytics(configuration: Configuration(writeKey: "cbt.testBlockWhenPartialConsentAvailable").trackApplicationLifecycleEvents(false)) // Artificially give segment.io destination some consent settings let segmentSettings = [ @@ -51,7 +51,7 @@ final class ConsentBlockerTests: XCTestCase { } func testBlockBecauseNoConsentSettings() { - let analytics = Analytics(configuration: Configuration(writeKey: "test").trackApplicationLifecycleEvents(false)) + let analytics = Analytics(configuration: Configuration(writeKey: "cbt.testBlockBecauseNoConsentSettings").trackApplicationLifecycleEvents(false)) let output = OutputReaderPlugin() let consentManager = ConsentManager(provider: NoConsentProvider()) @@ -72,7 +72,7 @@ final class ConsentBlockerTests: XCTestCase { } func testBlockBecauseNoStamp() { - let analytics = Analytics(configuration: Configuration(writeKey: "test").trackApplicationLifecycleEvents(false)) + let analytics = Analytics(configuration: Configuration(writeKey: "cbt.testBlockBecauseNoStamp").trackApplicationLifecycleEvents(false)) let output = OutputReaderPlugin() let consentManager = ConsentManager(provider: AllConsentProvider()) @@ -106,7 +106,7 @@ final class ConsentBlockerTests: XCTestCase { } func testBlockBecauseNoConsent() { - let analytics = Analytics(configuration: Configuration(writeKey: "test").trackApplicationLifecycleEvents(false)) + let analytics = Analytics(configuration: Configuration(writeKey: "cbt.testBlockBecauseNoConsent").trackApplicationLifecycleEvents(false)) let output = OutputReaderPlugin() let consentManager = ConsentManager(provider: NoConsentProvider()) diff --git a/Sources/SegmentConsent-Tests/ConsentNotEnabledAtSegment.swift b/Sources/SegmentConsent-Tests/ConsentNotEnabledAtSegment.swift index 690bcb8..325ff7a 100644 --- a/Sources/SegmentConsent-Tests/ConsentNotEnabledAtSegment.swift +++ b/Sources/SegmentConsent-Tests/ConsentNotEnabledAtSegment.swift @@ -20,10 +20,10 @@ final class ConsentNotEnabledAtSegment: XCTestCase { } func testNoToAll() { - removeUserDefaults(forWriteKey: "test") + removeUserDefaults(forWriteKey: "testNoToAll") let settings = Settings.load(resource: "ConsentNotEnabledAtSegment.json", bundle: Bundle.module) - let analytics = Analytics(configuration: Configuration(writeKey: "test") + let analytics = Analytics(configuration: Configuration(writeKey: "testNoToAll") .trackApplicationLifecycleEvents(false) .defaultSettings(settings) ) @@ -82,10 +82,10 @@ final class ConsentNotEnabledAtSegment: XCTestCase { } func testYesToSome() { - removeUserDefaults(forWriteKey: "test") + removeUserDefaults(forWriteKey: "testYesToSome") let settings = Settings.load(resource: "ConsentNotEnabledAtSegment.json", bundle: Bundle.module) - let analytics = Analytics(configuration: Configuration(writeKey: "test") + let analytics = Analytics(configuration: Configuration(writeKey: "testYesToSome") .trackApplicationLifecycleEvents(false) .defaultSettings(settings) ) @@ -144,10 +144,10 @@ final class ConsentNotEnabledAtSegment: XCTestCase { } func testYesToAll() { - removeUserDefaults(forWriteKey: "test") + removeUserDefaults(forWriteKey: "testYesToAll") let settings = Settings.load(resource: "ConsentNotEnabledAtSegment.json", bundle: Bundle.module) - let analytics = Analytics(configuration: Configuration(writeKey: "test") + let analytics = Analytics(configuration: Configuration(writeKey: "testYesToAll") .trackApplicationLifecycleEvents(false) .defaultSettings(settings) ) diff --git a/Sources/SegmentConsent-Tests/DestinationsMultipleCategories.swift b/Sources/SegmentConsent-Tests/DestinationsMultipleCategories.swift index 606e8df..c2db180 100644 --- a/Sources/SegmentConsent-Tests/DestinationsMultipleCategories.swift +++ b/Sources/SegmentConsent-Tests/DestinationsMultipleCategories.swift @@ -20,10 +20,10 @@ final class DestinationsMultipleCategoriesTests: XCTestCase { } func testNoToAll() { - removeUserDefaults(forWriteKey: "test") + removeUserDefaults(forWriteKey: "dmc.testNoToAll") let settings = Settings.load(resource: "DestinationsMultipleCategories.json", bundle: Bundle.module) - let analytics = Analytics(configuration: Configuration(writeKey: "test") + let analytics = Analytics(configuration: Configuration(writeKey: "dmc.testNoToAll") .trackApplicationLifecycleEvents(false) .defaultSettings(settings) ) @@ -67,10 +67,10 @@ final class DestinationsMultipleCategoriesTests: XCTestCase { } func testYesTo1() { - removeUserDefaults(forWriteKey: "test") + removeUserDefaults(forWriteKey: "dmc.testYesTo1") let settings = Settings.load(resource: "DestinationsMultipleCategories.json", bundle: Bundle.module) - let analytics = Analytics(configuration: Configuration(writeKey: "test") + let analytics = Analytics(configuration: Configuration(writeKey: "dmc.testYesTo1") .trackApplicationLifecycleEvents(false) .defaultSettings(settings) ) @@ -114,10 +114,10 @@ final class DestinationsMultipleCategoriesTests: XCTestCase { } func testYesTo2() { - removeUserDefaults(forWriteKey: "test") + removeUserDefaults(forWriteKey: "dmc.testYesTo2") let settings = Settings.load(resource: "DestinationsMultipleCategories.json", bundle: Bundle.module) - let analytics = Analytics(configuration: Configuration(writeKey: "test") + let analytics = Analytics(configuration: Configuration(writeKey: "dmc.testYesTo2") .trackApplicationLifecycleEvents(false) .defaultSettings(settings) ) @@ -161,10 +161,10 @@ final class DestinationsMultipleCategoriesTests: XCTestCase { } func testYesToAll() { - removeUserDefaults(forWriteKey: "test") + removeUserDefaults(forWriteKey: "dmc.testYesToAll") let settings = Settings.load(resource: "DestinationsMultipleCategories.json", bundle: Bundle.module) - let analytics = Analytics(configuration: Configuration(writeKey: "test") + let analytics = Analytics(configuration: Configuration(writeKey: "dmc.testYesToAll") .trackApplicationLifecycleEvents(false) .defaultSettings(settings) ) diff --git a/Sources/SegmentConsent-Tests/NoUnmappedDestinationsTests.swift b/Sources/SegmentConsent-Tests/NoUnmappedDestinationsTests.swift index 4dc7cce..cd9244e 100644 --- a/Sources/SegmentConsent-Tests/NoUnmappedDestinationsTests.swift +++ b/Sources/SegmentConsent-Tests/NoUnmappedDestinationsTests.swift @@ -20,10 +20,10 @@ final class NoUnmappedDestinationsTests: XCTestCase { } func testNoToAll() { - removeUserDefaults(forWriteKey: "test") + removeUserDefaults(forWriteKey: "nud.testNoToAll") let settings = Settings.load(resource: "NoUnmappedDestinations.json", bundle: Bundle.module) - let analytics = Analytics(configuration: Configuration(writeKey: "test") + let analytics = Analytics(configuration: Configuration(writeKey: "nud.testNoToAll") .trackApplicationLifecycleEvents(false) .defaultSettings(settings) ) diff --git a/Sources/SegmentConsent-Tests/UnmappedDestinationsTests.swift b/Sources/SegmentConsent-Tests/UnmappedDestinationsTests.swift index 0df8aa7..0c68175 100644 --- a/Sources/SegmentConsent-Tests/UnmappedDestinationsTests.swift +++ b/Sources/SegmentConsent-Tests/UnmappedDestinationsTests.swift @@ -20,10 +20,10 @@ final class UnmappedDestinationsTests: XCTestCase { } func testNoToAll() { - removeUserDefaults(forWriteKey: "test") + removeUserDefaults(forWriteKey: "ud.testNoToAll") let settings = Settings.load(resource: "UnmappedDestinations.json", bundle: Bundle.module) - let analytics = Analytics(configuration: Configuration(writeKey: "test") + let analytics = Analytics(configuration: Configuration(writeKey: "ud.testNoToAll") .trackApplicationLifecycleEvents(false) .defaultSettings(settings) ) @@ -82,10 +82,10 @@ final class UnmappedDestinationsTests: XCTestCase { } func testYesTo1() { - removeUserDefaults(forWriteKey: "test") + removeUserDefaults(forWriteKey: "ud.testYesTo1") let settings = Settings.load(resource: "UnmappedDestinations.json", bundle: Bundle.module) - let analytics = Analytics(configuration: Configuration(writeKey: "test") + let analytics = Analytics(configuration: Configuration(writeKey: "ud.testYesTo1") .trackApplicationLifecycleEvents(false) .defaultSettings(settings) ) @@ -144,10 +144,10 @@ final class UnmappedDestinationsTests: XCTestCase { } func testYesTo2() { - removeUserDefaults(forWriteKey: "test") + removeUserDefaults(forWriteKey: "ud.testYesTo2") let settings = Settings.load(resource: "UnmappedDestinations.json", bundle: Bundle.module) - let analytics = Analytics(configuration: Configuration(writeKey: "test") + let analytics = Analytics(configuration: Configuration(writeKey: "ud.testYesTo2") .trackApplicationLifecycleEvents(false) .defaultSettings(settings) ) @@ -206,10 +206,10 @@ final class UnmappedDestinationsTests: XCTestCase { } func testYesTo3() { - removeUserDefaults(forWriteKey: "test") + removeUserDefaults(forWriteKey: "ud.testYesTo3") let settings = Settings.load(resource: "UnmappedDestinations.json", bundle: Bundle.module) - let analytics = Analytics(configuration: Configuration(writeKey: "test") + let analytics = Analytics(configuration: Configuration(writeKey: "ud.testYesTo3") .trackApplicationLifecycleEvents(false) .defaultSettings(settings) ) @@ -268,10 +268,10 @@ final class UnmappedDestinationsTests: XCTestCase { } func testYesTo4() { - removeUserDefaults(forWriteKey: "test") + removeUserDefaults(forWriteKey: "ud.testYesTo4") let settings = Settings.load(resource: "UnmappedDestinations.json", bundle: Bundle.module) - let analytics = Analytics(configuration: Configuration(writeKey: "test") + let analytics = Analytics(configuration: Configuration(writeKey: "ud.testYesTo4") .trackApplicationLifecycleEvents(false) .defaultSettings(settings) ) @@ -330,10 +330,10 @@ final class UnmappedDestinationsTests: XCTestCase { } func testYesTo1and2() { - removeUserDefaults(forWriteKey: "test") + removeUserDefaults(forWriteKey: "ud.testYesTo1and2") let settings = Settings.load(resource: "UnmappedDestinations.json", bundle: Bundle.module) - let analytics = Analytics(configuration: Configuration(writeKey: "test") + let analytics = Analytics(configuration: Configuration(writeKey: "ud.testYesTo1and2") .trackApplicationLifecycleEvents(false) .defaultSettings(settings) ) @@ -392,10 +392,10 @@ final class UnmappedDestinationsTests: XCTestCase { } func testYesToAll() { - removeUserDefaults(forWriteKey: "test") + removeUserDefaults(forWriteKey: "ud.testYesToAll") let settings = Settings.load(resource: "UnmappedDestinations.json", bundle: Bundle.module) - let analytics = Analytics(configuration: Configuration(writeKey: "test") + let analytics = Analytics(configuration: Configuration(writeKey: "ud.testYesToAll") .trackApplicationLifecycleEvents(false) .defaultSettings(settings) ) diff --git a/Sources/SegmentConsent/Manager.swift b/Sources/SegmentConsent/Manager.swift index fa8e346..f3cbf12 100644 --- a/Sources/SegmentConsent/Manager.swift +++ b/Sources/SegmentConsent/Manager.swift @@ -81,7 +81,7 @@ extension ConsentManager { } public func start() { - started = true + _started.set(true) // replay events. they'll be sent back through the system and get stamped above. for event in queuedEvents { analytics?.process(event: event)