-
Notifications
You must be signed in to change notification settings - Fork 35
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
AB infrastructure #357
AB infrastructure #357
Changes from all commits
890855f
6be701c
e33995f
7047945
c5c22b5
06ccce9
98a9481
653173b
f599e4c
94190b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// AnalyticsUserPropertiesServiceProtocol.swift | ||
// SplitTests | ||
// | ||
// Created by Alex Zimin on 15/06/2018. | ||
// Copyright © 2018 Akexander. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
protocol AnalyticsUserPropertiesServiceProtocol { | ||
func setProperty(key: String, value: Any?) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// Numbers.swift | ||
// SplitTests | ||
// | ||
// Created by Alex Zimin on 15/06/2018. | ||
// Copyright © 2018 Akexander. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import CoreGraphics | ||
|
||
public extension Int { | ||
/// SwiftRandom extension | ||
public static func random(lower: Int = 0, _ upper: Int = 100) -> Int { | ||
return lower + Int(arc4random_uniform(UInt32(upper - lower + 1))) | ||
} | ||
} | ||
|
||
public extension Float { | ||
|
||
/// Returns a random floating point number between 0.0 and 1.0, inclusive. | ||
public static var random: Float { | ||
return Float(arc4random()) / 0xFFFFFFFF | ||
} | ||
|
||
/// Random float between 0 and n-1. | ||
/// | ||
/// - Parameter n: Interval max | ||
/// - Returns: Returns a random float point number between 0 and n max | ||
public static func random(min: Float, max: Float) -> Float { | ||
return Float.random * (max - min) + min | ||
} | ||
} | ||
|
||
public extension CGFloat { | ||
|
||
/// Randomly returns either 1.0 or -1.0. | ||
public static var randomSign: CGFloat { | ||
return (arc4random_uniform(2) == 0) ? 1.0 : -1.0 | ||
} | ||
|
||
/// Returns a random floating point number between 0.0 and 1.0, inclusive. | ||
public static var random: CGFloat { | ||
return CGFloat(Float.random) | ||
} | ||
|
||
/// Random CGFloat between 0 and n-1. | ||
/// | ||
/// - Parameter n: Interval max | ||
/// - Returns: Returns a random CGFloat point number between 0 and n max | ||
public static func random(min: CGFloat, max: CGFloat) -> CGFloat { | ||
return CGFloat.random * (max - min) + min | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
|
||
import Foundation | ||
import FirebaseRemoteConfig | ||
import FirebaseInstanceID | ||
|
||
enum RemoteConfigKeys: String { | ||
case showStreaksNotificationTrigger = "show_streaks_notification_trigger" | ||
|
@@ -22,6 +23,8 @@ class RemoteConfig { | |
var loadingDoneCallback: (() -> Void)? | ||
var fetchComplete: Bool = false | ||
|
||
var fetchDuration: TimeInterval = 43200 | ||
|
||
lazy var appDefaults: [String: NSObject] = [ | ||
RemoteConfigKeys.showStreaksNotificationTrigger.rawValue: defaultShowStreaksNotificationTrigger.rawValue as NSObject, | ||
RemoteConfigKeys.adaptiveBackendUrl.rawValue: StepicApplicationsInfo.adaptiveRatingURL as NSObject, | ||
|
@@ -86,7 +89,6 @@ class RemoteConfig { | |
} | ||
|
||
private func fetchCloudValues() { | ||
let fetchDuration: TimeInterval = 43200 | ||
#if DEBUG | ||
activateDebugMode() | ||
#endif | ||
|
@@ -107,7 +109,12 @@ class RemoteConfig { | |
} | ||
|
||
private func activateDebugMode() { | ||
fetchDuration = 0 | ||
let debugSettings = RemoteConfigSettings(developerModeEnabled: true) | ||
FirebaseRemoteConfig.RemoteConfig.remoteConfig().configSettings = debugSettings | ||
} | ||
|
||
func string(forKey key: String) -> String? { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Это конечно плохо, потому что тогда уж лучше переписать весь класс и сделать новый гибкий интерфейс. А получается, что какие-то ключи у нас обернуты в проперти, а какие-то мы дергаем без обертки 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Если мы так будем переписывать каждый класс, в котором что-то не нравится, не будем по пол года релизиться. |
||
return FirebaseRemoteConfig.RemoteConfig.remoteConfig().configValue(forKey: key).stringValue | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
У нас по-прежнему есть несколько провайдеров аналитики, поэтому подгонять под протокол меняя названия и модификатор доступа – не самая лучшая идея. Есть предложение сделать протокол не про задание проперти, а про задание проперти, связанной с A/B тестом. Тогда не нужно будет подгонять под протокол методы, а просто сделать отдельный метод, как я предлагал в предыдущем ревью.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не понимаю, чем плохо.
У нас есть протокол про проперти.
Я подогнал класс с проперти под этот протокол, просто переименовав один метод, который до этого был вообще приватным.
Другие провайдеры пока это не реализуют, но мы это и не используем.
В чем проблема здесь, я не вижу
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В чем смысл делать отдельный протокол про задание проперти для ab, если это будет то же самое, что и просто задание проперти?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно сказать про SOLID и ISP в нем, но к этому это вообще вряд ли относится, потому что разделить предлагается не по смыслу (не вижу кейсов, в котором задание юзер проперти и юзер проперти в ab-тесте будет различаться хоть как-то).