forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFreeTierLocalProcessingFlag.swift
More file actions
28 lines (25 loc) · 941 Bytes
/
Copy pathFreeTierLocalProcessingFlag.swift
File metadata and controls
28 lines (25 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import Foundation
/// Client gate for S11 local projection attach. Default off (dark).
///
/// Mirrors the backend `FREE_TIER_LOCAL_PROCESSING` boolean and the S9
/// env-or-UserDefaults kill-switch pattern. Flag off keeps today's
/// segments-only from-segments upload.
struct FreeTierLocalProcessingFlag: Sendable, Equatable {
static let environmentKey = "OMI_FREE_TIER_LOCAL_PROCESSING"
static let defaultsKey = "freeTierLocalProcessing"
static func isEnabled(
environment: [String: String] = ProcessInfo.processInfo.environment,
defaults: UserDefaults = .standard
) -> Bool {
isTruthy(environment[environmentKey]) || defaults.bool(forKey: defaultsKey)
}
static func isTruthy(_ raw: String?) -> Bool {
guard let raw else { return false }
switch raw.trimmingCharacters(in: .whitespacesAndNewlines).lowercased() {
case "1", "true", "yes":
return true
default:
return false
}
}
}