Skip to content

Commit

Permalink
Revert "feat: add support for getParameterStore" (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
weihao-statsig authored Jun 11, 2024
1 parent 0a81ded commit fb30551
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 280 deletions.
36 changes: 1 addition & 35 deletions Sources/Statsig/InternalStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ struct StatsigValuesCache {
var gates: [String: [String: Any]]? = nil
var configs: [String: [String: Any]]? = nil
var layers: [String: [String: Any]]? = nil
var paramStores: [String: [String: Any]]? = nil
var hashUsed: String? = nil
var sdkKey: String
var options: StatsigOptions
Expand All @@ -38,7 +37,6 @@ struct StatsigValuesCache {
gates = userCache[InternalStore.gatesKey] as? [String: [String: Any]]
configs = userCache[InternalStore.configsKey] as? [String: [String: Any]]
layers = userCache[InternalStore.layerConfigsKey] as? [String: [String: Any]]
paramStores = userCache[InternalStore.paramStoresKey] as? [String: [String: Any]]
hashUsed = userCache[InternalStore.hashUsedKey] as? String
}
}
Expand Down Expand Up @@ -102,33 +100,13 @@ struct StatsigValuesCache {
return Layer(
client: client,
name: layerName,
configObj: configObj,
evalDetails: getEvaluationDetails(.Recognized)
configObj: configObj, evalDetails: getEvaluationDetails(.Recognized)
)
}

print("[Statsig]: The layer with name \(layerName) does not exist. Returning an empty Layer.")
return createUnfoundLayer(client, layerName)
}

func getParamStore(_ client: StatsigClient?, _ storeName: String) -> ParameterStore {
guard let stores = paramStores else {
print("[Statsig]: Failed to get parameter store with name \(storeName). Returning an empty ParameterStore.")
return createUnfoundParamStore(client, storeName)
}

if let config = stores[storeName] ?? stores[storeName.hashSpecName(hashUsed)] {
return ParameterStore(
name: storeName,
evaluationDetails: getEvaluationDetails(.Recognized),
client: client,
configuration: config
)
}

print("[Statsig]: The parameter store with name \(storeName) does not exist. Returning an empty ParameterStore.")
return createUnfoundParamStore(client, storeName)
}

func getStickyExperiment(_ expName: String) -> [String: Any]? {
let expNameHash = expName.hashSpecName(hashUsed)
Expand Down Expand Up @@ -181,7 +159,6 @@ struct StatsigValuesCache {
cache[InternalStore.gatesKey] = values[InternalStore.gatesKey]
cache[InternalStore.configsKey] = values[InternalStore.configsKey]
cache[InternalStore.layerConfigsKey] = values[InternalStore.layerConfigsKey]
cache[InternalStore.paramStoresKey] = values[InternalStore.paramStoresKey]
cache[InternalStore.lcutKey] = Time.parse(values[InternalStore.lcutKey])
cache[InternalStore.evalTimeKey] = Time.now()
cache[InternalStore.userHashKey] = userHash
Expand Down Expand Up @@ -359,10 +336,6 @@ struct StatsigValuesCache {
evalDetails: getEvaluationDetails(.Unrecognized)
)
}

private func createUnfoundParamStore(_ client: StatsigClient?, _ name: String) -> ParameterStore {
ParameterStore(name: name, evaluationDetails: getEvaluationDetails(.Unrecognized))
}
}

class InternalStore {
Expand All @@ -380,7 +353,6 @@ class InternalStore {
static let configsKey = "dynamic_configs"
static let stickyExpKey = "sticky_experiments"
static let layerConfigsKey = "layer_configs"
static let paramStoresKey = "param_stores"
static let lcutKey = "time"
static let evalTimeKey = "evaluation_time"
static let userHashKey = "user_hash"
Expand Down Expand Up @@ -481,12 +453,6 @@ class InternalStore {
)
})
}

func getParamStore(client: StatsigClient?, forName storeName: String) -> ParameterStore {
storeQueue.sync {
return cache.getParamStore(client, storeName)
}
}

func finalizeValues(completion: (() -> Void)? = nil) {
storeQueue.async(flags: .barrier) { [weak self] in
Expand Down
2 changes: 1 addition & 1 deletion Sources/Statsig/Layer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public struct Layer: ConfigProtocol {
public let allocatedExperimentName: String

/**
(For debug purposes) Why did Statsig return this Layer
(For debug purposes) Why did Statsig return this DynamicConfig
*/
public let evaluationDetails: EvaluationDetails

Expand Down
180 changes: 0 additions & 180 deletions Sources/Statsig/ParameterStore.swift

This file was deleted.

18 changes: 0 additions & 18 deletions Sources/Statsig/Statsig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -251,24 +251,6 @@ public class Statsig {
public static func getLayerWithExposureLoggingDisabled(_ layerName: String, keepDeviceValue: Bool = false) -> Layer {
return getLayerImpl(layerName, keepDeviceValue: keepDeviceValue, withExposures: false, functionName: funcName())
}

/**

*/
public static func getParameterStore(_ storeName: String) -> ParameterStore {
let functionName = funcName()
var result = ParameterStore(name: storeName, evaluationDetails: .uninitialized())

errorBoundary.capture(functionName) {
guard let client = client else {
print("[Statsig]: \(getUnstartedErrorMessage(functionName)). Returning a dummy ParameterStore that will only return default values.")
return
}

result = client.getParameterStore(storeName)
}
return result
}

/**
Logs an exposure event for the given layer parameter. Only required if a related getLayerWithExposureLoggingDisabled call has been made.
Expand Down
15 changes: 0 additions & 15 deletions Sources/Statsig/StatsigClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -537,21 +537,6 @@ extension StatsigClient {
}
}

// MARK: Parameter Stores

extension StatsigClient {
public func getParameterStore(_ storeName: String) -> ParameterStore {
logger.incrementNonExposedCheck(storeName)

let store = store.getParamStore(client: self, forName: storeName)
if let cb = statsigOptions.evaluationCallback {
cb(.parameterStore(store))
}

return store
}
}


// MARK: Log Event
extension StatsigClient {
Expand Down
28 changes: 0 additions & 28 deletions Sources/Statsig/StatsigDynamicConfigValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,3 @@ extension Int: StatsigDynamicConfigValue {}
extension String: StatsigDynamicConfigValue {}

extension String?: StatsigDynamicConfigValue {}


fileprivate struct TypeString {
static let boolean = "boolean"
static let number = "number"
static let string = "string"
static let array = "array"
static let object = "object"
}

func getTypeOf<T: StatsigDynamicConfigValue>(_ value: T) -> String? {
switch value {
case is Bool:
return TypeString.boolean
case is Int, is Double:
return TypeString.number
case is String, is Optional<String>:
return TypeString.string
case is Array<StatsigDynamicConfigValue>:
return TypeString.array
case is Dictionary<String, StatsigDynamicConfigValue>:
return TypeString.object
default:
return nil
}
}


1 change: 0 additions & 1 deletion Sources/Statsig/StatsigOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public class StatsigOptions {
case config (DynamicConfig)
case experiment (DynamicConfig)
case layer (Layer)
case parameterStore (ParameterStore)
}

/**
Expand Down
2 changes: 0 additions & 2 deletions Tests/StatsigTests/EvaluationCallbackSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ final class EvaluationCallbackSpec: BaseSpec {
experimentNameResult = exp.name
case .layer(let layer):
layerNameResult = layer.name
case .parameterStore(let _paramStore):
break
}
}

Expand Down

0 comments on commit fb30551

Please sign in to comment.