Skip to content

[FME-4230] Events - Updated Segments #689

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 10 commits into
base: FME-4228-events-updatedFlag
Choose a base branch
from
29 changes: 11 additions & 18 deletions Split/Api/DefaultSplitClient.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
//
// DefaultSplitClient.swift
// Split
//
// Created by Brian Sztamfater on 20/9/17.
// Modified by Natalia Stele on 11/10/17.
//
//

import Foundation

Expand Down Expand Up @@ -55,7 +49,7 @@ public final class DefaultSplitClient: NSObject, SplitClient, TelemetrySplitClie
}
}

// MARK: Events
// MARK: Customers Listeners
extension DefaultSplitClient {

public func on(event: SplitEvent, execute action: @escaping SplitAction) {
Expand Down Expand Up @@ -173,7 +167,7 @@ extension DefaultSplitClient {
}
}

// MARK: Track Events
// MARK: Tracking
extension DefaultSplitClient {

public func track(trafficType: String, eventType: String) -> Bool {
Expand Down Expand Up @@ -223,7 +217,7 @@ extension DefaultSplitClient {
}
}

// MARK: Persistent attributes feature
// MARK: Persistence
extension DefaultSplitClient {

public func setAttribute(name: String, value: Any) -> Bool {
Expand Down Expand Up @@ -265,8 +259,7 @@ extension DefaultSplitClient {
}

private func isValidAttribute(_ value: Any) -> Bool {
return anyValueValidator.isPrimitiveValue(value: value) ||
anyValueValidator.isList(value: value)
return anyValueValidator.isPrimitiveValue(value: value) || anyValueValidator.isList(value: value)
}

private func logInvalidAttribute(name: String) {
Expand All @@ -275,31 +268,31 @@ extension DefaultSplitClient {
}

private func attributesStorage() -> AttributesStorage {
return storageContainer.attributesStorage
storageContainer.attributesStorage
}
}

// MARK: By Sets evaluation
// MARK: By Flagsets
extension DefaultSplitClient {
public func getTreatmentsByFlagSet(_ flagSet: String, attributes: [String: Any]?) -> [String: String] {
return treatmentManager.getTreatmentsByFlagSet(flagSet: flagSet, attributes: attributes, evaluationOptions: nil)
treatmentManager.getTreatmentsByFlagSet(flagSet: flagSet, attributes: attributes, evaluationOptions: nil)
}

public func getTreatmentsByFlagSets(_ flagSets: [String], attributes: [String: Any]?) -> [String: String] {
return treatmentManager.getTreatmentsByFlagSets(flagSets: flagSets, attributes: attributes, evaluationOptions: nil)
treatmentManager.getTreatmentsByFlagSets(flagSets: flagSets, attributes: attributes, evaluationOptions: nil)
}

public func getTreatmentsWithConfigByFlagSet(_ flagSet: String, attributes: [String: Any]?) -> [String: SplitResult] {
return treatmentManager.getTreatmentsWithConfigByFlagSet(flagSet: flagSet, attributes: attributes, evaluationOptions: nil)
treatmentManager.getTreatmentsWithConfigByFlagSet(flagSet: flagSet, attributes: attributes, evaluationOptions: nil)
}

public func getTreatmentsWithConfigByFlagSets(_ flagSets: [String],
attributes: [String: Any]?) -> [String: SplitResult] {
return treatmentManager.getTreatmentsWithConfigByFlagSets(flagSets: flagSets, attributes: attributes, evaluationOptions: nil)
treatmentManager.getTreatmentsWithConfigByFlagSets(flagSets: flagSets, attributes: attributes, evaluationOptions: nil)
}
}

// MARK: Flush / Destroy
// MARK: Lifecycle
extension DefaultSplitClient {

private func syncFlush() {
Expand Down
50 changes: 19 additions & 31 deletions Split/Api/FailHelpers.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
//
// FailHelpers.swift
// Split
//
// Created by Javier Avrudsky on 24-Apr-2022.
// Copyright © 2022 Split. All rights reserved.
//

import Foundation

Expand Down Expand Up @@ -57,54 +52,50 @@ class FailedClient: SplitClient {
func on(event: SplitEvent, execute action: @escaping SplitAction) {
}

func on(event: SplitEvent, runInBackground: Bool,
execute action: @escaping SplitAction) {
}
func on(event: SplitEvent, runInBackground: Bool, execute action: @escaping SplitAction) {}

func on(event: SplitEvent,
queue: DispatchQueue, execute action: @escaping SplitAction) {
}
func on(event: SplitEvent, queue: DispatchQueue, execute action: @escaping SplitAction) {}

func on(event: SplitEvent, executeWithMetadata: @escaping SplitActionWithMetadata) {}

func track(trafficType: String, eventType: String) -> Bool {
return false
false
}

func track(trafficType: String, eventType: String, value: Double) -> Bool {
return false
false
}

func track(eventType: String) -> Bool {
return false
false
}

func track(eventType: String, value: Double) -> Bool {
return false
false
}

func setAttribute(name: String, value: Any) -> Bool {
return false
false
}

func getAttribute(name: String) -> Any? {
return false
false
}

func setAttributes(_ values: [String: Any]) -> Bool {
return false
false
}

func getAttributes() -> [String: Any]? {
return [:]
}

func removeAttribute(name: String) -> Bool {
return false
false
}

func clearAttributes() -> Bool {
return false
false
}

func getTreatmentsByFlagSet(_ flagSet: String, attributes: [String: Any]?) -> [String: String] {
Expand Down Expand Up @@ -139,33 +130,30 @@ class FailedClient: SplitClient {
return [:]
}

func setUserConsent(enabled: Bool) {
}
func setUserConsent(enabled: Bool) {}

func flush() {
}
func flush() {}

func destroy() {
}
func destroy() {}

func destroy(completion: (() -> Void)?) {
completion?()
}

func track(trafficType: String, eventType: String, properties: [String: Any]?) -> Bool {
return false
false
}

func track(trafficType: String, eventType: String, value: Double, properties: [String: Any]?) -> Bool {
return false
false
}

func track(eventType: String, properties: [String: Any]?) -> Bool {
return false
false
}

func track(eventType: String, value: Double, properties: [String: Any]?) -> Bool {
return false
false
}
}

Expand All @@ -175,6 +163,6 @@ class FailedManager: SplitManager {
var splitNames: [String] = []

func split(featureName: String) -> SplitView? {
return nil
nil
}
}
Loading
Loading