Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update linux test suites #378

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
steps:
- uses: sersoft-gmbh/swifty-linux-action@v3
with:
platform: ubuntu-22.04
release-version: "5.9.2"
github-token: ${{secrets.GITHUB_TOKEN}}
- uses: actions/checkout@v2
Expand Down
30 changes: 15 additions & 15 deletions Sources/Segment/Analytics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -80,15 +80,15 @@ 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()

// 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
Expand All @@ -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)
}
Expand All @@ -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 {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand All @@ -273,7 +273,7 @@ extension Analytics {
}
}
}

completionGroup.run(mode: operatingMode) {
completion?()
}
Expand Down Expand Up @@ -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
Expand Down
Loading