From 2720993eeff6c97054792c6756c7f517c4c82abd Mon Sep 17 00:00:00 2001 From: Brandon Sneed Date: Tue, 14 Jan 2025 15:15:49 -0800 Subject: [PATCH 1/4] explicit ubuntu version for tests --- .github/workflows/swift.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index a8a43bd..09a6ceb 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -51,7 +51,7 @@ jobs: build_and_test_spm_linux: needs: cancel_previous - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - uses: sersoft-gmbh/swifty-linux-action@v3 with: From 67f54d6d3252bf24d1c14402aec03fd472cf7c6d Mon Sep 17 00:00:00 2001 From: Brandon Sneed Date: Tue, 14 Jan 2025 15:20:47 -0800 Subject: [PATCH 2/4] trying again --- .github/workflows/swift.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 09a6ceb..df5bd97 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -51,10 +51,11 @@ jobs: build_and_test_spm_linux: needs: cancel_previous - runs-on: ubuntu-24.04 + runs-on: ubuntu-latest steps: - uses: sersoft-gmbh/swifty-linux-action@v3 with: + platform: ubuntu-24.04 release-version: "5.9.2" github-token: ${{secrets.GITHUB_TOKEN}} - uses: actions/checkout@v2 From c5b7abfa4920e3335ced94da712aefd5c67f3ea1 Mon Sep 17 00:00:00 2001 From: Brandon Sneed Date: Tue, 14 Jan 2025 15:23:00 -0800 Subject: [PATCH 3/4] and again --- .github/workflows/swift.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index df5bd97..375f71b 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -55,7 +55,7 @@ jobs: steps: - uses: sersoft-gmbh/swifty-linux-action@v3 with: - platform: ubuntu-24.04 + platform: ubuntu-22.04 release-version: "5.9.2" github-token: ${{secrets.GITHUB_TOKEN}} - uses: actions/checkout@v2 From dd0f9c96637d518c6033d7025b1e8475fe749c98 Mon Sep 17 00:00:00 2001 From: Brandon Sneed Date: Tue, 14 Jan 2025 15:43:47 -0800 Subject: [PATCH 4/4] put the multi-writekey check back in --- Sources/Segment/Analytics.swift | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Sources/Segment/Analytics.swift b/Sources/Segment/Analytics.swift index bcaf696..f8c7c21 100644 --- a/Sources/Segment/Analytics.swift +++ b/Sources/Segment/Analytics.swift @@ -60,14 +60,14 @@ public class Analytics { /// - Parameters: /// - configuration: The configuration to use public init(configuration: Configuration) { - /*if Self.isActiveWriteKey(configuration.values.writeKey) { + if Self.isActiveWriteKey(configuration.values.writeKey) { // If you're hitting this in testing, it could be a memory leak, or something async is still running // and holding a reference. You can use XCTest.waitUntilFinished(...) to wait for things to complete. fatalError("Cannot initialize multiple instances of Analytics with the same write key") } else { Self.addActiveWriteKey(configuration.values.writeKey) - }*/ - + } + store = Store() storage = Storage( store: self.store, @@ -80,7 +80,7 @@ public class Analytics { // provide our default state store.provide(state: System.defaultState(configuration: configuration, from: storage)) store.provide(state: UserInfo.defaultState(from: storage, anonIdGenerator: configuration.values.anonymousIdGenerator)) - + storage.analytics = self checkSharedInstance() @@ -88,7 +88,7 @@ public class Analytics { // Get everything running platformStartup() - Telemetry.shared.increment(metric: Telemetry.INVOKE_METRIC) {it in + Telemetry.shared.increment(metric: Telemetry.INVOKE_METRIC) {it in it["message"] = "configured" it["apihost"] = configuration.values.apiHost it["cdnhost"] = configuration.values.cdnHost @@ -97,7 +97,7 @@ public class Analytics { it["config"] = "seg:\(configuration.values.autoAddSegmentDestination) ua:\(configuration.values.userAgent ?? "N/A")" } } - + deinit { Self.removeActiveWriteKey(configuration.values.writeKey) } @@ -117,9 +117,9 @@ public class Analytics { policy.reset() } }*/ - + let flushPolicies = configuration.values.flushPolicies - + var shouldFlush = false // if any policy says to flush, make note of that for policy in flushPolicies { @@ -178,12 +178,12 @@ extension Analytics { store.dispatch(action: System.ToggleEnabledAction(enabled: value)) } } - + /// Returns the writekey in use for this instance. public var writeKey: String { return configuration.values.writeKey } - + /// Returns the anonymousId currently in use. public var anonymousId: String { if let userInfo: UserInfo = store.currentState() { @@ -260,7 +260,7 @@ extension Analytics { public func flush(completion: (() -> Void)? = nil) { // only flush if we're enabled. guard enabled == true else { completion?(); return } - + let completionGroup = CompletionGroup(queue: configuration.values.flushQueue) apply { plugin in completionGroup.add { group in @@ -273,7 +273,7 @@ extension Analytics { } } } - + completionGroup.run(mode: operatingMode) { completion?() } @@ -450,18 +450,18 @@ extension Analytics { internal var isDead: Bool { return configuration.values.writeKey == Self.deadInstance } - + /// Manage active writekeys. It's wrapped in @atomic internal static func isActiveWriteKey(_ writeKey: String) -> Bool { Self.activeWriteKeys.contains(writeKey) } - + internal static func addActiveWriteKey(_ writeKey: String) { Self._activeWriteKeys.mutate { keys in keys.append(writeKey) } } - + internal static func removeActiveWriteKey(_ writeKey: String) { Self._activeWriteKeys.mutate { keys in keys.removeAll { key in