Skip to content

Added entities #648

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

Draft
wants to merge 7 commits into
base: development
Choose a base branch
from
Draft
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
2 changes: 0 additions & 2 deletions Split/Api/SplitClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

import Foundation

public typealias SplitAction = () -> Void

@objc public protocol SplitClient {

// MARK: Evaluation feature
Expand Down
63 changes: 55 additions & 8 deletions Split/Events/SplitEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,69 @@

import Foundation

// All events (internal & external) support metadata.
// Internal errors are propagated to the customer as events "(.sdkError)". The error info will travel as the event metadata.

@objcMembers public class SplitEventWithMetadata: NSObject {
let type: SplitEvent
let metadata: SplitMetadata?

@objc public init(type: SplitEvent, metadata: SplitMetadata? = nil) {
self.type = type
self.metadata = metadata
}

public override func isEqual(_ object: Any?) -> Bool {
guard let other = object as? SplitEventWithMetadata else { return false }
return self.type == other.type
}
}

@objc public enum SplitEvent: Int {
case sdkReady
case sdkReadyTimedOut
case sdkReadyFromCache
case sdkUpdated
case sdkError

public func toString() -> String {
switch self {
case .sdkReady:
return "SDK_READY"
case .sdkUpdated:
return "SDK_UPDATE"
case .sdkReadyTimedOut:
return "SDK_READY_TIMED_OUT"
case .sdkReadyFromCache:
return "SDK_READY_FROM_CACHE"
case .sdkReady:
return "SDK_READY"
case .sdkUpdated:
return "SDK_UPDATE"
case .sdkReadyTimedOut:
return "SDK_READY_TIMED_OUT"
case .sdkReadyFromCache:
return "SDK_READY_FROM_CACHE"
case .sdkError:
return "SDK_ERROR"
}
}
}

@objc public class SplitMetadata: NSObject {
var type: SplitMetadataType
var data: String = ""

init(type: SplitMetadataType, data: String) {
self.type = type
self.data = data
}
}

enum SplitMetadataType: Int {
case FEATURE_FLAGS_SYNC_ERROR
case SEGMENTS_SYNC_ERROR

public func toString() -> String {
switch self {
case .FEATURE_FLAGS_SYNC_ERROR:
return "FEATURE_FLAGS_SYNC_ERROR"
case .SEGMENTS_SYNC_ERROR:
return "SEGMENTS_SYNC_ERROR"

}
}
}

7 changes: 7 additions & 0 deletions Split/Events/SplitEventActionTask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@

import Foundation

public typealias SplitAction = () -> Void
public typealias SplitActionWithMetadata = (_ metadata: SplitMetadata?) -> Void

class SplitEventActionTask: SplitEventTask {

// Private
private var eventHandler: SplitAction?
private var eventHandlerWithMetadata: SplitActionWithMetadata?
private var queue: DispatchQueue?

// Public
var event: SplitEvent
var runInBackground: Bool = false
var factory: SplitFactory
Expand Down
14 changes: 14 additions & 0 deletions Split/Events/SplitInternalEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@

import Foundation

struct SplitInternalEventWithMetadata {
let type: SplitInternalEvent
let metadata: SplitMetadata?

init(_ type: SplitInternalEvent, metadata: SplitMetadata? = nil) {
self.type = type
self.metadata = metadata
}

static func == (lhs: SplitInternalEventWithMetadata, rhs: SplitInternalEventWithMetadata) -> Bool {
return lhs.type == rhs.type
}
}

enum SplitInternalEvent {
case mySegmentsUpdated
case myLargeSegmentsUpdated
Expand Down
1 change: 1 addition & 0 deletions SplitTests/Integration/Recorder/TelemetryTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ class TelemetryTest: XCTestCase {
XCTAssertEqual(0, sum(latenciesAfter.treatmentsWithConfig))
XCTAssertEqual(0, sum(latenciesAfter.track))


let semaphore = DispatchSemaphore(value: 0)
client.destroy(completion: {
_ = semaphore.signal()
Expand Down
Loading