Skip to content

[FME-4222] - New Events and InternalEvents with metadata #683

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

Open
wants to merge 1 commit into
base: FME-4220-events_baseline
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
26 changes: 21 additions & 5 deletions Split/Events/SplitEvent.swift
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
//
// SplitEvent.swift
// Split
//
// Created by Sebastian Arrubia on 4/17/18.
//

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: EventMetadata?

@objc public init(type: SplitEvent, metadata: EventMetadata? = 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 {
Expand All @@ -23,6 +37,8 @@ import Foundation
return "SDK_READY_TIMED_OUT"
case .sdkReadyFromCache:
return "SDK_READY_FROM_CACHE"
case .sdkError:
return "SDK_ERROR"
}
}
}
19 changes: 14 additions & 5 deletions Split/Events/SplitInternalEvent.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
//
// SplitInternalEvent.swift
// Split
//
// Created by Sebastian Arrubia on 4/16/18.
//

import Foundation

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

init(_ type: SplitInternalEvent, metadata: EventMetadata? = 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
Loading