Firebase AB 测试的变体比例失调

sli*_*kas 5 ab-testing ios firebase firebase-remote-config firebase-ab-testing

我们遇到了 AB 测试变体不成比例的问题。从理论上讲,两种变体的变体暴露程度应该几乎相同,这实际上与我们之前所做的 AB 测试效果相当好。 ab 测试配置 1 ab 测试配置 2

正如您在屏幕截图中看到的,当前总用户数为 161k,变体有 75.4k 和 85.9k。我们已经运行此测试几次,并稍微更改了代码,但每次都会出现类似的不成比例。

在运行的 AB 测试中,我们将远程配置参数“ios_show_recent_searches_v2”空字符串设置为默认值。

使用激活事件运行 ab 测试的代码如下所示:

@objc class FireBaseService: NSObject {
    struct Constants {
        static let recentSearchesABTestToggleKey: String = "ios_show_recent_searches_v2"
        static let abTestNotAvailableKey: String = "N/A"
    }

    @objc class func start() {
        FirebaseApp.configure()
        let remoteConfig = RemoteConfig.remoteConfig()

        let oldShowRecentSearches = showRecentSearches

        remoteConfig.fetch(withExpirationDuration: 0.0) { (status, error) -> Void in
            DispatchQueue.main.async {
                if status == .success {
                    remoteConfig.activateFetched()
                    FireBaseService.notifyRecentSearchesVisiblityChangeIfNeeded(oldValue: oldShowRecentSearches)
                    FireBaseService.sendRecentSearchesActivationEventIfNeeded()
                }
            }
        }
    }  

    private class func hasConfigs(for key: String) -> Bool {
        return (RemoteConfig.remoteConfig()[key].stringValue?.count ?? 0) > 0
    }
}

// MARK: - Recent Searches A/B Test
extension FireBaseService {

    @objc class var showRecentSearchesValue: String {
        if hasConfigs(for: Constants.recentSearchesABTestToggleKey) {
            return RemoteConfig.remoteConfig()[Constants.recentSearchesABTestToggleKey].stringValue ?? Constants.abTestNotAvailableKey
        }
        return Constants.abTestNotAvailableKey
    }

    class var showRecentSearches: Bool {
        return RemoteConfig.remoteConfig()[Constants.recentSearchesABTestToggleKey].boolValue
    }

    private class func sendRecentSearchesActivationEventIfNeeded() {
        if FireBaseService.showRecentSearchesValue != Constants.abTestNotAvailableKey {
            AnalyticsServiceAdapter.activateRecentSearchesExperiment()
        }
    }

    private class func notifyRecentSearchesVisiblityChangeIfNeeded(oldValue: Bool) {
        if oldValue != showRecentSearches {
            NotificationCenter.default.post(name: Notification.Name(FireBaseService.ShowRecentSearchesNotification), object: nil)
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

该函数GEFireBaseService.start在应用程序启动时调用。